Fix: vwap_reclaim shadow setup_id collides on sub-minute timestamps
Some sessions have irregular/sub-minute bar timestamps (no exact-duplicate timestamps, but two bars in the same HH:MM), so keying setup_id on the wall-clock minute let two fires a cooldown apart collide on the setup_events primary key and aborted the build. Key on the RTH bar index (unique per session) instead. Tests still 5/5. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
fa3f23cf6a
commit
2c2c457b0e
1 file changed
+4
-1
+4
-1
@@ -301,7 +301,10 @@ def compute_vwap_reclaim_setups(symbol, session_date, df, prior_close, avg_vol,
|
||||
sv = sig.signal_values
|
||||
vwap_at = round(entry_ref - float(sv.get("dist_from_vwap") or 0.0), 5)
|
||||
_, cat_fresh = _catalyst_at(cats, symbol, setup_ts)
|
||||
sid = f"{symbol}:{session_date}:{pd.Timestamp(setup_ts).strftime('%H%M')}:{VR_SETUP_VERSION}"
|
||||
# key on the RTH bar INDEX (unique per session) -- NOT the wall-clock minute:
|
||||
# some sessions have sub-minute/irregular timestamps, so two fires a cooldown
|
||||
# apart can share an HH:MM and collide on the primary key.
|
||||
sid = f"{symbol}:{session_date}:b{i}:{VR_SETUP_VERSION}"
|
||||
setup = dict(setup_id=sid, symbol=symbol, setup_time=setup_ts, session_date=session_date,
|
||||
setup_name=VR_NAME, setup_version=VR_SETUP_VERSION,
|
||||
entry_reference_price=entry_ref, invalidation_price=invalidation,
|
||||
|
||||
Reference in new issue
Block a user