Add objective external data sources to enhance trading decisions beyond market prices and user input. ## New Modules ### src/data/news_api.py - News sentiment analysis with Alpha Vantage and NewsAPI support - Sentiment scoring (-1.0 to +1.0) per article and aggregated - 5-minute caching to minimize API quota usage - Graceful degradation when APIs unavailable ### src/data/economic_calendar.py - Track major economic events (FOMC, GDP, CPI) - Earnings calendar per stock - Event proximity checking for high-volatility periods - Hardcoded major events for 2026 (no API required) ### src/data/market_data.py - Market sentiment indicators (Fear & Greed equivalent) - Market breadth (advance/decline ratios) - Sector performance tracking - Fear/Greed score calculation ## Integration Enhanced GeminiClient to seamlessly integrate external data: - Optional news_api, economic_calendar, and market_data parameters - Async build_prompt() includes external context when available - Backward-compatible build_prompt_sync() for existing code - Graceful fallback when external data unavailable External data automatically added to AI prompts: - News sentiment with top articles - Upcoming high-impact economic events - Market sentiment and breadth indicators ## Configuration Added optional settings to config.py: - NEWS_API_KEY: API key for news provider - NEWS_API_PROVIDER: "alphavantage" or "newsapi" - MARKET_DATA_API_KEY: API key for market data ## Testing Comprehensive test suite with 38 tests: - NewsAPI caching, sentiment parsing, API integration - EconomicCalendar event filtering, earnings lookup - MarketData sentiment and breadth calculations - GeminiClient integration with external data sources - All tests use mocks (no real API keys required) - 81% coverage for src/data module (exceeds 80% requirement) ## Circular Import Fix Fixed circular dependency between gemini_client.py and cache.py: - Use TYPE_CHECKING for imports in cache.py - String annotations for TradeDecision type hints All 195 existing tests pass. No breaking changes to existing functionality. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
29 lines
656 B
Plaintext
29 lines
656 B
Plaintext
# Korea Investment Securities API
|
|
KIS_APP_KEY=your_app_key_here
|
|
KIS_APP_SECRET=your_app_secret_here
|
|
KIS_ACCOUNT_NO=12345678-01
|
|
KIS_BASE_URL=https://openapivts.koreainvestment.com:9443
|
|
|
|
# Google Gemini
|
|
GEMINI_API_KEY=your_gemini_api_key_here
|
|
GEMINI_MODEL=gemini-pro
|
|
|
|
# Risk Management
|
|
CIRCUIT_BREAKER_PCT=-3.0
|
|
FAT_FINGER_PCT=30.0
|
|
CONFIDENCE_THRESHOLD=80
|
|
|
|
# Database
|
|
DB_PATH=data/trade_logs.db
|
|
|
|
# Rate Limiting
|
|
RATE_LIMIT_RPS=10.0
|
|
|
|
# Trading Mode (paper / live)
|
|
MODE=paper
|
|
|
|
# External Data APIs (optional — for enhanced decision-making)
|
|
# NEWS_API_KEY=your_news_api_key_here
|
|
# NEWS_API_PROVIDER=alphavantage
|
|
# MARKET_DATA_API_KEY=your_market_data_key_here
|