fix(types): clear 4 pre-existing mypy errors in the positioning path

Every minor is a latent bug, pre-existing is no exemption:
- bybit_book_eval __getattr__ missing -> Any return annotation
- two unused type: ignore[assignment] comments (mypy: unused) removed
- positioning_returns_from_store: bind the dict[int,float] 'net' to a typed local
  instead of returning Any from _book_breakdown(...)['net']

mypy clean on both files; 26 positioning tests still green (behavior-neutral).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 18:56:20 +00:00
parent 46401afbd1
commit f2730d195d
2 changed files with 7 additions and 6 deletions

View File

@@ -128,7 +128,7 @@ class _UniverseRestrictedStore:
def crypto_spot_panel(self, *, suffix: str = "USDT") -> dict[str, dict[int, float]]:
return self._restricted_panel("spot_close", suffix=suffix)
def __getattr__(self, name: str):
def __getattr__(self, name: str) -> Any:
# read_panel, close(), and anything else fall through to the inner store unchanged.
return getattr(self._inner, name)
@@ -212,14 +212,14 @@ def _xsfunding_series(store: _FeatureStore, *, cost_bps: float) -> dict[int, flo
captured[int(d)] = rv
return orig(daily, days_meta=days_meta)
carry_mod._curve_metrics = _capture # type: ignore[assignment]
carry_mod._curve_metrics = _capture
try:
# universe=None: the store passed in is ALREADY the universe-restricted proxy, so its panels only
# carry the liquid symbols — restricting again here would be a redundant set-intersect over an
# already-bounded panel. cost_bps is the per-turnover carry haircut (same as the edge evaluator).
carry_metrics_from_store(store, cost_bps=cost_bps, universe=None)
finally:
carry_mod._curve_metrics = orig # type: ignore[assignment]
carry_mod._curve_metrics = orig
return dict(captured)

View File

@@ -313,9 +313,10 @@ def positioning_returns_from_store(store: _FeatureStore, *, universe: set[str] |
`capacity_capital` / `tail_cap_k` enable the gains-only capacity + tail-concentration haircuts (see
`_book_breakdown`); both None (default) → the raw capturable-unaware book, unchanged.
`coin_gross_cap` (None default) applies the ex-ante per-coin concentration cap (see `positioning_weights`)."""
return _book_breakdown(store, universe=universe, cost_bps=cost_bps, direction=direction,
capacity_capital=capacity_capital, tail_cap_k=tail_cap_k,
coin_gross_cap=coin_gross_cap)["net"]
net: dict[int, float] = _book_breakdown(store, universe=universe, cost_bps=cost_bps, direction=direction,
capacity_capital=capacity_capital, tail_cap_k=tail_cap_k,
coin_gross_cap=coin_gross_cap)["net"]
return net
# Back-compat alias: `positioning_returns` was the original name; keep it pointing at the canonical