Files
fxhnt/tests/integration/test_strategy_allocation.py
jgrusewski f0bd4c4405 refactor(alloc): remove dead upsert_allocation; document vol conventions + soften SSOT claim (B2a review)
Nightly uses replace_allocations (wholesale-replace); upsert_allocation had no production caller — removed
+ test re-pointed to replace_allocations. Commented the obs-not-calendar / √365 convention and softened the
policy module's SSOT docstring (the legacy book_allocator/config defaults for the research plane remain).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 22:11:52 +02:00

20 lines
966 B
Python

import datetime as dt
from fxhnt.adapters.persistence.cockpit_models import StrategyAllocationRow
from fxhnt.adapters.persistence.forward_nav import ForwardNavRepo
def _row(sid, dollars, at):
return StrategyAllocationRow(strategy_id=sid, target_weight=0.5, target_dollars=dollars,
policy_version=1, policy_hash="h", as_of="2026-07-09", computed_at=at)
def test_replace_allocations_wholesale_replaces(tmp_path):
repo = ForwardNavRepo(f"sqlite:///{tmp_path}/a.db")
repo.migrate()
at = dt.datetime(2026, 7, 9, 23, 30)
repo.replace_allocations([_row("multistrat", 6000.0, at), _row("bybit_4edge", 4000.0, at)], at)
assert repo.current_allocation() == {"multistrat": 6000.0, "bybit_4edge": 4000.0}
repo.replace_allocations([_row("multistrat", 5000.0, at)], at) # bybit_4edge drops out
assert repo.current_allocation() == {"multistrat": 5000.0} # wholesale-replaced, no stale row