跳到主要内容

Bot Usage

This guide covers how to operate Freqtrade in different modes, from paper trading to live trading with real money.

Trading Modes

Dry Run Mode (Paper Trading)

Dry run mode simulates trading with fake money using real market data. This is perfect for:

  • Testing strategies safely
  • Learning how the bot works
  • Validating configuration
  • Monitoring strategy performance

Configuration:

{
"dry_run": true,
"dry_run_wallet": 1000
}

Start dry run:

freqtrade trade --config config.json

Live Trading Mode

Live trading uses real money and places actual orders on the exchange.

Real Money Warning

Live trading involves real financial risk. Only use money you can afford to lose. Always test thoroughly in dry run mode first.

Configuration:

{
"dry_run": false,
"exchange": {
"key": "your_api_key",
"secret": "your_api_secret"
}
}

Start live trading:

freqtrade trade --config config.json

Starting the Bot

Basic Commands

# Start with default config
freqtrade trade

# Start with specific config
freqtrade trade --config my_config.json

# Start with specific strategy
freqtrade trade --strategy MyStrategy

# Start in verbose mode
freqtrade trade --verbose

# Start with log file
freqtrade trade --logfile user_data/logs/freqtrade.log

Advanced Options

# Start with custom database
freqtrade trade --db-url sqlite:///my_trades.sqlite

# Start with specific user directory
freqtrade trade --user-data-dir /path/to/user_data

# Start with dry run wallet amount
freqtrade trade --dry-run-wallet 5000

Monitoring the Bot

Real-time Monitoring

View running status:

# Check if bot is running
ps aux | grep freqtrade

# View recent logs
tail -f user_data/logs/freqtrade.log

# View specific log entries
grep "ENTRY\|EXIT" user_data/logs/freqtrade.log

Key log messages to watch:

  • ENTRY - New trade opened
  • EXIT - Trade closed
  • ROI - Trade closed due to profit target
  • STOP_LOSS - Trade closed due to stop loss
  • TIMEOUT - Order timeout occurred

Performance Monitoring

Check trade statistics:

# Show profit summary
freqtrade show_trades --config config.json

# Show trades for specific days
freqtrade show_trades --days 7

# Show trades with profit details
freqtrade show_trades --print-json

Controlling the Bot

Command Line Control

Stop the bot gracefully:

# Send interrupt signal
pkill -INT freqtrade

# Or use Ctrl+C in the terminal

Force stop (emergency):

# Force kill (not recommended)
pkill -KILL freqtrade

Runtime Commands

While the bot is running, you can use these interfaces:

  1. FreqUI - Web interface
  2. Telegram - Mobile control
  3. REST API - Programmatic control

FreqUI Web Interface

FreqUI provides a web-based interface for monitoring and controlling your bot.

Setup FreqUI

Enable in configuration:

{
"api_server": {
"enabled": true,
"listen_ip_address": "127.0.0.1",
"listen_port": 8080,
"username": "freqtrade",
"password": "your_password"
}
}

Access FreqUI:

  • Open browser to http://localhost:8080
  • Login with configured credentials

FreqUI Features

  • Dashboard - Overview of bot performance
  • Trades - View open and closed trades
  • Performance - Profit/loss charts and statistics
  • Logs - Real-time log viewing
  • Control - Start/stop bot, force trades

Telegram Integration

Control your bot via Telegram messages.

Setup Telegram

  1. Create Telegram bot:

    • Message @BotFather on Telegram
    • Use /newbot command
    • Get bot token
  2. Get your chat ID:

    • Message your bot
    • Visit https://api.telegram.org/bot<TOKEN>/getUpdates
    • Find your chat ID in the response
  3. Configure Freqtrade:

{
"telegram": {
"enabled": true,
"token": "your_bot_token",
"chat_id": "your_chat_id"
}
}

Telegram Commands

Status Commands:

  • /status - Show open trades
  • /profit - Show profit summary
  • /balance - Show account balance
  • /stats - Show trade statistics
  • /performance - Show performance by pair

Control Commands:

  • /start - Start the bot
  • /stop - Stop the bot
  • /reload_config - Reload configuration
  • /show_config - Display current config

Trade Commands:

  • /forcebuy <pair> - Force buy a pair
  • /forcesell <trade_id> - Force sell a trade
  • /delete <trade_id> - Delete a trade

Information Commands:

  • /version - Show bot version
  • /help - Show available commands
  • /logs - Show recent log entries

Trade Management

Manual Trade Control

Force entry (buy):

# Via command line
freqtrade trade --config config.json --force-entry BTC/USDT

# Via Telegram
/forcebuy BTC/USDT

# Via FreqUI
Use the "Force Entry" button

Force exit (sell):

# Via Telegram
/forcesell 1 # Trade ID 1

# Via FreqUI
Click "Sell" button on trade

Position Management

View open positions:

freqtrade show_trades --config config.json --trade-ids 1,2,3

Close all positions:

# Via Telegram
/stopbuy # Stop opening new trades
/forcesell all # Close all open trades

Risk Management

Emergency Procedures

Market crash response:

  1. Stop new entries: /stopbuy
  2. Monitor positions closely
  3. Consider manual exits if needed
  4. Adjust stop losses if necessary

Bot malfunction:

  1. Stop the bot immediately
  2. Check exchange for open orders
  3. Cancel unfilled orders manually
  4. Review logs for errors

Safety Features

Configuration safety:

{
"cancel_open_orders_on_exit": true, // Cancel orders when stopping
"max_open_trades": 3, // Limit concurrent trades
"tradable_balance_ratio": 0.95, // Reserve some balance
"stoploss": -0.10 // Always use stop loss
}

API key security:

  • Use trading-only permissions
  • Restrict IP addresses
  • Regularly rotate keys
  • Monitor API usage

Performance Optimization

Resource Management

Memory optimization:

{
"reduce_df_footprint": true, // Reduce memory usage
"internals": {
"process_throttle_secs": 5 // Adjust processing frequency
}
}

Network optimization:

{
"exchange": {
"ccxt_config": {
"enableRateLimit": true, // Respect rate limits
"rateLimit": 1000 // Milliseconds between requests
}
}
}

Scaling Considerations

Multiple bots:

  • Use separate configurations
  • Different trading pairs
  • Separate databases
  • Monitor total exposure

High-frequency trading:

  • Faster timeframes (1m, 5m)
  • More concurrent trades
  • Better hardware requirements
  • Lower latency connections

Troubleshooting

Common Issues

Bot won't start:

# Check configuration syntax
freqtrade show-config

# Verify strategy
freqtrade list-strategies

# Test exchange connection
freqtrade test-pairlist

No trades opening:

  • Check strategy signals
  • Verify available balance
  • Check pair whitelist
  • Review entry conditions

Orders not filling:

  • Check order types (limit vs market)
  • Verify price levels
  • Check exchange status
  • Review order timeouts

Log Analysis

Important log patterns:

# Entry signals
grep "ENTRY" logs/freqtrade.log

# Exit reasons
grep "EXIT\|ROI\|STOP_LOSS" logs/freqtrade.log

# Errors
grep "ERROR\|CRITICAL" logs/freqtrade.log

# Exchange issues
grep "Exchange\|API" logs/freqtrade.log

Debug Mode

Enable debug logging:

freqtrade trade --config config.json --verbose

Debug configuration:

{
"verbosity": 3,
"logfile": "user_data/logs/freqtrade.log"
}

Maintenance

Regular Tasks

Daily:

  • Check bot status
  • Review trade performance
  • Monitor logs for errors
  • Verify exchange connectivity

Weekly:

  • Update market data
  • Review strategy performance
  • Check for software updates
  • Backup configuration and data

Monthly:

  • Analyze overall performance
  • Review and adjust parameters
  • Update strategies if needed
  • Security audit (API keys, etc.)

Updates and Upgrades

Update Freqtrade:

# Stop the bot first
pkill -INT freqtrade

# Update via pip
pip install -U freqtrade

# Or via git
git pull
pip install -e .

# Restart with same configuration
freqtrade trade --config config.json

Backup before updates:

# Backup configuration
cp config.json config.json.backup

# Backup database
cp user_data/tradesv3.sqlite user_data/tradesv3.sqlite.backup

# Backup strategies
cp -r user_data/strategies user_data/strategies.backup

Best Practices

Operational Excellence

  1. Start Small: Begin with small amounts
  2. Monitor Closely: Watch performance daily
  3. Keep Records: Document changes and results
  4. Stay Updated: Follow Freqtrade development
  5. Community: Engage with other users

Risk Management

  1. Never Risk More Than You Can Lose
  2. Use Stop Losses: Always protect downside
  3. Diversify: Don't put all funds in one strategy
  4. Test First: Always dry run before live trading
  5. Have Exit Plan: Know when to stop

Security

  1. Secure API Keys: Use minimal permissions
  2. Regular Backups: Protect your data
  3. Monitor Access: Watch for unauthorized activity
  4. Update Regularly: Keep software current
  5. Network Security: Use secure connections

Next Steps

After mastering bot operations:

  1. Strategy Optimization - Improve performance
  2. Advanced Features - Custom logic
  3. Data Analysis - Deep performance analysis
  4. Production Setup - Professional deployment

Resources