Skip to content

Add net-delta accounting; surface that the book is directional, not neutral - #14

Open
ethanterrero wants to merge 1 commit into
mainfrom
claude/net-delta-accounting
Open

Add net-delta accounting; surface that the book is directional, not neutral#14
ethanterrero wants to merge 1 commit into
mainfrom
claude/net-delta-accounting

Conversation

@ethanterrero

Copy link
Copy Markdown
Owner

Summary

The bot is named "delta-neutral" but every position it opens is a single perp leg — full price exposure, no spot hedge. This PR adds the missing accounting primitive so we can see how directional the book is, and seeds the hedge-leg work without touching the working fill/pairing/restore paths.

  • Position::signed_notional(mark) in perps-types+notional long, −notional short. A long-spot/short-perp pair of equal notional sums to zero (the delta-neutral invariant).
  • net_delta_usd + hedge_position_for in perps-risk. hedge_position_for returns the spot hedge Position that neutralizes a perp leg — the primitive the executor will call when the second leg lands.
  • perps-bot digest — new delta_usd column, a net delta / gross line, and a loud warning when the book is materially directional.

The finding

Running the new digest over the existing 3.5-day testnet paper run:

totals: realized $3.42  unrealized -$16.51  funding $25.49  net $12.41
net delta: -$2016.51 (gross $2016.51)
  ⚠ book is directional, not delta-neutral — hedge leg not yet wired (single-leg perp)

Funding works (+$25.49), but the book is 100% directional and half the funding got eaten by an unhedged price wiggle (−$16.51 unrealized). The fix is the second leg — sequenced in docs/MORNING-SUMMARY.md (6 PRs: instrument tag → simulate spot leg → drift rebalancing → real spot venue/basis → reconciliation → small-size mainnet).

Deliberately scoped: ships the accounting first so every later PR is judged against one number — did net delta move toward zero.

Test plan

  • cargo test — 52 pass (was 48): +1 in perps-types, +3 in perps-risk
  • cargo clippy clean
  • cargo run -p perps-bot -- digest renders the new delta column + warning on real state

🤖 Generated with Claude Code

The bot opens a single perp leg with no spot hedge, so it carries full
price exposure despite being a "delta-neutral" harvester. Add the
accounting to make that visible and to seed the hedge-leg work:

- Position::signed_notional (+long/-short) in perps-types
- net_delta_usd + hedge_position_for in perps-risk
- digest delta_usd column, net delta/gross line, directional warning

Running the digest over the existing 3.5-day paper run shows net delta
at 100% of gross (fully directional) with funding being eaten by
unrealized price PnL. The sequenced path to a real two-leg hedge is in
docs/MORNING-SUMMARY.md.

Tests: 52 (was 48).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants