3.7 KiB
3.7 KiB
TradingAgents - Docker Setup Guide
This directory contains the Docker setup for running TradingAgents with a FastAPI backend and Next.js frontend.
🚀 Quick Start
Prerequisites
- Docker and Docker Compose installed
- OpenAI API Key
- Alpha Vantage API Key (optional, for enhanced data)
Environment Setup
- Copy your
.envfile in the project root with your API keys:
OPENAI_API_KEY=your_openai_api_key_here
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here
Running with Docker
- Build and start all services:
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
-
Stop the services:
docker-compose down
📁 Project Structure
TradingAgents/
├── backend/ # FastAPI backend
│ ├── app/
│ │ ├── api/ # API routes
│ │ ├── models/ # Pydantic models
│ │ ├── services/ # Business logic
│ │ └── core/ # Configuration
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/ # Next.js frontend
│ ├── app/ # Next.js pages
│ ├── components/ # React components
│ ├── lib/ # Utilities and API client
│ ├── hooks/ # Custom React hooks
│ └── Dockerfile
├── tradingagents/ # Core TradingAgents package
└── docker-compose.yml # Docker orchestration
🔧 Backend API
Available Endpoints
GET /api/health- Health checkGET /api/config- Get configuration optionsPOST /api/analyze- Run trading analysisGET /api/tickers- Get popular tickers
Example API Request
curl -X POST http://localhost:8000/api/analyze \
-H "Content-Type: application/json" \
-d '{
"ticker": "NVDA",
"analysis_date": "2024-05-10",
"research_depth": 1
}'
🎨 Frontend Features
- Modern UI: Built with Next.js, React, and shadcn/ui
- Type Safety: Full TypeScript support
- Responsive Design: Works on desktop and mobile
- Real-time Updates: Live analysis status
- Rich Visualizations: Interactive reports and decisions
🛠️ Development
Running Backend Only
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload
Running Frontend Only
cd frontend
npm install
npm run dev
📊 Using the Application
- Navigate to http://localhost:3000
- Click "Start Analysis" or go to the Analysis page
- Configure your analysis parameters:
- Stock ticker (e.g., NVDA, AAPL)
- Analysis date
- Research depth (1-5)
- LLM models
- Click "Run Analysis"
- Wait for the multi-agent analysis to complete
- Review the trading decision and detailed reports
🔐 Security Notes
- Never commit
.envfiles with real API keys - Use environment variables for sensitive data
- The backend validates all inputs using Pydantic
- CORS is configured for frontend-backend communication
🐛 Troubleshooting
Backend Issues
- Check logs:
docker-compose logs backend - Verify API keys are set correctly
- Ensure port 8000 is not in use
Frontend Issues
- Check logs:
docker-compose logs frontend - Verify backend is running
- Ensure port 3000 is not in use
Network Issues
- Restart Docker:
docker-compose down && docker-compose up - Check network:
docker network ls - Verify services can communicate:
docker-compose exec frontend ping backend
📝 License
This project follows the same license as TradingAgents.
🤝 Contributing
See the main README.md for contribution guidelines.