hyperliquid-sdk 0.7.3__tar.gz → 0.7.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/PKG-INFO +166 -113
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/README.md +165 -112
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/__init__.py +7 -1
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/client.py +335 -48
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/order.py +36 -6
- hyperliquid_sdk-0.7.4/hyperliquid_sdk/prediction.py +225 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/pyproject.toml +1 -1
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/tests/test_order.py +11 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/tests/test_sdk.py +164 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/.gitignore +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/LICENSE +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/errors.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/evm.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/evm_stream.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/grpc_stream.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/hypercore.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/info.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/proto/__init__.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/proto/orderbook.proto +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/proto/orderbook_pb2.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/proto/orderbook_pb2_grpc.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/proto/streaming.proto +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/proto/streaming_pb2.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/proto/streaming_pb2_grpc.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/py.typed +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/hyperliquid_sdk/websocket.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/tests/__init__.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/tests/conftest.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/tests/test_hypercore.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/tests/test_info.py +0 -0
- {hyperliquid_sdk-0.7.3 → hyperliquid_sdk-0.7.4}/tests/test_websocket.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hyperliquid-sdk
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.4
|
|
4
4
|
Summary: Community SDK for Hyperliquid. One line to place orders, zero ceremony. HyperCore, HyperEVM, WebSocket and gRPC streams. Not affiliated with Hyperliquid Foundation.
|
|
5
5
|
Project-URL: Homepage, https://hyperliquidapi.com
|
|
6
6
|
Project-URL: Documentation, https://www.quicknode.com/docs/hyperliquid/api-overview
|
|
@@ -64,6 +64,23 @@ Everything is included: trading, market data, WebSocket streaming, gRPC streamin
|
|
|
64
64
|
|
|
65
65
|
## Quick Start
|
|
66
66
|
|
|
67
|
+
### Try without an account (read-only)
|
|
68
|
+
|
|
69
|
+
All market data APIs work without a private key or QuickNode account — great for exploration:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from hyperliquid_sdk import HyperliquidSDK
|
|
73
|
+
|
|
74
|
+
sdk = HyperliquidSDK("https://api.hyperliquid.xyz") # Public endpoint, no auth needed
|
|
75
|
+
|
|
76
|
+
# Fetch live market data right away
|
|
77
|
+
print(sdk.info.all_mids()) # All mid prices
|
|
78
|
+
print(sdk.info.meta()) # Exchange metadata (229 perp markets)
|
|
79
|
+
print(sdk.info.l2_book("BTC")) # BTC order book
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
To place orders, set up a private key and use a [QuickNode Hyperliquid endpoint](https://www.quicknode.com/).
|
|
83
|
+
|
|
67
84
|
### 1. Set your private key
|
|
68
85
|
|
|
69
86
|
```bash
|
|
@@ -105,64 +122,67 @@ You can create a Hyperliquid endpoint on [Quicknode](https://www.quicknode.com/)
|
|
|
105
122
|
sdk = HyperliquidSDK(endpoint)
|
|
106
123
|
|
|
107
124
|
# Market data
|
|
108
|
-
sdk.info
|
|
109
|
-
sdk.info
|
|
110
|
-
sdk.info
|
|
111
|
-
sdk.info
|
|
112
|
-
sdk.info
|
|
113
|
-
sdk.info
|
|
125
|
+
sdk.info.all_mids() # All mid prices
|
|
126
|
+
sdk.info.l2_book("BTC") # Order book
|
|
127
|
+
sdk.info.recent_trades("BTC") # Recent trades
|
|
128
|
+
sdk.info.candles("BTC", "1h", start, end) # OHLCV candles
|
|
129
|
+
sdk.info.funding_history("BTC", start, end) # Funding history
|
|
130
|
+
sdk.info.predicted_fundings() # Predicted funding rates
|
|
131
|
+
# Note: predicted_fundings() returns rates from multiple sources (HlPerp, BinPerp, BybitPerp).
|
|
132
|
+
# Each source uses a different funding interval (1h, 8h, or variable). Always normalise
|
|
133
|
+
# by the returned `fundingIntervalHours` field before comparing rates across exchanges.
|
|
114
134
|
|
|
115
135
|
# Metadata
|
|
116
|
-
sdk.info
|
|
117
|
-
sdk.info
|
|
118
|
-
sdk.info
|
|
119
|
-
sdk.info
|
|
120
|
-
sdk.info
|
|
136
|
+
sdk.info.meta() # Exchange metadata
|
|
137
|
+
sdk.info.spot_meta() # Spot metadata
|
|
138
|
+
sdk.info.exchange_status() # Exchange status
|
|
139
|
+
sdk.info.perp_dexs() # Perpetual DEX info
|
|
140
|
+
sdk.info.max_market_order_ntls() # Max market order notionals
|
|
121
141
|
|
|
122
142
|
# User data
|
|
123
|
-
sdk.info
|
|
124
|
-
sdk.info
|
|
125
|
-
sdk.info
|
|
126
|
-
sdk.info
|
|
127
|
-
sdk.info
|
|
128
|
-
sdk.info
|
|
129
|
-
sdk.info
|
|
130
|
-
sdk.info
|
|
131
|
-
sdk.info
|
|
132
|
-
sdk.info
|
|
133
|
-
sdk.info
|
|
134
|
-
sdk.info
|
|
135
|
-
sdk.info
|
|
136
|
-
sdk.info
|
|
137
|
-
sdk.info
|
|
143
|
+
sdk.info.clearinghouse_state("0x...") # Positions & margin
|
|
144
|
+
sdk.info.spot_clearinghouse_state("0x...") # Spot balances
|
|
145
|
+
sdk.info.open_orders("0x...") # Open orders
|
|
146
|
+
sdk.info.frontend_open_orders("0x...") # Enhanced open orders
|
|
147
|
+
sdk.info.order_status("0x...", oid) # Specific order status
|
|
148
|
+
sdk.info.historical_orders("0x...") # Order history
|
|
149
|
+
sdk.info.user_fills("0x...") # Trade history
|
|
150
|
+
sdk.info.user_fills_by_time("0x...", start) # Fills by time range
|
|
151
|
+
sdk.info.user_funding("0x...") # Funding payments
|
|
152
|
+
sdk.info.user_fees("0x...") # Fee structure
|
|
153
|
+
sdk.info.user_rate_limit("0x...") # Rate limit status
|
|
154
|
+
sdk.info.user_role("0x...") # Account type
|
|
155
|
+
sdk.info.portfolio("0x...") # Portfolio history
|
|
156
|
+
sdk.info.sub_accounts("0x...") # Sub-accounts
|
|
157
|
+
sdk.info.extra_agents("0x...") # API keys/agents
|
|
138
158
|
|
|
139
159
|
# TWAP
|
|
140
|
-
sdk.info
|
|
160
|
+
sdk.info.user_twap_slice_fills("0x...") # TWAP slice fills
|
|
141
161
|
|
|
142
162
|
# Batch queries
|
|
143
|
-
sdk.info
|
|
163
|
+
sdk.info.batch_clearinghouse_states(["0x...", "0x..."])
|
|
144
164
|
|
|
145
165
|
# Vaults
|
|
146
|
-
sdk.info
|
|
147
|
-
sdk.info
|
|
148
|
-
sdk.info
|
|
149
|
-
sdk.info
|
|
166
|
+
sdk.info.vault_summaries() # All vault summaries
|
|
167
|
+
sdk.info.vault_details("0x...") # Specific vault
|
|
168
|
+
sdk.info.user_vault_equities("0x...") # User's vault equities
|
|
169
|
+
sdk.info.leading_vaults("0x...") # Vaults user leads
|
|
150
170
|
|
|
151
171
|
# Delegation/Staking
|
|
152
|
-
sdk.info
|
|
153
|
-
sdk.info
|
|
154
|
-
sdk.info
|
|
155
|
-
sdk.info
|
|
172
|
+
sdk.info.delegations("0x...") # Active delegations
|
|
173
|
+
sdk.info.delegator_summary("0x...") # Delegation summary
|
|
174
|
+
sdk.info.delegator_history("0x...") # Delegation history
|
|
175
|
+
sdk.info.delegator_rewards("0x...") # Delegation rewards
|
|
156
176
|
|
|
157
177
|
# Tokens
|
|
158
|
-
sdk.info
|
|
159
|
-
sdk.info
|
|
178
|
+
sdk.info.token_details("token_id") # Token details
|
|
179
|
+
sdk.info.spot_deploy_state("0x...") # Spot deployment state
|
|
160
180
|
|
|
161
181
|
# Other
|
|
162
|
-
sdk.info
|
|
163
|
-
sdk.info
|
|
164
|
-
sdk.info
|
|
165
|
-
sdk.info
|
|
182
|
+
sdk.info.referral("0x...") # Referral info
|
|
183
|
+
sdk.info.max_builder_fee("0x...", "0x...") # Builder fee limits
|
|
184
|
+
sdk.info.approved_builders("0x...") # Approved builders
|
|
185
|
+
sdk.info.liquidatable() # Liquidatable positions
|
|
166
186
|
```
|
|
167
187
|
|
|
168
188
|
### HyperCore API
|
|
@@ -173,26 +193,26 @@ Block data, trading operations, and real-time data via JSON-RPC.
|
|
|
173
193
|
sdk = HyperliquidSDK(endpoint)
|
|
174
194
|
|
|
175
195
|
# Block data
|
|
176
|
-
sdk.core
|
|
177
|
-
sdk.core
|
|
178
|
-
sdk.core
|
|
179
|
-
sdk.core
|
|
196
|
+
sdk.core.latest_block_number() # Latest block
|
|
197
|
+
sdk.core.get_block(12345) # Get specific block
|
|
198
|
+
sdk.core.get_batch_blocks(100, 110) # Get block range
|
|
199
|
+
sdk.core.latest_blocks(count=10) # Latest blocks
|
|
180
200
|
|
|
181
201
|
# Recent data
|
|
182
|
-
sdk.core
|
|
183
|
-
sdk.core
|
|
184
|
-
sdk.core
|
|
185
|
-
sdk.core
|
|
202
|
+
sdk.core.latest_trades(count=10) # Recent trades (all coins)
|
|
203
|
+
sdk.core.latest_trades(count=10, coin="BTC") # Recent BTC trades
|
|
204
|
+
sdk.core.latest_orders(count=10) # Recent order events
|
|
205
|
+
sdk.core.latest_book_updates(count=10) # Recent book updates
|
|
186
206
|
|
|
187
207
|
# Discovery
|
|
188
|
-
sdk.core
|
|
189
|
-
sdk.core
|
|
190
|
-
sdk.core
|
|
208
|
+
sdk.core.list_dexes() # All DEXes
|
|
209
|
+
sdk.core.list_markets() # All markets
|
|
210
|
+
sdk.core.list_markets(dex="hyperliquidity") # Markets by DEX
|
|
191
211
|
|
|
192
212
|
# Order queries
|
|
193
|
-
sdk.core
|
|
194
|
-
sdk.core
|
|
195
|
-
sdk.core
|
|
213
|
+
sdk.core.open_orders("0x...") # User's open orders
|
|
214
|
+
sdk.core.order_status("0x...", oid) # Specific order status
|
|
215
|
+
sdk.core.preflight(...) # Validate order before signing
|
|
196
216
|
```
|
|
197
217
|
|
|
198
218
|
### EVM (Ethereum JSON-RPC)
|
|
@@ -203,45 +223,45 @@ sdk.core().preflight(...) # Validate order before signing
|
|
|
203
223
|
sdk = HyperliquidSDK(endpoint)
|
|
204
224
|
|
|
205
225
|
# Chain info
|
|
206
|
-
sdk.evm
|
|
207
|
-
sdk.evm
|
|
208
|
-
sdk.evm
|
|
209
|
-
sdk.evm
|
|
210
|
-
sdk.evm
|
|
211
|
-
sdk.evm
|
|
226
|
+
sdk.evm.block_number() # Latest block
|
|
227
|
+
sdk.evm.chain_id() # 999 mainnet, 998 testnet
|
|
228
|
+
sdk.evm.gas_price() # Current gas price
|
|
229
|
+
sdk.evm.max_priority_fee_per_gas() # Priority fee
|
|
230
|
+
sdk.evm.net_version() # Network version
|
|
231
|
+
sdk.evm.syncing() # Sync status
|
|
212
232
|
|
|
213
233
|
# Accounts
|
|
214
|
-
sdk.evm
|
|
215
|
-
sdk.evm
|
|
216
|
-
sdk.evm
|
|
217
|
-
sdk.evm
|
|
234
|
+
sdk.evm.get_balance("0x...") # Account balance
|
|
235
|
+
sdk.evm.get_transaction_count("0x...") # Nonce
|
|
236
|
+
sdk.evm.get_code("0x...") # Contract code
|
|
237
|
+
sdk.evm.get_storage_at("0x...", position) # Storage value
|
|
218
238
|
|
|
219
239
|
# Transactions
|
|
220
|
-
sdk.evm
|
|
221
|
-
sdk.evm
|
|
222
|
-
sdk.evm
|
|
223
|
-
sdk.evm
|
|
224
|
-
sdk.evm
|
|
240
|
+
sdk.evm.call({"to": "0x...", "data": "0x..."})
|
|
241
|
+
sdk.evm.estimate_gas(tx)
|
|
242
|
+
sdk.evm.send_raw_transaction(signed_tx)
|
|
243
|
+
sdk.evm.get_transaction_by_hash("0x...")
|
|
244
|
+
sdk.evm.get_transaction_receipt("0x...")
|
|
225
245
|
|
|
226
246
|
# Blocks
|
|
227
|
-
sdk.evm
|
|
228
|
-
sdk.evm
|
|
229
|
-
sdk.evm
|
|
230
|
-
sdk.evm
|
|
247
|
+
sdk.evm.get_block_by_number(12345)
|
|
248
|
+
sdk.evm.get_block_by_hash("0x...")
|
|
249
|
+
sdk.evm.get_block_receipts(12345)
|
|
250
|
+
sdk.evm.get_block_transaction_count_by_number(12345)
|
|
231
251
|
|
|
232
252
|
# Logs
|
|
233
|
-
sdk.evm
|
|
253
|
+
sdk.evm.get_logs({"address": "0x...", "topics": [...]})
|
|
234
254
|
|
|
235
255
|
# HyperEVM-specific
|
|
236
|
-
sdk.evm
|
|
237
|
-
sdk.evm
|
|
238
|
-
sdk.evm
|
|
256
|
+
sdk.evm.big_block_gas_price() # Big block gas price
|
|
257
|
+
sdk.evm.using_big_blocks() # Is using big blocks?
|
|
258
|
+
sdk.evm.get_system_txs_by_block_number(12345)
|
|
239
259
|
|
|
240
260
|
# Debug/Trace
|
|
241
|
-
sdk.evm
|
|
242
|
-
sdk.evm
|
|
243
|
-
sdk.evm
|
|
244
|
-
sdk.evm
|
|
261
|
+
sdk.evm.debug_trace_transaction("0x...", {"tracer": "callTracer"})
|
|
262
|
+
sdk.evm.debug_trace_block_by_number(12345)
|
|
263
|
+
sdk.evm.trace_transaction("0x...")
|
|
264
|
+
sdk.evm.trace_block(12345)
|
|
245
265
|
```
|
|
246
266
|
|
|
247
267
|
---
|
|
@@ -256,21 +276,21 @@ sdk.evm().trace_block(12345)
|
|
|
256
276
|
sdk = HyperliquidSDK(endpoint)
|
|
257
277
|
|
|
258
278
|
# Subscribe to trades
|
|
259
|
-
sdk.stream
|
|
279
|
+
sdk.stream.trades(["BTC", "ETH"], lambda t: print(f"Trade: {t}"))
|
|
260
280
|
|
|
261
281
|
# Subscribe to book updates
|
|
262
|
-
sdk.stream
|
|
282
|
+
sdk.stream.book_updates(["BTC"], lambda b: print(f"Book: {b}"))
|
|
263
283
|
|
|
264
284
|
# Subscribe to orders (your orders)
|
|
265
|
-
sdk.stream
|
|
285
|
+
sdk.stream.orders(["BTC"], lambda o: print(f"Order: {o}"), users=["0x..."])
|
|
266
286
|
|
|
267
287
|
# Run in background
|
|
268
|
-
sdk.stream
|
|
288
|
+
sdk.stream.start()
|
|
269
289
|
# ... do other work ...
|
|
270
|
-
sdk.stream
|
|
290
|
+
sdk.stream.stop()
|
|
271
291
|
|
|
272
292
|
# Or run blocking
|
|
273
|
-
sdk.stream
|
|
293
|
+
sdk.stream.run()
|
|
274
294
|
```
|
|
275
295
|
|
|
276
296
|
Available streams:
|
|
@@ -314,24 +334,24 @@ Lower latency streaming via gRPC for high-frequency applications.
|
|
|
314
334
|
sdk = HyperliquidSDK(endpoint)
|
|
315
335
|
|
|
316
336
|
# Subscribe to trades
|
|
317
|
-
sdk.grpc
|
|
337
|
+
sdk.grpc.trades(["BTC", "ETH"], lambda t: print(f"Trade: {t}"))
|
|
318
338
|
|
|
319
339
|
# Subscribe to L2 order book (aggregated by price level)
|
|
320
|
-
sdk.grpc
|
|
340
|
+
sdk.grpc.l2_book("BTC", lambda b: print(f"Book: {b}"), n_sig_figs=5)
|
|
321
341
|
|
|
322
342
|
# Subscribe to L4 order book (CRITICAL: individual orders with order IDs)
|
|
323
|
-
sdk.grpc
|
|
343
|
+
sdk.grpc.l4_book("BTC", lambda b: print(f"L4: {b}"))
|
|
324
344
|
|
|
325
345
|
# Subscribe to blocks
|
|
326
|
-
sdk.grpc
|
|
346
|
+
sdk.grpc.blocks(lambda b: print(f"Block: {b}"))
|
|
327
347
|
|
|
328
348
|
# Run in background
|
|
329
|
-
sdk.grpc
|
|
349
|
+
sdk.grpc.start()
|
|
330
350
|
# ... do other work ...
|
|
331
|
-
sdk.grpc
|
|
351
|
+
sdk.grpc.stop()
|
|
332
352
|
|
|
333
353
|
# Or run blocking
|
|
334
|
-
sdk.grpc
|
|
354
|
+
sdk.grpc.run()
|
|
335
355
|
```
|
|
336
356
|
|
|
337
357
|
**Available gRPC Streams:**
|
|
@@ -371,8 +391,8 @@ def on_l4_book(data):
|
|
|
371
391
|
print(f"Bid: ${float(px):,.2f} x {sz} (order: {oid})")
|
|
372
392
|
|
|
373
393
|
sdk = HyperliquidSDK(endpoint)
|
|
374
|
-
sdk.grpc
|
|
375
|
-
sdk.grpc
|
|
394
|
+
sdk.grpc.l4_book("BTC", on_l4_book)
|
|
395
|
+
sdk.grpc.run()
|
|
376
396
|
```
|
|
377
397
|
|
|
378
398
|
### L2 vs L4 Comparison
|
|
@@ -401,11 +421,35 @@ sdk.market_sell("ETH", notional=100)
|
|
|
401
421
|
sdk.buy("BTC", size=0.001, price=65000)
|
|
402
422
|
sdk.sell("ETH", size=0.5, price=4000, tif="gtc")
|
|
403
423
|
|
|
424
|
+
# Order priority. priority_fee=10000 is 1 bp.
|
|
425
|
+
# Priority fees are paid from undelegated staking HYPE.
|
|
426
|
+
sdk.fund_priority_fees(0.001)
|
|
427
|
+
sdk.market_buy("HYPE", size=0.3, priority_fee=10000)
|
|
428
|
+
|
|
404
429
|
# Perp trader aliases
|
|
405
430
|
sdk.long("BTC", size=0.001, price=65000)
|
|
406
431
|
sdk.short("ETH", notional=500, tif="ioc")
|
|
407
432
|
```
|
|
408
433
|
|
|
434
|
+
### HIP-4 Prediction Markets
|
|
435
|
+
|
|
436
|
+
Always discover the active markets first. The returned `market.yes` and `market.no` sides are directly tradeable, so users do not need to memorize `#10` or the native asset id.
|
|
437
|
+
|
|
438
|
+
```python
|
|
439
|
+
markets = sdk.prediction_markets()
|
|
440
|
+
for market in markets:
|
|
441
|
+
print(market.title, market.yes.symbol, market.yes.mid, market.no.symbol, market.no.mid)
|
|
442
|
+
|
|
443
|
+
market = markets.find(underlying="BTC", target_price="78213")
|
|
444
|
+
|
|
445
|
+
# HIP-4 uses USDH collateral and a 10 USDH minimum order value.
|
|
446
|
+
sdk.buy_usdh(10.7)
|
|
447
|
+
order = sdk.buy(market.yes, size=20, price="0.63")
|
|
448
|
+
exit_order = sdk.sell(market.yes, size=20, price="0.64")
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
HIP-4 sizes must be whole contracts. Priority fees are not supported for HIP-4, so omit `priority_fee` when trading `market.yes`, `market.no`, or raw `#` markets.
|
|
452
|
+
|
|
409
453
|
### Order Management
|
|
410
454
|
|
|
411
455
|
```python
|
|
@@ -448,7 +492,7 @@ for order in btc_orders:
|
|
|
448
492
|
f"type={order['orderType']} tif={order['tif']} oid={order['oid']}")
|
|
449
493
|
|
|
450
494
|
# For enhanced data (triggers, children), use frontend_open_orders()
|
|
451
|
-
enhanced = sdk.info
|
|
495
|
+
enhanced = sdk.info.frontend_open_orders(sdk.address)
|
|
452
496
|
```
|
|
453
497
|
|
|
454
498
|
### Partial Position Close by Percentage
|
|
@@ -458,7 +502,7 @@ enhanced = sdk.info().frontend_open_orders(sdk.address)
|
|
|
458
502
|
```python
|
|
459
503
|
def close_percentage(sdk, coin: str, percent: float):
|
|
460
504
|
"""Close a percentage (0-100) of an open position."""
|
|
461
|
-
state = sdk.info
|
|
505
|
+
state = sdk.info.clearinghouse_state(sdk.address)
|
|
462
506
|
position = next(
|
|
463
507
|
(p for p in state['assetPositions'] if p['position']['coin'] == coin), None
|
|
464
508
|
)
|
|
@@ -637,13 +681,15 @@ sdk.vault_withdraw(vault_address=HLP_VAULT, amount=50)
|
|
|
637
681
|
### Staking
|
|
638
682
|
|
|
639
683
|
```python
|
|
640
|
-
#
|
|
641
|
-
|
|
642
|
-
sdk.
|
|
684
|
+
# Move spot HYPE into undelegated staking HYPE.
|
|
685
|
+
# This is the balance Hyperliquid uses for order priority fees.
|
|
686
|
+
sdk.fund_priority_fees(0.001)
|
|
687
|
+
sdk.stake(amount=0.001)
|
|
688
|
+
sdk.unstake(amount=0.001) # 7-day queue
|
|
643
689
|
|
|
644
690
|
# Delegate to validators
|
|
645
|
-
sdk.delegate(validator="0x...", amount=
|
|
646
|
-
sdk.undelegate(validator="0x...", amount=
|
|
691
|
+
sdk.delegate(validator="0x...", amount=0.5)
|
|
692
|
+
sdk.undelegate(validator="0x...", amount=0.25)
|
|
647
693
|
```
|
|
648
694
|
|
|
649
695
|
### Fluent Order Builder
|
|
@@ -658,6 +704,13 @@ order = sdk.order(
|
|
|
658
704
|
.gtc()
|
|
659
705
|
.reduce_only()
|
|
660
706
|
)
|
|
707
|
+
|
|
708
|
+
priority_order = sdk.order(
|
|
709
|
+
Order.buy("HYPE")
|
|
710
|
+
.size(0.3)
|
|
711
|
+
.market()
|
|
712
|
+
.priority_fee(10000)
|
|
713
|
+
)
|
|
661
714
|
```
|
|
662
715
|
|
|
663
716
|
---
|
|
@@ -722,13 +775,13 @@ HyperliquidSDK(
|
|
|
722
775
|
timeout=30, # Request timeout in seconds
|
|
723
776
|
)
|
|
724
777
|
|
|
725
|
-
# Access sub-clients
|
|
726
|
-
sdk.info
|
|
727
|
-
sdk.core
|
|
728
|
-
sdk.evm
|
|
729
|
-
sdk.stream
|
|
730
|
-
sdk.grpc
|
|
731
|
-
sdk.evm_stream
|
|
778
|
+
# Access sub-clients (properties, not methods — no parentheses needed)
|
|
779
|
+
sdk.info # Info API (market data, user data, metadata)
|
|
780
|
+
sdk.core # HyperCore (blocks, trades, orders)
|
|
781
|
+
sdk.evm # EVM (Ethereum JSON-RPC)
|
|
782
|
+
sdk.stream # WebSocket streaming
|
|
783
|
+
sdk.grpc # gRPC streaming
|
|
784
|
+
sdk.evm_stream # EVM WebSocket (eth_subscribe)
|
|
732
785
|
```
|
|
733
786
|
|
|
734
787
|
---
|