Common issues and solutions when working with Trading Buddy.
Run this command to check your setup:
make check-envProblem: Missing Python dependencies.
Solution:
# Activate virtual environment first
source venv/bin/activate
# Reinstall dependencies
pip install -r requirements.txtProblem: Python not installed or not in PATH.
Solution:
# macOS
brew install python@3.11
# Ubuntu/Debian
sudo apt install python3.11 python3.11-venv
# Verify installation
python3 --versionProblem: source venv/bin/activate doesn't work.
Solution:
# Delete and recreate
rm -rf venv
python3 -m venv venv
source venv/bin/activateProblem: Missing or empty SECRET_KEY in .env file.
Solution:
# Generate a new secret key
python -c 'import secrets; print(secrets.token_hex(32))'
# Add to .env file
echo "SECRET_KEY=your_generated_key_here" >> .envProblem: Invalid configuration in .env.
Solution:
- Check .env file exists:
ls -la .env - Verify format (no spaces around
=):# Wrong SECRET_KEY = abc123 # Correct SECRET_KEY=abc123
- Check for special characters (wrap in quotes if needed):
SECRET_KEY="key_with_special/chars"
Problem: Alpaca API authentication failing.
Solutions:
-
Verify API keys are correct:
# Check keys are set echo $APCA_API_KEY_ID echo $APCA_API_SECRET_KEY
-
Ensure using correct URL for key type:
# Paper trading keys → Paper URL APCA_API_BASE_URL=https://paper-api.alpaca.markets # Live trading keys → Live URL APCA_API_BASE_URL=https://api.alpaca.markets
-
Check account status:
- Log into Alpaca Dashboard
- Verify account is active and approved
Problem: Too many API requests.
Solutions:
-
Wait and retry: The system has automatic backoff
-
Check rate limits:
Provider Free Tier Limit Polygon 5/min Finnhub 60/min Alpha Vantage 5/min, 25/day -
Add more providers: Requests are distributed across providers
Problem: Missing Polygon API key for real-time data.
Solution:
# Get free key at polygon.io
POLYGON_API_KEY=your_polygon_key
# Or use alternative (Finnhub)
FINNHUB_API_KEY=your_finnhub_keyProblem: Invalid or expired API key.
Solutions:
- Regenerate API key from provider dashboard
- Check for typos in .env file
- Verify key hasn't been revoked
Problem: Another process is using port 8000.
Solutions:
-
Find and kill the process:
# Find what's using port 8000 lsof -i :8000 # Kill it kill -9 <PID>
-
Use a different port:
python run_web.py --port 8080
Problem: Various startup errors.
Solutions:
-
Check logs:
tail -f logs/trading_web.log
-
Run in debug mode:
FLASK_DEBUG=1 python run_web.py
-
Verify all environment variables:
make check-env
Problem: Real-time data not updating.
Solutions:
- Check browser console for WebSocket errors
- Verify firewall isn't blocking WebSocket connections
- Check provider status:
Problem: Different providers returning different prices.
Explanation: This is normal - different providers have slightly different data due to:
- Different data sources
- Different update frequencies
- Different aggregation methods
The system automatically:
- Uses consensus (average) value
- Logs discrepancies for review
- Falls back to most reliable source
Problem: Quote returns empty or null.
Solutions:
-
Verify symbol is valid:
# Check if symbol exists curl "https://finnhub.io/api/v1/search?q=AAPL&token=YOUR_KEY"
-
Check market hours:
- US markets: 9:30 AM - 4:00 PM ET
- Some providers don't return data outside market hours
-
Try different provider:
# In provider_router.py, check provider priority
Problem: Prices seem outdated.
Solutions:
- Check WebSocket connection in browser dev tools
- Verify provider circuit breakers aren't tripped:
# Check health endpoint curl http://localhost:8000/api/health - Restart the application:
make run
Problem: Trades being blocked.
Possible reasons:
- Position size too large (>5% of portfolio)
- Sector exposure too high (>20%)
- Daily loss limit hit (-3%)
- Conviction score too low (<60%)
Solutions:
- Check rejection reason in API response
- Reduce position size
- Wait for circuit breaker reset (if loss limit hit)
- Adjust risk parameters in config.json
Problem: Trade submitted but not in positions.
Solutions:
- Check Alpaca dashboard directly
- Verify order status:
curl http://localhost:8000/api/orders
- Check if market is open
Solution:
# Install pnpm
npm install -g pnpm
# Or use npm instead
cd trading-agent && npm installSolution:
cd trading-agent
# Clean and rebuild
rm -rf dist node_modules
pnpm install
pnpm buildSolutions:
-
Check Docker is running:
docker ps
-
View container logs:
docker-compose logs -f
-
Rebuild container:
docker-compose down docker-compose build --no-cache docker-compose up -d
If you're still stuck:
- Search existing issues: GitHub Issues
- Check discussions: GitHub Discussions
- Open a new issue with:
- Python version (
python --version) - OS and version
- Error message (full traceback)
- Steps to reproduce
- Python version (
| Error | Likely Cause | Quick Fix |
|---|---|---|
SECRET_KEY must be set |
Missing .env config | Run make setup |
ModuleNotFoundError |
Missing dependencies | pip install -r requirements.txt |
ConnectionRefusedError |
Server not running | make run |
401 Unauthorized |
Invalid API key | Check .env keys |
429 Too Many Requests |
Rate limited | Wait or add more providers |
TimeoutError |
Network/API issues | Check internet connection |
Port already in use |
Port conflict | Kill process or use different port |