The WebDataInterface (src/interfaces/web_data.py) defines a standard contract for fetching and potentially parsing data from external web sources, such as financial news websites, economic calendars, or social media sentiment aggregators.
- Abstract the process of retrieving information from various web sources (e.g., scraping websites, calling specific news APIs).
- Provide a consistent way for services (primarily the
AIService) to access external information that might influence trading decisions (e.g., news headlines, sentiment scores, upcoming economic events). - Enable adding new web data sources by creating new implementations of the interface.
- Facilitate testing by allowing mock implementations that return sample web data without making live HTTP requests.
A WebDataInterface might define methods like:
fetch_news(query: str, max_results: int): Fetches recent news articles related to a specific query (e.g., a stock symbol, a market sector). Returns a list of news items (e.g., headlines, summaries, URLs, timestamps).fetch_economic_events(date_range: Tuple[date, date]): Retrieves scheduled economic events (e.g., GDP releases, interest rate decisions) within a given date range.fetch_sentiment(symbol: str): Attempts to fetch a sentiment score or related commentary for a specific trading symbol from a configured source.
The exact methods depend on the specific needs of the AIService and the data sources being integrated.
Concrete implementations could include:
NewsAPIFetcher: Uses a commercial News API service.WebScraper: Implements logic to scrape specific financial websites (requires careful handling of website terms of service and potential structure changes).MockWebData: Returns predefined sample news or event data for testing.
The OrchestrationDaemon or AIService would select and instantiate the appropriate implementation.
Implementations might require:
- API keys for commercial data providers.
- URLs for websites to be scraped.
- Configuration for parsing logic.
These would typically be stored in the .env file.
AIService: Likely the primary consumer, requesting external data to enrich the context provided to the LLM for analysis.config.py: Reads API keys or URLs needed by the implementation.- External Libraries: May use libraries like
requests,beautifulsoup4(for scraping), or specific API client libraries. logger.py: Logs attempts to fetch web data and their outcomes.