## Pragmarrakech 2 ## Execution **Feature: Implement Paradex/Hyperliquid Order Execution** - **Specification:** The system should be able to create, close, and modify positions on Hyperliquid and Paradex. - **Specification:** The system should handle order confirmations, rejections, and potential errors from Paradex and Hyperliquid. **Feature: Implement OMS & Tracking** - **Specification:** The system should consume orders from the Dispatcher. - **Specification:** The system should manage the lifecycle of simultaneous orders across both exchanges, including states such as pending, active, filled, partially filled, cancelled, and rejected. - **Specification:** The system should handle partial fills by attempting to fill the remainder and then cancelling the remaining part on the other leg. - **Specification:** The system should provide updates on order fills and position changes to relevant components, including Monitoring, Strategy Manager, and Risk Engine. - **Specification:** For Ekubo, the system should handle rebalancing of the position through swaps with AVNU. - **Specification:** The system should consider order book depth to estimate slippage for market orders on Hyperliquid and Paradex. - **Specification:** The system should calculate expected price impact for Ekubo swaps, limit swap sizes, and add slippage limits to avoid excessive slippage. ## Strategy Manager **Input:** Funding rates of Hyperliquid and Paradex on the major assets (HYPE, BTC, ETH, SOL) and current positions held by the account. **Output:** Trading signals - **Specification:** The system should establish secure secret management for API keys. - **Specification:** The system should implement a WebSocket client for real-time funding rates from Paradex and Hyperliquid for specified perpetual markets. - **Specification:** The system should implement a WebSocket client for fetching account information from Paradex and Hyperliquid. - **Specification:** The system should implement error handling and reconnection logic for Paradex and Hyperliquid WebSocket streams. - **Specification:** The system should calculate the funding rate differential between the two exchanges for target assets. - **Specification:** The system should define configurable thresholds for identifying entry and exit opportunities, including a minimum spread of at least 4% annualized and a minimum position size to absorb at least $10,000. - **Specification:** The system should generate arbitrage signals (e.g., Enter Long Paradex / Short Hyperliquid, Exit Position) based on thresholds and current positions. Initially, if thresholds are met and no position exists, it should proceed to the sizing module; if a position exists, it should check the sizing module; if the threshold condition is not met, it should close the positions. - **Specification:** The system should implement basic position sizing logic based on available capital/margin and risk parameters, with details refined by the Risk Engine. - **Specification:** The system should define the interface and data structure for signals sent to the Dispatcher. ## Strategy Dispatcher + Risk Engine - **Specification:** The system should consume real-time account balance and margin data from Paradex and Hyperliquid ingestion modules. - **Specification:** The system should perform pre-trade checks to verify sufficient margin exists on both exchanges before dispatching orders. - **Specification:** The system should perform pre-trade checks to verify proposed trade sizes against configured maximum position limits per asset and exchange, initially limiting new positions to a maximum of $10,000. - **Specification:** The system should perform portfolio-level checks to ensure overall risk exposure is within limits, with a maximum capital allocation of 80% of the total portfolio to this strategy. - **Specification:** The system should define a risk parameter configuration mechanism to enable flexibility in tuning risk controls and support safe updating of limits without changing core logic. - **Specification:** The system should consume signals from the Strategy Manager. - **Specification:** The system should translate approved signals into specific order parameters (symbol, side, size, order type) for both Paradex and Hyperliquid. - **Specification:** The system should define the interface and data structure for orders sent to the Execution Manager. - **Specification:** The system should handle risk check failures by notifying the monitoring component. - **Specification:** The system should calculate estimated transaction costs, including gas fees for DEXs and trading fees, for potential trades. ## Monitoring **Feature: Implement Core System Monitoring** **Feature: Implement Strategy Performance Monitoring** - **Specification:** The system should track real-time funding rates and the spread between Paradex and Hyperliquid. - **Specification:** The system should track open positions and overall PnL, including realized PnL from closed trades and unrealized PnL from funding payments. - **Specification:** The system should track margin usage and available balances on both exchanges. - **Specification:** The system should monitor order fill rates, slippage, and execution latency. - **Specification:** The system should monitor the overall delta of the portfolio. - **Specification:** The system should create a basic Grafana dashboard visualizing key strategy metrics. **Feature: Implement Alerting** - **Specification:** The system should set up alerts for critical errors, such as API connection failures, repeated order rejections, and discrepancies in the overall delta of positions. - **Specification:** The system should set up alerts for risk thresholds being breached, such as low margin or exceeding maximum position size. - **Specification:** The system should set up alerts for significant negative PnL or large funding rate reversals. - **Specification:** The system should configure alert delivery mechanisms. Finally, the system should undergo a little bit of testing to ensure functionality. {%preview https://nautilustrader.io/docs/latest/concepts/overview %}