Files
fxhnt/tests/unit/test_forward_definition.py
jgrusewski 8d0c6c67f9 feat(vrp): IBKR XSP mleg combo + execute-vrp + backfill-xsp-opra + vrp_exec twin (SUSPENDED)
place_combo (BAG combo, net credit); vrp_exec_record.plan_and_record_vrp (paper-envelope
refuse on non-paper, reuses Task-6 freeze machinery for selection); execute-vrp CLI;
backfill-xsp-opra CLI (2013-> monthly-chunked, cost-guard active for the wide band);
vrp_exec observed registry twin; fxhnt-vrp-rebalancer (suspend:true weekly) +
fxhnt-opra-backfill (manual one-time Job). Both exec paths SUSPENDED/untestable (no options
account, no live OPRA in CI) -> pure/testable contracts unit-tested (combo legs, refusal,
registry, yaml suspend). (Controller committed after self-verify + E402/ruff cleanup.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 00:15:36 +02:00

33 lines
1.4 KiB
Python

from fxhnt.application.forward_definition import definition_hash, track_definition
from fxhnt.registry import STRATEGY_REGISTRY
def test_hash_is_stable_under_key_reordering():
assert definition_hash({"a": 1, "b": 2}, 1) == definition_hash({"b": 2, "a": 1}, 1)
def test_hash_changes_when_a_param_changes():
# the BTC-drop case: instruments 6 -> 5 must change the hash
six = definition_hash({"instruments": ["SPY", "IEF", "GLD", "PDBC", "DBMF", "BTC-USD"]}, 1)
five = definition_hash({"instruments": ["SPY", "IEF", "GLD", "PDBC", "DBMF"]}, 1)
assert six != five
def test_hash_changes_when_version_bumps():
assert definition_hash({"a": 1}, 1) != definition_hash({"a": 1}, 2)
def test_every_active_track_declares_a_definition():
for sid in STRATEGY_REGISTRY:
params, version, mode = track_definition(sid)
assert isinstance(params, dict) and isinstance(version, int)
assert mode in ("recompute", "observed")
def test_observed_mode_is_exactly_xsfunding():
# Pin is deliberately exhaustive: whenever a new track adopts record_mode="observed", update this set
# (C2 Task 3 added bybit_4edge_exec; Task 7 added vrp_exec) so the change is reviewed, not silently
# absorbed.
observed = {sid for sid in STRATEGY_REGISTRY if track_definition(sid)[2] == "observed"}
assert observed == {"xsfunding", "multistrat_exec", "bybit_4edge_exec", "vrp_exec"}