feat(state): dvol_history multi-asset (ETH+BTC) + backfill ETH legacy rows
Migration 0006 promuove dvol_history da PK=(timestamp) mono-ETH a PK=(timestamp, asset), rinomina eth_spot -> spot, e backfilla con asset='ETH' le righe storiche. market_snapshot_cycle ora scrive sia per ETH che per BTC; monitor_cycle resta ETH-only via WHERE asset='ETH' nella lookup di return_4h. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -181,19 +181,18 @@ async def collect_market_snapshot(
|
||||
try:
|
||||
with transaction(conn):
|
||||
ctx.repository.record_market_snapshot(conn, record)
|
||||
# Mirror ETH spot+DVOL into dvol_history so monitor_cycle's
|
||||
# return_4h lookup has local samples even in data-only mode.
|
||||
if (
|
||||
record.asset == "ETH"
|
||||
and record.spot is not None
|
||||
and record.dvol is not None
|
||||
):
|
||||
# Mirror spot+DVOL into dvol_history (per asset) so
|
||||
# monitor_cycle's return_4h lookup has local samples even
|
||||
# in data-only mode. dvol_history enforces NOT NULL on
|
||||
# dvol/spot so skip if either is missing.
|
||||
if record.spot is not None and record.dvol is not None:
|
||||
ctx.repository.record_dvol_snapshot(
|
||||
conn,
|
||||
DvolSnapshot(
|
||||
timestamp=record.timestamp,
|
||||
asset=record.asset,
|
||||
dvol=record.dvol,
|
||||
eth_spot=record.spot,
|
||||
spot=record.spot,
|
||||
),
|
||||
)
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user