DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.21k stars 2.04k forks source link

Bollinger: changes in the startegy period affects the Buy & Hold return #2664

Closed enoris75 closed 3 years ago

enoris75 commented 3 years ago

System information

Describe the problem

Disclaimer: total n00b here.

I've been running some simulation on the Bollinger strategy and I'm seeing rather important differences in the buy & hold return when I change the period of the simulation.

I don't understand why this is the case for in the case of b&h only the first and last price should matter. As an example with:

a period of 15m gives a buy & hold return of 39.63% while a period of 2h gives only 28.85%

Does anyone else also noticed similar discrepancies? Am I missing something here. Thank you in advance

Source code / Error logs

hereby the command lines: node .\zenbot.js sim binance.BTC-USDT --strategy bollinger --period=15m --start 202004010000 --end 202005010000 and node .\zenbot.js sim binance.BTC-USDT --strategy bollinger --period=2h --start 202004010000 --end 202005010000

Period 15m:

end balance: 102.59210990 (2.59%) buy hold: 139.63352637 (39.63%) vs. buy hold: -26.53% 74 trades over 31 days (avg 2.38 trades/day) win/loss: 26/11 error rate: 29.72% { "asset_capital": 0, "avg_slippage_pct": 0.045, "bollinger_lower_bound_pct": 0, "bollinger_size": 20, "bollinger_time": 2, "bollinger_upper_bound_pct": 0, "buy_pct": 99, "buy_stop_pct": 0, "currency_capital": 100, "days": 30, "end": 1588284000000, "markdown_buy_pct": 0, "markup_sell_pct": 0, "max_buy_loss_pct": 99, "max_sell_loss_pct": 99, "max_slippage_pct": 5, "min_periods": 1, "mode": "sim", "order_adjust_time": 5000, "order_poll_time": 5000, "order_type": "maker", "period": "15m", "period_length": "15m", "profit_stop_enable_pct": 0, "profit_stop_pct": 1, "quarentine_time": 0, "rsi_periods": 14, "selector": { "exchange_id": "binance", "product_id": "BTC-USDT", "asset": "BTC", "currency": "USDT", "normalized": "binance.BTC-USDT" }, "sell_pct": 99, "sell_stop_pct": 0, "show_options": true, "silent": true, "start": 1585692000000, "stats": false, "strategy": "bollinger", "symmetrical": false, "verbose": false, "simresults": { "start_capital": 100, "last_buy_price": "8951.84000000", "last_assest_value": 8761.92, "asset_capital": 88.01964816959999, "currency": 102.5921099, "profit": 0.02592109899999997, "buy_hold": 139.63352637634782, "buy_hold_profit": 0.39633526376347816, "total_trades": 74, "length_days": 31, "total_sells": 37, "total_losses": 11, "vs_buy_hold": -26.527595082367107 }, "net_currency": 12.412326401600126 } wrote simulations/sim_result_binance.BTC-USDT_200430_215959_UTC.html

Period 2h:

end balance: 103.03003240 (3.03%) buy hold: 128.75709037 (28.75%) vs. buy hold: -19.99% 7 trades over 31 days (avg 0.22 trades/day) win/loss: 2/2 error rate: 50.00% { "asset_capital": 0, "avg_slippage_pct": 0.045, "bollinger_lower_bound_pct": 0, "bollinger_size": 20, "bollinger_time": 2, "bollinger_upper_bound_pct": 0, "buy_pct": 99, "buy_stop_pct": 0, "currency_capital": 100, "days": 30, "end": 1588284000000, "markdown_buy_pct": 0, "markup_sell_pct": 0, "max_buy_loss_pct": 99, "max_sell_loss_pct": 99, "max_slippage_pct": 5, "min_periods": 1, "mode": "sim", "order_adjust_time": 5000, "order_poll_time": 5000, "order_type": "maker", "period": "2h", "period_length": "2h", "profit_stop_enable_pct": 0, "profit_stop_pct": 1, "quarentine_time": 0, "rsi_periods": 14, "selector": { "exchange_id": "binance", "product_id": "BTC-USDT", "asset": "BTC", "currency": "USDT", "normalized": "binance.BTC-USDT" }, "sell_pct": 99, "sell_stop_pct": 0, "show_options": true, "silent": true, "start": 1585692000000, "stats": false, "strategy": "bollinger", "symmetrical": false, "verbose": false, "simresults": { "start_capital": 100, "last_buy_price": "6965.33000000", "last_assest_value": 8761.92, "asset_capital": 1.3559211944999998, "currency": 103.0300324, "profit": 0.030300323999999962, "buy_hold": 128.75709037472447, "buy_hold_profit": 0.2875709037472447, "total_trades": 7, "length_days": 31, "total_sells": 4, "total_losses": 2, "vs_buy_hold": -19.98108057571857 }, "net_currency": 101.76121877380001 } wrote simulations/sim_result_binance.BTC-USDT_200430_215959_UTC.html

enoris75 commented 3 years ago

I'm noticing some discrepancies with Ichimoku too, but they are vastly lower (minor discrepancies can indeed occur for the latest price will be the one 1 period before the end of the interval):

ichimoku Period initial Jan Feb Mar Apr Mai Jun Jul Aug Sep
buy and hold 005m 100 129.9068 91.84205 74.61094 135.9998 108.074 96.73515 124.2088 102.2401 92.07667
buy and hold 015m 100 130.3836 91.84205 74.61094 135.9998 108.074 96.73515 124.2088 102.2401 92.07667
buy and hold 030m 100 130.7528 91.84205 74.61094 135.9998 108.074 96.73515 124.2088 102.2401 92.07667
buy and hold 060m 100 130.4044 91.84205 74.61094 135.9998 108.074 96.73515 124.2088 102.2401 92.07667
buy and hold 120m 100 126.5859 92.33231 75.59087 135.9998 108.074 96.73515 124.5092 102.2401 92.07667
Bollinger Period initial Jan Feb Mar Apr Mai Jun
buy and hold 005m 100 130.370 91.800 74.708 137.538 109.763 96.232
buy and hold 015m 100 130.591 92.043 74.815 139.634 108.197 95.668
buy and hold 030m 100 129.790 92.529 75.996 140.556 107.050 96.293
buy and hold 060m 100 131.153 93.167 76.172 134.370 106.409 94.728
buy and hold 120m 100 134.898 90.789 73.559 128.757 105.544 93.832
enoris75 commented 3 years ago

I dug a little deeper and it seem like the initial value which is used to calculate buy and hold is not the value at the beginning of the testing period but rather the one corresponding to the first signal emitted by Bollinger.

image

Note: I quickly added the initial and final value of B&H to the end of simulation report for easier debugging (the from, to part).

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.