This PR introduces market_open and market_close methods to the ExchangeClient, aligning the Rust SDK's functionality with the existing Hyperliquid Python SDK.
Key Changes
Added market_open method for placing market buy/sell orders
Added market_close method for closing positions with market orders
Implemented price slippage calculation with respect to asset-specific decimal requirements
Added helper functions for rounding to significant figures and decimal places
Implementation Details
Mirrors the functionality of the Python SDK's market_open and market_close methods
Uses the existing InfoClient to fetch asset metadata and current mid-prices
Simulates market orders using IOC (Immediate-or-Cancel) limit orders
Respects Hyperliquid's tick size and lot size rules for each asset
Description
This PR introduces
market_open
andmarket_close
methods to theExchangeClient
, aligning the Rust SDK's functionality with the existing Hyperliquid Python SDK.Key Changes
market_open
method for placing market buy/sell ordersmarket_close
method for closing positions with market ordersImplementation Details
market_open
andmarket_close
methodsInfoClient
to fetch asset metadata and current mid-pricesUsage Example
Testing
Related Issues
Closes #44