Home Creators Posts Import Register Favorites Logout
haven't archived this post yet. have a subscription? use the importer!

Downloads

  • ft_userdata.7z.001
  • ft_userdata.7z.002
  • ft_userdata.7z.003
  • ft_userdata.7z.005
  • ft_userdata.7z.004

Missing 5 files, as this post has not yet been imported.

Content

Intro

In this post I am going to explain the process I use to update the backtesting data set for testing out the Algorithmic Crypto Trading Strategies for the coming year (2023). I make this post so you can follow my steps and can create the same backtests. This way you can check my video's results or do your own backtests.

You can also do backtests on the specific strategies that you want to test. Maybe because I do not have these (personal) strategies (why don't I have these btw. 🤔?) or did not get the time to test these yet...

In this procedure I am starting with a completely fresh 2023 Docker installation. So to follow these steps easily, you will have to have a similar installation here.

Step 1: create a fresh testing directory

In the created '/opt/ft_userdata' directory, create the necessary filestructure for the bot with

<code><code><code>sudo docker-compose run --rm freqtrade create-userdir --userdir user_data</code></code></code>

After the directorystructure is created by the bot, we can create the config files.

Step 2: create config files for spot and futures backtesting

In this step I am going to make two completely new files that will be used for spot and futures backtesting.

Spot config

Here I will start with the creation of a spot config file:

<code><code><code># the spot config
sudo docker-compose run --rm freqtrade new-config --config user_data/spot_config.json
</code></code></code>

In the creation procedure for the spot config, I will choose the following options:

<code><code><code>? Do you want to enable Dry-run (simulated trades)? Yes
? Please insert your stake currency: USDT
? Please insert your stake amount (Number or 'unlimited'): unlimited
? Please insert max_open_trades (Integer or -1 for unlimited open trades):
10
? Time Have the strategy define timeframe.
? Please insert your display Currency (for reporting): USD
? Select exchange binance
? Do you want to trade Perpetual Swaps (perpetual futures)? No
? Do you want to enable Telegram? No
? Do you want to enable the Rest API (includes FreqUI)? No
</code></code></code>

Notice that I only adjusted the amount of open trades at any time. This is comletely arbitrary and the reason why I do this is that, this way I can see if a certain strategy is fit for multiple pairs. The smaller this number, the longer I have to wait for new trades if the bot has used all it's trading slots.

Futures config

For the creation of a futures trading config I will use the following command:

<code><code><code># the futures config
sudo docker-compose run --rm freqtrade new-config --config user_data/futures_config.json
</code></code></code>

And during the creation of the file I use the following settings:

<code><code><code>? Do you want to enable Dry-run (simulated trades)? Yes
? Please insert your stake currency: USDT
? Please insert your stake amount (Number or 'unlimited'): unlimited
? Please insert max_open_trades (Integer or -1 for unlimited open trades):
10
? Time Have the strategy define timeframe.
? Please insert your display Currency (for reporting): USD
? Select exchange binance
? Do you want to trade Perpetual Swaps (perpetual futures)?
Yes
? Do you want to enable Telegram? No
? Do you want to enable the Rest API (includes FreqUI)? No
</code></code></code>

Here I choose to have 10 open and want to trade Perpetual Swaps.

Note that there are different lines between these files concerning the type of trading. For futures trading these are:

<code><code><code>"trading_mode": "futures",
"margin_mode": "isolated",
</code></code></code>

Now I have two config files that still need some adjustments in the pairs and pairlist sections.

Step 3: configure pairslist

In both of the files I will need to configure the StaticPairsList. Backtesting without this setting will not work. You can watch my video (link above) for an explanation why that is the case.

Backup

Before adjusting the configs, it is always wise to create a backup. To do this, use the following commands:

<code><code><code>cd user_data/
cp futures_config.json{,.backup}; cp spot_config.json{,.backup}
</code></code></code>

In the config files change the following section:

From:

<code><code><code>"pairlists": [
       {
           "method": "VolumePairList",
           "number_assets": 20,
           "sort_key": "quoteVolume",
           "min_value": 0,
           "refresh_period": 1800
       }
   ],
</code></code></code>

To read:

<code><code><code>"pairlists": [
       {
           "method": "StaticPairList",
       }
   ],
</code></code></code>

Step 4:  choose the pairs you want to test

This following section is completely personal and might differ from person to person concerning their preferred trading pairs. However, if you want to follow my trading methodology, then I suggest to do use the configs I show below.

Getting a snapshot from the top50 pairs start 2022

To try and simulate the best market circumstances for my backtests I use an 'Index' of the most popular crypto pairs at the beginning of the previous year. To make this more clear, at this very moment (january 2023) I will use the snapshot of january 2022 (which you can find at coinmarketcap here).

This way I can determine if a strategy performs also well over the top 50 coins at the start of 2022 over the last year (including all other historic backtest data).

You might discuss this and ask "Why not the Top 50 coins of today?".
And the answer is that the Top 50 of today is the result of the market changes over the last year, and I want to test the strategies over these changing circumstances. Do these strategies 'advise' me (not) to buy coins that perform (not) well in 2022? E.g. could these strategies prevent me from buying (or advise me to short) Solana (which dropped from 5th in 2022 to 15th in 2023)?
Also, how can you tell what the performance will be over the current (2023) Top 50 the coming year? That is simply impossible...

Also, the used Top 50 coins are also depending on the availability on the exchange (I use Binance in this case). If a certain coin is not available on the exchange, I simply use the next entry. Until I have 50 pairs in the config.

Adding the pairs to the config file

This is manual labour and here I will search for the 'jan 2022 top 50 pair' in question in the list of pairs that is available on the Binance exchange. To get the pairs that are available on the Binance exchange, I use the command:

<code><code><code>sudo docker-compose run --rm freqtrade list-pairs --exchange binance --quote USDT --print-json</code></code></code>

The output will look something like this:

<code><code><code>2023-01-05 15:05:18,417 - freqtrade.commands.list_commands - INFO - Exchange Binance has 329 active pairs with USDT as quote currency.
["1INCH/USDT","AAVE/USDT","ACA/USDT","ACH/USDT","ACM/USDT","ADA/USDT","ADADOWN/USDT","ADAUP/USDT","ADX/USDT","AGLD/USDT","AION/USDT","AKRO/USDT","ALCX/USDT","ALGO/USDT","ALICE/USDT","ALPACA/USDT","ALPHA/USDT","ALPINE/USDT","AMP/USDT",...
</code></code></code>

The cool thing about this format is that I can now search for the crypto symbols this output and copy/past the Top 50 pairs in a temporary file. The output is already in json format, which saves time.

Now it is time to go over the 50 most popular pairs in january 2022 and place them in the spot and futures config files. And in my case the output looks like this:

<code><code><code>["BTC/USDT","ETH/USDT","BNB/USDT","SOL/USDT","ADA/USDT","XRP/USDT","LUNA/USDT","DOT/USDT","AVAX/USDT","DOGE/USDT","SHIB/USDT","MATIC/USDT","UNI/USDT","ALGO/USDT","LTC/USDT","LINK/USDT","NEAR/USDT","BCH/USDT","ATOM/USDT","TRX/USDT","XLM/USDT","FTM/USDT","MANA/USDT","AXS/USDT","HBAR/USDT","VET/USDT","SAND/USDT","ICP/USDT","FIL/USDT","THETA/USDT","ETC/USDT","XMR/USDT","XTZ/USDT","AAVE/USDT","KLAY/USDT","ONE/USDT","GRT/USDT","GALA/USDT","EOS/USDT","CAKE/USDT","STX/USDT","FLOW/USDT","LRC/USDT","CRV/USDT","KSM/USDT","MKR/USDT","ENJ/USDT","QNT/USDT","XEC/USDT","AMP/USDT"]</code></code></code>

Add these pairs to the exchange section in the "pair_whitelist":

<code><code><code>"exchange": {
       "name": "binance",
       "key": "",
       "secret": "",
       "ccxt_config": {},
       "ccxt_async_config": {},
       "pair_whitelist": [
       "BTC/USDT","ETH/USDT","BNB/USDT","SOL/USDT","ADA/USDT","XRP/USDT","LUNA/USDT",
       "DOT/USDT","AVAX/USDT","DOGE/USDT","SHIB/USDT","MATIC/USDT","UNI/USDT",
       "ALGO/USDT","LTC/USDT","LINK/USDT","NEAR/USDT","BCH/USDT","ATOM/USDT","TRX/USDT",
       "XLM/USDT","FTM/USDT","MANA/USDT","AXS/USDT","HBAR/USDT","VET/USDT","SAND/USDT",
       "ICP/USDT","FIL/USDT","THETA/USDT","ETC/USDT","XMR/USDT","XTZ/USDT","AAVE/USDT",
       "KLAY/USDT","ONE/USDT","GRT/USDT","GALA/USDT","EOS/USDT","CAKE/USDT","STX/USDT",
       "FLOW/USDT","LRC/USDT","CRV/USDT","KSM/USDT","MKR/USDT","ENJ/USDT","QNT/USDT",
       "XEC/USDT","AMP/USDT"
       ],
</code></code></code>

And remove pairs from the blacklist if there are any and save the file (here the "BNB/.*" line should be removed).

<code><code><code>"pair_blacklist": [
           "BNB/.*"
       ]
</code></code></code>

Checking the configured pairs

After this is done, I can check if the configured pairlists is correct in the config files.

<code><code><code>sudo docker-compose run --rm freqtrade test-pairlist --config user_data/spot_config.json</code></code></code>

The output should look like this. It is also a verification that 50 pairs that are available on the exchange are configured:

<code><code><code>2023-01-07 08:18:57,722 - freqtrade.exchange.exchange - INFO - Markets were not loaded. Loading them now..
2023-01-07 08:18:59,821 - freqtrade.plugins.pairlistmanager - INFO - Whitelist with 50 pairs: ['BTC/USDT', 'ETH/USDT', 'BNB/USDT', 'SOL/USDT', 'ADA/USDT', 'XRP/USDT', 'LUNA/USDT', 'DOT/USDT', 'AVAX/USDT', 'DOGE/USDT', 'SHIB/USDT', 'MATIC/USDT', 'UNI/USDT', 'ALGO/USDT', 'LTC/USDT', 'LINK/USDT', 'NEAR/USDT', 'BCH/USDT', 'ATOM/USDT', 'TRX/USDT', 'XLM/USDT', 'FTM/USDT', 'MANA/USDT', 'AXS/USDT', 'HBAR/USDT', 'VET/USDT', 'SAND/USDT', 'ICP/USDT', 'FIL/USDT', 'THETA/USDT', 'ETC/USDT', 'XMR/USDT', 'XTZ/USDT', 'AAVE/USDT', 'KLAY/USDT', 'ONE/USDT', 'GRT/USDT', 'GALA/USDT', 'EOS/USDT', 'CAKE/USDT', 'STX/USDT', 'FLOW/USDT', 'LRC/USDT', 'CRV/USDT', 'KSM/USDT', 'MKR/USDT', 'ENJ/USDT', 'QNT/USDT', 'XEC/USDT', 'AMP/USDT']
Pairs for USDT:
['BTC/USDT', 'ETH/USDT', 'BNB/USDT', 'SOL/USDT', 'ADA/USDT', 'XRP/USDT', 'LUNA/USDT', 'DOT/USDT', 'AVAX/USDT', 'DOGE/USDT', 'SHIB/USDT', 'MATIC/USDT', 'UNI/USDT', 'ALGO/USDT', 'LTC/USDT', 'LINK/USDT', 'NEAR/USDT', 'BCH/USDT', 'ATOM/USDT', 'TRX/USDT', 'XLM/USDT', 'FTM/USDT', 'MANA/USDT', 'AXS/USDT', 'HBAR/USDT', 'VET/USDT', 'SAND/USDT', 'ICP/USDT', 'FIL/USDT', 'THETA/USDT', 'ETC/USDT', 'XMR/USDT', 'XTZ/USDT', 'AAVE/USDT', 'KLAY/USDT', 'ONE/USDT', 'GRT/USDT', 'GALA/USDT', 'EOS/USDT', 'CAKE/USDT', 'STX/USDT', 'FLOW/USDT', 'LRC/USDT', 'CRV/USDT', 'KSM/USDT', 'MKR/USDT', 'ENJ/USDT', 'QNT/USDT', 'XEC/USDT', 'AMP/USDT']
</code></code></code>

The bot should give no errors and I can proceed with downloading of the necessary data for spot backtesting.

However with the futures config, there is a small issue.

<code><code><code>docker-compose run --rm freqtrade test-pairlist --config user_data/futures_config.json</code></code></code>

The output shows that of the 50 pairs for spot trading, only 44 pairs are available for futures trading.

<code><code><code>2023-01-07 08:26:17,530 - freqtrade.plugins.pairlistmanager - INFO - Whitelist with 44 pairs: ['BTC/USDT', 'ETH/USDT', 'BNB/USDT', 'SOL/USDT', 'ADA/USDT', 'XRP/USDT', 'DOT/USDT', 'AVAX/USDT', 'DOGE/USDT', 'MATIC/USDT', 'UNI/USDT', 'ALGO/USDT', 'LTC/USDT', 'LINK/USDT', 'NEAR/USDT', 'BCH/USDT', 'ATOM/USDT', 'TRX/USDT', 'XLM/USDT', 'FTM/USDT', 'MANA/USDT', 'AXS/USDT', 'HBAR/USDT', 'VET/USDT', 'SAND/USDT', 'ICP/USDT', 'FIL/USDT', 'THETA/USDT', 'ETC/USDT', 'XMR/USDT', 'XTZ/USDT', 'AAVE/USDT', 'KLAY/USDT', 'ONE/USDT', 'GRT/USDT', 'GALA/USDT', 'EOS/USDT', 'FLOW/USDT', 'LRC/USDT', 'CRV/USDT', 'KSM/USDT', 'MKR/USDT', 'ENJ/USDT', 'QNT/USDT']
Pairs for USDT:
['BTC/USDT', 'ETH/USDT', 'BNB/USDT', 'SOL/USDT', 'ADA/USDT', 'XRP/USDT', 'DOT/USDT', 'AVAX/USDT', 'DOGE/USDT', 'MATIC/USDT', 'UNI/USDT', 'ALGO/USDT', 'LTC/USDT', 'LINK/USDT', 'NEAR/USDT', 'BCH/USDT', 'ATOM/USDT', 'TRX/USDT', 'XLM/USDT', 'FTM/USDT', 'MANA/USDT', 'AXS/USDT', 'HBAR/USDT', 'VET/USDT', 'SAND/USDT', 'ICP/USDT', 'FIL/USDT', 'THETA/USDT', 'ETC/USDT', 'XMR/USDT', 'XTZ/USDT', 'AAVE/USDT', 'KLAY/USDT', 'ONE/USDT', 'GRT/USDT', 'GALA/USDT', 'EOS/USDT', 'FLOW/USDT', 'LRC/USDT', 'CRV/USDT', 'KSM/USDT', 'MKR/USDT', 'ENJ/USDT', 'QNT/USDT']
</code></code></code>

So I am missing 6 pairs between spot and futures trading. And one might argue that the futures trading should get six additional pairs or that the spot list should get the 6 missing pairs removed.

In this case I am going to leave it like this because besides this problem there is also the issue that the futures dataset will never be the same as the spot dataset. Futures trading was introduced much later and between pairs there are differences the time that sits between the start of the spot dataset and the start of futures trading. For example, the time between BTC spot and bitcoin futures trading is around two years. While the time between spot and futures trading of a much younger coin (like SHIB can be around a year or even some months).

So to make a longstory short, I can never quite exactly create datasets between spot and futures trading that are exactly the same and also have the largest possible dataset to test on.
Only the choice of the pairs I want to trade (in this case the Top 50 pairs in market cap) can be the same.

And everybody else is welcome to create their own lists of coins to test ofcourse. But if you want to check my work, this will be the dataset I am going to use.

Step 5: downloading the data

Now it is time to download the data needed. For this I am going to use the commands below.
The datasets will be from the start of the pairs availability on the (Binance) exchange to the current date (don't worry if you do this on a later date, I will provide the timerange in the backtesting commands).

<code><code><code>sudo docker-compose run --rm freqtrade download-data --config user_data/spot_config.json --timeframe 5m 15m 30m 1h 4h 1d --timerange 20160101-</code></code></code>

With the command above, even the data for bitcoin on the 1d timeframe  starts from 2017-08-17. So I think I can get all the data that is  available on the exchange this way.

However, If you use an exchange that has a longer time range than Binance, then feel free to use that data (you might not get the same results as I get when backtesting though).

For futures data I will use the futures config ofcourse:

<code><code><code>sudo docker-compose run --rm freqtrade download-data --config user_data/futures_config.json --timeframe 5m 15m 30m 1h 4h 1d --timerange 20160101-</code></code></code>

For futures trading the dataset starts at 2019-09-08:

Last check

One final check I can do is to list the data in a Pandas dataframe to see if the dataset is correctly downloaded. So I opened up the BTC/USDT 1 day file in Jupyter Notebooks and made a small check on the data. And as you can see, everything looks like it's correct.

Now I can start with backtesting the strategies in 2023.

One final remark before I leave

I cannot repeat myself often enough, but please be warned of the following:

An algorithmic strategy that proves successful in backtests but might not ever be succesful in real trading. To do a due-dilligence by doing a forward test (Dry run) and see of the strategy also performs well after a couple of weeks of 'simulated' live trading. Only when you have enough confidence in your newly found succesful algo strategy, it is time to carefully run the bot with real money (and preferably small amounts first).

Do not repeat my mistakes (if you get what I mean).

Data

Oh, and btw. My dataset is in this post so that you can download it here too. It is a .tar.gz file within a 7zip file so you will have to open/decompress it twice!

Comments

Ivan Karpushchenko

I triied to do the same but for futures config it always returns an empty list, however it works for the spot config. Do you have any idea? ```2024-02-28 01:09:39,560 - freqtrade.exchange.exchange - INFO - Markets were not loaded. Loading them now.. 2024-02-28 01:09:42,928 - freqtrade.plugins.pairlistmanager - INFO - Whitelist with 0 pairs: [] Pairs for USDT: [] ```

Dutch Algotrading

Sorry, I have no clue. Up until now I never had problems with this setup and I never changed anything. If you try a default config with only one or two pairs, what happens then? Just to figure out where the error is.

Ivan Karpushchenko

It returns pairs with VolumePairsList, but when I set pairlists to [ { "method": "StaticPairList", } ] ( with 50 whitelisted pairs ) it returns []. It is a new config, just generated. I will check later and update you if I will find an issue

Ivan Karpushchenko

It worked with :USDT added after the pair name, so the list is "pair_whitelist": [ "BTC/USDT:USDT","ETH/USDT:USDT","BNB/USDT:USDT","SOL/USDT:USDT","ADA/USDT:USDT","XRP/USDT:USDT","LUNA/USDT:USDT", "DOT/USDT:USDT","AVAX/USDT:USDT","DOGE/USDT:USDT","SHIB/USDT:USDT","MATIC/USDT:USDT","UNI/USDT:USDT", "ALGO/USDT:USDT","LTC/USDT:USDT","LINK/USDT:USDT","NEAR/USDT:USDT","BCH/USDT:USDT","ATOM/USDT:USDT","TRX/USDT:USDT", "XLM/USDT:USDT","FTM/USDT:USDT","MANA/USDT:USDT","AXS/USDT:USDT","HBAR/USDT:USDT","VET/USDT:USDT","SAND/USDT:USDT", "ICP/USDT:USDT","FIL/USDT:USDT","THETA/USDT:USDT","ETC/USDT:USDT","XMR/USDT:USDT","XTZ/USDT:USDT","AAVE/USDT:USDT", "KLAY/USDT:USDT","ONE/USDT:USDT","GRT/USDT:USDT","GALA/USDT:USDT","EOS/USDT:USDT","CAKE/USDT:USDT","STX/USDT:USDT", "FLOW/USDT:USDT","LRC/USDT:USDT","CRV/USDT:USDT","KSM/USDT:USDT","MKR/USDT:USDT","ENJ/USDT:USDT","QNT/USDT:USDT", "XEC/USDT:USDT","AMP/USDT:USDT" ],

Dutch Algotrading

This is strange. Did the original futures file not already have these pairs? Maybe I made a mistake uploading. But you are the first one to notice this. ANyway, great that you found this out!