happydasch / btoandav20

Support for Oanda-V20 API in backtrader
Apache License 2.0
131 stars 52 forks source link

Datafeeds delay candle when set node candles=True #65

Closed santatic closed 3 years ago

santatic commented 3 years ago

Hello, I have get candle with mode candles=True when I get datafeeds I try to get M5 candles from Oanda It works well, but some time I get 2 candle at same time

[2020-12-10 06:30:02,791 INFO log(30)] [2020-12-09 23:20:00.000000] Current OHLC: O=1.335290, H=1.335290, L=1.334820, C=1.334900
[2020-12-10 06:30:02,792 INFO log(30)] [2020-12-09 23:25:00.000000] Current OHLC: O=1.334870, H=1.334920, L=1.334780, C=1.334800

(time on the left is system logging time, time on the right is candle time)


I have debug that in function _t_candles of oandav20store.py, sometime I get candles but it didn't complete, so library will skip that candle

[2020-12-10 06:25:00,623 INFO _t_candles(713)] =====>> request cancles: GBP_USD, M5, M, {'fromTime': '2020-12-09T23:15:00.000000000Z', 'includeFirst': False}
[2020-12-10 06:25:00,873 INFO _t_candles(744)] =====>> produce candle: {'time': '1607556000.000000000', 'mid': {'o': 1.33529, 'h': 1.33529, 'l': 1.33482, 'c': 1.3349}, 'volume': 63, 'complete': False}

Do we have any option to retry to get candle when is doesn't complete?

happydasch commented 3 years ago

i have added a param: candles_delay which you may change to see if the issue resolves. The param allows to increase the time to wait until a new candle is being fetched. Would like to hear feedback about this change.

santatic commented 3 years ago

I tested with 3 second delay, and it stills happen. Even I updated my computer date time with ntp time server. Hope it can fix on Oanda API soon.

happydasch commented 3 years ago

closing this issue since no new updates, not really sure, where the issue may come from. Feel free to open a new issue if required.