Python Examples
Hyperliquid Trailing Order
Hyperliquid Trailing Order — CCXT Python code example.
import os
import sys
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
async def example():
exchange = ccxt.hyperliquid({
'walletAddress': 'MY_WALLET_ADDRESS',
'privateKey': 'MY_PRIVATE_KEY',
})
await exchange.load_markets()
symbol = 'SOL/USDC:USDC'
order_type = 'market'
side = 'sell'
amount = 0.2
price = None
params = {
'trailingPercent': 5,
'trailingTriggerPrice': 100,
'reduceOnly': True,
}
try:
order = await exchange.create_order(symbol, order_type, side, amount, price, params)
print(order)
open_orders = await exchange.fetch_open_orders(symbol)
print(open_orders)
canceled = await exchange.cancel_order(order['id'], symbol)
print(canceled)
except Exception as e:
print(str(e))
await exchange.close()
asyncio.run(example())