# 🎉 New Features in TradingAgents This document highlights the major enhancements added to TradingAgents! ## Overview We've added **four major features** to TradingAgents: 1. ✅ **Multi-LLM Provider Support** - Use Claude, GPT-4, or Gemini 2. ✅ **Paper Trading Integration** - Practice with real market data 3. ✅ **Web Interface** - Beautiful GUI for analysis and trading 4. ✅ **Docker Support** - One-command deployment --- ## 1. 🤖 Multi-LLM Provider Support ### What's New You can now use **any LLM provider** for TradingAgents analysis: - **Anthropic Claude** (Recommended for deep reasoning) - **OpenAI GPT-4** (Proven performance) - **Google Gemini** (Cost-effective alternative) ### Why It Matters - **Choose the best model** for your needs - **Save costs** with appropriate models for different tasks - **Avoid vendor lock-in** - switch providers anytime - **Use your existing subscription** - Claude, OpenAI, or Google ### How to Use **1. Configure Provider** Edit `.env`: ```bash # Use Claude (Recommended!) LLM_PROVIDER=anthropic ANTHROPIC_API_KEY=your_key_here # Or use OpenAI LLM_PROVIDER=openai OPENAI_API_KEY=your_key_here # Or use Google LLM_PROVIDER=google GOOGLE_API_KEY=your_key_here ``` **2. Run Example** ```python from tradingagents.graph.trading_graph import TradingAgentsGraph from tradingagents.default_config import DEFAULT_CONFIG # Configure for Claude config = DEFAULT_CONFIG.copy() config["llm_provider"] = "anthropic" config["deep_think_llm"] = "claude-3-5-sonnet-20241022" config["quick_think_llm"] = "claude-3-5-sonnet-20241022" # Run analysis ta = TradingAgentsGraph(config=config) final_state, signal = ta.propagate("NVDA", "2024-05-10") print(f"Signal: {signal}") ``` **3. Try It** ```bash python examples/use_claude.py ``` ### Recommended Models | Provider | Deep Thinking | Quick Thinking | Budget | |----------|---------------|----------------|---------| | Anthropic | claude-3-5-sonnet-20241022 | claude-3-5-sonnet-20241022 | claude-3-5-haiku-20241022 | | OpenAI | gpt-4o | gpt-4o-mini | gpt-4o-mini | | Google | gemini-1.5-pro | gemini-1.5-flash | gemini-1.5-flash | **Files:** - `tradingagents/llm_factory.py` - LLM provider factory - `examples/use_claude.py` - Claude usage example --- ## 2. 📈 Paper Trading Integration ### What's New Connect TradingAgents to **real broker platforms** for paper trading: - **Alpaca** - FREE paper trading with real market data - Easy order execution - Portfolio tracking - Real-time positions and P&L ### Why It Matters - **Practice risk-free** - No real money involved - **Test strategies** - Validate before going live - **Real market data** - Actual prices and execution - **Build confidence** - Learn without financial risk ### How to Use **1. Sign Up for Alpaca (FREE!)** Visit [alpaca.markets](https://alpaca.markets) and create account. **2. Get API Keys** Dashboard → Paper Trading → API Keys **3. Configure** Edit `.env`: ```bash ALPACA_API_KEY=your_key_id ALPACA_SECRET_KEY=your_secret ALPACA_PAPER_TRADING=true ``` **4. Start Trading** ```python from tradingagents.brokers import AlpacaBroker from decimal import Decimal # Connect broker = AlpacaBroker(paper_trading=True) broker.connect() # Check account account = broker.get_account() print(f"Buying Power: ${account.buying_power:,.2f}") # Buy AAPL order = broker.buy_market("AAPL", Decimal("10")) print(f"Order ID: {order.order_id}") # Check positions positions = broker.get_positions() for pos in positions: print(f"{pos.symbol}: {pos.quantity} shares, P&L: ${pos.unrealized_pnl}") ``` **5. Try Examples** ```bash # Basic paper trading python examples/paper_trading_alpaca.py # TradingAgents + Alpaca integration python examples/tradingagents_with_alpaca.py ``` ### Supported Features - ✅ Market orders - ✅ Limit orders - ✅ Stop-loss orders - ✅ Position tracking - ✅ Real-time P&L - ✅ Account management **Files:** - `tradingagents/brokers/base.py` - Broker interface - `tradingagents/brokers/alpaca_broker.py` - Alpaca implementation - `examples/paper_trading_alpaca.py` - Basic example - `examples/tradingagents_with_alpaca.py` - Full integration --- ## 3. 🌐 Web Interface ### What's New Beautiful **web-based GUI** for TradingAgents: - Chat-based interface - Stock analysis - Order execution - Portfolio management - Real-time updates ### Why It Matters - **User-friendly** - No coding required - **Interactive** - Chat with your trading assistant - **Visual** - See analysis and results - **Accessible** - Use from any browser ### How to Use **1. Install Dependencies** Already included in `requirements.txt`: - chainlit **2. Configure** Edit `.env` (same as before - no extra setup needed!) **3. Start Web Interface** ```bash chainlit run web_app.py -w ``` **4. Open Browser** Visit http://localhost:8000 **5. Try Commands** ``` # Analyze a stock analyze NVDA # Connect to paper trading connect # Check account account # View portfolio portfolio # Buy shares buy NVDA 5 # Sell shares sell NVDA 5 # Get help help ``` ### Available Commands | Command | Description | Example | |---------|-------------|---------| | `analyze TICKER` | AI analysis | `analyze AAPL` | | `connect` | Connect broker | `connect` | | `account` | Account status | `account` | | `portfolio` | View positions | `portfolio` | | `buy TICKER QTY` | Buy shares | `buy NVDA 10` | | `sell TICKER QTY` | Sell shares | `sell NVDA 5` | | `provider NAME` | Change LLM | `provider anthropic` | | `settings` | View config | `settings` | | `help` | Show help | `help` | ### Screenshots **Welcome Screen:** ``` 🤖 Welcome to TradingAgents! I'm your AI-powered trading assistant... ``` **Analysis:** ``` 📊 Analysis Complete: NVDA 🎯 Trading Signal: BUY Market Analysis: [Detailed analysis...] Fundamentals: [Financial metrics...] News Sentiment: [Recent news...] Recommendation: BUY ``` **Portfolio:** ``` 📈 Current Positions NVDA - Quantity: 10 shares - Avg Cost: $895.50 - Current: $920.00 - P&L: $245.00 (2.73%) Total Position Value: $9,200.00 ``` **Files:** - `web_app.py` - Main web application - `.chainlit` - Chainlit configuration --- ## 4. 🐳 Docker Support ### What's New **One-command deployment** with Docker: - Pre-configured environment - All dependencies included - Persistent data storage - Easy scaling ### Why It Matters - **Quick setup** - No dependency hell - **Reproducible** - Same environment everywhere - **Isolated** - Won't conflict with other projects - **Production-ready** - Deploy anywhere ### How to Use **1. Prerequisites** Install Docker and Docker Compose **2. Configure** ```bash # Copy environment file cp .env.example .env # Edit with your keys nano .env ``` **3. Build and Run** ```bash # Build container docker-compose build # Start services docker-compose up # Access at http://localhost:8000 ``` **That's it!** 🎉 ### Docker Commands ```bash # Start in background docker-compose up -d # View logs docker-compose logs -f # Stop docker-compose down # Restart docker-compose restart # Run Python scripts docker-compose run tradingagents python examples/portfolio_example.py # Open shell docker-compose run tradingagents bash # Run tests docker-compose run tradingagents pytest tests/ -v ``` ### Optional: Jupyter Notebook ```bash # Start with Jupyter docker-compose --profile jupyter up # Access at http://localhost:8888 ``` ### Data Persistence Data is automatically persisted in: ``` ./data/ # Market data cache ./eval_results/ # Analysis results ./portfolio_data/ # Portfolio state ``` **Files:** - `Dockerfile` - Container image definition - `docker-compose.yml` - Multi-service setup - `.dockerignore` - Build optimization - `DOCKER.md` - Complete Docker guide --- ## 🚀 Getting Started with New Features ### Quick Start Guide **1. Clone Repository** ```bash git clone https://github.com/TauricResearch/TradingAgents.git cd TradingAgents ``` **2. Configure Environment** ```bash cp .env.example .env nano .env ``` Add your API keys: ```bash # LLM Provider (choose one) ANTHROPIC_API_KEY=your_claude_key # or OPENAI_API_KEY=your_openai_key # Data Provider ALPHA_VANTAGE_API_KEY=your_av_key # Paper Trading (optional) ALPACA_API_KEY=your_alpaca_key ALPACA_SECRET_KEY=your_alpaca_secret ``` **3. Choose Your Method** **Option A: Docker (Easiest)** ```bash docker-compose up # Open http://localhost:8000 ``` **Option B: Local Installation** ```bash pip install -r requirements.txt pip install -e . chainlit run web_app.py -w # Open http://localhost:8000 ``` **4. Try It Out** In the web interface: ``` analyze NVDA connect buy NVDA 5 portfolio ``` Or run Python scripts: ```bash python examples/use_claude.py python examples/paper_trading_alpaca.py python examples/tradingagents_with_alpaca.py ``` --- ## 📊 Complete Example Workflow Here's a complete workflow using all new features: **1. Analyze Stock with Claude** ```python from tradingagents.graph.trading_graph import TradingAgentsGraph from tradingagents.default_config import DEFAULT_CONFIG config = DEFAULT_CONFIG.copy() config["llm_provider"] = "anthropic" config["deep_think_llm"] = "claude-3-5-sonnet-20241022" ta = TradingAgentsGraph(config=config) final_state, signal = ta.propagate("NVDA", "2024-05-10") ``` **2. Execute Trade on Alpaca** ```python from tradingagents.brokers import AlpacaBroker from decimal import Decimal broker = AlpacaBroker(paper_trading=True) broker.connect() if signal == "BUY": order = broker.buy_market("NVDA", Decimal("5")) print(f"Bought NVDA: {order.order_id}") ``` **3. Track Performance** ```python positions = broker.get_positions() for pos in positions: print(f"{pos.symbol}: ${pos.unrealized_pnl:,.2f} P&L") ``` **4. Use Web Interface** ```bash chainlit run web_app.py -w ``` Then in browser: ``` analyze NVDA buy NVDA 5 portfolio ``` **5. Run in Docker** ```bash docker-compose up # Access http://localhost:8000 ``` --- ## 🎓 Learning Resources ### Documentation - **Multi-LLM**: `tradingagents/llm_factory.py` docstrings - **Paper Trading**: `tradingagents/brokers/README.md` - **Web Interface**: `web_app.py` comments - **Docker**: `DOCKER.md` ### Examples - `examples/use_claude.py` - Claude integration - `examples/paper_trading_alpaca.py` - Basic paper trading - `examples/tradingagents_with_alpaca.py` - Full integration - `examples/portfolio_example.py` - Portfolio management ### Tests - `tests/portfolio/` - Portfolio tests (96% coverage) - `tests/backtest/` - Backtesting tests - Run with: `pytest tests/ -v` --- ## 🔮 What's Next? Future enhancements we're considering: - **More Brokers**: Interactive Brokers, TD Ameritrade - **Advanced Charts**: TradingView integration - **Alerts**: Email/SMS notifications - **Strategies**: Pre-built trading strategies - **Backtesting UI**: Visual backtesting in web interface - **Mobile App**: iOS/Android support --- ## 💬 Support Need help? - **Documentation**: Check README files in each module - **Examples**: Run scripts in `examples/` directory - **Issues**: Report bugs on GitHub - **Questions**: Use GitHub Discussions --- ## 🎉 Summary You now have access to: ✅ **Claude Integration** - Best-in-class LLM for trading analysis ✅ **Paper Trading** - Risk-free practice with real market data ✅ **Web Interface** - User-friendly GUI for everything ✅ **Docker Support** - One-command deployment anywhere **Get started today:** ```bash # Clone and configure git clone https://github.com/TauricResearch/TradingAgents.git cd TradingAgents cp .env.example .env # Edit .env with your keys # Start with Docker docker-compose up # Or run locally chainlit run web_app.py -w # Open http://localhost:8000 and start trading! 🚀 ``` Happy Trading! 📈