Files
fxhnt/tests/unit/test_unit_shadow_positions.py
jgrusewski 251eece8e2 feat(paper): persist_paper_book leverage (notional only) + unit_shadow_positions
Add `leverage: float = 1.0` param to `persist_paper_book` and
`PaperBookService.derive_and_persist`; scales only the `capital` arg
passed to `target_positions`, leaving equity base unscaled.
Add `unit_shadow_positions` helper (sleeve_weight=1, capital=1 composition).
Default leverage=1.0 leaves all existing callers and tests unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 08:18:22 +02:00

12 lines
504 B
Python

from fxhnt.application.paper_book import unit_shadow_positions
def test_builds_unit_notional_composition():
swb = {"ts": {"BTCUSDT": 1.0}, "sc": {"USDTUSD": -1.0}}
prices = {"BTCUSDT": 100.0, "USDTUSD": 1.0}
out = unit_shadow_positions(swb, prices, "2026-01-01")
by = {(p.sleeve, p.symbol): p for p in out}
assert by[("ts", "BTCUSDT")].qty == 1.0 / 100.0 # w*1*1 / px
assert by[("sc", "USDTUSD")].qty == -1.0 / 1.0
assert all(p.entry_date == "2026-01-01" for p in out)