Quick Freqtrade Tutorial for Beginners

Before we start, there are several points that you will need to understand

  • I’m assuming that you have successfully installed freqtrade. I won’t touch on any subject regarding freqtrade installation.
  • I’m assuming that you know how to download files into your freqtrade folder
  • I’m assuming you know how to edit files in your freqtrade folder
  • In case you don’t know yet, if you are using docker, then to run any commands in this tutorial, you need to add docker-compose run --rm in front of every commands. For those using non-docker setup, you don’t need to add that.
  • If you aren’t using docker, then every commands written here have to be run from “freqtrade” folder
  • I’ll not explain each commands’ arguments. You would need to read the docs for it. I’ll give links to relevant page throughout this tutorial when needed
  • For this guide, please download following files
    • Put this inside “user_data” folder
    • Put this inside “user_data/strategies” folder

Download data

First, we need to download candles’ data for the past 40 days. To do that, use this command freqtrade download-data -c 'user_data/config-static-tutorial.json' --days 40 -t 5m 1h

Why are we downloading 40 days of data if we are gonna backtest on past 30 days only? Because you need to account for startup_candle_count, which are needed to make sure the indicators on the start of your backtest are valid.

Backtest

We gonna backtest the strategy for the past 30 days. Please note that you would need to modify the command to match your current date. I’m writing this tutorial on 05 July 2023, so the command would be freqtrade backtesting --config user_data/config-static-tutorial.json --strategy SMAOffsetProtectOptV1  --timerange=20230605-

Please make sure to change the timerange start date to (approx) previous 30 days from your current date.

Hyperopt

To hyperopt, you would need to install hyperopt dependency during installation (for non-docker user. For docker user, it’s already included in the image), and your computer/VPS MUST have more than 1 core CPU.

We gonna hyperopt the strategy using the past 30 days data. Please note that you would need to modify the command to suit your current date. I’m writing this tutorial on 05 July 2023, so the command would be freqtrade hyperopt --config user_data/config-static-tutorial.json --hyperopt-loss SharpeHyperOptLoss --spaces buy sell --strategy SMAOffsetProtectOptV1 --epochs 10 --timerange=20230605- --disable-param-export

Please make sure to change the timerange start date to (approx) previous 30 days from your current date.

The bot would print result formatted like this for example

# Buy hyperspace params:
buy_params = {
“base_nb_candles_buy”: 16,
“ewo_high”: 5.638,
“ewo_low”: -19.993,
“low_offset”: 0.978,
“rsi_buy”: 61,
}

# Sell hyperspace params:
sell_params = {
“base_nb_candles_sell”: 49,
“high_offset”: 1.006,
}

Copy those results into the strategy file. Look at this for example of where to copy paste the hyperopt result

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *