Just warn on single-bar nulls instead of bping
Replace the debug breakpoint with a warning-log when a single-bar null-segment is detected in `get_null_segs()`. This lets the gap analysis continue while still alerting about the anomaly. Deats, - extract the 3-bar window (before, null, after) and calculate a `gap: pendulum.Interval` for the warning msg. - comment-out the old breakpoint block for optional debugging as needed. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codegap_annotator
parent
056128de0b
commit
01fc1d3887
|
|
@ -276,14 +276,41 @@ def get_null_segs(
|
||||||
absi_zdiff: np.ndarray = np.diff(absi_zeros)
|
absi_zdiff: np.ndarray = np.diff(absi_zeros)
|
||||||
|
|
||||||
if zero_t.size < 2:
|
if zero_t.size < 2:
|
||||||
try:
|
idx: int = zero_t['index'][0]
|
||||||
breakpoint()
|
idx_before: int = idx - 1
|
||||||
except RuntimeError:
|
idx_after: int = idx + 1
|
||||||
# XXX, if greenback not active from
|
index = frame['index']
|
||||||
# piker store ldshm cmd..
|
before_cond = idx_before <= index
|
||||||
log.exception(
|
after_cond = index <= idx_after
|
||||||
"Can't debug single-sample null!\n"
|
bars: np.ndarray = frame[
|
||||||
)
|
before_cond
|
||||||
|
&
|
||||||
|
after_cond
|
||||||
|
]
|
||||||
|
time: np.ndarray = bars['time']
|
||||||
|
from pendulum import (
|
||||||
|
from_timestamp,
|
||||||
|
Interval,
|
||||||
|
)
|
||||||
|
gap: Interval = (
|
||||||
|
from_timestamp(time[-1])
|
||||||
|
-
|
||||||
|
from_timestamp(time[0])
|
||||||
|
)
|
||||||
|
log.warning(
|
||||||
|
f'Single OHLCV-bar null-segment detected??\n'
|
||||||
|
f'gap -> {gap}\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
# ^^XXX, if you want to debug the above bar-gap^^
|
||||||
|
# try:
|
||||||
|
# breakpoint()
|
||||||
|
# except RuntimeError:
|
||||||
|
# # XXX, if greenback not active from
|
||||||
|
# # piker store ldshm cmd..
|
||||||
|
# log.exception(
|
||||||
|
# "Can't debug single-sample null!\n"
|
||||||
|
# )
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue