hyperliquid-cli-python 0.1.4__tar.gz → 0.1.5__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_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/PKG-INFO +85 -26
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/README.md +84 -25
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/pyproject.toml +1 -1
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/cli/argparse_main.py +34 -177
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/cli/markets_tui.py +0 -12
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/cli/runtime.py +0 -7
- hyperliquid_cli_python-0.1.5/src/hl_cli/commands/account.py +302 -0
- hyperliquid_cli_python-0.1.5/src/hl_cli/commands/app.py +135 -0
- hyperliquid_cli_python-0.1.5/src/hl_cli/commands/asset.py +122 -0
- hyperliquid_cli_python-0.1.5/src/hl_cli/commands/common.py +75 -0
- hyperliquid_cli_python-0.1.5/src/hl_cli/commands/markets.py +310 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/commands/order.py +100 -69
- hyperliquid_cli_python-0.1.5/src/hl_cli/commands/referral.py +18 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/core/context.py +3 -19
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/core/order_config.py +0 -2
- hyperliquid_cli_python-0.1.5/src/hl_cli/core/testnet_policy.py +22 -0
- hyperliquid_cli_python-0.1.4/src/hl_cli/infra/db.py → hyperliquid_cli_python-0.1.5/src/hl_cli/infra/account_repo.py +19 -118
- hyperliquid_cli_python-0.1.5/src/hl_cli/infra/db.py +41 -0
- hyperliquid_cli_python-0.1.5/src/hl_cli/infra/db_crypto.py +77 -0
- hyperliquid_cli_python-0.1.5/src/hl_cli/services/account_fetch.py +93 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/utils/market_table.py +0 -4
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/utils/output.py +0 -22
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/utils/validators.py +7 -9
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/utils/watch.py +0 -1
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hyperliquid_cli_python.egg-info/PKG-INFO +85 -26
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hyperliquid_cli_python.egg-info/SOURCES.txt +9 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/tests/test_account_testnet_mode.py +3 -8
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/tests/test_accounts_networks.py +0 -2
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/tests/test_completion.py +0 -3
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/tests/test_json_patterns.py +2 -5
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/tests/test_markets_testnet_mode.py +2 -7
- hyperliquid_cli_python-0.1.5/tests/test_order_testnet_routing.py +82 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/tests/test_testnet_context.py +1 -2
- hyperliquid_cli_python-0.1.4/src/hl_cli/commands/app.py +0 -1081
- hyperliquid_cli_python-0.1.4/tests/test_order_testnet_routing.py +0 -13
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/LICENSE +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/setup.cfg +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/cli/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/commands/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/core/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/infra/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/infra/paths.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hl_cli/utils/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hyperliquid_cli_python.egg-info/dependency_links.txt +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hyperliquid_cli_python.egg-info/entry_points.txt +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hyperliquid_cli_python.egg-info/requires.txt +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.5}/src/hyperliquid_cli_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hyperliquid-cli-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Python CLI for Hyperliquid DEX
|
|
5
5
|
Author: hyperliquid-cli contributors
|
|
6
6
|
License-Expression: BSD-2-Clause
|
|
@@ -13,9 +13,46 @@ Requires-Dist: hyperliquid-python-sdk>=0.18.0
|
|
|
13
13
|
Requires-Dist: eth-account>=0.13.4
|
|
14
14
|
Dynamic: license-file
|
|
15
15
|
|
|
16
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
17
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
18
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
|
19
|
+
|
|
20
|
+
- [Hyperliquid CLI (Python)](#hyperliquid-cli-python)
|
|
21
|
+
- [Setup](#setup)
|
|
22
|
+
- [Requirements](#requirements)
|
|
23
|
+
- [Installation](#installation)
|
|
24
|
+
- [Bash Completion](#bash-completion)
|
|
25
|
+
- [CLI Basics](#cli-basics)
|
|
26
|
+
- [Global Options](#global-options)
|
|
27
|
+
- [Supported Commands](#supported-commands)
|
|
28
|
+
- [Configuration](#configuration)
|
|
29
|
+
- [Security Notes](#security-notes)
|
|
30
|
+
- [Development](#development)
|
|
31
|
+
- [Run for Development](#run-for-development)
|
|
32
|
+
- [JSON Pattern Tests](#json-pattern-tests)
|
|
33
|
+
- [Order Features](#order-features)
|
|
34
|
+
- [TWAP Orders](#twap-orders)
|
|
35
|
+
- [Stake-Based Orders](#stake-based-orders)
|
|
36
|
+
- [Project](#project)
|
|
37
|
+
- [Acknowledgments](#acknowledgments)
|
|
38
|
+
|
|
39
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
40
|
+
|
|
16
41
|
# Hyperliquid CLI (Python)
|
|
17
42
|
|
|
18
|
-
|
|
43
|
+
Python CLI for Hyperliquid account management, market data, and order execution.
|
|
44
|
+
|
|
45
|
+
## Setup
|
|
46
|
+
|
|
47
|
+
### Requirements
|
|
48
|
+
|
|
49
|
+
- Python 3.10+
|
|
50
|
+
- `hyperliquid-python-sdk` for API interactions
|
|
51
|
+
- `rich` for pretty console output
|
|
52
|
+
- `eth-account` for key management
|
|
53
|
+
- Optional: `make` for installation and uninstallation scripts
|
|
54
|
+
|
|
55
|
+
### Installation
|
|
19
56
|
|
|
20
57
|
Install from git and also set up Bash completion with `make install`:
|
|
21
58
|
|
|
@@ -29,7 +66,7 @@ Install from source for local development:
|
|
|
29
66
|
|
|
30
67
|
```bash
|
|
31
68
|
cd hl
|
|
32
|
-
pip install -e .
|
|
69
|
+
python3 -m pip install --user -e .
|
|
33
70
|
```
|
|
34
71
|
|
|
35
72
|
Install from PyPI:
|
|
@@ -44,7 +81,7 @@ After installation, the `hl` command is available:
|
|
|
44
81
|
hl --help
|
|
45
82
|
```
|
|
46
83
|
|
|
47
|
-
|
|
84
|
+
### Bash Completion
|
|
48
85
|
|
|
49
86
|
`hl` can print a Bash completion script for top-level commands and subcommands.
|
|
50
87
|
|
|
@@ -72,12 +109,14 @@ To remove the package and any managed `~/.bashrc` completion line:
|
|
|
72
109
|
make uninstall
|
|
73
110
|
```
|
|
74
111
|
|
|
75
|
-
##
|
|
112
|
+
## CLI Basics
|
|
113
|
+
|
|
114
|
+
### Global Options
|
|
76
115
|
|
|
77
116
|
- `--json` Output JSON
|
|
78
117
|
- `--testnet` Use testnet
|
|
79
118
|
|
|
80
|
-
|
|
119
|
+
### Supported Commands
|
|
81
120
|
|
|
82
121
|
- `hl account add|ls|set-default|remove`
|
|
83
122
|
- `hl account positions|orders|balances|portfolio`
|
|
@@ -86,7 +125,7 @@ make uninstall
|
|
|
86
125
|
- `hl markets ls|search`
|
|
87
126
|
- `hl referral set|status`
|
|
88
127
|
|
|
89
|
-
|
|
128
|
+
### Configuration
|
|
90
129
|
|
|
91
130
|
- DB: `~/.hl/hl.db`
|
|
92
131
|
- Order config: `~/.hl/order-config.json`
|
|
@@ -96,7 +135,7 @@ Environment variable fallback (when DB account is not configured):
|
|
|
96
135
|
- `HYPERLIQUID_PRIVATE_KEY`
|
|
97
136
|
- `HYPERLIQUID_WALLET_ADDRESS`
|
|
98
137
|
|
|
99
|
-
|
|
138
|
+
### Security Notes
|
|
100
139
|
|
|
101
140
|
Account data stored in `~/.hl/hl.db` is encrypted at rest for these fields:
|
|
102
141
|
|
|
@@ -155,14 +194,16 @@ Practical guidance:
|
|
|
155
194
|
- Restrict which OS user can run this tool
|
|
156
195
|
- If you need stronger protection, use disk encryption as the higher-level control
|
|
157
196
|
|
|
158
|
-
##
|
|
197
|
+
## Development
|
|
198
|
+
|
|
199
|
+
### Run for Development
|
|
159
200
|
|
|
160
201
|
```bash
|
|
161
202
|
cd hl
|
|
162
203
|
PYTHONPATH=src python -m hl_cli.cli.argparse_main --help
|
|
163
204
|
```
|
|
164
205
|
|
|
165
|
-
|
|
206
|
+
### JSON Pattern Tests
|
|
166
207
|
|
|
167
208
|
`tests/` validates that every subcommand pattern produces parseable raw JSON output in `--json` mode.
|
|
168
209
|
|
|
@@ -171,29 +212,45 @@ cd hl
|
|
|
171
212
|
PYTHONPATH=src python -m unittest -v tests.test_json_patterns
|
|
172
213
|
```
|
|
173
214
|
|
|
174
|
-
##
|
|
215
|
+
## Order Features
|
|
216
|
+
|
|
217
|
+
Order side semantics:
|
|
218
|
+
|
|
219
|
+
- `buy` / `sell` are for spot markets
|
|
220
|
+
- `long` / `short` are for perp markets
|
|
221
|
+
- `close` is for closing an open perp position
|
|
222
|
+
|
|
223
|
+
### TWAP Orders
|
|
175
224
|
|
|
176
225
|
`hyperliquid-python-sdk` does not provide a high-level TWAP method, so this CLI signs and submits the official
|
|
177
226
|
`exchange` actions `twapOrder` / `twapCancel`.
|
|
178
227
|
|
|
228
|
+
TWAP is perp-only, so use `long` / `short`.
|
|
229
|
+
|
|
179
230
|
```bash
|
|
180
231
|
# 30-minute native TWAP
|
|
181
|
-
hl order twap
|
|
232
|
+
hl order twap long 1.0 BTC 30
|
|
182
233
|
|
|
183
234
|
# Derive total TWAP size from USD margin (stake * leverage)
|
|
184
|
-
hl order twap
|
|
235
|
+
hl order twap long 0 BTC 30 --stake 5
|
|
185
236
|
|
|
186
237
|
# Compatibility format: 5,10 is sent as total 50 minutes
|
|
187
|
-
hl order twap
|
|
238
|
+
hl order twap short 2.0 ETH 5,10 --randomize
|
|
188
239
|
|
|
189
240
|
# Cancel TWAP
|
|
190
241
|
hl order twap-cancel BTC 12345
|
|
191
242
|
```
|
|
192
243
|
|
|
193
|
-
|
|
244
|
+
### Stake-Based Orders
|
|
194
245
|
|
|
195
246
|
`--stake` is used by the CLI to derive order size.
|
|
196
247
|
|
|
248
|
+
Mode-specific behavior:
|
|
249
|
+
|
|
250
|
+
- `buy` / `sell` derive spot order size
|
|
251
|
+
- `long` / `short` derive perp order size
|
|
252
|
+
- `--leverage`, `--cross`, `--isolated`, and `--reduce-only` are only supported with `long` / `short`
|
|
253
|
+
|
|
197
254
|
- If you pass `--stake 50 --leverage 20`, the CLI derives size from about `$1000`
|
|
198
255
|
of notional (`50 * 20`).
|
|
199
256
|
- If you pass `--stake 50` without `--leverage`, the CLI derives size from about
|
|
@@ -216,17 +273,17 @@ So:
|
|
|
216
273
|
shown later in `hl account positions`
|
|
217
274
|
|
|
218
275
|
```bash
|
|
219
|
-
#
|
|
220
|
-
hl order market buy
|
|
276
|
+
# Spot buy: CLI sizes the order from about $50 of spot notional
|
|
277
|
+
hl order market buy @142 --stake 50
|
|
221
278
|
|
|
222
|
-
#
|
|
223
|
-
hl order market
|
|
279
|
+
# Spot sell: CLI sizes the order from about $50 of spot notional
|
|
280
|
+
hl order market sell @142 --stake 50
|
|
224
281
|
|
|
225
|
-
#
|
|
226
|
-
hl order limit
|
|
282
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
283
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
227
284
|
|
|
228
|
-
#
|
|
229
|
-
hl order market
|
|
285
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
286
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
230
287
|
|
|
231
288
|
# Example:
|
|
232
289
|
# BTC at 69,000
|
|
@@ -238,8 +295,8 @@ hl order market buy BTC --stake 50 --leverage 20 --isolated
|
|
|
238
295
|
# - --stake 50 --leverage 20 => about 0.2475 ETH
|
|
239
296
|
|
|
240
297
|
# Set leverage and margin mode at order time
|
|
241
|
-
hl order limit
|
|
242
|
-
hl order market
|
|
298
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
299
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
243
300
|
|
|
244
301
|
# Set leverage directly
|
|
245
302
|
hl order set-leverage BTC 20 --cross
|
|
@@ -259,7 +316,9 @@ hl order tpsl ETH --tp 1900 --sl 1800
|
|
|
259
316
|
hl order tpsl ETH --sl 1800 --ratio 0.5
|
|
260
317
|
```
|
|
261
318
|
|
|
262
|
-
##
|
|
319
|
+
## Project
|
|
320
|
+
|
|
321
|
+
### Acknowledgments
|
|
263
322
|
|
|
264
323
|
- https://app.hyperliquid.xyz/
|
|
265
324
|
- https://github.com/chrisling-dev/hyperliquid-cli
|
|
@@ -1,6 +1,43 @@
|
|
|
1
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
3
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
|
4
|
+
|
|
5
|
+
- [Hyperliquid CLI (Python)](#hyperliquid-cli-python)
|
|
6
|
+
- [Setup](#setup)
|
|
7
|
+
- [Requirements](#requirements)
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Bash Completion](#bash-completion)
|
|
10
|
+
- [CLI Basics](#cli-basics)
|
|
11
|
+
- [Global Options](#global-options)
|
|
12
|
+
- [Supported Commands](#supported-commands)
|
|
13
|
+
- [Configuration](#configuration)
|
|
14
|
+
- [Security Notes](#security-notes)
|
|
15
|
+
- [Development](#development)
|
|
16
|
+
- [Run for Development](#run-for-development)
|
|
17
|
+
- [JSON Pattern Tests](#json-pattern-tests)
|
|
18
|
+
- [Order Features](#order-features)
|
|
19
|
+
- [TWAP Orders](#twap-orders)
|
|
20
|
+
- [Stake-Based Orders](#stake-based-orders)
|
|
21
|
+
- [Project](#project)
|
|
22
|
+
- [Acknowledgments](#acknowledgments)
|
|
23
|
+
|
|
24
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
25
|
+
|
|
1
26
|
# Hyperliquid CLI (Python)
|
|
2
27
|
|
|
3
|
-
|
|
28
|
+
Python CLI for Hyperliquid account management, market data, and order execution.
|
|
29
|
+
|
|
30
|
+
## Setup
|
|
31
|
+
|
|
32
|
+
### Requirements
|
|
33
|
+
|
|
34
|
+
- Python 3.10+
|
|
35
|
+
- `hyperliquid-python-sdk` for API interactions
|
|
36
|
+
- `rich` for pretty console output
|
|
37
|
+
- `eth-account` for key management
|
|
38
|
+
- Optional: `make` for installation and uninstallation scripts
|
|
39
|
+
|
|
40
|
+
### Installation
|
|
4
41
|
|
|
5
42
|
Install from git and also set up Bash completion with `make install`:
|
|
6
43
|
|
|
@@ -14,7 +51,7 @@ Install from source for local development:
|
|
|
14
51
|
|
|
15
52
|
```bash
|
|
16
53
|
cd hl
|
|
17
|
-
pip install -e .
|
|
54
|
+
python3 -m pip install --user -e .
|
|
18
55
|
```
|
|
19
56
|
|
|
20
57
|
Install from PyPI:
|
|
@@ -29,7 +66,7 @@ After installation, the `hl` command is available:
|
|
|
29
66
|
hl --help
|
|
30
67
|
```
|
|
31
68
|
|
|
32
|
-
|
|
69
|
+
### Bash Completion
|
|
33
70
|
|
|
34
71
|
`hl` can print a Bash completion script for top-level commands and subcommands.
|
|
35
72
|
|
|
@@ -57,12 +94,14 @@ To remove the package and any managed `~/.bashrc` completion line:
|
|
|
57
94
|
make uninstall
|
|
58
95
|
```
|
|
59
96
|
|
|
60
|
-
##
|
|
97
|
+
## CLI Basics
|
|
98
|
+
|
|
99
|
+
### Global Options
|
|
61
100
|
|
|
62
101
|
- `--json` Output JSON
|
|
63
102
|
- `--testnet` Use testnet
|
|
64
103
|
|
|
65
|
-
|
|
104
|
+
### Supported Commands
|
|
66
105
|
|
|
67
106
|
- `hl account add|ls|set-default|remove`
|
|
68
107
|
- `hl account positions|orders|balances|portfolio`
|
|
@@ -71,7 +110,7 @@ make uninstall
|
|
|
71
110
|
- `hl markets ls|search`
|
|
72
111
|
- `hl referral set|status`
|
|
73
112
|
|
|
74
|
-
|
|
113
|
+
### Configuration
|
|
75
114
|
|
|
76
115
|
- DB: `~/.hl/hl.db`
|
|
77
116
|
- Order config: `~/.hl/order-config.json`
|
|
@@ -81,7 +120,7 @@ Environment variable fallback (when DB account is not configured):
|
|
|
81
120
|
- `HYPERLIQUID_PRIVATE_KEY`
|
|
82
121
|
- `HYPERLIQUID_WALLET_ADDRESS`
|
|
83
122
|
|
|
84
|
-
|
|
123
|
+
### Security Notes
|
|
85
124
|
|
|
86
125
|
Account data stored in `~/.hl/hl.db` is encrypted at rest for these fields:
|
|
87
126
|
|
|
@@ -140,14 +179,16 @@ Practical guidance:
|
|
|
140
179
|
- Restrict which OS user can run this tool
|
|
141
180
|
- If you need stronger protection, use disk encryption as the higher-level control
|
|
142
181
|
|
|
143
|
-
##
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
### Run for Development
|
|
144
185
|
|
|
145
186
|
```bash
|
|
146
187
|
cd hl
|
|
147
188
|
PYTHONPATH=src python -m hl_cli.cli.argparse_main --help
|
|
148
189
|
```
|
|
149
190
|
|
|
150
|
-
|
|
191
|
+
### JSON Pattern Tests
|
|
151
192
|
|
|
152
193
|
`tests/` validates that every subcommand pattern produces parseable raw JSON output in `--json` mode.
|
|
153
194
|
|
|
@@ -156,29 +197,45 @@ cd hl
|
|
|
156
197
|
PYTHONPATH=src python -m unittest -v tests.test_json_patterns
|
|
157
198
|
```
|
|
158
199
|
|
|
159
|
-
##
|
|
200
|
+
## Order Features
|
|
201
|
+
|
|
202
|
+
Order side semantics:
|
|
203
|
+
|
|
204
|
+
- `buy` / `sell` are for spot markets
|
|
205
|
+
- `long` / `short` are for perp markets
|
|
206
|
+
- `close` is for closing an open perp position
|
|
207
|
+
|
|
208
|
+
### TWAP Orders
|
|
160
209
|
|
|
161
210
|
`hyperliquid-python-sdk` does not provide a high-level TWAP method, so this CLI signs and submits the official
|
|
162
211
|
`exchange` actions `twapOrder` / `twapCancel`.
|
|
163
212
|
|
|
213
|
+
TWAP is perp-only, so use `long` / `short`.
|
|
214
|
+
|
|
164
215
|
```bash
|
|
165
216
|
# 30-minute native TWAP
|
|
166
|
-
hl order twap
|
|
217
|
+
hl order twap long 1.0 BTC 30
|
|
167
218
|
|
|
168
219
|
# Derive total TWAP size from USD margin (stake * leverage)
|
|
169
|
-
hl order twap
|
|
220
|
+
hl order twap long 0 BTC 30 --stake 5
|
|
170
221
|
|
|
171
222
|
# Compatibility format: 5,10 is sent as total 50 minutes
|
|
172
|
-
hl order twap
|
|
223
|
+
hl order twap short 2.0 ETH 5,10 --randomize
|
|
173
224
|
|
|
174
225
|
# Cancel TWAP
|
|
175
226
|
hl order twap-cancel BTC 12345
|
|
176
227
|
```
|
|
177
228
|
|
|
178
|
-
|
|
229
|
+
### Stake-Based Orders
|
|
179
230
|
|
|
180
231
|
`--stake` is used by the CLI to derive order size.
|
|
181
232
|
|
|
233
|
+
Mode-specific behavior:
|
|
234
|
+
|
|
235
|
+
- `buy` / `sell` derive spot order size
|
|
236
|
+
- `long` / `short` derive perp order size
|
|
237
|
+
- `--leverage`, `--cross`, `--isolated`, and `--reduce-only` are only supported with `long` / `short`
|
|
238
|
+
|
|
182
239
|
- If you pass `--stake 50 --leverage 20`, the CLI derives size from about `$1000`
|
|
183
240
|
of notional (`50 * 20`).
|
|
184
241
|
- If you pass `--stake 50` without `--leverage`, the CLI derives size from about
|
|
@@ -201,17 +258,17 @@ So:
|
|
|
201
258
|
shown later in `hl account positions`
|
|
202
259
|
|
|
203
260
|
```bash
|
|
204
|
-
#
|
|
205
|
-
hl order market buy
|
|
261
|
+
# Spot buy: CLI sizes the order from about $50 of spot notional
|
|
262
|
+
hl order market buy @142 --stake 50
|
|
206
263
|
|
|
207
|
-
#
|
|
208
|
-
hl order market
|
|
264
|
+
# Spot sell: CLI sizes the order from about $50 of spot notional
|
|
265
|
+
hl order market sell @142 --stake 50
|
|
209
266
|
|
|
210
|
-
#
|
|
211
|
-
hl order limit
|
|
267
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
268
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
212
269
|
|
|
213
|
-
#
|
|
214
|
-
hl order market
|
|
270
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
271
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
215
272
|
|
|
216
273
|
# Example:
|
|
217
274
|
# BTC at 69,000
|
|
@@ -223,8 +280,8 @@ hl order market buy BTC --stake 50 --leverage 20 --isolated
|
|
|
223
280
|
# - --stake 50 --leverage 20 => about 0.2475 ETH
|
|
224
281
|
|
|
225
282
|
# Set leverage and margin mode at order time
|
|
226
|
-
hl order limit
|
|
227
|
-
hl order market
|
|
283
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
284
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
228
285
|
|
|
229
286
|
# Set leverage directly
|
|
230
287
|
hl order set-leverage BTC 20 --cross
|
|
@@ -244,7 +301,9 @@ hl order tpsl ETH --tp 1900 --sl 1800
|
|
|
244
301
|
hl order tpsl ETH --sl 1800 --ratio 0.5
|
|
245
302
|
```
|
|
246
303
|
|
|
247
|
-
##
|
|
304
|
+
## Project
|
|
305
|
+
|
|
306
|
+
### Acknowledgments
|
|
248
307
|
|
|
249
308
|
- https://app.hyperliquid.xyz/
|
|
250
309
|
- https://github.com/chrisling-dev/hyperliquid-cli
|