Commit Graph

3 Commits

Author SHA1 Message Date
jgrusewski
fd9534e978 feat(exec): multistrat book on Alpaca — target-weight bridge + crypto BTC leg
Puts the adaptive multi-strat ETF book on the clean execution port:
- multistrat.target_weights(closes): exposes the final-day per-instrument weights
  (L*tw*volnorm_scale) that book_series applies but only collapses into a return.
  Refactored _volnorm via a shared _volnorm_scale so book_series stays byte-identical.
  Tested: sum(w*R[last]) reconstructs book_series's last booked return exactly.
- ExecutionService.rebalance_weights(weights, prices): a direct pre-computed-weights
  entry beside rebalance(book), sharing one _plan engine (gates + fractional sizing).
  Caller owns data<->broker symbol mapping.
- AlpacaBroker crypto-aware: a slash symbol (BTC/USD) -> time_in_force gtc; equities
  stay day. So the book's BTC-USD leg trades on Alpaca crypto alongside the 5 ETFs.
- CLI fxhnt execute-multistrat (maps BTC-USD -> BTC/USD); the alpaca-rebalancer
  CronJob now runs it (suspended until paper keys).

Full suite green (1832); +5 tests. Alpaca-crypto position-symbol form validated on
first paper run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 00:33:22 +02:00
jgrusewski
4ada050f7e feat(exec): Alpaca broker adapter + fractional execution (commission-free US-equity leg)
Foundation for a 2nd, uncorrelated execution venue alongside the Bybit crypto book:
- AlpacaBroker (httpx REST, Broker port): account_state + place_order, FRACTIONAL
  market+day orders, is_paper from base_url, supports_fractional=True. httpx test
  seam (MockTransport) — no network.
- ExecutionService fractional-aware: sizes float shares when broker.supports_fractional
  (Alpaca) — precise weights at small capital — else whole shares (IBKR, unchanged).
- AlpacaSettings (paper base_url default; live gated by allow_live). CLI
  .
- Suspended CronJob + credentials scaffold (arm after paper keys, like the Bybit
  testnet leg). Runs the survivor book end-to-end.

The multi-strat ETF book on Alpaca is a documented follow-up (its position logic
isn't on the clean port yet). Full suite green (1827); 6 new tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 00:00:06 +02:00
jgrusewski
7fb14c47a0 feat: multi-strategy execution layer (domain netting + Broker port + ExecutionService)
Layer-by-layer: domain/portfolio (Book + StrategyAllocation + compute_target_weights — nets many
sleeves, incl. same market, into per-market targets capped at gross leverage) | ports/broker (Broker
contract + Order/AccountState DTOs) | application/execution (ExecutionService: net → reconcile vs
broker → whole-share orders with entry-floor/hysteresis, behind the hard-won gates: paper-guard,
data-consistency/conservative-NLV, leverage-cap) | config ExecutionSettings. Tested with fake
data+broker (no network/IBKR): netting, leverage cap, buy-from-flat, in-band no-op, live-block,
inconsistent-data-block. 10/10 tests green. IBKR adapter (behind Broker port) is the next step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 13:52:32 +02:00