pub struct HyperLiquid { /* private fields */ }Expand description
HyperLiquid exchange structure.
Implementations§
Source§impl HyperLiquid
impl HyperLiquid
Sourcepub async fn exchange_request(
&self,
action: Value,
nonce: u64,
) -> Result<Value, Error>
👎Deprecated since 0.2.0: Use signed_action() builder instead
pub async fn exchange_request( &self, action: Value, nonce: u64, ) -> Result<Value, Error>
Make an exchange action request (requires authentication).
§Deprecated
This method is deprecated. Use signed_action() builder instead:
let exchange = HyperLiquid::builder()
.private_key("0x...")
.testnet(true)
.build()?;
let action = json!({"type": "order", "orders": [], "grouping": "na"});
let response = exchange.signed_action(action).execute().await?;Sourcepub fn get_nonce(&self) -> u64
👎Deprecated since 0.2.0: Use signed_action() builder which auto-generates nonce
pub fn get_nonce(&self) -> u64
Get current timestamp as nonce.
§Deprecated
This method is deprecated. The signed_action() builder automatically
generates the nonce. Use signed_action().nonce(value) if you need
to override the auto-generated nonce.
Sourcepub async fn fetch_markets(
&self,
) -> Result<Arc<HashMap<String, Arc<Market>>>, Error>
pub async fn fetch_markets( &self, ) -> Result<Arc<HashMap<String, Arc<Market>>>, Error>
Fetch all trading markets.
Sourcepub async fn load_markets(
&self,
reload: bool,
) -> Result<Arc<HashMap<String, Arc<Market>>>, Error>
pub async fn load_markets( &self, reload: bool, ) -> Result<Arc<HashMap<String, Arc<Market>>>, Error>
Load and cache market data.
Sourcepub async fn fetch_ticker(&self, symbol: &str) -> Result<Ticker, Error>
pub async fn fetch_ticker(&self, symbol: &str) -> Result<Ticker, Error>
Fetch ticker for a single trading pair.
Sourcepub async fn fetch_tickers(
&self,
symbols: Option<Vec<String>>,
) -> Result<Vec<Ticker>, Error>
pub async fn fetch_tickers( &self, symbols: Option<Vec<String>>, ) -> Result<Vec<Ticker>, Error>
Fetch tickers for multiple trading pairs.
Sourcepub async fn fetch_order_book(
&self,
symbol: &str,
_limit: Option<u32>,
) -> Result<OrderBook, Error>
pub async fn fetch_order_book( &self, symbol: &str, _limit: Option<u32>, ) -> Result<OrderBook, Error>
Fetch order book for a trading pair.
Sourcepub async fn fetch_trades(
&self,
symbol: &str,
limit: Option<u32>,
) -> Result<Vec<Trade>, Error>
pub async fn fetch_trades( &self, symbol: &str, limit: Option<u32>, ) -> Result<Vec<Trade>, Error>
Fetch recent public trades.
Sourcepub async fn fetch_ohlcv(
&self,
symbol: &str,
timeframe: &str,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<Ohlcv>, Error>
pub async fn fetch_ohlcv( &self, symbol: &str, timeframe: &str, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<Ohlcv>, Error>
Fetch OHLCV (candlestick) data.
Sourcepub async fn fetch_funding_rate(
&self,
symbol: &str,
) -> Result<FundingRate, Error>
pub async fn fetch_funding_rate( &self, symbol: &str, ) -> Result<FundingRate, Error>
Fetch current funding rate for a symbol.
Sourcepub async fn fetch_balance(&self) -> Result<Balance, Error>
pub async fn fetch_balance(&self) -> Result<Balance, Error>
Fetch account balance.
Sourcepub async fn fetch_positions(
&self,
symbols: Option<Vec<String>>,
) -> Result<Vec<Position>, Error>
pub async fn fetch_positions( &self, symbols: Option<Vec<String>>, ) -> Result<Vec<Position>, Error>
Fetch open positions.
Sourcepub async fn fetch_open_orders(
&self,
symbol: Option<&str>,
_since: Option<i64>,
_limit: Option<u32>,
) -> Result<Vec<Order>, Error>
pub async fn fetch_open_orders( &self, symbol: Option<&str>, _since: Option<i64>, _limit: Option<u32>, ) -> Result<Vec<Order>, Error>
Fetch open orders.
Sourcepub async fn create_order(
&self,
symbol: &str,
order_type: OrderType,
side: OrderSide,
amount: Amount,
price: Option<Price>,
) -> Result<Order, Error>
pub async fn create_order( &self, symbol: &str, order_type: OrderType, side: OrderSide, amount: Amount, price: Option<Price>, ) -> Result<Order, Error>
Create a new order.
§Arguments
symbol- Trading pair symbol.order_type- Order type (Market, Limit, etc.).side- Order side (Buy or Sell).amount- Order quantity asAmounttype.price- Optional price asPricetype (required for limit orders).
§Returns
Returns the created Order structure with order details.
§Errors
Returns an error if authentication fails, market is not found, or the API request fails.
Sourcepub async fn cancel_order(&self, id: &str, symbol: &str) -> Result<Order, Error>
pub async fn cancel_order(&self, id: &str, symbol: &str) -> Result<Order, Error>
Cancel an order.
Source§impl HyperLiquid
impl HyperLiquid
Sourcepub fn builder() -> HyperLiquidBuilder
pub fn builder() -> HyperLiquidBuilder
Creates a new HyperLiquid instance using the builder pattern.
This is the recommended way to create a HyperLiquid instance.
§Example
use ccxt_exchanges::hyperliquid::HyperLiquid;
let exchange = HyperLiquid::builder()
.private_key("0x...")
.testnet(true)
.build()
.unwrap();Sourcepub fn new_with_options(
config: ExchangeConfig,
options: HyperLiquidOptions,
auth: Option<HyperLiquidAuth>,
) -> Result<HyperLiquid, Error>
pub fn new_with_options( config: ExchangeConfig, options: HyperLiquidOptions, auth: Option<HyperLiquidAuth>, ) -> Result<HyperLiquid, Error>
Creates a new HyperLiquid instance with custom options.
This is used internally by the builder pattern.
§Arguments
config- Exchange configuration.options- HyperLiquid-specific options.auth- Optional authentication instance.
Sourcepub fn base(&self) -> &BaseExchange
pub fn base(&self) -> &BaseExchange
Returns a reference to the base exchange.
Sourcepub fn base_mut(&mut self) -> &mut BaseExchange
pub fn base_mut(&mut self) -> &mut BaseExchange
Returns a mutable reference to the base exchange.
Sourcepub fn options(&self) -> &HyperLiquidOptions
pub fn options(&self) -> &HyperLiquidOptions
Returns the HyperLiquid options.
Sourcepub fn auth(&self) -> Option<&HyperLiquidAuth>
pub fn auth(&self) -> Option<&HyperLiquidAuth>
Returns a reference to the authentication instance.
Sourcepub fn signed_action(
&self,
action: Value,
) -> HyperliquidSignedRequestBuilder<'_>
pub fn signed_action( &self, action: Value, ) -> HyperliquidSignedRequestBuilder<'_>
Creates a signed action builder for authenticated exchange requests.
This method provides a fluent API for constructing and executing authenticated Hyperliquid exchange actions using EIP-712 signing.
§Arguments
action- The action JSON to be signed and executed
§Returns
A HyperliquidSignedRequestBuilder that can be configured and executed.
§Example
use ccxt_exchanges::hyperliquid::HyperLiquid;
use serde_json::json;
let exchange = HyperLiquid::builder()
.private_key("0x...")
.testnet(true)
.build()?;
// Create an order
let action = json!({
"type": "order",
"orders": [{"a": 0, "b": true, "p": "50000", "s": "0.001", "r": false, "t": {"limit": {"tif": "Gtc"}}}],
"grouping": "na"
});
let response = exchange.signed_action(action)
.execute()
.await?;Sourcepub fn rate_limit(&self) -> u32
pub fn rate_limit(&self) -> u32
Returns the rate limit in requests per second.
Sourcepub fn is_sandbox(&self) -> bool
pub fn is_sandbox(&self) -> bool
Returns true if sandbox/testnet mode is enabled.
Sandbox mode is enabled when either:
config.sandboxis set totrueoptions.testnetis set totrue
§Returns
true if sandbox mode is enabled, false otherwise.
§Example
use ccxt_exchanges::hyperliquid::HyperLiquid;
let exchange = HyperLiquid::builder()
.testnet(true)
.build()
.unwrap();
assert!(exchange.is_sandbox());Sourcepub fn urls(&self) -> HyperLiquidUrls
pub fn urls(&self) -> HyperLiquidUrls
Returns the API URLs.
Returns testnet URLs when sandbox mode is enabled (either via
config.sandbox or options.testnet), otherwise returns mainnet URLs.
Sourcepub fn wallet_address(&self) -> Option<&str>
pub fn wallet_address(&self) -> Option<&str>
Returns the wallet address if authenticated.