DEV Community

Cover image for Article 9: Freqtrade Quantitative Trading - config.json Basics and Initialization
itrade icu
itrade icu

Posted on • Originally published at itrade.icu

Article 9: Freqtrade Quantitative Trading - config.json Basics and Initialization

Article 9: Freqtrade Quantitative Trading - config.json Basics and Initialization

πŸ“ Complete Breakdown of Freqtrade's Most Critical File: config.json (With Practical Tips)
Before using Freqtrade for strategy backtesting, data downloading, or live trading, the most essential preparation is creating and configuring the config.json file. It serves as the "command center" of the entire trading framework, determining which exchange to connect to, how to trade, how strategies run, how much trading capital to use, and how to allocate balances.

This article will systematically guide you through the role of config.json, how to generate it, its file structure, and editing tips to help you get started quickly and avoid common pitfalls.

πŸš€ Want to Learn Quantitative Trading?

πŸ‘‰ Click to visit: https://www.itrade.icu

Here you'll find Freqtrade beginner tutorials, real-world strategy examples, indicator breakdowns, and more to help you master quantitative trading techniques with ease!

🧱 What is config.json?

config.json is Freqtrade's main configuration file, used to centrally manage all runtime parameters of the project. It is a standard JSON-formatted text file containing the following information:

  • Exchange account details (API Key/Secret)
  • Trading pairs and amount settings
  • Strategy execution rules (e.g., maximum open positions, shorting allowed, etc.)
  • Data timeframes and backtesting settings
  • Limit/market order control logic
  • Risk management configurations (stop-loss, take-profit, slippage control, etc.)
  • Webhook/Telegram notification channels (optional) Whether you're doing data analysis, backtest optimization, or live deployment, this configuration file is an indispensable foundation. --- ## πŸ†• How to Generate config.json? Freqtrade provides a command-line tool to generate a default configuration template with one clickβ€”perfect for beginners to get started quickly.
freqtrade new-config --config user_data/config.json
Enter fullscreen mode Exit fullscreen mode
  • Specify your target path after --config (recommended: user_data/config.json)
  • The directory will be created automatically if it doesn't exist
  • After generation, edit the file using any text editor ## πŸ“‚ Recommended File Structure The recommended basic directory structure for a Freqtrade project is as follows:
freqtrade/
β”œβ”€β”€ user_data/
β”‚ β”œβ”€β”€ config.json ← βœ… Main configuration file
β”‚ β”œβ”€β”€ strategies/ ← Strategy folder (.py files)
β”‚ β”œβ”€β”€ logs/ ← Log output
β”‚ β”œβ”€β”€ ...
β”œβ”€β”€ freqtrade/ ← Project source code (or virtual environment)
Enter fullscreen mode Exit fullscreen mode

Placing config.json in the user_data/ folder is the officially recommended practice, which helps maintain path consistency and ease of backup management.

🐳 Directory Structure When Running with Docker

If you're using the officially recommended Docker method to run Freqtrade (highly recommended!), the directory structure is controlled by Docker volume mappings and differs slightly from local execution.

ft_userdata/
β”œβ”€β”€ user_data/
β”‚ β”œβ”€β”€ config.json ← βœ… Main configuration file (for modifying runtime parameters)
β”‚ β”œβ”€β”€ strategies/ ← Strategy folder (.py files)
β”‚ β”œβ”€β”€ hyperopt/ ← Parameter optimization results
β”‚ β”œβ”€β”€ logs/ ← Log output
β”‚ β”œβ”€β”€ ...
β”œβ”€β”€ docker-compose.yml ← Service startup entry configuration
Enter fullscreen mode Exit fullscreen mode

πŸ” Beginner Preview Example

Below is a preview of the most basic version of a config.json file (showing only the initial part):

{
  "max_open_trades": 3,
  "stake_currency": "USDT",
  "stake_amount": 100,
  "tradable_balance_ratio": 0.95,
  "dry_run": true,
  "exchange": {
    "name": "binance",
    "key": "your_api_key",
    "secret": "your_api_secret",
    "password": "your_api_password" // Required only for certain exchanges like OKX or Kraken
  }
}
Enter fullscreen mode Exit fullscreen mode

Field explanations:

  • max_open_trades: Maximum number of positions allowed open simultaneously (to prevent overexposure)
  • stake_currency: Base currency for trading funds, usually USDT
  • stake_amount: Amount of funds used per trade
  • dry_run: Whether to enable dry-run mode (true means no real money is used) ## πŸ› οΈ Debugging Tips When Modifying Configuration
  • βœ… After modification, use the following command to check if the EXCHANGE API key is valid:
freqtrade list-markets --config user_data/config.json
Enter fullscreen mode Exit fullscreen mode
API Key Configured? Can list-markets run? Can trade? Notes
βœ… Yes βœ… Yes βœ… Yes Suitable for live trading with full features
❌ No βœ… Depends on exchange ❌ No Only some exchanges allow anonymous market listing
  1. βœ… You can also run a strategy initialization before backtesting to check for errors:
freqtrade backtesting --config user_data/config.json
Enter fullscreen mode Exit fullscreen mode

🧠 Summary

Key Point Recommendation
Configuration file name Fixed as config.json, recommended in user_data/
Generation command freqtrade new-config --config <path>
Error troubleshooting Use backtesting or list-markets to verify
Version control βœ… Strongly recommended to include config.json in Git

Top comments (0)