11 KiB
Configuration Guide
This guide explains how to configure Crypto Trader to suit your needs.
Configuration Files
Configuration files are stored in ~/.config/crypto_trader/ following the XDG Base Directory Specification.
Main Configuration
The main configuration file is config.yaml. It contains:
- Database settings
- Logging configuration
- Paper trading settings
- Update preferences
- Notification settings
- Backtesting defaults
Logging Configuration
Logging settings are in logging.yaml. You can configure:
- Log levels (DEBUG, INFO, WARNING, ERROR)
- Log file location
- Log rotation settings
- Retention policies
Exchange Configuration
Adding Exchange API Keys via UI
- Open the application
- Navigate to the Settings tab
- In the Exchanges section, click Add Exchange
- Enter exchange details:
- Exchange Name: Name of the exchange (e.g., Coinbase)
- API Key: Your exchange API key
- API Secret: Your exchange API secret
- Use Sandbox/Testnet: Enable for testing
- Read-Only Mode: Recommended for safety (prevents trading)
- Enabled: Enable the exchange connection
- Click Save
- Test the connection using Test Connection button
Editing Exchange Settings
- Select an exchange from the exchanges table
- Click Edit Exchange
- Update API keys or settings as needed
- Click Save
Managing Exchanges
The Settings page provides comprehensive exchange management:
- Status Indicators: Each exchange shows a color-coded status indicator:
- Green: Enabled and connected
- Gray: Disabled
- Red: Error state
- Test Connection: Click the checkmark icon to test the connection
- You'll receive a notification with detailed connection status
- Success: Green notification
- Warning: Yellow notification with details
- Error: Red notification with error message
- Edit Exchange: Click the pencil icon to edit exchange settings
- Delete Exchange: Click the trash icon to delete (removes API keys)
- Confirmation dialog will appear
- You'll receive a success notification when deleted
API Key Security
- API keys are encrypted before storage
- Use read-only keys when possible
- Enable IP whitelisting on your exchange account
- Never share your API keys
Paper Trading Configuration
Paper trading settings can be configured in the Settings page:
- Navigate to Settings page
- Click on Paper Trading tab
- Configure:
- Initial Capital ($): Starting capital in USD (default: $100)
- Fee Model (Exchange): Select which exchange's fee structure to simulate
- Click Save Settings
- You'll receive a success notification when settings are saved
Fee Exchange Models
Choose from available exchange fee models:
| Exchange | Maker Fee | Taker Fee | Best For |
|---|---|---|---|
| Default | 0.10% | 0.10% | General testing |
| Coinbase | 0.40% | 0.60% | Conservative estimates |
| Kraken | 0.16% | 0.26% | Moderate fee simulation |
| Binance | 0.10% | 0.10% | Low-fee simulation |
The fee rates display shows your current maker fee, taker fee, and estimated round-trip cost.
Resetting Paper Account
To reset your paper trading account (closes all positions and resets balance):
- Navigate to Settings > Paper Trading tab
- Click Reset Paper Account button
- Confirm the reset in the dialog
- All positions will be closed and balance reset to initial capital
- You'll receive a success notification when complete
Warning: This action cannot be undone. All paper trading history will be preserved, but positions and balance will be reset.
Data Provider Configuration
Data providers are used to fetch real-time pricing data for paper trading, backtesting, and ML training. They work independently of exchange integrations and don't require API keys.
Configuring Providers
- Navigate to Settings page
- Click on Data Providers tab
- Configure provider settings:
Primary Providers (CCXT)
Primary providers use CCXT to connect to cryptocurrency exchanges:
- Kraken: Default priority 1 (tried first)
- Coinbase: Default priority 2
- Binance: Default priority 3
Each provider can be:
- Enabled/Disabled: Toggle using the switch
- Reordered: Use up/down arrows to change priority order
- Monitored: View health status, response times, and success rates
Fallback Provider
CoinGecko is used as a fallback when primary providers are unavailable:
- Free tier API (no authentication required)
- Lower rate limits than primary providers
- Provides basic price data
Cache Settings
Configure caching behavior:
- Ticker TTL (seconds): How long to cache ticker data (default: 2 seconds)
- OHLCV TTL (seconds): How long to cache candlestick data (default: 60 seconds)
Provider Status
The Data Providers tab shows:
- Active Provider: Currently used provider
- Health Status: Color-coded status for each provider:
- Green: Healthy and working
- Yellow: Degraded performance
- Red: Unhealthy or unavailable
- Response Times: Average response time for each provider
- Success/Failure Counts: Historical performance metrics
Automatic Failover
The system automatically:
- Monitors provider health
- Switches to the next available provider if current one fails
- Opens circuit breakers for repeatedly failing providers
- Retries failed providers after a timeout period
Troubleshooting Providers
If all providers fail:
- Check your internet connection
- Verify firewall isn't blocking connections
- Check provider status in the Settings tab
- Try enabling/disabling specific providers
- Reset provider metrics if needed
Risk Management Settings
Configure risk limits in the Settings page:
- Navigate to Settings page
- Click on Risk Management tab
- Configure the following settings:
- Max Drawdown Limit (%): Maximum portfolio drawdown before trading stops
- Daily Loss Limit (%): Maximum daily loss percentage
- Default Position Size (%): Default percentage of capital to use per trade
- Click Save Risk Settings
- You'll receive a success notification when settings are saved
Settings are validated before saving and you'll see error messages if values are invalid.
Data Storage
Data is stored in ~/.local/share/crypto_trader/:
trading.db- Legacy file (removed)historical/- Historical market datalogs/- Application logs
Database Options
Database Options
PostgreSQL (Required):
- All production data is stored in PostgreSQL.
- Requires a running PostgreSQL instance.
- Configure connection in
config.yaml.
SQLite (Internal):
- Used internally for unit testing only.
- No configuration required for users.
Redis Configuration
Redis is used for distributed state management, ensuring autopilot state persists across restarts and preventing duplicate instances.
Default Settings
Redis settings are configured in config.yaml:
redis:
host: "127.0.0.1"
port: 6379
db: 0
password: null # Set if Redis requires authentication
socket_connect_timeout: 5
Environment Variables
You can also configure Redis via environment variables:
REDIS_HOST- Redis server hostnameREDIS_PORT- Redis server portREDIS_PASSWORD- Redis password (if required)
Verifying Redis Connection
Run the verification script:
python scripts/verify_redis.py
Celery Configuration (Background Tasks)
Celery handles long-running tasks like ML model training in the background.
Starting the Worker
# From project root (with virtualenv activated)
celery -A src.worker.app worker --loglevel=info
Or use the helper script:
./scripts/start_all.sh
Task Queues
Tasks are routed to specific queues:
ml_training- Model training and data bootstrappingreporting- Report generationcelery- Default queue
ML Model Training Configuration
Configure how the autopilot ML model is trained via the Settings page.
Training Data Configuration
Navigate to Settings > Autopilot tab to access these settings:
| Setting | Description | Recommended |
|---|---|---|
| Historical Data (days) | Amount of historical data to fetch for training | 90-365 days |
| Timeframe | OHLCV candle timeframe for training data | 1h (balanced) |
| Min Samples per Strategy | Minimum samples required per strategy | 30+ |
| Training Symbols | Cryptocurrencies to include in training | 5-10 major coins |
Setting Training Symbols
- Navigate to Settings > Autopilot tab
- In the Training Data Configuration section, find Training Symbols
- Click to add/remove symbols from the multi-select dropdown
- Common symbols: BTC/USD, ETH/USD, SOL/USD, XRP/USD, ADA/USD
- Click Save Bootstrap Config to persist your changes
Triggering Model Training
- Click Retrain Model button in the Model Management section
- A progress bar will appear showing:
- Data fetching progress (20-60%)
- Training progress (70-100%)
- Training typically takes 30-60 seconds depending on data volume
- Upon completion, the model card updates to show:
- "Global Model Trained" badge
- Number of strategies and features
- Training accuracy
- Which symbols the model was trained on
Training Progress Persistence
Training progress persists across page navigation:
- If you navigate away during training, progress resumes on return
- The training task ID is stored in browser localStorage
- On task completion or failure, the task ID is cleared
Model Management
- Retrain Model: Triggers retraining with current configuration
- Reset Model: Deletes all saved model files (confirmation required)
Troubleshooting Training
If training fails:
- Check that Redis and Celery are running
- Review Celery worker logs:
tail -f celery.log - Ensure sufficient historical data is available
- Try reducing the number of training symbols
- Check backend logs for error details
Monitoring Tasks
The API provides endpoints to monitor background tasks:
POST /api/autopilot/intelligent/retrain- Starts training, returns task IDGET /api/autopilot/tasks/{task_id}- Check task status
Environment Variables
You can override configuration using environment variables:
CRYPTO_TRADER_CONFIG_DIR- Custom config directoryCRYPTO_TRADER_DATA_DIR- Custom data directoryCRYPTO_TRADER_LOG_DIR- Custom log directoryDB_PASSWORD- Database password (for PostgreSQL)REDIS_HOST- Redis server hostnameREDIS_PORT- Redis server portREDIS_PASSWORD- Redis password
Backup and Restore
Backup
- Stop the application and Celery workers
- Backup PostgreSQL database
- Copy the entire
~/.local/share/crypto_trader/directory - Copy
~/.config/crypto_trader/directory - (Optional) Export Redis data with
redis-cli SAVE
Restore
- Stop the application
- Restore PostgreSQL database
- Replace the directories with your backup
- Restart Redis, Celery worker, and application