feat(skyhook): pos_fn introspection for SKH01 sleeve (current open trade / flat)

_skyhook_positions(): replays the non-overlap entry+exit logic (TP/SL/max_bars) to the last
closed 230m bar and reports, per asset, the current OPEN trade (dir/entry/sl/tp/bars_in) or
'flat'. Wired into skyhook_sleeve(pos_fn=...) so the Deribit book report & web dashboard show
Skyhook's live position. Causal (closed bars only). +1 test. Currently flat/flat.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adriano Dal Pastro
2026-06-23 20:32:14 +00:00
parent 160ad300be
commit 384b9cb0af
2 changed files with 44 additions and 1 deletions
+10
View File
@@ -129,6 +129,16 @@ def test_short_override_changes_only_shorts():
assert longs_same > 0 and shorts_diff > 0
def test_skyhook_pos_fn_structure():
"""pos_fn introspettiva: dict BTC/ETH, ciascuno 'flat' o dict con dir/entry/sl/tp coerenti."""
from src.portfolio.sleeves import _skyhook_positions
pos = _skyhook_positions()
assert set(pos.keys()) == {"BTC", "ETH"}
for a, p in pos.items():
assert p == "flat" or (isinstance(p, dict) and p["dir"] in ("LONG", "SHORT")
and p["sl"] > 0 and p["tp"] > 0 and 0 <= p["bars_in"] <= p["max_bars"])
def test_v2dd_robust_both_assets():
"""SKH01-V2-DD: PASS netto fee su BTC&ETH, hold-out forte, e maxDD standalone <30%."""
import skyhooklib as sk