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