hyperliquid-cli-python 0.1.4__tar.gz → 0.1.6__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/src/hyperliquid_cli_python.egg-info → hyperliquid_cli_python-0.1.6}/PKG-INFO +91 -28
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/README.md +90 -27
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/pyproject.toml +1 -1
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/cli/argparse_main.py +38 -181
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/cli/markets_tui.py +0 -12
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/cli/runtime.py +0 -7
- hyperliquid_cli_python-0.1.6/src/hl_cli/commands/account.py +302 -0
- hyperliquid_cli_python-0.1.6/src/hl_cli/commands/app.py +135 -0
- hyperliquid_cli_python-0.1.6/src/hl_cli/commands/asset.py +122 -0
- hyperliquid_cli_python-0.1.6/src/hl_cli/commands/common.py +75 -0
- hyperliquid_cli_python-0.1.6/src/hl_cli/commands/markets.py +310 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/commands/order.py +217 -73
- hyperliquid_cli_python-0.1.6/src/hl_cli/commands/referral.py +18 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/core/context.py +3 -19
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/core/order_config.py +0 -2
- hyperliquid_cli_python-0.1.6/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.6/src/hl_cli/infra/account_repo.py +19 -118
- hyperliquid_cli_python-0.1.6/src/hl_cli/infra/db.py +41 -0
- hyperliquid_cli_python-0.1.6/src/hl_cli/infra/db_crypto.py +77 -0
- hyperliquid_cli_python-0.1.6/src/hl_cli/infra/twap_registry.py +144 -0
- hyperliquid_cli_python-0.1.6/src/hl_cli/services/account_fetch.py +93 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/utils/market_table.py +0 -4
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/utils/output.py +0 -22
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/utils/validators.py +7 -9
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/utils/watch.py +0 -1
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6/src/hyperliquid_cli_python.egg-info}/PKG-INFO +91 -28
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hyperliquid_cli_python.egg-info/SOURCES.txt +12 -1
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/tests/test_account_testnet_mode.py +3 -8
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/tests/test_accounts_networks.py +0 -2
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/tests/test_completion.py +0 -3
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/tests/test_json_patterns.py +2 -5
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/tests/test_markets_testnet_mode.py +2 -7
- hyperliquid_cli_python-0.1.6/tests/test_order_testnet_routing.py +97 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/tests/test_testnet_context.py +1 -2
- hyperliquid_cli_python-0.1.6/tests/test_twap_registry.py +44 -0
- 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.6}/LICENSE +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/setup.cfg +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/cli/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/commands/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/core/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/infra/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/infra/paths.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hl_cli/utils/__init__.py +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hyperliquid_cli_python.egg-info/dependency_links.txt +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hyperliquid_cli_python.egg-info/entry_points.txt +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/src/hyperliquid_cli_python.egg-info/requires.txt +0 -0
- {hyperliquid_cli_python-0.1.4 → hyperliquid_cli_python-0.1.6}/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.6
|
|
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,13 +66,13 @@ 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:
|
|
36
73
|
|
|
37
74
|
```bash
|
|
38
|
-
pip install hyperliquid-cli-python
|
|
75
|
+
pip install --user hyperliquid-cli-python
|
|
39
76
|
```
|
|
40
77
|
|
|
41
78
|
After installation, the `hl` command is available:
|
|
@@ -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,49 @@ 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
|
-
`exchange` actions `twapOrder` / `twapCancel`.
|
|
226
|
+
`exchange` actions `twapOrder` / `twapCancel`. Successful submissions store the returned `twapId`
|
|
227
|
+
locally under `~/.hl/twap_orders.json` so the CLI can show and cancel tracked TWAPs later.
|
|
228
|
+
|
|
229
|
+
TWAP is perp-only, so use `long` / `short`.
|
|
178
230
|
|
|
179
231
|
```bash
|
|
180
232
|
# 30-minute native TWAP
|
|
181
|
-
hl order twap
|
|
233
|
+
hl order twap long 1.0 BTC 30
|
|
182
234
|
|
|
183
235
|
# Derive total TWAP size from USD margin (stake * leverage)
|
|
184
|
-
hl order twap
|
|
236
|
+
hl order twap long 0 BTC 30 --stake 5
|
|
185
237
|
|
|
186
238
|
# Compatibility format: 5,10 is sent as total 50 minutes
|
|
187
|
-
hl order twap
|
|
239
|
+
hl order twap short 2.0 ETH 5,10 --randomize
|
|
188
240
|
|
|
189
241
|
# Cancel TWAP
|
|
190
242
|
hl order twap-cancel BTC 12345
|
|
243
|
+
|
|
244
|
+
# Or list tracked active TWAPs and pick one interactively
|
|
245
|
+
hl order twap-cancel
|
|
191
246
|
```
|
|
192
247
|
|
|
193
|
-
|
|
248
|
+
### Stake-Based Orders
|
|
194
249
|
|
|
195
250
|
`--stake` is used by the CLI to derive order size.
|
|
196
251
|
|
|
252
|
+
Mode-specific behavior:
|
|
253
|
+
|
|
254
|
+
- `buy` / `sell` derive spot order size
|
|
255
|
+
- `long` / `short` derive perp order size
|
|
256
|
+
- `--leverage`, `--cross`, `--isolated`, and `--reduce-only` are only supported with `long` / `short`
|
|
257
|
+
|
|
197
258
|
- If you pass `--stake 50 --leverage 20`, the CLI derives size from about `$1000`
|
|
198
259
|
of notional (`50 * 20`).
|
|
199
260
|
- If you pass `--stake 50` without `--leverage`, the CLI derives size from about
|
|
@@ -216,17 +277,17 @@ So:
|
|
|
216
277
|
shown later in `hl account positions`
|
|
217
278
|
|
|
218
279
|
```bash
|
|
219
|
-
#
|
|
220
|
-
hl order market buy
|
|
280
|
+
# Spot buy: CLI sizes the order from about $50 of spot notional
|
|
281
|
+
hl order market buy @142 --stake 50
|
|
221
282
|
|
|
222
|
-
#
|
|
223
|
-
hl order market
|
|
283
|
+
# Spot sell: CLI sizes the order from about $50 of spot notional
|
|
284
|
+
hl order market sell @142 --stake 50
|
|
224
285
|
|
|
225
|
-
#
|
|
226
|
-
hl order limit
|
|
286
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
287
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
227
288
|
|
|
228
|
-
#
|
|
229
|
-
hl order market
|
|
289
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
290
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
230
291
|
|
|
231
292
|
# Example:
|
|
232
293
|
# BTC at 69,000
|
|
@@ -238,8 +299,8 @@ hl order market buy BTC --stake 50 --leverage 20 --isolated
|
|
|
238
299
|
# - --stake 50 --leverage 20 => about 0.2475 ETH
|
|
239
300
|
|
|
240
301
|
# Set leverage and margin mode at order time
|
|
241
|
-
hl order limit
|
|
242
|
-
hl order market
|
|
302
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
303
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
243
304
|
|
|
244
305
|
# Set leverage directly
|
|
245
306
|
hl order set-leverage BTC 20 --cross
|
|
@@ -259,7 +320,9 @@ hl order tpsl ETH --tp 1900 --sl 1800
|
|
|
259
320
|
hl order tpsl ETH --sl 1800 --ratio 0.5
|
|
260
321
|
```
|
|
261
322
|
|
|
262
|
-
##
|
|
323
|
+
## Project
|
|
324
|
+
|
|
325
|
+
### Acknowledgments
|
|
263
326
|
|
|
264
327
|
- https://app.hyperliquid.xyz/
|
|
265
328
|
- 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,13 +51,13 @@ 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:
|
|
21
58
|
|
|
22
59
|
```bash
|
|
23
|
-
pip install hyperliquid-cli-python
|
|
60
|
+
pip install --user hyperliquid-cli-python
|
|
24
61
|
```
|
|
25
62
|
|
|
26
63
|
After installation, the `hl` command is available:
|
|
@@ -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,49 @@ 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
|
-
`exchange` actions `twapOrder` / `twapCancel`.
|
|
211
|
+
`exchange` actions `twapOrder` / `twapCancel`. Successful submissions store the returned `twapId`
|
|
212
|
+
locally under `~/.hl/twap_orders.json` so the CLI can show and cancel tracked TWAPs later.
|
|
213
|
+
|
|
214
|
+
TWAP is perp-only, so use `long` / `short`.
|
|
163
215
|
|
|
164
216
|
```bash
|
|
165
217
|
# 30-minute native TWAP
|
|
166
|
-
hl order twap
|
|
218
|
+
hl order twap long 1.0 BTC 30
|
|
167
219
|
|
|
168
220
|
# Derive total TWAP size from USD margin (stake * leverage)
|
|
169
|
-
hl order twap
|
|
221
|
+
hl order twap long 0 BTC 30 --stake 5
|
|
170
222
|
|
|
171
223
|
# Compatibility format: 5,10 is sent as total 50 minutes
|
|
172
|
-
hl order twap
|
|
224
|
+
hl order twap short 2.0 ETH 5,10 --randomize
|
|
173
225
|
|
|
174
226
|
# Cancel TWAP
|
|
175
227
|
hl order twap-cancel BTC 12345
|
|
228
|
+
|
|
229
|
+
# Or list tracked active TWAPs and pick one interactively
|
|
230
|
+
hl order twap-cancel
|
|
176
231
|
```
|
|
177
232
|
|
|
178
|
-
|
|
233
|
+
### Stake-Based Orders
|
|
179
234
|
|
|
180
235
|
`--stake` is used by the CLI to derive order size.
|
|
181
236
|
|
|
237
|
+
Mode-specific behavior:
|
|
238
|
+
|
|
239
|
+
- `buy` / `sell` derive spot order size
|
|
240
|
+
- `long` / `short` derive perp order size
|
|
241
|
+
- `--leverage`, `--cross`, `--isolated`, and `--reduce-only` are only supported with `long` / `short`
|
|
242
|
+
|
|
182
243
|
- If you pass `--stake 50 --leverage 20`, the CLI derives size from about `$1000`
|
|
183
244
|
of notional (`50 * 20`).
|
|
184
245
|
- If you pass `--stake 50` without `--leverage`, the CLI derives size from about
|
|
@@ -201,17 +262,17 @@ So:
|
|
|
201
262
|
shown later in `hl account positions`
|
|
202
263
|
|
|
203
264
|
```bash
|
|
204
|
-
#
|
|
205
|
-
hl order market buy
|
|
265
|
+
# Spot buy: CLI sizes the order from about $50 of spot notional
|
|
266
|
+
hl order market buy @142 --stake 50
|
|
206
267
|
|
|
207
|
-
#
|
|
208
|
-
hl order market
|
|
268
|
+
# Spot sell: CLI sizes the order from about $50 of spot notional
|
|
269
|
+
hl order market sell @142 --stake 50
|
|
209
270
|
|
|
210
|
-
#
|
|
211
|
-
hl order limit
|
|
271
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
272
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
212
273
|
|
|
213
|
-
#
|
|
214
|
-
hl order market
|
|
274
|
+
# Perp long with leverage 20: CLI sizes the order from about $1,000 of BTC notional
|
|
275
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
215
276
|
|
|
216
277
|
# Example:
|
|
217
278
|
# BTC at 69,000
|
|
@@ -223,8 +284,8 @@ hl order market buy BTC --stake 50 --leverage 20 --isolated
|
|
|
223
284
|
# - --stake 50 --leverage 20 => about 0.2475 ETH
|
|
224
285
|
|
|
225
286
|
# Set leverage and margin mode at order time
|
|
226
|
-
hl order limit
|
|
227
|
-
hl order market
|
|
287
|
+
hl order limit long BTC 65000 --stake 50 --leverage 20 --cross
|
|
288
|
+
hl order market long BTC --stake 50 --leverage 20 --isolated
|
|
228
289
|
|
|
229
290
|
# Set leverage directly
|
|
230
291
|
hl order set-leverage BTC 20 --cross
|
|
@@ -244,7 +305,9 @@ hl order tpsl ETH --tp 1900 --sl 1800
|
|
|
244
305
|
hl order tpsl ETH --sl 1800 --ratio 0.5
|
|
245
306
|
```
|
|
246
307
|
|
|
247
|
-
##
|
|
308
|
+
## Project
|
|
309
|
+
|
|
310
|
+
### Acknowledgments
|
|
248
311
|
|
|
249
312
|
- https://app.hyperliquid.xyz/
|
|
250
313
|
- https://github.com/chrisling-dev/hyperliquid-cli
|