Handle valid null frames and 0-bar cases in backfill
Add guards for empty-array and zero-bar-diff cases in the TSP backfill loops to avoid crashes and allow graceful loop termination. In `maybe_fill_null_segments()`, - add `array.size == 0` guard in `maybe_fill_null_segments()` to detect valid (venue closure) gaps from the backend; add a warning + bp + break for this case. - add TODO that we should likely be filling nulls with the close price for the gap's duration. In `start_backfill()`, - expand the "0 bars after diff" warning msg with `backfill_until_dt` and `end_dt_param` context. - mask the `await tractor.pause()` and add a `break` to avoid blocking the backfill loop. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codeib_async_CONT
parent
137aee510b
commit
3b0e413e96
|
|
@ -251,10 +251,20 @@ async def maybe_fill_null_segments(
|
||||||
end_dt=end_dt,
|
end_dt=end_dt,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if array.size == 0:
|
||||||
|
log.warning(
|
||||||
|
f'Valid gap from backend ??\n'
|
||||||
|
f'{end_dt} -> {start_dt}\n'
|
||||||
|
)
|
||||||
|
# ?TODO? do we want to remove the nulls and push
|
||||||
|
# the close price here for the gap duration?
|
||||||
|
await tractor.pause()
|
||||||
|
break
|
||||||
|
|
||||||
if (
|
if (
|
||||||
frame_start_dt := (
|
frame_start_dt := (from_timestamp(array['time'][0]))
|
||||||
from_timestamp(array['time'][0])
|
<
|
||||||
) < backfill_until_dt
|
backfill_until_dt
|
||||||
):
|
):
|
||||||
log.error(
|
log.error(
|
||||||
f'Invalid frame_start !?\n'
|
f'Invalid frame_start !?\n'
|
||||||
|
|
@ -616,10 +626,17 @@ async def start_backfill(
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.warning(
|
log.warning(
|
||||||
'0 BARS TO PUSH after diff!?\n'
|
f'0 BARS TO PUSH after diff!?\n'
|
||||||
f'{next_start_dt} -> {last_start_dt}'
|
f'{next_start_dt} -> {last_start_dt}'
|
||||||
|
f'\n'
|
||||||
|
f'This might mean we rxed a gap frame which starts BEFORE,\n'
|
||||||
|
f'backfill_until_dt: {backfill_until_dt}\n'
|
||||||
|
f'end_dt_param: {end_dt_param}\n'
|
||||||
|
|
||||||
)
|
)
|
||||||
await tractor.pause()
|
# XXX, to debug it and be sure.
|
||||||
|
# await tractor.pause()
|
||||||
|
break
|
||||||
|
|
||||||
# Check if we're about to exceed buffer capacity BEFORE
|
# Check if we're about to exceed buffer capacity BEFORE
|
||||||
# attempting the push
|
# attempting the push
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue