Compare commits

...

4 Commits

Author SHA1 Message Date
Gud Boi f39b362bc4 Add a couple cooler "cooler"/"muted" red and greens 2026-01-27 13:34:52 -05:00
Gud Boi d2e1d6ce91 Add break for single bar null segments 2026-01-27 13:33:46 -05:00
Gud Boi d0966e0363 Space gap rect-annots "between" start-end bars 2026-01-27 13:33:13 -05:00
Gud Boi 4081336bd3 Catch too-early ib hist frames
For now by REPLing them and raising an RTE inside `.ib.feed` as well as
tracing any such cases that make it (from other providers) up to the
`.tsp._history` layer during null-segment backfilling.
2026-01-27 13:17:28 -05:00
5 changed files with 57 additions and 16 deletions

View File

@ -178,8 +178,8 @@ async def open_history_client(
async def get_hist(
timeframe: float,
end_dt: datetime | None = None,
start_dt: datetime | None = None,
end_dt: datetime|None = None,
start_dt: datetime|None = None,
) -> tuple[np.ndarray, str]:
@ -262,7 +262,29 @@ async def open_history_client(
vlm = bars_array['volume']
vlm[vlm < 0] = 0
return bars_array, first_dt, last_dt
# XXX, if a start-limit was passed ensure we only
# return history that far back!
if (
start_dt
and
last_dt < start_dt
):
bars_array = bars_array[
bars_array['time'] >= start_dt.timestamp()
]
# TODO! rm this once we're more confident it never hits!
breakpoint()
raise RuntimeError(
f'OHLC-bars array start is gt `start_dt` limit !!\n'
f'start_dt: {start_dt}\n'
f'last_dt: {last_dt}\n'
)
return (
bars_array,
first_dt,
last_dt,
)
# TODO: it seems like we can do async queries for ohlc
# but getting the order right still isn't working and I'm not
@ -397,7 +419,7 @@ async def get_bars(
# blank to start which tells ib to look up the latest datum
end_dt: str = '',
start_dt: str | None = '',
start_dt: str|None = '',
# TODO: make this more dynamic based on measured frame rx latency?
# how long before we trigger a feed reset (seconds)
@ -451,6 +473,8 @@ async def get_bars(
dt_duration,
) = await proxy.bars(
fqme=fqme,
# XXX TODO! lol we're not using this..
# start_dt=start_dt,
end_dt=end_dt,
sample_period_s=timeframe,

View File

@ -275,6 +275,10 @@ def get_null_segs(
# diff of abs index steps between each zeroed row
absi_zdiff: np.ndarray = np.diff(absi_zeros)
if zero_t.size < 2:
breakpoint()
return None
# scan for all frame-indices where the
# zeroed-row-abs-index-step-diff is greater then the
# expected increment of 1.
@ -434,8 +438,8 @@ def get_null_segs(
def iter_null_segs(
timeframe: float,
frame: Frame | None = None,
null_segs: tuple | None = None,
frame: Frame|None = None,
null_segs: tuple|None = None,
) -> Generator[
tuple[
@ -487,7 +491,8 @@ def iter_null_segs(
start_dt = None
if (
absi_start is not None
and start_t != 0
and
start_t != 0
):
fi_start: int = absi_start - absi_first
start_row: Seq = frame[fi_start]
@ -501,8 +506,8 @@ def iter_null_segs(
yield (
absi_start, absi_end, # abs indices
fi_start, fi_end, # relative "frame" indices
start_t, end_t,
start_dt, end_dt,
start_t, end_t, # epoch times
start_dt, end_dt, # dts
)

View File

@ -121,21 +121,24 @@ async def markup_gaps(
# iend += margin
# istart -= margin
rect_gap: float = BGM*3/8
opn: float = row['open'][0]
cls: float = prev_r['close'][0]
ro: tuple[float, float] = (
iend + rect_gap + 1,
opn,
)
# BGM=0.16 is the normal diff from overlap between bars, SO
# just go slightly "in" from that "between them".
from_idx: int = BGM - .06 # = .10
lc: tuple[float, float] = (
istart - rect_gap, # + 1 ,
istart + 1 - from_idx,
cls,
)
ro: tuple[float, float] = (
iend + from_idx,
opn,
)
diff: float = cls - opn
sgn: float = copysign(1, diff)
color: str = 'dad_blue'
# TODO? mks more sense to have up/down coloring?
# color: str = {

View File

@ -242,6 +242,13 @@ async def maybe_fill_null_segments(
end_dt=end_dt,
)
if (
from_timestamp(
array['time'][0]
) < backfill_until_dt
):
await tractor.pause()
# XXX TODO: pretty sure if i plot tsla, btcusdt.binance
# and mnq.cme.ib this causes a Qt crash XXDDD

View File

@ -308,6 +308,7 @@ def hcolor(name: str) -> str:
'cool_green': '#33b864',
'dull_green': '#74a662',
'hedge_green': '#518360',
'lilypad_green': '#839c84',
# orders and alerts
'alert_yellow': '#e2d083',
@ -335,6 +336,7 @@ def hcolor(name: str) -> str:
'sell_red': '#b6003f',
# 'sell_red': '#d00048',
'sell_red_light': '#f85462',
'wine': '#69212d',
# 'sell_red': '#f85462',
# 'sell_red_light': '#ff4d5c',