Introduction to Freqtrade’s config.json
Setting up and managing Freqtrade configurations within Docker Compose can greatly enhance your automated trading experience. In this guide, we’ll cover creating a new configuration file “config.json”, using it at startup, exploring configuration options, employing multiple configuration files, and understanding different configuration sections of freqtrade’s “config.json”.
1. Creating a New Configuration File
1.1. An initial config file was created during the freqtrade installation & setup, we can also create a new config file with the below command
docker compose run --rm freqtrade new-config --config user_data/newconfig.json
2. Using New Configuration file in Freqtrade
# Download data with new config file
docker compose run --rm freqtrade download-data --config user_data/newconfig.json --days 30 -t 5m
# Backtesting data with new config file
docker compose run --rm freqtrade backtesting --config user_data/newconfig.json --strategy SampleStrategy
# Hyperopt with new config file
docker compose run --rm freqtrade hyperopt --hyperopt-loss SharpeHyperOptLossDaily --spaces roi stoploss trailing --strategy SampleStrategy --config user_data/newconfig.json -e 10
# Start trading with new config file
docker compose run --rm freqtrade trade --config user_data/newconfig.json --strategy SampleStrategy
3 Prevalence of the Configuration Option understanding Config Options
Freqtrade can load numerous options through command-line (CLI) arguments, as indicated in the –help output for specific details. The hierarchy of precedence for all options is outlined as follows:
- CLI arguments take precedence over any other options.
- Configuration files are utilized sequentially, with the last file taking precedence, and they override Strategy configurations.
- Strategy configurations come into play only if they are not specified in the configuration or via command-line arguments. Such options are denoted as Strategy Override .
4.Illustrative Scenarios for Freqtrade Configuration Precedence
Here are various Freqtrade config file examples showcasing the hierarchy of configuration options in Freqtrade:
Case 1: Command-Line Argument Overrides Configuration File
- Suppose your
config.jsonfile has a defaultstake_currencyset to ‘USDT’. - You aim to override this for a specific backtesting run using a command-line argument.
docker-compose run --rm freqtrade backtesting \
--config user_data/config.json \
--strategy SampleStrategy \
--dry_run 'False'
Explanation:
- The
--stake_currency 'BUSD'command-line argument takes precedence, overriding the defaultstake_currencyfromconfig.jsonfor this backtesting session.
Case 2: Configuration File Override Strategy Defaults
- Assume your
MyStrategyclass defaults to astoplossvalue of -0.05. - You intend to adjust this stoploss for backtesting in your
config.jsonfile.
{
"strategy": "MyStrategy",
"stoploss": -0.02 # Adjusted stoploss value
}
- Execute the backtesting command:
docker-compose run --rm freqtrade freqtrade backtesting \
--config user_data/config.json \
--strategy MyStrategy
Explanation:
- The
stoplossvalue specified inconfig.json(-0.02) takes precedence over the default stoploss set within theMyStrategyclass.
Case 3: Strategy Configuration Applies (Not Overridden)
- In a scenario where neither
config.jsonnor command-line arguments specify a value fortrailing_stop. - In such a case, the default
trailing_stopvalue defined within yourMyStrategyclass would be utilized.
Key Points:
- Command-line arguments hold the highest priority, followed by configuration files (loaded sequentially with the last one prevailing), and lastly, strategy defaults.
- This approach provides flexibility for fine-tuning Freqtrade configurations based on specific scenarios.
Additional Notes:
- Although config stacking (using multiple configuration files) is technically feasible, Freqtrade does not officially recommend it due to potential conflicts and unexpected behavior.
- It is generally advisable to maintain a single, well-organized configuration file and employ command-line arguments for specific overrides.
Conclusion
Freqtrade configurations, allowing traders to optimize their strategies seamlessly. By creating, using, and stacking multiple configuration files, users can tailor their setups to specific trading scenarios. Understanding the prevalence of configuration options and exploring different sections empower traders to make informed decisions for effective automated trading.

