feat(hyperliquid): add leverage, margin, liquidation, and PnL prisms with tests#623
Open
helmutkocksmann wants to merge 1 commit into
Open
Conversation
…with tests Add missing perpetual trading features for Hyperliquid integration (issue Spectral-Finance#82): New Prisms: - HyperliquidSetLeveragePrism: Set leverage (1-50x) with cross/isolated margin - HyperliquidMarginManagementPrism: Add/remove margin from positions - HyperliquidLiquidationMonitorPrism: Monitor liquidation proximity with configurable warning/critical thresholds and per-position risk levels - HyperliquidPnLTrackerPrism: Track unrealized PnL, funding costs, and portfolio ROI across all positions New Beam: - PositionManagementBeam: Orchestrates liquidation monitoring and PnL tracking with overall risk status (healthy/warning/critical) New Tests (10 schema validation test suites for ALL Hyperliquid prisms): - Unit tests for all 6 existing prisms (previously had zero coverage) - Unit tests for all 4 new prisms - Integration test for the full trading workflow - Liquidation monitor tests include pure-function risk classification and distance calculation tests Documentation: - Livebook guide (hyperliquid_perps.livemd) covering all prisms, beams, configuration, usage examples, and risk management best practices Acceptance criteria coverage: - [x] Order placement and management (existing prisms) - [x] Position tracking system (user_state + PnL tracker) - [x] Risk management implementation (risk_assessment + liquidation_monitor) - [x] Liquidation monitoring (liquidation_monitor with thresholds) - [x] Margin management system (margin_management prism) - [x] Documentation and examples (livebook guide) - [x] Integration tests for trading operations - [x] Risk control verification (schema tests + classification tests)
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.
Changes
Adds missing perpetual trading features for the Hyperliquid integration (issue #82):
New Prisms
New Beam
New Tests (10 test suites)
All Hyperliquid prisms previously had zero test coverage. This PR adds:
Documentation
hyperliquid_perps.livemd) covering all prisms, beams, configuration, usage examples, and risk management best practicesAcceptance Criteria Coverage
Closes #82