Add net-delta accounting; surface that the book is directional, not neutral - #14
Open
ethanterrero wants to merge 1 commit into
Open
Add net-delta accounting; surface that the book is directional, not neutral#14ethanterrero wants to merge 1 commit into
ethanterrero wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)inperps-types—+notionallong,−notionalshort. A long-spot/short-perp pair of equal notional sums to zero (the delta-neutral invariant).net_delta_usd+hedge_position_forinperps-risk.hedge_position_forreturns the spot hedgePositionthat neutralizes a perp leg — the primitive the executor will call when the second leg lands.perps-bot digest— newdelta_usdcolumn, anet delta / grossline, 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:
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 inperps-types, +3 inperps-riskcargo clippycleancargo run -p perps-bot -- digestrenders the new delta column + warning on real state🤖 Generated with Claude Code