Mastering Freqtrade config.json : A Step-by-Step Guide

Freqtrade Docker Compose File Elevate Your Algorithmic Trading Ai Bot Trading Go Traddy

Introduction

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, using it at startup, exploring configuration options, employing multiple configuration files, and understanding different configuration sections.

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:

  1. CLI arguments take precedence over any other options.
  2. Configuration files are utilized sequentially, with the last file taking precedence, and they override Strategy configurations.
  3. 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

  1. Suppose your config.json file has a default stake_currency set to ‘USDT’.
  2. 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 default stake_currency from config.json for this backtesting session.

Case 2: Configuration File Override Strategy Defaults

  1. Assume your MyStrategy class defaults to a stoploss value of -0.05.
  2. You intend to adjust this stoploss for backtesting in your config.json file.
{
  "strategy": "MyStrategy",
  "stoploss": -0.02  # Adjusted stoploss value
}
  1. Execute the backtesting command:
docker-compose run --rm freqtrade freqtrade backtesting \
  --config user_data/config.json \
  --strategy MyStrategy

Explanation:

  • The stoploss value specified in config.json (-0.02) takes precedence over the default stoploss set within the MyStrategy class.

Case 3: Strategy Configuration Applies (Not Overridden)

  1. In a scenario where neither config.json nor command-line arguments specify a value for trailing_stop.
  2. In such a case, the default trailing_stop value defined within your MyStrategy class 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.