🚀 AlpacaTradingAgent - An independent enhanced version built upon the original TradingAgents framework, specifically designed for Alpaca users who want to test or use AI agents to trade on their Alpaca accounts.
This project is an independent upgrade inspired by the original TradingAgents framework by Tauric Research, extending it with real-time Alpaca integration, crypto support, automated trading capabilities, and an enhanced web interface.
Disclaimer: This project is provided solely for educational and research purposes. It is not financial, investment, or trading advice. Trading involves risk, and users should conduct their own due diligence before making any trading decisions.
🚀 Enhanced Features | ⚡ Installation & Setup | 📦 Package Usage | 🌐 Web Interface | 📖 Complete Guide | 🤝 Contributing | 📄 Citation
AlpacaTradingAgent introduces powerful new capabilities specifically designed for Alpaca users:
- Live Trading: Direct integration with Alpaca API for real-time trading execution
- Paper & Live Trading: Support for both paper trading (testing) and live trading with real money
- Margin Trading: Full support for margin accounts, including short selling capabilities
- Portfolio Management: Real-time portfolio tracking, position monitoring, and order management
- Multi-Asset Analysis: Analyze both traditional stocks and cryptocurrencies in a single session
- Crypto Format: Use proper crypto format (e.g.,
BTC/USD,ETH/USD) for cryptocurrency analysis - Mixed Portfolios: Support for mixed symbol inputs like
"NVDA, ETH/USD, AAPL"for diversified analysis - Dedicated Data Sources: Coindesk API for crypto news and DeFi Llama for fundamental crypto data
- Market Analyst: Evaluates overall market conditions and trends
- Social Sentiment Analyst: Analyzes social media sentiment and public opinion
- News Analyst: Monitors and interprets financial news and events
- Fundamental Analyst: Assesses company financials and intrinsic value
- Macro Analyst: Analyzes macroeconomic indicators and Federal Reserve data
- Market Hours Trading: Automatic execution during market hours
- Scheduled Analysis: Configurable recurring analysis every N hours
- Auto-Execution: Optional automatic trade execution based on agent recommendations
- Smart Scheduling: Respects market hours for different asset classes
- Multi-Symbol Dashboard: Analyze and trade multiple symbols simultaneously
- Progress Tracking: Real-time progress table showing analysis status for each symbol
- Interactive Charts: Live Alpaca data integration with technical indicators
- Tabbed Reports: Organized analysis reports with easy navigation
- Chat-Style Debates: Visualize agent debates as conversation threads
- Position Management: View current positions, recent orders, and liquidate positions directly from UI
For an in-depth, step-by-step walkthrough of using the AlpacaTradingAgent web UI for automated trading, check out the complete guide on Dev.to:
AlpacaTradingAgent is a multi-agent trading framework that mirrors the dynamics of real-world trading firms. By deploying specialized LLM-powered agents working collaboratively, the platform evaluates market conditions across multiple asset classes and executes informed trading decisions through the Alpaca API.
AlpacaTradingAgent framework is designed for research and educational purposes. Trading performance may vary based on many factors, including the chosen backbone language models, model temperature, trading periods, the quality of data, and other non-deterministic factors. It is not intended as financial, investment, or trading advice.
Our enhanced framework decomposes complex trading tasks into specialized roles while providing real-time market connectivity and execution capabilities.
- Market Analyst: Evaluates overall market conditions, sector trends, and market sentiment indicators
- Social Sentiment Analyst: Analyzes Twitter, Reddit, and other social platforms to gauge market sentiment and momentum
- News Analyst: Monitors financial news, earnings announcements, and global events that impact markets
- Fundamental Analyst: Evaluates company financials, earnings reports, and intrinsic value calculations
- Macro Analyst: Analyzes Federal Reserve data, economic indicators, and macroeconomic trends using FRED API
- Comprises both bullish and bearish researchers who critically assess the insights provided by the Analyst Team. Through structured debates, they balance potential gains against inherent risks, now with enhanced support for both equity and crypto markets.
- Composes reports from analysts and researchers to make informed trading decisions. Determines timing, magnitude, and direction (long/short) of trades with direct execution through Alpaca API.
- Continuously evaluates portfolio risk across stocks and crypto assets. Monitors margin requirements, position sizes, and overall portfolio exposure. Provides real-time risk assessment and position management through the Alpaca integration.
Clone AlpacaTradingAgent:
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgentsCreate a virtual environment:
conda create -n alpacatradingagent python=3.13
conda activate alpacatradingagentInstall dependencies:
pip install -r requirements.txtFor full functionality including real-time trading, you'll need to set up the following API keys:
-
Copy the sample environment file:
cp env.sample .env
-
Edit the
.envfile with your API keys:
-
Alpaca API Keys (Required for trading):
- Sign up at Alpaca Markets
- Get your API key and secret from the dashboard
- Set
ALPACA_USE_PAPER=Truefor paper trading (recommended for testing) - Set
ALPACA_USE_PAPER=Falsefor live trading with real money
-
OpenAI API Key (Required for LLM agents):
- Sign up at OpenAI Platform
-
Finnhub API Key (Required for stock news and data):
- Sign up at Finnhub
-
FRED API Key (Required for macro analysis):
- Get your free key from FRED
- CoinDesk API Key (Required for crypto news):
- Sign up at CryptoCompare
- Twitter Bearer Token (Optional for enhanced social sentiment):
- Get from Twitter Developer for API-based sentiment analysis
- The system can fallback to web scraping if not provided
- Restart the application after setting up your API keys.
Note: Without valid Alpaca API keys, the application will fall back to demo mode without trading capabilities.
You can try out the CLI by running:
python -m cli.mainThe CLI now supports multiple symbols and crypto assets:
- Single stock:
NVDA - Single crypto:
BTC/USD - Multiple mixed assets:
NVDA, ETH/USD, AAPL, BTC/USD
Launch the enhanced Dash-based web interface:
python run_webui_dash.pyCommon options:
--port PORT: Specify a custom port (default: 7860)--share: Create a public link to share with others--server-name: Specify the server name/IP to bind to (default: 127.0.0.1)--debug: Run in debug mode with more logging--max-threads N: Set the maximum number of threads (default: 40)
This will start a local web server at http://localhost:7860.
The web interface offers comprehensive trading and analysis capabilities:
Multi-Asset Analysis Dashboard
- Analyze multiple stocks and crypto assets simultaneously
- Real-time progress tracking for each symbol
- Support for mixed portfolios (e.g.,
"NVDA, ETH/USD, AAPL")
Live Trading Integration
- View current Alpaca positions and recent orders
- Execute trades directly from the interface
- Liquidate positions with one-click functionality
- Real-time portfolio value tracking
Interactive Charts & Data
- Live price charts powered by Alpaca API
- Technical indicators and analysis overlays
- Support for both stock and crypto price data
Enhanced Reporting Interface
- Tabbed navigation for different analysis reports
- Chat-style conversation view for agent debates
- Progress table showing analysis status for each symbol
- Downloadable reports and trade recommendations
Automated Trading Controls
- Schedule recurring analysis during market hours
- Configure auto-execution of trade recommendations
- Set custom analysis intervals (every N hours)
- Margin trading controls and risk management
Built with LangGraph for flexibility and modularity. The enhanced version integrates with multiple financial APIs and supports both paper and live trading through Alpaca. We recommend using gpt-5-mini for testing to minimize API costs, as the framework makes numerous API calls across all 5 agents.
from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
# Initialize with default config
ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy())
# Analyze a single stock
_, decision = ta.propagate("NVDA", "2024-05-10")
print(decision)
# Analyze multiple assets including crypto
symbols = ["NVDA", "ETH/USD", "AAPL"]
for symbol in symbols:
_, decision = ta.propagate(symbol, "2024-05-10")
print(f"{symbol}: {decision}")from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
# Create custom config for enhanced features
config = DEFAULT_CONFIG.copy()
config["deep_think_llm"] = "gpt-5-mini" # Cost-effective for testing
config["quick_think_llm"] = "gpt-5-mini"
config["max_debate_rounds"] = 2 # Increase debate rounds
config["online_tools"] = True # Use real-time data
config["enable_margin_trading"] = True # Allow short selling
config["auto_execute_trades"] = False # Manual approval required
# Initialize with custom config
ta = TradingAgentsGraph(debug=True, config=config)
# Analyze with crypto support
_, decision = ta.propagate("BTC/USD", "2024-05-10")
print(decision)We welcome contributions from the community! AlpacaTradingAgent is an independent project that builds upon concepts from the original TradingAgents framework, continuously evolving with new features for Alpaca integration and multi-asset support.
This project is inspired by and builds upon concepts from the original TradingAgents framework by Tauric Research. We extend our gratitude to the original authors for their pioneering work in multi-agent financial trading systems.
AlpacaTradingAgent is an independent project that focuses specifically on providing Alpaca users with a production-ready trading interface, real-time market connectivity, and expanded asset class support while implementing an enhanced multi-agent architecture.
Please reference the original TradingAgents work that inspired this project:
@misc{xiao2025tradingagentsmultiagentsllmfinancial,
title={TradingAgents: Multi-Agents LLM Financial Trading Framework},
author={Yijia Xiao and Edward Sun and Di Luo and Wei Wang},
year={2025},
eprint={2412.20138},
archivePrefix={arXiv},
primaryClass={q-fin.TR},
url={https://arxiv.org/abs/2412.20138},
}



