feat(runtime): entry_cycle popola iv_rv_history e dvol_24h_ago
Quando i flag adaptive_enabled / vol_of_vol_guard_enabled sono attivi, entry_cycle carica history e lookback dal repository prima di costruire EntryContext. Il decisions log riceve i meta n_history e dvol_24h_ago per audit ex-post. Quando i flag sono off, niente query DB extra (zero overhead). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -429,6 +429,35 @@ async def run_entry_cycle(
|
||||
)
|
||||
|
||||
# 2. Entry filters
|
||||
entry_cfg = cfg.entry
|
||||
asset = cfg.asset.symbol
|
||||
|
||||
iv_rv_history: tuple[Decimal, ...] = ()
|
||||
dvol_24h_ago: Decimal | None = None
|
||||
if entry_cfg.iv_minus_rv_filter_enabled and entry_cfg.iv_minus_rv_adaptive_enabled:
|
||||
conn = connect_state(ctx.db_path)
|
||||
try:
|
||||
iv_rv_history = tuple(
|
||||
ctx.repository.iv_rv_history(
|
||||
conn,
|
||||
asset=asset,
|
||||
max_days=entry_cfg.iv_minus_rv_window_target_days,
|
||||
as_of=when,
|
||||
)
|
||||
)
|
||||
finally:
|
||||
conn.close()
|
||||
if entry_cfg.vol_of_vol_guard_enabled:
|
||||
conn = connect_state(ctx.db_path)
|
||||
try:
|
||||
dvol_24h_ago = ctx.repository.dvol_lookback(
|
||||
conn,
|
||||
asset=asset,
|
||||
reference=when - timedelta(hours=entry_cfg.vol_of_vol_lookback_hours),
|
||||
)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
entry_ctx = EntryContext(
|
||||
capital_usd=capital_usd,
|
||||
dvol_now=snap.dvol,
|
||||
@@ -439,6 +468,8 @@ async def run_entry_cycle(
|
||||
dealer_net_gamma=snap.dealer_net_gamma,
|
||||
iv_minus_rv=snap.iv_minus_rv,
|
||||
liquidation_squeeze_risk_high=snap.liquidation_squeeze_risk_high,
|
||||
iv_rv_history=iv_rv_history,
|
||||
dvol_24h_ago=dvol_24h_ago,
|
||||
)
|
||||
decision = validate_entry(entry_ctx, cfg)
|
||||
inputs = {
|
||||
@@ -458,6 +489,10 @@ async def run_entry_cycle(
|
||||
"iv_minus_rv": (
|
||||
str(snap.iv_minus_rv) if snap.iv_minus_rv is not None else None
|
||||
),
|
||||
"iv_rv_history_n": len(iv_rv_history),
|
||||
"dvol_24h_ago": (
|
||||
str(dvol_24h_ago) if dvol_24h_ago is not None else None
|
||||
),
|
||||
}
|
||||
}
|
||||
if not decision.accepted:
|
||||
|
||||
Reference in New Issue
Block a user