Youssef Aitousarrah
369f8c444b
feat: discovery system code quality improvements and concurrent execution
...
Implement comprehensive code quality improvements and performance optimizations
for the discovery pipeline based on code review findings.
## Key Improvements
### 1. Common Utilities (DRY Principle)
- Created `tradingagents/dataflows/discovery/common_utils.py`
- Extracted ticker parsing logic (eliminates 40+ lines of duplication)
- Centralized stopwords list (71 common non-ticker words)
- Added ReDoS protection (100KB text length limit)
- Provides `validate_candidate_structure()` for output validation
### 2. Scanner Output Validation
- Two-layer validation approach:
- Registration-time: Check scanner class structure
- Runtime: Validate each candidate dictionary
- Added `scan_with_validation()` wrapper in BaseScanner
- Validates required keys: ticker, source, context, priority
- Graceful error handling with structured logging
### 3. Configuration-Driven Design
- Moved magic numbers to `default_config.py`:
- `ticker_universe`: Top 20 liquid options tickers
- `min_volume`: 1000 (options flow threshold)
- `min_transaction_value`: $25,000 (insider buying filter)
- Fixed hardcoded absolute paths to relative paths
- Improved portability across development environments
### 4. Concurrent Scanner Execution (37% Performance Gain)
- Implemented ThreadPoolExecutor for parallel scanner execution
- Configuration: `scanner_execution.concurrent`, `max_workers`, `timeout_seconds`
- Performance: 42s vs 67s (37% faster with 8 scanners)
- Thread-safe state management (each scanner gets copy)
- Per-scanner timeout with graceful degradation
- Error isolation (one failure doesn't stop others)
### 5. Error Handling Improvements
- Changed bare `except:` to `except Exception:` (avoid catching KeyboardInterrupt)
- Added structured logging with `exc_info=True` and extra fields
- Implemented graceful degradation throughout pipeline
## Files Changed
### Core Implementation
- `tradingagents/__init__.py` (NEW) - Package initialization
- `tradingagents/default_config.py` - Scanner execution config, magic numbers
- `tradingagents/graph/discovery_graph.py` - Concurrent execution logic
- `tradingagents/dataflows/discovery/common_utils.py` (NEW) - Shared utilities
- `tradingagents/dataflows/discovery/scanner_registry.py` - Validation wrapper
- `tradingagents/dataflows/discovery/scanners/*.py` - Use common utilities
### Testing & Documentation
- `tests/test_concurrent_scanners.py` (NEW) - Comprehensive test suite
- `verify_concurrent_execution.py` (NEW) - Performance verification
- `CONCURRENT_EXECUTION.md` (NEW) - Implementation documentation
## Test Results
All tests passing (exit code 0):
- ✅ Concurrent execution: 42s, 66-69 candidates
- ✅ Sequential fallback: 56-67s, 65-68 candidates
- ✅ Timeout handling: Graceful degradation with 1s timeout
- ✅ Error isolation: Individual failures don't cascade
## Performance Impact
- Scanner execution: 37% faster (42s vs 67s)
- Time saved: ~25 seconds per discovery run
- At scale: 4+ minutes saved daily in production
- Same candidate quality (65-69 tickers in both modes)
## Breaking Changes
None. Concurrent execution is opt-in via config flag.
Sequential mode remains available as fallback.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 23:27:01 -08:00
Youssef Aitousarrah
2376fc74a1
Update
2025-12-11 00:23:28 -08:00
Youssef Aitousarrah
ea4ee9176b
Update
2025-12-09 23:16:53 -08:00
Youssef Aitousarrah
ccc78c694b
Update
2025-12-06 15:39:49 -08:00
Youssef Aitousarrah
5cf57e5d97
Update
2025-12-02 20:49:42 -08:00
Youssef Aitousarrah
9ee66746a5
Fix: Stop after all primary vendors in multi-vendor config
...
When multiple primary vendors are configured (e.g., 'reddit,alpha_vantage'),
the system now correctly stops after attempting all primary vendors instead
of continuing through all fallback vendors.
Changes:
- Track which primary vendors have been attempted in a list
- Add stopping condition when all primary vendors are attempted
- Preserve existing single-vendor behavior (stop after first success)
This prevents unnecessary API calls and ensures predictable behavior.
2025-11-23 17:09:15 -08: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
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
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
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
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