| from typing import Any |
| from datetime import datetime |
| import yfinance as yf |
|
|
| from data.earnings import fetch_earnings_data |
| from data.finance_fetchers import fetch_fundamentals, fetch_news, fetch_price_data |
| from data.technicals import fetch_technicals |
| from llm.web_search import fetch_web_search |
| from utils.data_types import MarketData |
|
|
|
|
| def collect_data(client, intent, tools): |
| |
| ticker = intent.get("ticker", "") |
| period = intent.get("time_range", "1y") |
|
|
| print(f"[โข] ๋ฐ์ดํฐ ์์ง ์ค (ticker={ticker}, period={period})...") |
|
|
| price_data = {} |
| fundamentals = {} |
| technicals = {} |
| news_snippets = [] |
| earnings_data = {} |
| web_search_results = [] |
|
|
| if ticker: |
| if "price" in tools: |
| price_data = fetch_price_data(ticker, period) |
| print(f" โ ๊ฐ๊ฒฉ ๋ฐ์ดํฐ: {len(price_data)}๊ฐ ์งํ") |
|
|
| if "fundamentals" in tools: |
| fundamentals = fetch_fundamentals(ticker) |
| print(f" โ ํ๋๋ฉํธ: {len(fundamentals)}๊ฐ ์งํ") |
|
|
| if "technicals" in tools: |
| technicals = fetch_technicals(ticker, "6mo") |
| print(f" โ ๊ธฐ์ ์งํ: {len(technicals)}๊ฐ ์งํ") |
|
|
| if "news" in tools: |
| news_snippets = fetch_news(ticker) |
| print(f" โ ๋ด์ค: {len(news_snippets)}๊ฐ ํค๋๋ผ์ธ") |
|
|
| if "earnings" in tools: |
| earnings_data = fetch_earnings_data( |
| ticker, |
| target_year=intent.get("target_year"), |
| target_quarter=intent.get("target_quarter") |
| ) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| return MarketData( |
| ticker=ticker, |
| price_data=price_data, |
| fundamentals=fundamentals, |
| technicals=technicals, |
| news_snippets=news_snippets, |
| earnings_data=earnings_data, |
| web_search_results=web_search_results, |
| ) |
|
|