62 KiB
hyperliquid{docsify-ignore}
Kind: global class
Extends: Exchange
- fetchCurrencies
- fetchMarkets
- fetchSwapMarkets
- calculatePricePrecision
- fetchSpotMarkets
- fetchBalance
- fetchOrderBook
- fetchTickers
- fetchFundingRates
- fetchOHLCV
- fetchTrades
- createOrder
- createOrders
- createOrdersRequest
- cancelOrder
- cancelOrders
- cancelOrdersRequest
- cancelOrdersForSymbols
- cancelAllOrdersAfter
- editOrder
- editOrders
- createVault
- fetchFundingRateHistory
- fetchOpenOrders
- fetchClosedOrders
- fetchCanceledOrders
- fetchCanceledAndClosedOrders
- fetchOrders
- fetchOrder
- fetchMyTrades
- fetchPosition
- fetchPositions
- setMarginMode
- setLeverage
- addMargin
- reduceMargin
- transfer
- withdraw
- fetchTradingFee
- fetchLedger
- fetchDeposits
- fetchWithdrawals
- fetchOpenInterests
- fetchOpenInterest
- fetchFundingHistory
- reserveRequestWeight
- createOrdersWs
- createOrderWs
- editOrderWs
- cancelOrdersWs
- cancelOrderWs
- watchOrderBook
- unWatchOrderBook
- watchTicker
- watchTickers
- unWatchTickers
- watchMyTrades
- unWatchTrades
- watchOHLCV
- unWatchOHLCV
- watchOrders
fetchCurrencies{docsify-ignore}
fetches all available currencies on an exchange
Kind: instance method of hyperliquid
Returns: object - an associative dictionary of currencies
| Param | Type | Required | Description |
|---|---|---|---|
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.fetchCurrencies ([params])
fetchMarkets{docsify-ignore}
retrieves data on all markets for hyperliquid
Kind: instance method of hyperliquid
Returns: Array<object> - an array of objects representing market data
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
| Param | Type | Required | Description |
|---|---|---|---|
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.fetchMarkets ([params])
fetchSwapMarkets{docsify-ignore}
retrieves data on all swap markets for hyperliquid
Kind: instance method of hyperliquid
Returns: Array<object> - an array of objects representing market data
| Param | Type | Required | Description |
|---|---|---|---|
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.fetchSwapMarkets ([params])
calculatePricePrecision{docsify-ignore}
Helper function to calculate the Hyperliquid DECIMAL_PLACES price precision
Kind: instance method of hyperliquid
Returns: int - The calculated price precision
| Param | Type | Description |
|---|---|---|
| price | float |
the price to use in the calculation |
| amountPrecision | int |
the amountPrecision to use in the calculation |
| maxDecimals | int |
the maxDecimals to use in the calculation |
hyperliquid.calculatePricePrecision (price, amountPrecision, maxDecimals[])
fetchSpotMarkets{docsify-ignore}
retrieves data on all spot markets for hyperliquid
Kind: instance method of hyperliquid
Returns: Array<object> - an array of objects representing market data
| Param | Type | Required | Description |
|---|---|---|---|
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.fetchSpotMarkets ([params])
fetchBalance{docsify-ignore}
query for balance and get the amount of funds available for trading or funds locked in orders
Kind: instance method of hyperliquid
Returns: object - a balance structure
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
| Param | Type | Required | Description |
|---|---|---|---|
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
| params.type | string |
No | wallet type, ['spot', 'swap'], defaults to swap |
| params.marginMode | string |
No | 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchBalance ([params])
fetchOrderBook{docsify-ignore}
fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
Kind: instance method of hyperliquid
Returns: object - A dictionary of order book structures indexed by market symbols
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch the order book for |
| limit | int |
No | the maximum amount of order book entries to return |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.fetchOrderBook (symbol[, limit, params])
fetchTickers{docsify-ignore}
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
Kind: instance method of hyperliquid
Returns: object - a dictionary of ticker structures
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> |
No | unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.type | string |
No | 'spot' or 'swap', by default fetches both |
hyperliquid.fetchTickers ([symbols, params])
fetchFundingRates{docsify-ignore}
retrieves data on all swap markets for hyperliquid
Kind: instance method of hyperliquid
Returns: Array<object> - an array of objects representing market data
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> |
No | list of unified market symbols |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.fetchFundingRates ([symbols, params])
fetchOHLCV{docsify-ignore}
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
Kind: instance method of hyperliquid
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch OHLCV data for |
| timeframe | string |
Yes | the length of time each candle represents, support '1m', '15m', '1h', '1d' |
| since | int |
No | timestamp in ms of the earliest candle to fetch |
| limit | int |
No | the maximum amount of candles to fetch |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.until | int |
No | timestamp in ms of the latest candle to fetch |
hyperliquid.fetchOHLCV (symbol, timeframe[, since, limit, params])
fetchTrades{docsify-ignore}
get the list of most recent trades for a particular symbol
Kind: instance method of hyperliquid
Returns: Array<Trade> - a list of trade structures
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills-by-time
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| since | int |
No | the earliest time in ms to fetch trades for |
| limit | int |
No | the maximum number of trades structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.until | int |
No | timestamp in ms of the latest trade |
| params.address | string |
No | wallet address that made trades |
| params.user | string |
No | wallet address that made trades |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchTrades (symbol[, since, limit, params])
createOrder{docsify-ignore}
create a trade order
Kind: instance method of hyperliquid
Returns: object - an order structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to create an order in |
| type | string |
Yes | 'market' or 'limit' |
| side | string |
Yes | 'buy' or 'sell' |
| amount | float |
Yes | how much of currency you want to trade in units of base currency |
| price | float |
No | the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.timeInForce | string |
No | 'Gtc', 'Ioc', 'Alo' |
| params.postOnly | bool |
No | true or false whether the order is post-only |
| params.reduceOnly | bool |
No | true or false whether the order is reduce-only |
| params.triggerPrice | float |
No | The price at which a trigger order is triggered at |
| params.clientOrderId | string |
No | client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) |
| params.slippage | string |
No | the slippage for market order |
| params.vaultAddress | string |
No | the vault address for order |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.createOrder (symbol, type, side, amount[, price, params])
createOrders{docsify-ignore}
create a list of trade orders
Kind: instance method of hyperliquid
Returns: object - an order structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
| Param | Type | Required | Description |
|---|---|---|---|
| orders | Array |
Yes | list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.createOrders (orders[, params])
createOrdersRequest{docsify-ignore}
create a list of trade orders
Kind: instance method of hyperliquid
Returns: object - an order structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
| Param | Type | Description |
|---|---|---|
| orders | Array |
list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params |
hyperliquid.createOrdersRequest (orders, [undefined])
cancelOrder{docsify-ignore}
cancels an open order
Kind: instance method of hyperliquid
Returns: object - An order structure
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
| Param | Type | Required | Description |
|---|---|---|---|
| id | string |
Yes | order id |
| symbol | string |
Yes | unified symbol of the market the order was made in |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.clientOrderId | string |
No | client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) |
| params.vaultAddress | string |
No | the vault address for order |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.cancelOrder (id, symbol[, params])
cancelOrders{docsify-ignore}
cancel multiple orders
Kind: instance method of hyperliquid
Returns: object - an list of order structures
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
| Param | Type | Required | Description |
|---|---|---|---|
| ids | Array<string> |
Yes | order ids |
| symbol | string |
No | unified market symbol |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.clientOrderId | string, Array<string> |
No | client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) |
| params.vaultAddress | string |
No | the vault address |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.cancelOrders (ids[, symbol, params])
cancelOrdersRequest{docsify-ignore}
build the request payload for cancelling multiple orders
Kind: instance method of hyperliquid
Returns: object - the raw request object to be sent to the exchange
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
| Param | Type | Required | Description |
|---|---|---|---|
| ids | Array<string> |
Yes | order ids |
| symbol | string |
Yes | unified market symbol |
| params | object |
No |
hyperliquid.cancelOrdersRequest (ids, symbol[, params])
cancelOrdersForSymbols{docsify-ignore}
cancel multiple orders for multiple symbols
Kind: instance method of hyperliquid
Returns: object - an list of order structures
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
| Param | Type | Required | Description |
|---|---|---|---|
| orders | Array<CancellationRequest> |
Yes | each order should contain the parameters required by cancelOrder namely id and symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}] |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.vaultAddress | string |
No | the vault address |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.cancelOrdersForSymbols (orders[, params])
cancelAllOrdersAfter{docsify-ignore}
dead man's switch, cancel all orders after the given timeout
Kind: instance method of hyperliquid
Returns: object - the api result
| Param | Type | Required | Description |
|---|---|---|---|
| timeout | number |
Yes | time in milliseconds, 0 represents cancel the timer |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.vaultAddress | string |
No | the vault address |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.cancelAllOrdersAfter (timeout[, params])
editOrder{docsify-ignore}
edit a trade order
Kind: instance method of hyperliquid
Returns: object - an order structure
| Param | Type | Required | Description |
|---|---|---|---|
| id | string |
Yes | cancel order id |
| symbol | string |
Yes | unified symbol of the market to create an order in |
| type | string |
Yes | 'market' or 'limit' |
| side | string |
Yes | 'buy' or 'sell' |
| amount | float |
Yes | how much of currency you want to trade in units of base currency |
| price | float |
No | the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.timeInForce | string |
No | 'Gtc', 'Ioc', 'Alo' |
| params.postOnly | bool |
No | true or false whether the order is post-only |
| params.reduceOnly | bool |
No | true or false whether the order is reduce-only |
| params.triggerPrice | float |
No | The price at which a trigger order is triggered at |
| params.clientOrderId | string |
No | client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) |
| params.vaultAddress | string |
No | the vault address for order |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.editOrder (id, symbol, type, side, amount[, price, params])
editOrders{docsify-ignore}
edit a list of trade orders
Kind: instance method of hyperliquid
Returns: object - an order structure
| Param | Type | Required | Description |
|---|---|---|---|
| orders | Array |
Yes | list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.editOrders (orders[, params])
createVault{docsify-ignore}
creates a value
Kind: instance method of hyperliquid
Returns: object - the api result
| Param | Type | Required | Description |
|---|---|---|---|
| name | string |
Yes | The name of the vault |
| description | string |
Yes | The description of the vault |
| initialUsd | number |
Yes | The initialUsd of the vault |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.createVault (name, description, initialUsd[, params])
fetchFundingRateHistory{docsify-ignore}
fetches historical funding rate prices
Kind: instance method of hyperliquid
Returns: Array<object> - a list of funding rate structures
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch the funding rate history for |
| since | int |
No | timestamp in ms of the earliest funding rate to fetch |
| limit | int |
No | the maximum amount of funding rate structures to fetch |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.until | int |
No | timestamp in ms of the latest funding rate |
hyperliquid.fetchFundingRateHistory (symbol[, since, limit, params])
fetchOpenOrders{docsify-ignore}
fetch all unfilled currently open orders
Kind: instance method of hyperliquid
Returns: Array<Order> - a list of order structures
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| since | int |
No | the earliest time in ms to fetch open orders for |
| limit | int |
No | the maximum number of open orders structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
| params.method | string |
No | 'openOrders' or 'frontendOpenOrders' default is 'frontendOpenOrders' |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchOpenOrders (symbol[, since, limit, params])
fetchClosedOrders{docsify-ignore}
fetch all unfilled currently closed orders
Kind: instance method of hyperliquid
Returns: Array<Order> - a list of order structures
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| since | int |
No | the earliest time in ms to fetch open orders for |
| limit | int |
No | the maximum number of open orders structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
hyperliquid.fetchClosedOrders (symbol[, since, limit, params])
fetchCanceledOrders{docsify-ignore}
fetch all canceled orders
Kind: instance method of hyperliquid
Returns: Array<Order> - a list of order structures
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| since | int |
No | the earliest time in ms to fetch open orders for |
| limit | int |
No | the maximum number of open orders structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
hyperliquid.fetchCanceledOrders (symbol[, since, limit, params])
fetchCanceledAndClosedOrders{docsify-ignore}
fetch all closed and canceled orders
Kind: instance method of hyperliquid
Returns: Array<Order> - a list of order structures
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| since | int |
No | the earliest time in ms to fetch open orders for |
| limit | int |
No | the maximum number of open orders structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
hyperliquid.fetchCanceledAndClosedOrders (symbol[, since, limit, params])
fetchOrders{docsify-ignore}
fetch all orders
Kind: instance method of hyperliquid
Returns: Array<Order> - a list of order structures
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| since | int |
No | the earliest time in ms to fetch open orders for |
| limit | int |
No | the maximum number of open orders structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchOrders (symbol[, since, limit, params])
fetchOrder{docsify-ignore}
fetches information on an order made by the user
Kind: instance method of hyperliquid
Returns: object - An order structure
| Param | Type | Required | Description |
|---|---|---|---|
| id | string |
Yes | order id |
| symbol | string |
Yes | unified symbol of the market the order was made in |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.clientOrderId | string |
No | client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchOrder (id, symbol[, params])
fetchMyTrades{docsify-ignore}
fetch all trades made by the user
Kind: instance method of hyperliquid
Returns: Array<Trade> - a list of trade structures
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-fills-by-time
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| since | int |
No | the earliest time in ms to fetch trades for |
| limit | int |
No | the maximum number of trades structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.until | int |
No | timestamp in ms of the latest trade |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchMyTrades (symbol[, since, limit, params])
fetchPosition{docsify-ignore}
fetch data on an open position
Kind: instance method of hyperliquid
Returns: object - a position structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol of the market the position is held in |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
hyperliquid.fetchPosition (symbol[, params])
fetchPositions{docsify-ignore}
fetch all open positions
Kind: instance method of hyperliquid
Returns: Array<object> - a list of position structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> |
No | list of unified market symbols |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchPositions ([symbols, params])
setMarginMode{docsify-ignore}
set margin mode (symbol)
Kind: instance method of hyperliquid
Returns: object - response from the exchange
| Param | Type | Required | Description |
|---|---|---|---|
| marginMode | string |
Yes | margin mode must be either [isolated, cross] |
| symbol | string |
Yes | unified market symbol of the market the position is held in, default is undefined |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.leverage | string |
No | the rate of leverage, is required if setting trade mode (symbol) |
| params.vaultAddress | string |
No | the vault address |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.setMarginMode (marginMode, symbol[, params])
setLeverage{docsify-ignore}
set the level of leverage for a market
Kind: instance method of hyperliquid
Returns: object - response from the exchange
| Param | Type | Required | Description |
|---|---|---|---|
| leverage | float |
Yes | the rate of leverage |
| symbol | string |
Yes | unified market symbol |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.marginMode | string |
No | margin mode must be either [isolated, cross], default is cross |
hyperliquid.setLeverage (leverage, symbol[, params])
addMargin{docsify-ignore}
add margin
Kind: instance method of hyperliquid
Returns: object - a margin structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| amount | float |
Yes | amount of margin to add |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.vaultAddress | string |
No | the vault address |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.addMargin (symbol, amount[, params])
reduceMargin{docsify-ignore}
remove margin from a position
Kind: instance method of hyperliquid
Returns: object - a margin structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| amount | float |
Yes | the amount of margin to remove |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.vaultAddress | string |
No | the vault address |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.reduceMargin (symbol, amount[, params])
transfer{docsify-ignore}
transfer currency internally between wallets on the same account
Kind: instance method of hyperliquid
Returns: object - a transfer structure
| Param | Type | Required | Description |
|---|---|---|---|
| code | string |
Yes | unified currency code |
| amount | float |
Yes | amount to transfer |
| fromAccount | string |
Yes | account to transfer from spot, swap |
| toAccount | string |
Yes | account to transfer to swap, spot or address |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.vaultAddress | string |
No | the vault address for order |
hyperliquid.transfer (code, amount, fromAccount, toAccount[, params])
withdraw{docsify-ignore}
make a withdrawal (only support USDC)
Kind: instance method of hyperliquid
Returns: object - a transaction structure
See
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request
- https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault
| Param | Type | Required | Description |
|---|---|---|---|
| code | string |
Yes | unified currency code |
| amount | float |
Yes | the amount to withdraw |
| address | string |
Yes | the address to withdraw to |
| tag | string |
Yes | |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.vaultAddress | string |
No | vault address withdraw from |
hyperliquid.withdraw (code, amount, address, tag[, params])
fetchTradingFee{docsify-ignore}
fetch the trading fees for a market
Kind: instance method of hyperliquid
Returns: object - a fee structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchTradingFee (symbol[, params])
fetchLedger{docsify-ignore}
fetch the history of changes, actions done by the user or operations that altered the balance of the user
Kind: instance method of hyperliquid
Returns: object - a ledger structure
| Param | Type | Required | Description |
|---|---|---|---|
| code | string |
No | unified currency code |
| since | int |
No | timestamp in ms of the earliest ledger entry |
| limit | int |
No | max number of ledger entries to return |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.until | int |
No | timestamp in ms of the latest ledger entry |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchLedger ([code, since, limit, params])
fetchDeposits{docsify-ignore}
fetch all deposits made to an account
Kind: instance method of hyperliquid
Returns: Array<object> - a list of transaction structures
| Param | Type | Required | Description |
|---|---|---|---|
| code | string |
Yes | unified currency code |
| since | int |
No | the earliest time in ms to fetch deposits for |
| limit | int |
No | the maximum number of deposits structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.until | int |
No | the latest time in ms to fetch withdrawals for |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchDeposits (code[, since, limit, params])
fetchWithdrawals{docsify-ignore}
fetch all withdrawals made from an account
Kind: instance method of hyperliquid
Returns: Array<object> - a list of transaction structures
| Param | Type | Required | Description |
|---|---|---|---|
| code | string |
Yes | unified currency code |
| since | int |
No | the earliest time in ms to fetch withdrawals for |
| limit | int |
No | the maximum number of withdrawals structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.until | int |
No | the latest time in ms to fetch withdrawals for |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchWithdrawals (code[, since, limit, params])
fetchOpenInterests{docsify-ignore}
Retrieves the open interest for a list of symbols
Kind: instance method of hyperliquid
Returns: object - an open interest structurehttps://docs.ccxt.com/#/?id=open-interest-structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> |
No | Unified CCXT market symbol |
| params | object |
No | exchange specific parameters |
hyperliquid.fetchOpenInterests ([symbols, params])
fetchOpenInterest{docsify-ignore}
retrieves the open interest of a contract trading pair
Kind: instance method of hyperliquid
Returns: object - an open interest structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified CCXT market symbol |
| params | object |
No | exchange specific parameters |
hyperliquid.fetchOpenInterest (symbol[, params])
fetchFundingHistory{docsify-ignore}
fetch the history of funding payments paid and received on this account
Kind: instance method of hyperliquid
Returns: object - a funding history structure
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
No | unified market symbol |
| since | int |
No | the earliest time in ms to fetch funding history for |
| limit | int |
No | the maximum number of funding history structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.subAccountAddress | string |
No | sub account user address |
hyperliquid.fetchFundingHistory ([symbol, since, limit, params])
reserveRequestWeight{docsify-ignore}
Instead of trading to increase the address based rate limits, this action allows reserving additional actions for 0.0005 USDC per request. The cost is paid from the Perps balance.
Kind: instance method of hyperliquid
Returns: object - a response object
| Param | Type | Required | Description |
|---|---|---|---|
| weight | number |
Yes | the weight to reserve, 1 weight = 1 action, 0.0005 USDC per action |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.reserveRequestWeight (weight[, params])
createOrdersWs{docsify-ignore}
create a list of trade orders using WebSocket post request
Kind: instance method of hyperliquid
Returns: object - an order structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
| Param | Type | Required | Description |
|---|---|---|---|
| orders | Array |
Yes | list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.createOrdersWs (orders[, params])
createOrderWs{docsify-ignore}
create a trade order using WebSocket post request
Kind: instance method of hyperliquid
Returns: object - an order structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to create an order in |
| type | string |
Yes | 'market' or 'limit' |
| side | string |
Yes | 'buy' or 'sell' |
| amount | float |
Yes | how much of currency you want to trade in units of base currency |
| price | float |
No | the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.timeInForce | string |
No | 'Gtc', 'Ioc', 'Alo' |
| params.postOnly | bool |
No | true or false whether the order is post-only |
| params.reduceOnly | bool |
No | true or false whether the order is reduce-only |
| params.triggerPrice | float |
No | The price at which a trigger order is triggered at |
| params.clientOrderId | string |
No | client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) |
| params.slippage | string |
No | the slippage for market order |
| params.vaultAddress | string |
No | the vault address for order |
hyperliquid.createOrderWs (symbol, type, side, amount[, price, params])
editOrderWs{docsify-ignore}
edit a trade order
Kind: instance method of hyperliquid
Returns: object - an order structure
| Param | Type | Required | Description |
|---|---|---|---|
| id | string |
Yes | cancel order id |
| symbol | string |
Yes | unified symbol of the market to create an order in |
| type | string |
Yes | 'market' or 'limit' |
| side | string |
Yes | 'buy' or 'sell' |
| amount | float |
Yes | how much of currency you want to trade in units of base currency |
| price | float |
No | the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.timeInForce | string |
No | 'Gtc', 'Ioc', 'Alo' |
| params.postOnly | bool |
No | true or false whether the order is post-only |
| params.reduceOnly | bool |
No | true or false whether the order is reduce-only |
| params.triggerPrice | float |
No | The price at which a trigger order is triggered at |
| params.clientOrderId | string |
No | client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef) |
| params.vaultAddress | string |
No | the vault address for order |
hyperliquid.editOrderWs (id, symbol, type, side, amount[, price, params])
cancelOrdersWs{docsify-ignore}
cancel multiple orders using WebSocket post request
Kind: instance method of hyperliquid
Returns: Array<object> - a list of order structures
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/post-requests
| Param | Type | Required | Description |
|---|---|---|---|
| ids | Array<string> |
Yes | list of order ids to cancel |
| symbol | string |
Yes | unified symbol of the market the orders were made in |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.clientOrderId | Array<string> |
No | list of client order ids to cancel instead of order ids |
| params.vaultAddress | string |
No | the vault address for order cancellation |
hyperliquid.cancelOrdersWs (ids, symbol[, params])
cancelOrderWs{docsify-ignore}
cancel a single order using WebSocket post request
Kind: instance method of hyperliquid
Returns: object - an order structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/post-requests
| Param | Type | Required | Description |
|---|---|---|---|
| id | string |
Yes | order id to cancel |
| symbol | string |
Yes | unified symbol of the market the order was made in |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.clientOrderId | string |
No | client order id to cancel instead of order id |
| params.vaultAddress | string |
No | the vault address for order cancellation |
hyperliquid.cancelOrderWs (id, symbol[, params])
watchOrderBook{docsify-ignore}
watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
Kind: instance method of hyperliquid
Returns: object - A dictionary of order book structures indexed by market symbols
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch the order book for |
| limit | int |
No | the maximum amount of order book entries to return |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.watchOrderBook (symbol[, limit, params])
unWatchOrderBook{docsify-ignore}
unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
Kind: instance method of hyperliquid
Returns: object - A dictionary of order book structures indexed by market symbols
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch the order book for |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.unWatchOrderBook (symbol[, params])
watchTicker{docsify-ignore}
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
Kind: instance method of hyperliquid
Returns: object - a ticker structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch the ticker for |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.watchTicker (symbol[, params])
watchTickers{docsify-ignore}
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
Kind: instance method of hyperliquid
Returns: object - a ticker structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> |
Yes | unified symbol of the market to fetch the ticker for |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.watchTickers (symbols[, params])
unWatchTickers{docsify-ignore}
unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
Kind: instance method of hyperliquid
Returns: object - a ticker structure
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> |
Yes | unified symbol of the market to fetch the ticker for |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.unWatchTickers (symbols[, params])
watchMyTrades{docsify-ignore}
watches information on multiple trades made by the user
Kind: instance method of hyperliquid
Returns: Array<object> - a list of order structures
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol of the market orders were made in |
| since | int |
No | the earliest time in ms to fetch orders for |
| limit | int |
No | the maximum number of order structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
hyperliquid.watchMyTrades (symbol[, since, limit, params])
unWatchTrades{docsify-ignore}
unWatches information on multiple trades made in a market
Kind: instance method of hyperliquid
Returns: Array<object> - a list of trade structures
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol of the market trades were made in |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.unWatchTrades (symbol[, params])
watchOHLCV{docsify-ignore}
watches historical candlestick data containing the open, high, low, close price, and the volume of a market
Kind: instance method of hyperliquid
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch OHLCV data for |
| timeframe | string |
Yes | the length of time each candle represents |
| since | int |
No | timestamp in ms of the earliest candle to fetch |
| limit | int |
No | the maximum amount of candles to fetch |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.watchOHLCV (symbol, timeframe[, since, limit, params])
unWatchOHLCV{docsify-ignore}
watches historical candlestick data containing the open, high, low, close price, and the volume of a market
Kind: instance method of hyperliquid
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified symbol of the market to fetch OHLCV data for |
| timeframe | string |
Yes | the length of time each candle represents |
| params | object |
No | extra parameters specific to the exchange API endpoint |
hyperliquid.unWatchOHLCV (symbol, timeframe[, params])
watchOrders{docsify-ignore}
watches information on multiple orders made by the user
Kind: instance method of hyperliquid
Returns: Array<object> - a list of order structures
See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string |
Yes | unified market symbol of the market orders were made in |
| since | int |
No | the earliest time in ms to fetch orders for |
| limit | int |
No | the maximum number of order structures to retrieve |
| params | object |
No | extra parameters specific to the exchange API endpoint |
| params.user | string |
No | user address, will default to this.walletAddress if not provided |
hyperliquid.watchOrders (symbol[, since, limit, params])