From cdc22e0807df3f1589a8d2d41f3eaab7797c175b Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 22 Dec 2022 13:20:55 -0500 Subject: [PATCH] Sync 1s (or less) sampler steps using rounded now-epoch --- piker/data/_sampling.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/piker/data/_sampling.py b/piker/data/_sampling.py index c4b182ae..faa17da9 100644 --- a/piker/data/_sampling.py +++ b/piker/data/_sampling.py @@ -137,6 +137,14 @@ async def increment_ohlc_buffer( '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 last[[ 'time', @@ -149,7 +157,7 @@ async def increment_ohlc_buffer( 'volume', ]][0] = ( # epoch timestamp - t + this_delay_s, + next_t, # OHLC close,