| 1 | # Backtesting |
| 2 | |
| 3 | This page explains how to validate your strategy performance by using Backtesting. |
| 4 | |
| 5 | Backtesting requires historic data to be available. |
| 6 | To learn how to get data for the pairs and exchange you're interested in, head over to the [Data Downloading](data-download.md) section of the documentation. |
| 7 | |
| 8 | ## Backtesting command reference |
| 9 | |
| 10 | ``` |
| 11 | usage: freqtrade backtesting [-h] [-v] [--logfile FILE] [-V] [-c PATH] |
| 12 | [-d PATH] [--userdir PATH] [-s NAME] |
| 13 | [--strategy-path PATH] [-i TIMEFRAME] |
| 14 | [--timerange TIMERANGE] |
| 15 | [--data-format-ohlcv {json,jsongz,hdf5}] |
| 16 | [--max-open-trades INT] |
| 17 | [--stake-amount STAKE_AMOUNT] [--fee FLOAT] |
| 18 | [-p PAIRS [PAIRS ...]] [--eps] [--dmmp] |
| 19 | [--enable-protections] |
| 20 | [--dry-run-wallet DRY_RUN_WALLET] |
| 21 | [--strategy-list STRATEGY_LIST [STRATEGY_LIST ...]] |
| 22 | [--export EXPORT] [--export-filename PATH] |
| 23 | |
| 24 | optional arguments: |
| 25 | -h, --help show this help message and exit |
| 26 | -i TIMEFRAME, --timeframe TIMEFRAME, --ticker-interval TIMEFRAME |
| 27 | Specify timeframe (`1m`, `5m`, `30m`, `1h`, `1d`). |
| 28 | --timerange TIMERANGE |
| 29 | Specify what timerange of data to use. |
| 30 | --data-format-ohlcv {json,jsongz,hdf5} |
| 31 | Storage format for downloaded candle (OHLCV) data. |
| 32 | (default: `None`). |
| 33 | --max-open-trades INT |
| 34 | Override the value of the `max_open_trades` |
| 35 | configuration setting. |
| 36 | --stake-amount STAKE_AMOUNT |
| 37 | Override the value of the `stake_amount` configuration |
| 38 | setting. |
| 39 | --fee FLOAT Specify fee ratio. Will be applied twice (on trade |
| 40 | entry and exit). |
| 41 | -p PAIRS [PAIRS ...], --pairs PAIRS [PAIRS ...] |
| 42 | Limit command to these pairs. Pairs are space- |
| 43 | separated. |
| 44 | --eps, --enable-position-stacking |
| 45 | Allow buying the same pair multiple times (position |
| 46 | stacking). |
| 47 | --dmmp, --disable-max-market-positions |
| 48 | Disable applying `max_open_trades` during backtest |
| 49 | (same as setting `max_open_trades` to a very high |
| 50 | number). |
| 51 | --enable-protections, --enableprotections |
| 52 | Enable protections for backtesting.Will slow |
| 53 | backtesting down by a considerable amount, but will |
| 54 | include configured protections |
| 55 | --dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET |
| 56 | Starting balance, used for backtesting / hyperopt and |
| 57 | dry-runs. |
| 58 | --strategy-list STRATEGY_LIST [STRATEGY_LIST ...] |
| 59 | Provide a space-separated list of strategies to |
| 60 | backtest. Please note that ticker-interval needs to be |
| 61 | set either in config or via command line. When using |
| 62 | this together with `--export trades`, the strategy- |
| 63 | name is injected into the filename (so `backtest- |
| 64 | data.json` becomes `backtest-data- |
| 65 | DefaultStrategy.json` |
| 66 | --export EXPORT Export backtest results, argument are: trades. |
| 67 | Example: `--export=trades` |
| 68 | --export-filename PATH |
| 69 | Save backtest results to the file with this filename. |
| 70 | Requires `--export` to be set as well. Example: |
| 71 | `--export-filename=user_data/backtest_results/backtest |
| 72 | _today.json` |
| 73 | |
| 74 | Common arguments: |
| 75 | -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). |
| 76 | --logfile FILE Log to the file specified. Special values are: |
| 77 | 'syslog', 'journald'. See the documentation for more |
| 78 | details. |
| 79 | -V, --version show program's version number and exit |
| 80 | -c PATH, --config PATH |
| 81 | Specify configuration file (default: |
| 82 | `userdir/config.json` or `config.json` whichever |
| 83 | exists). Multiple --config options may be used. Can be |
| 84 | set to `-` to read config from stdin. |
| 85 | -d PATH, --datadir PATH |
| 86 | Path to directory with historical backtesting data. |
| 87 | --userdir PATH, --user-data-dir PATH |
| 88 | Path to userdata directory. |
| 89 | |
| 90 | Strategy arguments: |
| 91 | -s NAME, --strategy NAME |
| 92 | Specify strategy class name which will be used by the |
| 93 | bot. |
| 94 | --strategy-path PATH Specify additional strategy lookup path. |
| 95 | |
| 96 | ``` |
| 97 | |
| 98 | ## Test your strategy with Backtesting |
| 99 | |
| 100 | Now you have good Buy and Sell strategies and some historic data, you want to test it against |
| 101 | real data. This is what we call [backtesting](https://en.wikipedia.org/wiki/Backtesting). |
| 102 | |
| 103 | Backtesting will use the crypto-currencies (pairs) from your config file and load historical candle (OHCLV) data from `user_data/data/<exchange>` by default. |
| 104 | If no data is available for the exchange / pair / timeframe combination, backtesting will ask you to download them first using `freqtrade download-data`. |
| 105 | For details on downloading, please refer to the [Data Downloading](data-download.md) section in the documentation. |
| 106 | |
| 107 | The result of backtesting will confirm if your bot has better odds of making a profit than a loss. |
| 108 | |
| 109 | All profit calculations include fees, and freqtrade will use the exchange's default fees for the calculation. |
| 110 | |
| 111 | !!! Warning "Using dynamic pairlists for backtesting" |
| 112 | Using dynamic pairlists is possible, however it relies on the current market conditions - which will not reflect the historic status of the pairlist. |
| 113 | Also, when using pairlists other than StaticPairlist, reproducability of backtesting-results cannot be guaranteed. |
| 114 | Please read the [pairlists documentation](plugins.md#pairlists) for more information. |
| 115 | |
| 116 | To achieve reproducible results, best generate a pairlist via the [`test-pairlist`](utils.md#test-pairlist) command and use that as static pairlist. |
| 117 | |
| 118 | ### Starting balance |
| 119 | |
| 120 | Backtesting will require a starting balance, which can be provided as `--dry-run-wallet <balance>` or `--starting-balance <balance>` command line argument, or via `dry_run_wallet` configuration setting. |
| 121 | This amount must be higher than `stake_amount`, otherwise the bot will not be able to simulate any trade. |
| 122 | |
| 123 | ### Dynamic stake amount |
| 124 | |
| 125 | Backtesting supports [dynamic stake amount](configuration.md#dynamic-stake-amount) by configuring `stake_amount` as `"unlimited"`, which will split the starting balance into `max_open_trades` pieces. |
| 126 | Profits from early trades will result in subsequent higher stake amounts, resulting in compounding of profits over the backtesting period. |
| 127 | |
| 128 | ### Example backtesting commands |
| 129 | |
| 130 | With 5 min candle (OHLCV) data (per default) |
| 131 | |
| 132 | ```bash |
| 133 | freqtrade backtesting --strategy AwesomeStrategy |
| 134 | ``` |
| 135 | |
| 136 | Where `--strategy AwesomeStrategy` / `-s AwesomeStrategy` refers to the class name of the strategy, which is within a python file in the `user_data/strategies` directory. |
| 137 | |
| 138 | --- |
| 139 | |
| 140 | With 1 min candle (OHLCV) data |
| 141 | |
| 142 | ```bash |
| 143 | freqtrade backtesting --strategy AwesomeStrategy --timeframe 1m |
| 144 | ``` |
| 145 | |
| 146 | --- |
| 147 | |
| 148 | Providing a custom starting balance of 1000 (in stake currency) |
| 149 | |
| 150 | ```bash |
| 151 | freqtrade backtesting --strategy AwesomeStrategy --dry-run-wallet 1000 |
| 152 | ``` |
| 153 | |
| 154 | --- |
| 155 | |
| 156 | Using a different on-disk historical candle (OHLCV) data source |
| 157 | |
| 158 | Assume you downloaded the history data from the Bittrex exchange and kept it in the `user_data/data/bittrex-20180101` directory. |
| 159 | You can then use this data for backtesting as follows: |
| 160 | |
| 161 | ```bash |
| 162 | freqtrade backtesting --strategy AwesomeStrategy --datadir user_data/data/bittrex-20180101 |
| 163 | ``` |
| 164 | |
| 165 | --- |
| 166 | |
| 167 | Comparing multiple Strategies |
| 168 | |
| 169 | ```bash |
| 170 | freqtrade backtesting --strategy-list SampleStrategy1 AwesomeStrategy --timeframe 5m |
| 171 | ``` |
| 172 | |
| 173 | Where `SampleStrategy1` and `AwesomeStrategy` refer to class names of strategies. |
| 174 | |
| 175 | --- |
| 176 | |
| 177 | Exporting trades to file |
| 178 | |
| 179 | ```bash |
| 180 | freqtrade backtesting --strategy backtesting --export trades --config config.json |
| 181 | ``` |
| 182 | |
| 183 | The exported trades can be used for [further analysis](#further-backtest-result-analysis), or can be used by the plotting script `plot_dataframe.py` in the scripts directory. |
| 184 | |
| 185 | --- |
| 186 | |
| 187 | Exporting trades to file specifying a custom filename |
| 188 | |
| 189 | ```bash |
| 190 | freqtrade backtesting --strategy backtesting --export trades --export-filename=backtest_samplestrategy.json |
| 191 | ``` |
| 192 | |
| 193 | Please also read about the [strategy startup period](strategy-customization.md#strategy-startup-period). |
| 194 | |
| 195 | --- |
| 196 | |
| 197 | Supplying custom fee value |
| 198 | |
| 199 | Sometimes your account has certain fee rebates (fee reductions starting with a certain account size or monthly volume), which are not visible to ccxt. |
| 200 | To account for this in backtesting, you can use the `--fee` command line option to supply this value to backtesting. |
| 201 | This fee must be a ratio, and will be applied twice (once for trade entry, and once for trade exit). |
| 202 | |
| 203 | For example, if the buying and selling commission fee is 0.1% (i.e., 0.001 written as ratio), then you would run backtesting as the following: |
| 204 | |
| 205 | ```bash |
| 206 | freqtrade backtesting --fee 0.001 |
| 207 | ``` |
| 208 | |
| 209 | !!! Note |
| 210 | Only supply this option (or the corresponding configuration parameter) if you want to experiment with different fee values. By default, Backtesting fetches the default fee from the exchange pair/market info. |
| 211 | |
| 212 | --- |
| 213 | |
| 214 | Running backtest with smaller test-set by using timerange |
| 215 | |
| 216 | Use the `--timerange` argument to change how much of the test-set you want to use. |
| 217 | |
| 218 | For example, running backtesting with the `--timerange=20190501-` option will use all available data starting with May 1st, 2019 from your input data. |
| 219 | |
| 220 | ```bash |
| 221 | freqtrade backtesting --timerange=20190501- |
| 222 | ``` |
| 223 | |
| 224 | You can also specify particular date ranges. |
| 225 | |
| 226 | The full timerange specification: |
| 227 | |
| 228 | - Use data until 2018/01/31: `--timerange=-20180131` |
| 229 | - Use data since 2018/01/31: `--timerange=20180131-` |
| 230 | - Use data since 2018/01/31 till 2018/03/01 : `--timerange=20180131-20180301` |
| 231 | - Use data between POSIX / epoch timestamps 1527595200 1527618600: `--timerange=1527595200-1527618600` |
| 232 | |
| 233 | ## Understand the backtesting result |
| 234 | |
| 235 | The most important in the backtesting is to understand the result. |
| 236 | |
| 237 | A backtesting result will look like that: |
| 238 | |
| 239 | ``` |
| 240 | ========================================================= BACKTESTING REPORT ======================================================== |
| 241 | | Pair | Buys | Avg Profit % | Cum Profit % | Tot Profit BTC | Tot Profit % | Avg Duration | Wins | Draws | Losses | |
| 242 | |:---------|-------:|---------------:|---------------:|-----------------:|---------------:|:---------------|------:|-------:|--------:| |
| 243 | | ADA/BTC | 35 | -0.11 | -3.88 | -0.00019428 | -1.94 | 4:35:00 | 14 | 0 | 21 | |
| 244 | | ARK/BTC | 11 | -0.41 | -4.52 | -0.00022647 | -2.26 | 2:03:00 | 3 | 0 | 8 | |
| 245 | | BTS/BTC | 32 | 0.31 | 9.78 | 0.00048938 | 4.89 | 5:05:00 | 18 | 0 | 14 | |
| 246 | | DASH/BTC | 13 | -0.08 | -1.07 | -0.00005343 | -0.53 | 4:39:00 | 6 | 0 | 7 | |
| 247 | | ENG/BTC | 18 | 1.36 | 24.54 | 0.00122807 | 12.27 | 2:50:00 | 8 | 0 | 10 | |
| 248 | | EOS/BTC | 36 | 0.08 | 3.06 | 0.00015304 | 1.53 | 3:34:00 | 16 | 0 | 20 | |
| 249 | | ETC/BTC | 26 | 0.37 | 9.51 | 0.00047576 | 4.75 | 6:14:00 | 11 | 0 | 15 | |
| 250 | | ETH/BTC | 33 | 0.30 | 9.96 | 0.00049856 | 4.98 | 7:31:00 | 16 | 0 | 17 | |
| 251 | | IOTA/BTC | 32 | 0.03 | 1.09 | 0.00005444 | 0.54 | 3:12:00 | 14 | 0 | 18 | |
| 252 | | LSK/BTC | 15 | 1.75 | 26.26 | 0.00131413 | 13.13 | 2:58:00 | 6 | 0 | 9 | |
| 253 | | LTC/BTC | 32 | -0.04 | -1.38 | -0.00006886 | -0.69 | 4:49:00 | 11 | 0 | 21 | |
| 254 | | NANO/BTC | 17 | 1.26 | 21.39 | 0.00107058 | 10.70 | 1:55:00 | 10 | 0 | 7 | |
| 255 | | NEO/BTC | 23 | 0.82 | 18.97 | 0.00094936 | 9.48 | 2:59:00 | 10 | 0 | 13 | |
| 256 | | REQ/BTC | 9 | 1.17 | 10.54 | 0.00052734 | 5.27 | 3:47:00 | 4 | 0 | 5 | |
| 257 | | XLM/BTC | 16 | 1.22 | 19.54 | 0.00097800 | 9.77 | 3:15:00 | 7 | 0 | 9 | |
| 258 | | XMR/BTC | 23 | -0.18 | -4.13 | -0.00020696 | -2.07 | 5:30:00 | 12 | 0 | 11 | |
| 259 | | XRP/BTC | 35 | 0.66 | 22.96 | 0.00114897 | 11.48 | 3:49:00 | 12 | 0 | 23 | |
| 260 | | ZEC/BTC | 22 | -0.46 | -10.18 | -0.00050971 | -5.09 | 2:22:00 | 7 | 0 | 15 | |
| 261 | | TOTAL | 429 | 0.36 | 152.41 | 0.00762792 | 76.20 | 4:12:00 | 186 | 0 | 243 | |
| 262 | ========================================================= SELL REASON STATS ========================================================= |
| 263 | | Sell Reason | Sells | Wins | Draws | Losses | |
| 264 | |:-------------------|--------:|------:|-------:|--------:| |
| 265 | | trailing_stop_loss | 205 | 150 | 0 | 55 | |
| 266 | | stop_loss | 166 | 0 | 0 | 166 | |
| 267 | | sell_signal | 56 | 36 | 0 | 20 | |
| 268 | | force_sell | 2 | 0 | 0 | 2 | |
| 269 | ====================================================== LEFT OPEN TRADES REPORT ====================================================== |
| 270 | | Pair | Buys | Avg Profit % | Cum Profit % | Tot Profit BTC | Tot Profit % | Avg Duration | Wins | Draws | Losses | |
| 271 | |:---------|-------:|---------------:|---------------:|-----------------:|---------------:|:---------------|------:|-------:|--------:| |
| 272 | | ADA/BTC | 1 | 0.89 | 0.89 | 0.00004434 | 0.44 | 6:00:00 | 1 | 0 | 0 | |
| 273 | | LTC/BTC | 1 | 0.68 | 0.68 | 0.00003421 | 0.34 | 2:00:00 | 1 | 0 | 0 | |
| 274 | | TOTAL | 2 | 0.78 | 1.57 | 0.00007855 | 0.78 | 4:00:00 | 2 | 0 | 0 | |
| 275 | =============== SUMMARY METRICS =============== |
| 276 | | Metric | Value | |
| 277 | |-----------------------+---------------------| |
| 278 | | Backtesting from | 2019-01-01 00:00:00 | |
| 279 | | Backtesting to | 2019-05-01 00:00:00 | |
| 280 | | Max open trades | 3 | |
| 281 | | | | |
| 282 | | Total trades | 429 | |
| 283 | | Starting balance | 0.01000000 BTC | |
| 284 | | Final balance | 0.01762792 BTC | |
| 285 | | Absolute profit | 0.00762792 BTC | |
| 286 | | Total profit % | 76.2% | |
| 287 | | Trades per day | 3.575 | |
| 288 | | Avg. stake amount | 0.001 BTC | |
| 289 | | Total trade volume | 0.429 BTC | |
| 290 | | | | |
| 291 | | Best Pair | LSK/BTC 26.26% | |
| 292 | | Worst Pair | ZEC/BTC -10.18% | |
| 293 | | Best Trade | LSK/BTC 4.25% | |
| 294 | | Worst Trade | ZEC/BTC -10.25% | |
| 295 | | Best day | 0.00076 BTC | |
| 296 | | Worst day | -0.00036 BTC | |
| 297 | | Days win/draw/lose | 12 / 82 / 25 | |
| 298 | | Avg. Duration Winners | 4:23:00 | |
| 299 | | Avg. Duration Loser | 6:55:00 | |
| 300 | | | | |
| 301 | | Min balance | 0.00945123 BTC | |
| 302 | | Max balance | 0.01846651 BTC | |
| 303 | | Drawdown | 50.63% | |
| 304 | | Drawdown | 0.0015 BTC | |
| 305 | | Drawdown high | 0.0013 BTC | |
| 306 | | Drawdown low | -0.0002 BTC | |
| 307 | | Drawdown Start | 2019-02-15 14:10:00 | |
| 308 | | Drawdown End | 2019-04-11 18:15:00 | |
| 309 | | Market change | -5.88% | |
| 310 | =============================================== |
| 311 | ``` |
| 312 | |
| 313 | ### Backtesting report table |
| 314 | |
| 315 | The 1st table contains all trades the bot made, including "left open trades". |
| 316 | |
| 317 | The last line will give you the overall performance of your strategy, |
| 318 | here: |
| 319 | |
| 320 | ``` |
| 321 | | TOTAL | 429 | 0.36 | 152.41 | 0.00762792 | 76.20 | 4:12:00 | 186 | 243 | |
| 322 | ``` |
| 323 | |
| 324 | The bot has made `429` trades for an average duration of `4:12:00`, with a performance of `76.20%` (profit), that means it has |
| 325 | earned a total of `0.00762792 BTC` starting with a capital of 0.01 BTC. |
| 326 | |
| 327 | The column `Avg Profit %` shows the average profit for all trades made while the column `Cum Profit %` sums up all the profits/losses. |
| 328 | The column `Tot Profit %` shows instead the total profit % in relation to the starting balance. |
| 329 | In the above results, we have a starting balance of 0.01 BTC and an absolute profit of 0.00762792 BTC - so the `Tot Profit %` will be `(0.00762792 / 0.01) * 100 ~= 76.2%`. |
| 330 | |
| 331 | Your strategy performance is influenced by your buy strategy, your sell strategy, and also by the `minimal_roi` and `stop_loss` you have set. |
| 332 | |
| 333 | For example, if your `minimal_roi` is only `"0": 0.01` you cannot expect the bot to make more profit than 1% (because it will sell every time a trade reaches 1%). |
| 334 | |
| 335 | ```json |
| 336 | "minimal_roi": { |
| 337 | "0": 0.01 |
| 338 | }, |
| 339 | ``` |
| 340 | |
| 341 | On the other hand, if you set a too high `minimal_roi` like `"0": 0.55` |
| 342 | (55%), there is almost no chance that the bot will ever reach this profit. |
| 343 | Hence, keep in mind that your performance is an integral mix of all different elements of the strategy, your configuration, and the crypto-currency pairs you have set up. |
| 344 | |
| 345 | ### Sell reasons table |
| 346 | |
| 347 | The 2nd table contains a recap of sell reasons. |
| 348 | This table can tell you which area needs some additional work (e.g. all or many of the `sell_signal` trades are losses, so you should work on improving the sell signal, or consider disabling it). |
| 349 | |
| 350 | ### Left open trades table |
| 351 | |
| 352 | The 3rd table contains all trades the bot had to `forcesell` at the end of the backtesting period to present you the full picture. |
| 353 | This is necessary to simulate realistic behavior, since the backtest period has to end at some point, while realistically, you could leave the bot running forever. |
| 354 | These trades are also included in the first table, but are also shown separately in this table for clarity. |
| 355 | |
| 356 | ### Summary metrics |
| 357 | |
| 358 | The last element of the backtest report is the summary metrics table. |
| 359 | It contains some useful key metrics about performance of your strategy on backtesting data. |
| 360 | |
| 361 | ``` |
| 362 | =============== SUMMARY METRICS =============== |
| 363 | | Metric | Value | |
| 364 | |-----------------------+---------------------| |
| 365 | | Backtesting from | 2019-01-01 00:00:00 | |
| 366 | | Backtesting to | 2019-05-01 00:00:00 | |
| 367 | | Max open trades | 3 | |
| 368 | | | | |
| 369 | | Total trades | 429 | |
| 370 | | Starting balance | 0.01000000 BTC | |
| 371 | | Final balance | 0.01762792 BTC | |
| 372 | | Absolute profit | 0.00762792 BTC | |
| 373 | | Total profit % | 76.2% | |
| 374 | | Trades per day | 3.575 | |
| 375 | | Avg. stake amount | 0.001 BTC | |
| 376 | | Total trade volume | 0.429 BTC | |
| 377 | | | | |
| 378 | | Best Pair | LSK/BTC 26.26% | |
| 379 | | Worst Pair | ZEC/BTC -10.18% | |
| 380 | | Best Trade | LSK/BTC 4.25% | |
| 381 | | Worst Trade | ZEC/BTC -10.25% | |
| 382 | | Best day | 0.00076 BTC | |
| 383 | | Worst day | -0.00036 BTC | |
| 384 | | Days win/draw/lose | 12 / 82 / 25 | |
| 385 | | Avg. Duration Winners | 4:23:00 | |
| 386 | | Avg. Duration Loser | 6:55:00 | |
| 387 | | | | |
| 388 | | Min balance | 0.00945123 BTC | |
| 389 | | Max balance | 0.01846651 BTC | |
| 390 | | Drawdown | 50.63% | |
| 391 | | Drawdown | 0.0015 BTC | |
| 392 | | Drawdown high | 0.0013 BTC | |
| 393 | | Drawdown low | -0.0002 BTC | |
| 394 | | Drawdown Start | 2019-02-15 14:10:00 | |
| 395 | | Drawdown End | 2019-04-11 18:15:00 | |
| 396 | | Market change | -5.88% | |
| 397 | =============================================== |
| 398 | |
| 399 | ``` |
| 400 | |
| 401 | - `Backtesting from` / `Backtesting to`: Backtesting range (usually defined with the `--timerange` option). |
| 402 | - `Max open trades`: Setting of `max_open_trades` (or `--max-open-trades`) - or number of pairs in the pairlist (whatever is lower). |
| 403 | - `Total trades`: Identical to the total trades of the backtest output table. |
| 404 | - `Starting balance`: Start balance - as given by dry-run-wallet (config or command line). |
| 405 | - `Final balance`: Final balance - starting balance + absolute profit. |
| 406 | - `Absolute profit`: Profit made in stake currency. |
| 407 | - `Total profit %`: Total profit. Aligned to the `TOTAL` row's `Tot Profit %` from the first table. Calculated as `(End capital − Starting capital) / Starting capital`. |
| 408 | - `Trades per day`: Total trades divided by the backtesting duration in days (this will give you information about how many trades to expect from the strategy). |
| 409 | - `Avg. stake amount`: Average stake amount, either `stake_amount` or the average when using dynamic stake amount. |
| 410 | - `Total trade volume`: Volume generated on the exchange to reach the above profit. |
| 411 | - `Best Pair` / `Worst Pair`: Best and worst performing pair, and it's corresponding `Cum Profit %`. |
| 412 | - `Best Trade` / `Worst Trade`: Biggest single winning trade and biggest single losing trade. |
| 413 | - `Best day` / `Worst day`: Best and worst day based on daily profit. |
| 414 | - `Days win/draw/lose`: Winning / Losing days (draws are usually days without closed trade). |
| 415 | - `Avg. Duration Winners` / `Avg. Duration Loser`: Average durations for winning and losing trades. |
| 416 | - `Min balance` / `Max balance`: Lowest and Highest Wallet balance during the backtest period. |
| 417 | - `Drawdown`: Maximum drawdown experienced. For example, the value of 50% means that from highest to subsequent lowest point, a 50% drop was experienced). |
| 418 | - `Drawdown high` / `Drawdown low`: Profit at the beginning and end of the largest drawdown period. A negative low value means initial capital lost. |
| 419 | - `Drawdown Start` / `Drawdown End`: Start and end datetime for this largest drawdown (can also be visualized via the `plot-dataframe` sub-command). |
| 420 | - `Market change`: Change of the market during the backtest period. Calculated as average of all pairs changes from the first to the last candle using the "close" column. |
| 421 | |
| 422 | ### Assumptions made by backtesting |
| 423 | |
| 424 | Since backtesting lacks some detailed information about what happens within a candle, it needs to take a few assumptions: |
| 425 | |
| 426 | - Buys happen at open-price |
| 427 | - All orders are filled at the requested price (no slippage, no unfilled orders) |
| 428 | - Sell-signal sells happen at open-price of the consecutive candle |
| 429 | - Sell-signal is favored over Stoploss, because sell-signals are assumed to trigger on candle's open |
| 430 | - ROI |
| 431 | - sells are compared to high - but the ROI value is used (e.g. ROI = 2%, high=5% - so the sell will be at 2%) |
| 432 | - sells are never "below the candle", so a ROI of 2% may result in a sell at 2.4% if low was at 2.4% profit |
| 433 | - Forcesells caused by `<N>=-1` ROI entries use low as sell value, unless N falls on the candle open (e.g. `120: -1` for 1h candles) |
| 434 | - Stoploss sells happen exactly at stoploss price, even if low was lower, but the loss will be `2 * fees` higher than the stoploss price |
| 435 | - Stoploss is evaluated before ROI within one candle. So you can often see more trades with the `stoploss` sell reason comparing to the results obtained with the same strategy in the Dry Run/Live Trade modes |
| 436 | - Low happens before high for stoploss, protecting capital first |
| 437 | - Trailing stoploss |
| 438 | - High happens first - adjusting stoploss |
| 439 | - Low uses the adjusted stoploss (so sells with large high-low difference are backtested correctly) |
| 440 | - ROI applies before trailing-stop, ensuring profits are "top-capped" at ROI if both ROI and trailing stop applies |
| 441 | - Sell-reason does not explain if a trade was positive or negative, just what triggered the sell (this can look odd if negative ROI values are used) |
| 442 | - Evaluation sequence (if multiple signals happen on the same candle) |
| 443 | - ROI (if not stoploss) |
| 444 | - Sell-signal |
| 445 | - Stoploss |
| 446 | |
| 447 | Taking these assumptions, backtesting tries to mirror real trading as closely as possible. However, backtesting will **never** replace running a strategy in dry-run mode. |
| 448 | Also, keep in mind that past results don't guarantee future success. |
| 449 | |
| 450 | In addition to the above assumptions, strategy authors should carefully read the [Common Mistakes](strategy-customization.md#common-mistakes-when-developing-strategies) section, to avoid using data in backtesting which is not available in real market conditions. |
| 451 | |
| 452 | ### Further backtest-result analysis |
| 453 | |
| 454 | To further analyze your backtest results, you can [export the trades](#exporting-trades-to-file). |
| 455 | You can then load the trades to perform further analysis as shown in our [data analysis](data-analysis.md#backtesting) backtesting section. |
| 456 | |
| 457 | ## Backtesting multiple strategies |
| 458 | |
| 459 | To compare multiple strategies, a list of Strategies can be provided to backtesting. |
| 460 | |
| 461 | This is limited to 1 timeframe value per run. However, data is only loaded once from disk so if you have multiple |
| 462 | strategies you'd like to compare, this will give a nice runtime boost. |
| 463 | |
| 464 | All listed Strategies need to be in the same directory. |
| 465 | |
| 466 | ``` bash |
| 467 | freqtrade backtesting --timerange 20180401-20180410 --timeframe 5m --strategy-list Strategy001 Strategy002 --export trades |
| 468 | ``` |
| 469 | |
| 470 | This will save the results to `user_data/backtest_results/backtest-result-<strategy>.json`, injecting the strategy-name into the target filename. |
| 471 | There will be an additional table comparing win/losses of the different strategies (identical to the "Total" row in the first table). |
| 472 | Detailed output for all strategies one after the other will be available, so make sure to scroll up to see the details per strategy. |
| 473 | |
| 474 | ``` |
| 475 | =========================================================== STRATEGY SUMMARY =========================================================== |
| 476 | | Strategy | Buys | Avg Profit % | Cum Profit % | Tot Profit BTC | Tot Profit % | Avg Duration | Wins | Draws | Losses | |
| 477 | |:------------|-------:|---------------:|---------------:|-----------------:|---------------:|:---------------|------:|-------:|-------:| |
| 478 | | Strategy1 | 429 | 0.36 | 152.41 | 0.00762792 | 76.20 | 4:12:00 | 186 | 0 | 243 | |
| 479 | | Strategy2 | 1487 | -0.13 | -197.58 | -0.00988917 | -98.79 | 4:43:00 | 662 | 0 | 825 | |
| 480 | ``` |
| 481 | |
| 482 | ## Next step |
| 483 | |
| 484 | Great, your strategy is profitable. What if the bot can give your the optimal parameters to use for your strategy? |
| 485 | Your next step is to learn [how to find optimal parameters with Hyperopt](hyperopt.md) |