From 7802febd208fa207d2ab1f05e0bf498ec56010f2 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 26 Jul 2023 12:56:06 -0400 Subject: [PATCH] Backfill history gaps with pre-gap close --- piker/data/history.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/piker/data/history.py b/piker/data/history.py index 3319293a..0b4f3bf9 100644 --- a/piker/data/history.py +++ b/piker/data/history.py @@ -140,8 +140,18 @@ async def shm_push_in_between( # memory... array = shm.array zeros = array[array['low'] == 0] - if 0 < zeros.size < 1000: - await tractor.pause() + + # always backfill gaps with the earliest (price) datum's + # value to avoid the y-ranger including zeros and completely + # stretching the y-axis.. + if 0 < zeros.size: + zeros[[ + 'open', + 'high', + 'low', + 'close', + ]] = shm._array[zeros['index'][0] - 1]['close'] + # await tractor.pause() async def start_backfill(