Commit Graph

72 Commits

Author SHA1 Message Date
0x7d0 07d0bcccb9 feat: Add comprehensive portfolio analysis system
Add multi-stock portfolio analysis capabilities:
- Parallel analysis of multiple positions using existing trading agents
- Portfolio-level metrics: correlation, beta, volatility, Sharpe ratio, diversification
- Risk assessment: concentration risk, sector exposure, correlation analysis
- Rebalancing recommendations based on AI analysis
- Comprehensive PDF reports with visualizations:
  * Allocation pie chart
  * Correlation heatmap
  * Sector distribution
  * Position performance charts
- Interactive CLI for portfolio input
- Programmatic API for custom integration
- Full backward compatibility with single-stock analysis

New modules:
- tradingagents/portfolio/: Core portfolio models, metrics, and graph
- cli/portfolio_cli.py: Interactive portfolio analysis interface
- cli/portfolio_pdf_generator.py: Portfolio-specific PDF generation
- PORTFOLIO_ANALYSIS.md: Comprehensive documentation

New command: python -m cli.main analyze-portfolio

Dependencies added: seaborn for correlation heatmaps

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 11:58:31 +02:00
0x7d0 1f6256d346 feat: Add PDF report generation with charts for trading analysis
- Add comprehensive PDF report generation with all analysis stages
- Include market data visualizations: price chart, volume chart, and technical indicators (RSI/MACD)
- Fix text parsing issues with proper HTML/markdown escaping
- Add reportlab and matplotlib dependencies for PDF and chart generation
- PDF reports saved automatically after analysis completion in results directory

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-09 18:46:37 +02:00
Zygmunt Dyras 1122505cd3 fix: Update Perplexity model names to current API models
- Changed default model to 'sonar' (verified working)
- Updated VALID_MODELS list with current API models
- Added Perplexity API key to .env
- Created test scripts to verify connectivity
- API is now working and can analyze stocks in real-time
2025-10-08 01:42:01 +02:00
Zygmunt Dyras 4bb26e22f9 fix: Critical fixes for AI research and Perplexity integration
FIXED CRITICAL ISSUES (35+ bugs resolved):

PERPLEXITY CONNECTOR:
 Added missing pandas import in data_aggregator
 Fixed bare except clauses - now properly handle exceptions
 Fixed ResearchDepth enum usage (was using strings)
 Added comprehensive API response validation
 Fixed timezone-naive datetime issues (now using UTC)
 Removed inefficient double API calls for parsing
 Added proper rate limiting with exponential backoff
 Fixed cache serialization issues with dataclasses
 Added model validation and fallbacks
 Sanitized error messages to prevent API key leaks

AI RESEARCH AGENT:
 Fixed async/sync mismatch with LangChain tools
 Fixed missing dependencies in DataAggregator initialization
 Fixed database method calls (removed incorrect await)
 Fixed LangChain agent creation (using proper method)
 Added proper error handling for all tools
 Fixed method name process_signal -> process_signals
 Added input sanitization to prevent injection
 Fixed ResearchMode enum values (STANDARD doesn't exist)
 Added proper timeout handling (30 seconds)
 Fixed tool execution in async context

SCHEDULER INTEGRATION:
 Added ResearchDepth import
 Fixed enum usage in analyze_stock calls
 Added proper error handling for missing components

DATA VALIDATION:
 Added response structure validation
 Added null checks before operations
 Added proper JSON parsing with error handling
 Added ticker validation
 Added rate limit response handling (429)

PERFORMANCE:
 Removed double API calls in parsing
 Added proper caching with TTL
 Optimized rate limiting logic
 Added request counting and reset

SECURITY:
 Sanitized prompts to prevent injection
 Removed API keys from error logs
 Added input length limits
 Added proper exception handling

The system is now production-ready with all critical issues resolved.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 01:36:14 +02:00
Zygmunt Dyras 950edd4acf feat: Add Perplexity Finance API and conversational AI research interface
PERPLEXITY FINANCE INTEGRATION:
- Complete connector for real-time financial analysis
- Stock analysis with fundamental, technical, and valuation modes
- Natural language stock screening
- Market sentiment analysis
- Earnings analysis and insider trading monitoring
- Congressional trades integration
- Peer comparison and similarity analysis

AI RESEARCH AGENT:
- LangChain-powered conversational interface
- Natural language investment queries
- Multi-tool orchestration for comprehensive research
- Portfolio gap analysis
- Risk-reward assessment
- Automated opportunity discovery
- Caching and performance optimization

RESEARCH CLI:
- Interactive command-line interface
- Rich formatting with tables and panels
- Stock screening with filters
- Investment opportunity finder
- Query history tracking
- Real-time market analysis

SCHEDULER INTEGRATION:
- AI research analysis every 2 hours
- Weekly opportunity scanning
- Automatic alerts for high-confidence signals
- Portfolio position analysis with Perplexity
- Market insights generation

EXAMPLE USAGE:
- research_demo.py showcases all capabilities
- Natural language queries like "Find undervalued tech stocks"
- Screening with specific criteria
- Portfolio optimization suggestions

This enables asking questions like:
- "What undervalued companies should I invest in?"
- "Is NVDA overvalued at current prices?"
- "What are Congress members buying?"
- "Find dividend stocks yielding over 4%"

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 01:28:31 +02:00
Zygmunt Dyras 380f29768e feat: Add Redis caching, security validation, and Docker containerization
REDIS CACHING:
- Connection pooling with max 50 connections
- Namespace-based cache keys (market, ai, signal, etc)
- TTL management per data type
- Batch operations and pattern deletion
- Distributed locking support
- LRU eviction policy

SECURITY VALIDATION:
- SQL injection prevention
- XSS prevention with HTML entity encoding
- SSRF prevention in webhooks
- Rate limiting with time windows
- HMAC-SHA256 request signing
- API key validation and secure generation
- Pydantic validation for all inputs

DOCKER CONTAINERIZATION:
- Multi-stage Dockerfile for optimization
- Complete production stack with docker-compose
- Services: PostgreSQL/TimescaleDB, Redis, Prometheus, Grafana
- Development environment with hot reload
- Health checks and resource limits
- Non-root user execution for security
- Persistent volumes and backups

System is now production-ready with institutional-grade infrastructure.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 01:15:47 +02:00
Zygmunt Dyras 9c33019243 feat: Add world-class production infrastructure
CRITICAL INFRASTRUCTURE:
- Database persistence layer with PostgreSQL/TimescaleDB
- Full order lifecycle tracking with audit trail
- Performance metrics and trade history

RESILIENT IBKR CONNECTOR:
- Auto-reconnection with exponential backoff
- Circuit breaker pattern for fault tolerance
- Connection health monitoring with heartbeat
- WebSocket support for real-time data
- Bracket order support (entry + stop + target)

ORDER MANAGEMENT SYSTEM:
- State machine for order lifecycle (pending→filled→closed)
- Idempotency to prevent duplicate orders
- Order validation with market checks
- Partial fill handling
- Comprehensive error handling

RISK MANAGEMENT ENGINE:
- Enforces position size limits (max 20%)
- Daily loss circuit breaker (5% limit)
- Concentration risk monitoring
- Pattern day trader rule compliance
- Correlation and volatility checks
- Portfolio health scoring
- Kelly Criterion position sizing
- Automatic stop-loss enforcement

This transforms the system from prototype to institutional-grade
with 99.9% target uptime and bank-level security practices.
2025-10-08 01:03:00 +02:00
Zygmunt Dyras 22ff8d8a4f feat: Add autonomous trading system with IBKR integration
- Implement IBKR connector for live portfolio monitoring
- Add multi-source data aggregator (congressional trades, news, insider trading)
- Create AI-powered signal processor with TradingAgents integration
- Build multi-channel alert system (Discord, Telegram, Email)
- Set up automated scheduler for 24/7 monitoring
- Add comprehensive configuration and safety controls
- Include portfolio analysis tools for IBKR positions

This system monitors markets continuously, tracks congressional trades,
and provides actionable trading signals with specific entry/exit prices.
2025-10-08 00:49:35 +02:00
Yijia Xiao 32be17c606
Merge pull request #235 from luohy15/data_vendor
Add Alpha Vantage API Integration and Refactor Data Provider Architecture
2025-10-05 16:01:30 -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 8fdbbcca3d alpha vantage api key url 2025-09-29 18:22:31 +08:00
luohy15 86bc0e793f minor fix 2025-09-27 00:04:59 +08:00
luohy15 7fc9c28a94 Add environment variable configuration support
- Add .env.example file with API key placeholders
- Update README.md with .env file setup instructions
- Add dotenv loading in main.py for environment variables

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 23:58:51 +08:00
luohy15 7bcc2cbd8a Update configuration documentation for Alpha Vantage data vendor
Add data vendor configuration examples in README and main.py showing how to configure Alpha Vantage as the primary data provider. Update documentation to reflect the current default behavior of using Alpha Vantage for real-time market data access.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 23:52:26 +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
Yijia Xiao a438acdbbd
Merge pull request #89 from Mirza-Samad-Ahmed-Baig/fixes
Enhancement: agent reflection, logging improvement
2025-07-03 10:15:39 -04:00
Yijia Xiao c73e374e7c
Update main.py 2025-07-03 10:14:06 -04:00
mirza-samad-ahmed-baig f704828f89 Fix: Prevent infinite loops, enable reflection, and improve logging 2025-07-03 17:43:40 +05:00
Edward Sun fda4f664e8
Merge pull request #49 from Zhongyi-Lu/a
Exclude `.env` from Git.
2025-07-01 09:17:46 -07: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 7abff0f354
Merge pull request #46 from AtharvSabde/patch-2
Updated requirements.txt based on latest commit
2025-06-23 20:40:58 -04: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
Zhongyi Lu b8f712b170 Exclude `.env` from Git 2025-06-21 23:29:26 -07: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
Atharv Sabde 11804f88ff
Updated requirements.txt based on latest commit
PULL REQUEST: Add support for other backends, such as OpenRouter and Ollama

it had two requirments missing. added those
2025-06-20 15:58:22 +05:30
Yijia Xiao 1e86e74314
Merge pull request #40 from RealMyth21/main
Updated README.md: Swap Trader and Management order.
2025-06-19 15:10:36 -04: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
Yijia Xiao ed32081f57
Merge pull request #44 from TauricResearch/dev
Merge dev into main branch
2025-06-19 15:00:07 -04:00
Atharv Sabde 2af7ef3d79
fundamentals_analyst.py(spelling mistake.markdown) 2025-06-19 21:48:16 +05:30
Mithil Srungarapu 383deb72aa
Updated README.md
The diagrams were switched, so I fixed it.
2025-06-18 19:08:10 -07:00
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
ZeroAct 417b09712c refactor 2025-06-12 13:53:28 +09: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
neo a879868396
docs: add links to other language versions of README (#13)
Added language selection links to the README for easier access to translated versions: German, Spanish, French, Japanese, Korean, Portuguese, Russian, and Chinese.
2025-06-09 15:51:06 -07:00
Yijia-Xiao 0013415378 Add star history 2025-06-09 15:14:41 -07:00
Edward Sun 0fdfd35867
Fix default python usage config code 2025-06-08 13:16:10 -07:00
Edward Sun e994e56c23
Remove EODHD from readme 2025-06-07 15:04:43 -07:00