@backtrader said in Best Approach for Live-Trading With Cheat on Open:
So it seems that I have to supply the --replay parameter in oandav20test.py.
I don't know. What you need is a data source which is tick based. You said you wanted to be notified of each price change. There should be no need to replay anything for that data feed.
Hi,
with samples/ibtest/ibtest.py I did some tests with Interactive Brokers livetrading. These are the results:
ibtest.py --data0 EUR.USD-CASH-IDEALPRO --timeframe Seconds --compression 30 --port 7497 --no-rightedge
***** DATA NOTIF: LIVE
LIVE, Data0, 0962, 736801.8864360515, 2018-04-17T17:16:28.074845, 1.23699, 1.23699, 1.23699, 1.23699, 0, 0, 1.23703
LIVE, Data0, 0963, 736801.8866241798, 2018-04-17T17:16:44.329133, 1.237, 1.237, 1.237, 1.237, 0, 0, 1.237046
LIVE, Data0, 0964, 736801.8866485074, 2018-04-17T17:16:46.431042, 1.2371, 1.2371, 1.2371, 1.2371, 0, 0, 1.237034
LIVE, Data0, 0965, 736801.8866486517, 2018-04-17T17:16:46.443504, 1.237, 1.237, 1.237, 1.237, 0, 0, 1.237002
LIVE, Data0, 0966, 736801.886811497, 2018-04-17T17:17:00.513344, 1.23694, 1.23694, 1.23694, 1.23694, 0, 0, 1.237006
LIVE, Data0, 0967, 736801.8868541777, 2018-04-17T17:17:04.200952, 1.23693, 1.23693, 1.23693, 1.23693, 0, 0, 1.236994
LIVE, Data0, 0968, 736801.8869536915, 2018-04-17T17:17:12.798944, 1.23694, 1.23694, 1.23694, 1.23694, 0, 0, 1.236982
LIVE, Data0, 0969, 736801.8871321745, 2018-04-17T17:17:28.219872, 1.23691, 1.23691, 1.23691, 1.23691, 0, 0, 1.236944
LIVE, Data0, 0970, 736801.8871946137, 2018-04-17T17:17:33.614623, 1.23699, 1.23699, 1.23699, 1.23699, 0, 0, 1.236942
LIVE, Data0, 0971, 736801.8871946996, 2018-04-17T17:17:33.622046, 1.23698, 1.23698, 1.23698, 1.23698, 0, 0, 1.23695
LIVE, Data0, 0972, 736801.8871947962, 2018-04-17T17:17:33.630394, 1.23699, 1.23699, 1.23699, 1.23699, 0, 0, 1.236962
LIVE, Data0, 0973, 736801.8872731669, 2018-04-17T17:17:40.401621, 1.23698, 1.23698, 1.23698, 1.23698, 0, 0, 1.23697
LIVE, Data0, 0974, 736801.8872752264, 2018-04-17T17:17:40.579562, 1.23699, 1.23699, 1.23699, 1.23699, 0, 0, 1.236986
LIVE, Data0, 0975, 736801.8874047493, 2018-04-17T17:17:51.770338, 1.237, 1.237, 1.237, 1.237, 0, 0, 1.236988
ibtest.py --data0 EUR.USD-CASH-IDEALPRO --timeframe Seconds --compression 30 --port 7497 --resample
***** DATA NOTIF: LIVE
LIVE, Data0, 0962, 736801.8892361111, 2018-04-17T17:20:30.000000, 1.23689, 1.23706, 1.23689, 1.23701, 0.0, 0, 1.2369620000000001
LIVE, Data0, 0963, 736801.8895833333, 2018-04-17T17:21:00.000000, 1.23702, 1.23703, 1.237, 1.23702, 0.0, 0, 1.23696
LIVE, Data0, 0964, 736801.8899305556, 2018-04-17T17:21:30.000000, 1.23701, 1.23707, 1.23699, 1.23707, 0.0, 0, 1.236974
LIVE, Data0, 0965, 736801.8902777778, 2018-04-17T17:22:00.000000, 1.23708, 1.23708, 1.23696, 1.23702, 0.0, 0, 1.237004
ibtest.py --data0 EUR.USD-CASH-IDEALPRO --timeframe Seconds --compression 30 --port 7497 --replay
***** DATA NOTIF: LIVE
LIVE, Data0, 0962, 736801.8905911663, 2018-04-17T17:22:27.076771, 1.23694, 1.23694, 1.23694, 1.23694, 0.0, 0, 1.2369999999999999
LIVE, Data0, 0962, 736801.890625, 2018-04-17T17:22:30.000000, 1.23694, 1.23694, 1.23694, 1.23694, 0.0, 0, 1.2369999999999999
LIVE, Data0, 0963, 736801.8908331305, 2018-04-17T17:22:47.982471, 1.23693, 1.23693, 1.23693, 1.23693, 0.0, 0, 1.236982
LIVE, Data0, 0963, 736801.8908331448, 2018-04-17T17:22:47.983708, 1.23693, 1.23696, 1.23693, 1.23696, 0.0, 0, 1.236988
LIVE, Data0, 0963, 736801.8908638399, 2018-04-17T17:22:50.635766, 1.23693, 1.23698, 1.23693, 1.23698, 0.0, 0, 1.236992
LIVE, Data0, 0963, 736801.8908640771, 2018-04-17T17:22:50.656264, 1.23693, 1.23699, 1.23693, 1.23699, 0.0, 0, 1.236994
LIVE, Data0, 0963, 736801.8908658416, 2018-04-17T17:22:50.808718, 1.23693, 1.237, 1.23693, 1.237, 0.0, 0, 1.236996
LIVE, Data0, 0963, 736801.8908685311, 2018-04-17T17:22:51.041084, 1.23693, 1.23701, 1.23693, 1.23701, 0.0, 0, 1.236998
LIVE, Data0, 0963, 736801.8908700076, 2018-04-17T17:22:51.168654, 1.23693, 1.23702, 1.23693, 1.23702, 0.0, 0, 1.2369999999999999
LIVE, Data0, 0963, 736801.8908825091, 2018-04-17T17:22:52.248782, 1.23693, 1.23702, 1.23693, 1.23701, 0.0, 0, 1.236998
LIVE, Data0, 0963, 736801.890961202, 2018-04-17T17:22:59.047850, 1.23693, 1.23702, 1.23693, 1.23702, 0.0, 0, 1.2369999999999999
LIVE, Data0, 0963, 736801.8909623256, 2018-04-17T17:22:59.144933, 1.23693, 1.23704, 1.23693, 1.23704, 0.0, 0, 1.237004
LIVE, Data0, 0963, 736801.8909629615, 2018-04-17T17:22:59.199871, 1.23693, 1.23705, 1.23693, 1.23705, 0.0, 0, 1.2370059999999998
LIVE, Data0, 0963, 736801.890965801, 2018-04-17T17:22:59.445203, 1.23693, 1.23705, 1.23693, 1.23704, 0.0, 0, 1.237004
LIVE, Data0, 0963, 736801.8909722222, 2018-04-17T17:23:00.000000, 1.23693, 1.23705, 1.23693, 1.23704, 0.0, 0, 1.237004
LIVE, Data0, 0964, 736801.8909756911, 2018-04-17T17:23:00.299714, 1.23705, 1.23705, 1.23705, 1.23705, 0, 0, 1.2369999999999999
LIVE, Data0, 0964, 736801.8909989573, 2018-04-17T17:23:02.309913, 1.23705, 1.23705, 1.23704, 1.23704, 0.0, 0, 1.236998
LIVE, Data0, 0964, 736801.8910004616, 2018-04-17T17:23:02.439886, 1.23705, 1.23705, 1.23703, 1.23703, 0.0, 0, 1.236996
It seems to me, that the --replay parameter really delivers what I need:
tick based during live streaming
after each candlestick timeframe, len(self.data0) increases by one and also the last call to next() for that block seems to comprise consistent values for OHLC for the whole candlestick.