Open mr-m0nst3r opened 5 years ago
Hi @mr-m0nst3r
Thanks for the submission and report. Yes, resampling currently does not work from my testing. It is an item to tackle in the future. I have marked this as a bug and will keep it open.
Okay, thank you.
Btw, I guess I have to calculate the macd without using the bt.Indicators.
Thanks and hope someone could make this bug fixed.
@Dave-Vallance
I find that if we remove fromdate
parameter, the script runs well, but started at about 1 day before, without the error described above.
Any help with this finding?
Here's the question I posted on the backtrader community: https://community.backtrader.com/topic/1914/resample-live-feed-from-ccxt-problem/4
After testing it seems that this bug only triggers when a bar which needs to be resampled is only a few seconds old. I haven't been able to trigger it while walking through the code.
I came up with this ugly fix: Inside of ccxtfeed.py -> _load
start = datetime.utcnow()
if start.second < 15:
time.sleep(15 - start.second)
self._fetch_ohlcv()
Log snippets from some testing I did with 1 and 2 minute bars:
2020-03-16 16:22:22.377627 - fetch_ohlcv - Attempt 0
03-16 16:22 - custom_classes.f_cerebro: WARNING works as intended
2020-03-16 16:24:22.207071 - fetch_ohlcv - Attempt 0
03-16 16:24 - custom_classes.f_cerebro: WARNING works as intended
2020-03-16 16:26:21.639287 - fetch_ohlcv - Attempt 0
03-16 16:26 - custom_classes.f_cerebro: WARNING works as intended
2020-03-16 16:32:11.773225 - fetch_ohlcv - Attempt 0
03-16 16:32 - custom_classes.f_cerebro: WARNING works as intended
2020-03-16 16:42:17.367415 - fetch_ohlcv - Attempt 0
03-16 16:42 - custom_classes.f_cerebro: WARNING works as intended
2020-03-16 16:46:17.382720 - fetch_ohlcv - Attempt 0
03-16 16:46 - custom_classes.f_cerebro: WARNING works as intended
2020-03-16 16:34:08.293936 - fetch_ohlcv - Attempt 0
03-16 16:34 - custom_classes.f_cerebro: WARNING resampled bug triggered
2020-03-16 16:40:03.369245 - fetch_ohlcv - Attempt 0
03-16 16:40 - custom_classes.f_cerebro: WARNING resampled bug triggered
2020-03-16 16:44:05.686620 - fetch_ohlcv - Attempt 0
03-16 16:44 - custom_classes.f_cerebro: WARNING resampled bug triggered
2020-03-16 16:48:07.024158 - fetch_ohlcv - Attempt 0
03-16 16:48 - custom_classes.f_cerebro: WARNING resampled bug triggered
No, at least it is not working for me
@Dave-Vallance
I find that if we remove
fromdate
parameter, the script runs well, but started at about 1 day before, without the error described above.Any help with this finding?
Here's the question I posted on the backtrader community: https://community.backtrader.com/topic/1914/resample-live-feed-from-ccxt-problem/4
For me it worked when I checked while escape condition to:
if len(self.data) != 0: break
After testing it seems that this bug only triggers when a bar which needs to be resampled is only a few seconds old. I haven't been able to trigger it while walking through the code.
I came up with this ugly fix: Inside of ccxtfeed.py -> _load
start = datetime.utcnow() if start.second < 15: time.sleep(15 - start.second) self._fetch_ohlcv()
Log snippets from some testing I did with 1 and 2 minute bars:
2020-03-16 16:22:22.377627 - fetch_ohlcv - Attempt 0 03-16 16:22 - custom_classes.f_cerebro: WARNING works as intended 2020-03-16 16:24:22.207071 - fetch_ohlcv - Attempt 0 03-16 16:24 - custom_classes.f_cerebro: WARNING works as intended 2020-03-16 16:26:21.639287 - fetch_ohlcv - Attempt 0 03-16 16:26 - custom_classes.f_cerebro: WARNING works as intended 2020-03-16 16:32:11.773225 - fetch_ohlcv - Attempt 0 03-16 16:32 - custom_classes.f_cerebro: WARNING works as intended 2020-03-16 16:42:17.367415 - fetch_ohlcv - Attempt 0 03-16 16:42 - custom_classes.f_cerebro: WARNING works as intended 2020-03-16 16:46:17.382720 - fetch_ohlcv - Attempt 0 03-16 16:46 - custom_classes.f_cerebro: WARNING works as intended 2020-03-16 16:34:08.293936 - fetch_ohlcv - Attempt 0 03-16 16:34 - custom_classes.f_cerebro: WARNING resampled bug triggered 2020-03-16 16:40:03.369245 - fetch_ohlcv - Attempt 0 03-16 16:40 - custom_classes.f_cerebro: WARNING resampled bug triggered 2020-03-16 16:44:05.686620 - fetch_ohlcv - Attempt 0 03-16 16:44 - custom_classes.f_cerebro: WARNING resampled bug triggered 2020-03-16 16:48:07.024158 - fetch_ohlcv - Attempt 0 03-16 16:48 - custom_classes.f_cerebro: WARNING resampled bug triggered
This works for me. Thanks. But are there any specific reasons to use 15 seconds? I used 5 seconds and it seems to work as well.
This works for me. Thanks. But are there any specific reasons to use 15 seconds? I used 5 seconds and it seems to work as well.
No specific reason. Excessive caution.
Hi there,
I'm trying to add 1 minute data to CCXTFeed, and then resample it to 5 minutes, so I can get MACD of 1m and 5m. But failed.
Here's the code:
And here's the output:
Any idea?
Thank you.