Commit Graph

45 Commits

Author SHA1 Message Date
Joseph O'Brien fb1a66f5a6 feat: add database-backed caching to dataflows interface
- Add MarketDataService for database-backed market data caching
- Integrate cache lookup/write into route_to_vendor function
- Support configurable TTL per data type (stock data: 1h, fundamentals: 24h+)
- Make caching opt-in via database_enabled and db_cache_enabled config flags

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 11:45:46 -05:00
Joseph O'Brien 1db81e1fc6 feat: integrate database persistence with TradingAgentsGraph
Add database services layer with AnalysisService, TradingService, and DiscoveryService
for persisting analysis sessions, trading decisions, and discovery runs.

Integration with TradingAgentsGraph:
- Add config options: database_enabled, database_path
- Persist analysis state to database in _log_state when enabled
- Persist discovery results to database when enabled
- Save analyst reports, debates, and trading decisions

Database integration is opt-in via config setting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 11:31:21 -05:00
Joseph O'Brien c39f9aab36 Add pre-commit hooks and ruff code quality configuration
- Add .pre-commit-config.yaml with trailing whitespace, ruff linter/formatter
- Configure ruff in pyproject.toml with selected rules (E, F, W, I, UP, B, C4, SIM)
- Add F401 to unfixable to preserve re-exported imports in __init__.py files
- Fix BacktestMetrics import in backtesting/engine.py
- Update todos.md with enhanced trade discovery and database implementation tasks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 11:22:13 -05:00
Joseph O'Brien 85992fc05b chore: remove unused imports across codebase
Removed unused imports from 36 files including:
- Unused stdlib imports (json, time, re, os, signal, etc.)
- Unused typing imports (List, Dict, Optional, Tuple, Sequence, etc.)
- Unused langchain imports (AIMessage, ChatOpenAI, etc.)
- Unused langgraph imports (END, StateGraph, START, ToolNode, etc.)
- Unused project imports (DataLoader, get_config, parse_date, etc.)

Preserved intentional re-exports in:
- tradingagents/agents/utils/agent_utils.py (re-exports tool functions)
- tradingagents/dataflows/alpha_vantage.py (re-exports submodule functions)
- All __init__.py files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 04:44:37 -05:00
Joseph O'Brien 1346e20b5e feat: create enums for status strings
Added AgentStatus enum for CLI agent tracking (pending, in_progress,
completed, error) and BacktestStatus enum for backtest results (pending,
running, completed, failed). Replaces string literals with type-safe
enum values throughout the codebase.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 04:13:59 -05:00
Joseph O'Brien b8be981bc8 feat: add type hints to function signatures across codebase
Added return type hints and parameter type hints to functions in:
- tradingagents/graph/trading_graph.py
- tradingagents/graph/reflection.py
- tradingagents/dataflows/y_finance.py
- tradingagents/dataflows/local.py
- tradingagents/backtesting/engine.py
- cli/analysis.py, cli/discovery.py, cli/display.py, cli/state.py, cli/backtest_cmd.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 03:50:49 -05:00
Joseph O'Brien 9c252fdc2c refactor: consolidate configuration management with Pydantic-based settings
- Add tradingagents/config.py with TradingAgentsSettings Pydantic model
- Centralize all environment variable handling and API key management
- Add validation for log_level, llm_provider, and numeric bounds
- Update dataflows/config.py to use central config as backend
- Update logging.py to get settings from central config
- Update API key access in alpha_vantage, brave, and tavily modules
- Replace DEFAULT_CONFIG imports with get_config() calls
- Add 20 comprehensive tests for config module

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 03:20:41 -05:00
Joseph O'Brien 0c04bdb0ee perf: replace iterrows() with vectorized operations in y_finance.py
Replace slow iterrows() loop with vectorized pandas operations using
apply() and dict(zip()) for better performance when building indicator
result dictionaries.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 03:15:23 -05:00
Joseph O'Brien e862c4f803 feat: add centralized input validation for ticker symbols and dates
- Create tradingagents/validation.py with comprehensive validation functions:
  - validate_ticker/validate_tickers for ticker symbol validation
  - validate_date/validate_date_range for date validation
  - parse_date for flexible date parsing (multiple formats)
  - Helper functions: is_valid_ticker, is_valid_date, is_trading_day
  - get_previous_trading_day, get_next_trading_day utilities
- Add validation to y_finance.py (get_YFin_data_online, get_stock_stats_indicators_window)
- Add validation to trading_graph.py propagate method
- Create comprehensive test suite (55 tests) in tests/test_validation.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 03:09:05 -05:00
Joseph O'Brien f70874982a feat: add backtesting framework and fix code quality issues
- Add complete backtesting engine with portfolio simulation, metrics calculation
  (Sharpe, Sortino, max drawdown), and agent integration
- Add Pydantic data models for market data, trading, portfolio, and backtest results
- Add backtest CLI command with SMA, RSI, and hold strategies
- Fix 24+ bare exception handlers with specific exception types
- Fix hardcoded path in default_config.py (use TRADINGAGENTS_DATA_DIR env var)
- Fix unclosed file handle in local.py with context manager
- Disable store=True in OpenAI API calls for data privacy
- Fix typo: rename aggresive_debator.py to aggressive_debator.py
- Add request timeouts (30s) to alpha_vantage_common.py and googlenews_utils.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 02:55:28 -05:00
Joseph O'Brien 80e8fb0eee feat: add centralized logging module with dual output support
Add tradingagents/logging.py with JSONFormatter for structured file logs
and RichHandler for colored console output. Migrate 59 print statements
across 13 files to proper logger calls. Configure via environment
variables (TRADINGAGENTS_LOG_LEVEL, etc.) with default_config fallback.

- Rotating file handler: 10MB max, 5 backups to logs/tradingagents.log
- Rich console handler with tracebacks for development
- Logger hierarchy follows module paths (tradingagents.dataflows.*, etc.)
- 20 feature-specific tests covering core, config, migration, integration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 02:11:29 -05:00
Joseph O'Brien 3c85b21e0b Improve CLI with loading indicators and enhance discovery pipeline
- Add MultiStageLoader and LoadingIndicator classes to cli/utils.py
- Improve CLI main.py with explicit imports and UI enhancements
- Update entity_extractor.py with improved LLM provider handling
- Add Ollama embedding model configuration to memory.py
- Add get_bulk_news_alpha_vantage function to alpha_vantage_news.py
- Add discovery imports to trading_graph.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 00:49:49 -05:00
Joseph O'Brien 24e955d29b Add Brave and Tavily news data vendors with retry handling
- Add Brave Search API integration for bulk news fetching
- Add Tavily API integration for bulk news fetching
- Implement timeout and retry logic with exponential backoff for both vendors
- Make bulk news vendor order configurable via default_config.py
- Add tavily-python to requirements.txt
- Document BRAVE_API_KEY and TAVILY_API_KEY in .env.example and README
- Add comprehensive unit tests for both vendors (49 tests)

The news discovery system now uses fallback chain: Tavily → Brave → Alpha Vantage → OpenAI → Google

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 00:43:27 -05:00
Joseph O'Brien 7647e08e54 Update stock_resolver.py 2025-12-02 20:41:02 -05:00
Joseph O'Brien 819f62e459 Update openai.py 2025-12-02 20:40:58 -05:00
Joseph O'Brien 43e7d98ff1 Update interface.py 2025-12-02 20:40:56 -05:00
Joseph O'Brien f998d59b5e Update alpha_vantage_news.py 2025-12-02 20:40:50 -05:00
Joseph O'Brien bd4bb009a9 Update google.py 2025-12-02 20:40:44 -05:00
Joseph O'Brien 3f6b1e9f39 Add trending stock discovery feature
Implement a multi-stage pipeline to discover trending stocks from news:
- Entity extraction from news articles using LLM
- Stock ticker resolution via Yahoo Finance
- Sector classification and event categorization
- Scoring algorithm based on mentions, sentiment, and recency
- CLI integration with interactive stock selection and analysis flow
- Persistence layer for saving discovery results
- Comprehensive test suite for all discovery components

Update README with uv-based installation instructions and remove emojis.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 20:19:34 -05:00
Edward Sun 7bb2941b07 optimized yfin fetching to be much faster 2025-10-06 19:58:01 -07:00
Edward Sun c07dcf026b added fallbacks for tools 2025-10-03 22:40:09 -07:00
luohy15 d23fb539e9 minor fix 2025-09-30 13:27:48 +08:00
luohy15 b01051b9f4 Switch default data vendor
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 12:43:27 +08:00
luohy15 86bc0e793f minor fix 2025-09-27 00:04:59 +08:00
luohy15 6211b1132a Improve Alpha Vantage indicator column parsing with robust mapping
- Replace hardcoded column indices with column name lookup
- Add mapping for all supported indicators to their expected CSV column names
- Handle missing columns gracefully with descriptive error messages
- Strip whitespace from header parsing for reliability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 23:36:36 +08:00
luohy15 8b04ec307f minor fix 2025-09-26 23:25:33 +08:00
luohy15 0ab323c2c6 Add Alpha Vantage API integration as primary data provider
- Replace FinnHub with Alpha Vantage API in README documentation
- Implement comprehensive Alpha Vantage modules:
  - Stock data (daily OHLCV with date filtering)
  - Technical indicators (SMA, EMA, MACD, RSI, Bollinger Bands, ATR)
  - Fundamental data (overview, balance sheet, cashflow, income statement)
  - News and sentiment data with insider transactions
- Update news analyst tools to use ticker-based news search
- Integrate Alpha Vantage vendor methods into interface routing
- Maintain backward compatibility with existing vendor system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 22:57:50 +08:00
luohy15 a6734d71bc WIP 2025-09-26 16:17:50 +08:00
mirza-samad-ahmed-baig f704828f89 Fix: Prevent infinite loops, enable reflection, and improve logging 2025-07-03 17:43:40 +05:00
Yijia Xiao 718df34932
Merge pull request #29 from ZeroAct/save_results
Save results
2025-06-26 00:28:30 -04:00
Max Wong 43aa9c5d09
Local Ollama (#53)
- Fix typo 'Start' 'End'
- Add llama3.1 selection
- Use 'quick_think_llm' model instead of hard-coding GPT
2025-06-26 00:27:01 -04:00
Yijia Xiao 26c5ba5a78
Revert "Docker support and Ollama support (#47)" (#57)
This reverts commit 78ea029a0b.
2025-06-26 00:07:58 -04:00
Geeta Chauhan 78ea029a0b
Docker support and Ollama support (#47)
- Added support for running CLI and Ollama server via Docker
- Introduced tests for local embeddings model and standalone Docker setup
- Enabled conditional Ollama server launch via LLM_PROVIDER
2025-06-25 23:57:05 -04:00
Huijae Lee ee3d499894
Merge branch 'TauricResearch:main' into save_results 2025-06-25 08:43:19 +09:00
Yijia Xiao b575bd0941
Merge pull request #52 from TauricResearch/dev
Merge dev into main. Add support for Anthropic and OpenRouter.
2025-06-23 20:38:14 -04:00
Edward Sun 52284ce13c fixed anthropic support. Anthropic has different format of response when it has tool calls. Explicit handling added 2025-06-21 12:51:34 -07:00
Yijia Xiao c2f897fc67
Merge pull request #43 from AtharvSabde/patch-1
fundamentals_analyst.py (spelling mistake in instruction: Makrdown -> Markdown)
2025-06-19 15:05:08 -04:00
Atharv Sabde 2af7ef3d79
fundamentals_analyst.py(spelling mistake.markdown) 2025-06-19 21:48:16 +05:30
Edward Sun 7eaf4d995f update clear msg bc anthropic needs at least 1 msg in chat call 2025-06-15 23:14:47 -07:00
Edward Sun da84ef43aa main works, cli bugs 2025-06-15 22:20:59 -07:00
Edward Sun 90b23e72f5
Merge pull request #25 from maxer137/main
Add support for other backends, such as OpenRouter and Ollama
2025-06-15 16:06:20 -07:00
saksham0161 570644d939
Fix ticker hardcoding in prompt (#28) 2025-06-11 19:43:39 -07:00
ZeroAct 9647359246 save reports & logs under results_dir 2025-06-12 11:25:07 +09:00
maxer137 99789f9cd1 Add support for other backends, such as OpenRouter and olama
This aims to offer alternative OpenAI capable api's.
This offers people to experiment with running the application locally
2025-06-11 14:19:25 +02:00
Yijia-Xiao cc97cb6d5d chore(release): v0.1.0 – initial public release of TradingAgents 2025-06-05 04:27:57 -07:00