Troubleshooting
Common issues and solutions for the alpha-oracle system.
Backend / API Issues
“Connection refused” on port 8000
Symptom: Frontend shows connection error, curl http://localhost:8000 fails
Diagnosis:
# Check if backend is running
ps aux | grep uvicorn
# Check PID file
cat .pids/backend.pid
# Check logs
tail -f logs/backend.log
Solutions:
- Backend not started →
./scripts/start-backend.sh - Backend crashed → Check
logs/backend.logfor errors - Port already in use →
lsof -i :8000(kill conflicting process) - Permission error → Check file ownership, run as non-root
FastAPI startup fails
Symptom: Backend exits immediately after start
Check logs:
tail -50 logs/backend.log
Common causes:
1. Missing environment variables:
KeyError: 'SA_ALPHA_VANTAGE_API_KEY'
Solution: Set in .env file or export:
export SA_ALPHA_VANTAGE_API_KEY=your_key_here
2. Database connection error:
sqlalchemy.exc.OperationalError: could not connect to server
Solution: Start TimescaleDB:
docker compose up -d timescaledb
docker compose logs timescaledb
3. Redis connection error:
redis.exceptions.ConnectionError: Error connecting to Redis
Solution: Start Redis:
docker compose up -d redis
docker compose logs redis
4. Import error:
ModuleNotFoundError: No module named 'ib_async'
Solution: Install dependencies:
pip install -e ".[dev]"
Database Issues
“Connection refused” on port 5432
Symptom: Backend logs show PostgreSQL connection errors
Diagnosis:
docker compose ps
docker compose logs timescaledb
Solutions:
- TimescaleDB not running →
docker compose up -d timescaledb - Database initializing → Wait 10-15 seconds for health check
- Port conflict → Check if another Postgres instance is using 5432
- Volume corruption →
docker compose down -v && docker compose up -d(destroys data)
Empty query results despite backfill
Symptom: Queries return no rows, but backfill completed
Diagnosis:
docker exec -it alpha-oracle-timescaledb-1 psql -U trader -d stock_analysis
-- Check row count
SELECT COUNT(*) FROM ohlcv;
-- Check symbols
SELECT DISTINCT symbol FROM ohlcv LIMIT 10;
-- Check date range
SELECT MIN(timestamp), MAX(timestamp) FROM ohlcv;
Common causes:
- Timezone mismatch → Queries use wrong timezone
- Symbol case sensitivity → Use uppercase symbols
- Wrong database → Check connection string points to
stock_analysis
Hypertable errors
Symptom:
ERROR: relation "ohlcv" is not a hypertable
Solution: Re-initialize database:
docker compose down -v # WARNING: destroys all data
docker compose up -d timescaledb
# Wait for initialization to complete
python scripts/backfill_history.py --years 2 --symbols sp500
Redis Issues
“Connection refused” on port 6379
Symptom: Backend logs show Redis connection errors
Diagnosis:
docker compose ps
docker compose logs redis
Solutions:
- Redis not running →
docker compose up -d redis - Port conflict → Check if another Redis instance is using 6379
- Max clients reached →
docker restart alpha-oracle-redis-1
Redis out of memory
Symptom:
redis.exceptions.ResponseError: OOM command not allowed when used memory > 'maxmemory'
Solution: Increase Redis max memory in docker-compose.yml:
redis:
command: redis-server --maxmemory 512mb --maxmemory-policy allkeys-lru
Then restart:
docker compose restart redis
Lost PDT tracking data
Symptom: Day trade count resets unexpectedly
Diagnosis:
docker exec -it alpha-oracle-redis-1 redis-cli ZRANGE risk:pdt:trades 0 -1 WITHSCORES
Causes:
- Redis
FLUSHALLexecuted → Data lost, cannot recover - Container restart with no volume → Check
docker-compose.ymlhasredis_datavolume
Prevention:
- Never run
FLUSHALLin production - Always use
docker compose down(notdocker compose down -v) - Backup Redis data:
docker exec alpha-oracle-redis-1 redis-cli SAVE
IBKR Gateway Issues
“Client ID already in use”
Symptom:
ib_async.wrapper.Connection error: 326, clientId 1 is already in use.
Cause: Another connection is using the same client ID
Diagnosis:
# Check for orphaned Python processes
ps aux | grep python
# Check IB Gateway connections (in Gateway UI)
# File → Global Configuration → API → Settings → Active Clients
Solutions:
- Kill orphaned process:
pkill -f "uvicorn src.api.main" - Restart IB Gateway to clear stuck connections
- Use unique client IDs: broker=1, data=2, feed=3 (default)
- Check
SA_BROKER__IBKR__CLIENT_IDenvironment variable
“No security definition found for”
Symptom:
ERROR: No security definition found for symbol XYZ
Causes:
- Invalid ticker symbol
- Symbol not traded on SMART routing
- Delisted stock
Solutions:
- Verify ticker spelling (use IBKR’s primary symbol)
- Check symbol on IBKR TWS → Symbol search
- Remove delisted symbols from universe
IB Gateway not reachable
Symptom:
ERROR: ibkr_gateway.not_connected - system is running in degraded mode
Diagnosis:
- Is IB Gateway running?
- Check Gateway status indicator (should be green “Ready”)
- Check port configuration (paper=4002, live=4001)
Solutions:
- Start IB Gateway and wait for “Ready” status
- Verify port in
.env:SA_BROKER__IBKR__PORT=4002 - Check firewall allows localhost connections
- Restart IB Gateway if stuck in “Connecting…” state
Delayed market data
Symptom: Prices are 15 minutes behind
Cause: No real-time market data subscription
Expected in paper trading: Delayed data is normal without subscription
Solution for live trading:
- Log in to IBKR Account Management
- Navigate to Market Data Subscriptions
- Subscribe to “US Equity and Options Add-On Streaming Bundle” (~$10/mo)
Connection drops at 4pm ET
Symptom: Feed disconnects every day at market close
Cause: Expected behavior — IBKR closes connections at 4pm ET
Solution: System auto-reconnects. Check logs for:
system:feed:disconnected
system:feed:reconnected
No action needed. This is normal.
Test Failures
Tests fail with import errors
Symptom:
AttributeError: <module 'src.data.storage'> has no attribute 'TimeSeriesStorage'
Cause: Lazy imports in job functions not patched correctly
Solution: Patch at source module path:
# WRONG
@patch('src.scheduling.jobs.TimeSeriesStorage')
# CORRECT
@patch('src.data.storage.TimeSeriesStorage')
Rule: Patch where the object is imported from, not where it’s used.
PDT guard rejecting all orders
Symptom: All BUY orders rejected with PDT warning
Diagnosis:
# Check day trade count
docker exec -it alpha-oracle-redis-1 redis-cli ZCARD risk:pdt:trades
Causes:
- Account under $25K → PDT rules apply
- 3+ day trades in last 5 business days → At limit
- Redis key corrupted → Contains invalid dates
Solutions:
- Wait for old trades to expire (7 days)
- Increase
min_hold_daysto 3+ in strategies - Clear Redis (development only):
redis-cli DEL risk:pdt:trades
NEVER disable PDT guard in production.
Kill Switch Issues
Kill switch stuck in active state
Symptom: Trading halted, cannot resume
Diagnosis:
# Check Redis key
docker exec -it alpha-oracle-redis-1 redis-cli GET risk:kill_switch
# Check database
docker exec -it alpha-oracle-timescaledb-1 psql -U trader -d stock_analysis
SELECT * FROM kill_switch;
Solutions:
- Use dashboard kill switch modal with “RESUME” confirmation
- Manual override (development only):
docker exec -it alpha-oracle-redis-1 redis-cli SET risk:kill_switch inactive - Database update (development only):
UPDATE kill_switch SET active = FALSE, deactivated_at = NOW();
In production: Always use proper deactivation flow (dashboard or API) for audit trail.
Data Quality Issues
Stale data alerts
Symptom: Circuit breaker activates due to stale data
Causes:
- Market feed disconnected
- No recent bar ingestion
- Scheduler job failed
Diagnosis:
# Check feed status
curl http://localhost:8000/api/system/health
# Check latest bars
docker exec -it alpha-oracle-timescaledb-1 psql -U trader -d stock_analysis
SELECT symbol, MAX(timestamp) FROM ohlcv GROUP BY symbol ORDER BY MAX(timestamp) DESC LIMIT 10;
# Check scheduler logs
grep "daily_bars_job" logs/backend.log
Solutions:
- Restart market feed (restart backend)
- Manually trigger job:
POST /api/system/scheduler/trigger/daily_bars - Check Alpha Vantage API key and rate limits
Missing fundamental data
Symptom: Strategies fail due to missing PE ratio, etc.
Cause: Alpha Vantage does not provide fundamentals for all symbols
Solutions:
- Check if symbol is excluded:
grep "fundamentals.symbol_error" logs/backend.log - Manually trigger job:
POST /api/system/scheduler/trigger/weekly_fundamentals - Some symbols (ETFs, foreign stocks) don’t have fundamentals → Strategy should handle
None
Frontend Issues
Frontend not loading
Symptom: Blank page or “Cannot GET /” error
Diagnosis:
# Check if Vite is running
ps aux | grep vite
# Check PID file
cat .pids/frontend.pid
# Check logs
tail -f logs/frontend.log
Solutions:
- Frontend not started →
./scripts/start-frontend.sh - Port conflict (3000) → Kill conflicting process
- Build error → Check
logs/frontend.log, runnpm run lint
API proxy not working
Symptom: API calls fail with CORS errors or 404
Cause: Vite proxy misconfigured or backend not reachable
Diagnosis:
# Check Vite config
cat web/vite.config.ts
# Should contain:
# proxy: {
# '/api': 'http://localhost:8000',
# }
# Check backend
curl http://localhost:8000/api/portfolio
Solutions:
- Restart Vite dev server
- Check backend is running on port 8000
- Verify proxy config in
vite.config.ts
WebSocket disconnected
Symptom: Dashboard shows “Disconnected” status
Diagnosis:
# Check WebSocket endpoint
curl http://localhost:8000/ws
# Should return "Method Not Allowed"
# Check backend logs
grep "WebSocket" logs/backend.log
Solutions:
- Backend not running → Start backend
- Redis not running → Start Redis
- Browser console shows error → Check for JavaScript errors
Auto-reconnect: Frontend automatically reconnects after 3 seconds.
Performance Issues
Slow API responses
Symptom: Dashboard takes 5+ seconds to load
Diagnosis:
# Check database query time
docker exec -it alpha-oracle-timescaledb-1 psql -U trader -d stock_analysis
\timing on
SELECT * FROM ohlcv WHERE symbol = 'AAPL' AND timestamp > NOW() - INTERVAL '1 year';
# Check backend logs for slow queries
grep "slow_query" logs/backend.log
Solutions:
- Add indexes on frequently queried columns
- Reduce time range for historical queries
- Implement caching for portfolio snapshots
- Check TimescaleDB chunk compression settings
High memory usage
Symptom: System uses 8GB+ RAM
Causes:
- Large dataset in memory (pandas DataFrames)
- Redis cache growing unbounded
- Leaked WebSocket connections
Solutions:
- Use Polars instead of pandas for large datasets
- Configure Redis max memory:
maxmemory 512mb - Set TTL on cache keys
- Restart services periodically
Getting Help
If troubleshooting steps don’t resolve the issue:
- Check logs:
logs/backend.log,logs/frontend.log - Check Docker logs:
docker compose logs - Enable debug logging: Set
SA_ENVIRONMENT=developmentin.env - Run tests:
pytest tests/ -v -s(verbose + print output) - File an issue: https://github.com/anthropics/claude-code/issues (with logs, config, steps to reproduce)
Provide in issue report:
- System version (git commit hash)
- Environment (development/paper/live)
- Full error message and stack trace
- Relevant log excerpts
- Steps to reproduce