Sync 1s (or less) sampler steps using rounded now-epoch

samplerd_service
Tyler Goodlet 2022-12-22 13:20:55 -05:00
parent 009bbe456e
commit 3efb0b5884
1 changed files with 9 additions and 1 deletions

View File

@ -137,6 +137,14 @@ async def increment_ohlc_buffer(
'close', 'close',
]] ]]
next_t = t + this_delay_s
i_epoch = round(time.time())
if this_delay_s <= 1:
next_t = i_epoch
# print(f'epoch {shm.token["shm_name"]}: {next_t}')
# this copies non-std fields (eg. vwap) from the last datum # this copies non-std fields (eg. vwap) from the last datum
last[[ last[[
'time', 'time',
@ -149,7 +157,7 @@ async def increment_ohlc_buffer(
'volume', 'volume',
]][0] = ( ]][0] = (
# epoch timestamp # epoch timestamp
t + this_delay_s, next_t,
# OHLC # OHLC
close, close,