Write shm volume (facepalm), update open=close on first volume
parent
b23e459027
commit
1640906b09
|
@ -645,15 +645,26 @@ async def stream_quotes(
|
||||||
if not writer_already_exists:
|
if not writer_already_exists:
|
||||||
for tick in iterticks(quote, type='trade'):
|
for tick in iterticks(quote, type='trade'):
|
||||||
last = tick['price']
|
last = tick['price']
|
||||||
# print(f'broker last: {tick}')
|
|
||||||
|
|
||||||
# update last entry
|
# update last entry
|
||||||
# benchmarked in the 4-5 us range
|
# benchmarked in the 4-5 us range
|
||||||
high, low = shm.array[-1][['high', 'low']]
|
o, high, low, v = shm.array[-1][
|
||||||
shm.array[['high', 'low', 'close']][-1] = (
|
['open', 'high', 'low', 'volume']
|
||||||
|
]
|
||||||
|
|
||||||
|
new_v = tick['size']
|
||||||
|
|
||||||
|
if v == 0 and new_v:
|
||||||
|
# no trades for this bar yet so the open
|
||||||
|
# is also the close/last trade price
|
||||||
|
o = last
|
||||||
|
|
||||||
|
shm.array[['open', 'high', 'low', 'close', 'volume']][-1] = (
|
||||||
|
o,
|
||||||
max(high, last),
|
max(high, last),
|
||||||
min(low, last),
|
min(low, last),
|
||||||
last,
|
last,
|
||||||
|
v + new_v,
|
||||||
)
|
)
|
||||||
|
|
||||||
con = quote['contract']
|
con = quote['contract']
|
||||||
|
|
|
@ -342,12 +342,31 @@ async def stream_quotes(
|
||||||
if not writer_exists:
|
if not writer_exists:
|
||||||
# update last entry
|
# update last entry
|
||||||
# benchmarked in the 4-5 us range
|
# benchmarked in the 4-5 us range
|
||||||
high, low = shm.array[-1][['high', 'low']]
|
o, high, low, v = shm.array[-1][
|
||||||
shm.array[['high', 'low', 'close', 'vwap']][-1] = (
|
['open', 'high', 'low', 'volume']
|
||||||
|
]
|
||||||
|
new_v = tick_volume
|
||||||
|
|
||||||
|
if v == 0 and new_v:
|
||||||
|
# no trades for this bar yet so the open
|
||||||
|
# is also the close/last trade price
|
||||||
|
o = last
|
||||||
|
|
||||||
|
# write shm
|
||||||
|
shm.array[
|
||||||
|
['open',
|
||||||
|
'high',
|
||||||
|
'low',
|
||||||
|
'close',
|
||||||
|
'vwap',
|
||||||
|
'volume']
|
||||||
|
][-1] = (
|
||||||
|
o,
|
||||||
max(high, last),
|
max(high, last),
|
||||||
min(low, last),
|
min(low, last),
|
||||||
last,
|
last,
|
||||||
ohlc.vwap,
|
ohlc.vwap,
|
||||||
|
volume,
|
||||||
)
|
)
|
||||||
|
|
||||||
# XXX: format required by ``tractor.msg.pub``
|
# XXX: format required by ``tractor.msg.pub``
|
||||||
|
|
Loading…
Reference in New Issue