-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backtesting issue in returning a resample dataframe #62
Comments
I'll have a look at it tonight. Any particular pair you're looking at - or is it "pair-agnostic" ... ? |
it seems pair-agnostic. I tried with a dozen of different pairs. |
Now i've moved this issue to the strategy repository, as i think it's better suited here, as the problem is with the strategy - not with freqtrade itself. I've also opened a PR with the (#63) fixes applied. I think it's accidental that it never worked in backtesting but did work during dry-run. Since the dataframe did not fill na values after merging, it was causing only accidental buys at the resampled timeframe. Also, by using |
@maxma-bit the fixes were merged, |
I still can't get the strategy ReinforcedAverageStrategy to work. I updated technical, the strategies and also the container. And backtested again. I'm getting the KeyError: 'resample_2880_sma', see:
|
(^^ formatted) |
Well this strategy uses 4h candles by default - and the resampling used is If you're using different candles (1h / lower) you need to adjust the key. the calculation is rather simple - it's 4h ( Now obviously, if you're using 1h candles, you'll need Hope this makes sense? unfortunately, the logs don't show which interval you're actually using. |
The strategy ReinforcedAverageStrategy in the folder Berlinguyinca https://github.com/freqtrade/freqtrade-strategies/tree/master/user_data/strategies/berlinguyinca works perfectly in real-mode and dry-mode but does not work with backtesting. This stradegy manipulates the dataframe before returning it to the populate_buy_trend method, namelly adding the column called resample_sma
I noticed that if you print the dataframe in backtesting mode, the column called resample_sma follows the buy columns in the resulting dataframe, see:
['date', 'open', 'high', 'low', 'close', 'volume', 'maShort', 'maMedium', 'bb_lowerband', 'bb_upperband', 'bb_middleband', 'buy', 'sell', 'resample_sma']
date open high ... buy sell resample_sma
475 2020-01-09 22:45:00+00:00 0.000028 0.000029 ... 0 0 NaN
476 2020-01-09 23:00:00+00:00 0.000029 0.000029 ... 0 0 NaN
477 2020-01-09 23:15:00+00:00 0.000028 0.000028 ... 0 0 NaN
478 2020-01-09 23:30:00+00:00 0.000028 0.000028 ... 0 0 NaN
479 2020-01-09 23:45:00+00:00 0.000028 0.000028 ... 0 0 NaN
[5 rows x 14 columns]
['date', 'open', 'high', 'low', 'close', 'volume', 'maShort', 'maMedium', 'bb_lowerband', 'bb_upperband', 'bb_middleband', 'buy', 'sell', 'resample_sma']
date open high ... buy sell resample_sma
475 2020-01-09 22:45:00+00:00 0.001830 0.001835 ... 0 0 NaN
476 2020-01-09 23:00:00+00:00 0.001834 0.001835 ... 0 0 NaN
477 2020-01-09 23:15:00+00:00 0.001833 0.001836 ... 0 0 NaN
478 2020-01-09 23:30:00+00:00 0.001836 0.001839 ... 0 0 NaN
479 2020-01-09 23:45:00+00:00 0.001838 0.001844 ... 0 0 NaN
while the same strategy ReinforcedAverageStrategy in dry-mode returns a correct dataframe with the columns buy and sell at the end. See below:
[5 rows x 14 columns]
['date', 'open', 'high', 'low', 'close', 'volume', 'maShort', 'maMedium', 'bb_lowerband', 'bb_upperband', 'bb_middleband', 'resample_sma', 'buy', 'sell']
date open high ... resample_sma buy sell
494 2020-01-15 20:30:00+00:00 0.000277 0.000278 ... NaN NaN NaN
495 2020-01-15 20:45:00+00:00 0.000276 0.000276 ... NaN NaN NaN
496 2020-01-15 21:00:00+00:00 0.000276 0.000278 ... NaN NaN NaN
497 2020-01-15 21:15:00+00:00 0.000277 0.000277 ... NaN NaN NaN
498 2020-01-15 21:30:00+00:00 0.000275 0.000276 ... NaN NaN NaN
[5 rows x 14 columns]
['date', 'open', 'high', 'low', 'close', 'volume', 'maShort', 'maMedium', 'bb_lowerband', 'bb_upperband', 'bb_middleband', 'resample_sma', 'buy', 'sell']
date open high ... resample_sma buy sell
494 2020-01-15 20:30:00+00:00 0.000002 0.000002 ... NaN NaN NaN
495 2020-01-15 20:45:00+00:00 0.000002 0.000002 ... NaN NaN NaN
496 2020-01-15 21:00:00+00:00 0.000002 0.000002 ... NaN NaN NaN
497 2020-01-15 21:15:00+00:00 0.000002 0.000002 ... NaN NaN 1.0
498 2020-01-15 21:30:00+00:00 0.000002 0.000002 ... NaN NaN NaN
I tried different variation of returning a resampled dataframe to populate_buy_trend method, but I have the same problem described above in the case of backtesting, any suggestions?
The text was updated successfully, but these errors were encountered: