hypertrader 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,416 @@
1
+ Metadata-Version: 2.4
2
+ Name: hypertrader
3
+ Version: 0.1.0
4
+ Summary: Async Hyperliquid trading helper built on the async SDK.
5
+ Author: darkerego
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: eth-account
15
+ Requires-Dist: hyperliquid-python-sdk-async
16
+ Requires-Dist: python-dotenv
17
+ Requires-Dist: uvloop
18
+ Provides-Extra: auto
19
+ Requires-Dist: numpy; extra == "auto"
20
+ Requires-Dist: TA-Lib; extra == "auto"
21
+ Dynamic: author
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: license
26
+ Dynamic: provides-extra
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+ Dynamic: summary
30
+
31
+ # Hypertrader
32
+
33
+ Async Hyperliquid trading helper built around the async SDK from `darkerego/hyperliquid-python-sdk-async`.
34
+
35
+ The canonical bot file in this repo is [`hypertrader.py`](/media/anon/development/anon/PycharmProjects/hypertrader/hypertrader.py). It provides five modes:
36
+
37
+ - `enter`: top-of-book limit entry with modify-order repricing, optional market fallback, and TP/SL management
38
+ - `watch`: attach TP/SL management to newly opened or existing positions
39
+ - `trailing`: manage local trailing stops for open positions
40
+ - `auto`: TA-Lib multi-timeframe signal scanner that routes through the same bracket-entry path as `enter`
41
+ - `market_maker`: event-driven maker ladder that stays separate from the bracket and hidden-order logic
42
+
43
+ ## Behavior Summary
44
+
45
+ - Async SDK only: `Info` and `Exchange` are created and used asynchronously end-to-end.
46
+ - Websocket market data is enabled by default. Use `--no-websocket` to force HTTP polling only.
47
+ - HTTP remains the fallback and authoritative path for account state, reconciliation, candles, and trading actions.
48
+ - Entry logic uses `exchange.modify_order(...)` to move one working limit order instead of cancel/repost on every loop.
49
+ - Market fallback cleans up stale non-reduce-only entry orders before and after any market entry.
50
+ - TP reversal never crosses back through entry into loss territory.
51
+ - `--hide-orders` is available for `enter`, `watch`, `trailing`, and `auto`. It does not apply to `market_maker`.
52
+ - Runtime monitors print current uPnL, session realized PnL, and account balance.
53
+
54
+ ## Requirements
55
+
56
+ - Python 3.10+
57
+ - Hyperliquid account credentials
58
+ - Network access to Hyperliquid APIs
59
+ - Account created with referral code [DARKEREGO](https://app.hyperliquid.xyz/join/DARKEREGO) (see account creation [*])
60
+
61
+ Base dependencies:
62
+
63
+ ```bash
64
+ python3 -m venv .venv
65
+ . .venv/bin/activate
66
+ pip install --upgrade pip
67
+ pip install python-dotenv eth-account hyperliquid-python-sdk-async
68
+ ```
69
+
70
+ Optional `auto` mode dependencies:
71
+
72
+ ```bash
73
+ pip install numpy TA-Lib
74
+ ```
75
+
76
+ `auto` imports `numpy` and `talib` defensively, so the other modes can still run without TA-Lib installed.
77
+
78
+ Please see TA-Lib documentation if you need help installing the required binary library:
79
+
80
+ https://ta-lib.org/install/#linux
81
+
82
+
83
+ ## Configuration
84
+
85
+ 1) Create a hyperliquid account with referral code `DARKEREGO` with this URL:
86
+
87
+ [https://app.hyperliquid.xyz/join/DARKEREGO](https://app.hyperliquid.xyz/join/DARKEREGO)
88
+
89
+ 2) Once in HyperLiquid panel, click more -> API and create an API key.
90
+
91
+ - The API key is a private Ethereum key. Copy to clipboard and continue:
92
+
93
+ 3) Set credentials in the environment or a local `.env` file:
94
+
95
+ ```text
96
+ HYPERLIQUID_SECRET_KEY=...
97
+ HYPERLIQUID_ACCOUNT_ADDRESS=...
98
+ ```
99
+
100
+ - `HYPERLIQUID_SECRET_KEY`: private key for the trading wallet or API wallet (the API key you just created)
101
+ - `HYPERLIQUID_ACCOUNT_ADDRESS`: main account address used for the account state
102
+
103
+ Do not commit real credentials.
104
+
105
+ ## Quick Start
106
+
107
+ Show global help:
108
+
109
+ ```bash
110
+ python3 hypertrader.py --help
111
+ ```
112
+
113
+ Enter a long with a 1% TP and default half-TP stop:
114
+
115
+ ```bash
116
+ python3 hypertrader.py enter HYPE long --size 1 --take-profit-pct 0.01
117
+ ```
118
+
119
+ Enter with hidden local TP/SL targets:
120
+
121
+ ```bash
122
+ python3 hypertrader.py enter ETH short --size 0.25 --take-profit-pct 0.012 --hide-orders
123
+ ```
124
+
125
+ Enter, let TP level 1 fill, then cancel the rest of the ladder and trail the remainder:
126
+
127
+ ```bash
128
+ python3 hypertrader.py enter BTC long --size 0.1 --take-profit-pct 0.01 --trailing-tp
129
+ ```
130
+
131
+ Watch an existing position and attach management:
132
+
133
+ ```bash
134
+ python3 hypertrader.py watch BTC --take-profit-pct 0.01 --manage-existing
135
+ ```
136
+
137
+ Watch a position and switch from the TP ladder to a trailing TP after TP level 1 fills:
138
+
139
+ ```bash
140
+ python3 hypertrader.py watch BTC --take-profit-pct 0.01 --manage-existing --trailing-tp
141
+ ```
142
+
143
+ Run local trailing management:
144
+
145
+ ```bash
146
+ python3 hypertrader.py trailing BTC --trail-pct 0.01
147
+ ```
148
+
149
+ Dry-run auto mode across short intervals:
150
+
151
+ ```bash
152
+ python3 hypertrader.py auto SOL --intervals "1m 3m 5m" --size 10 --dry-run
153
+ ```
154
+
155
+ Run the market maker on testnet:
156
+
157
+ ```bash
158
+ python3 hypertrader.py market_maker HYPE --base-size 0.01 --testnet
159
+ ```
160
+
161
+ ## Commands
162
+
163
+ ### `enter`
164
+
165
+ Opens a position with a top-of-book limit order, reprices the same working order with `modify_order`, optionally falls back to market for the remainder, then manages TP/SL.
166
+
167
+ ```bash
168
+ python3 hypertrader.py enter COIN long|short --size SIZE [options]
169
+ ```
170
+
171
+ Key options:
172
+
173
+ - `--take-profit-pct`: TP target fraction
174
+ - `--stop-loss-pct`: SL fraction; defaults to `TP * 0.5` if TP is supplied
175
+ - `--take-profit-levels`: number of weighted TP ladder levels
176
+ - `--trailing-tp`: keep the TP ladder live, then switch to a local trailing TP after the configured TP level fills
177
+ - `--trailing-tp-trigger-level`: TP ladder level that must fill before trailing TP activates
178
+ - `--trailing-tp-remaining-levels`: switch the remaining ladder to a local trailing TP when this many TP levels are left
179
+ - `--trailing-tp-profit-pct`: trailing distance as a fraction of favorable unrealized profit
180
+ - `--entry-retries`: limit modify attempts before fallback
181
+ - `--entry-repost-interval`: seconds between modify attempts
182
+ - `--entry-tif`: entry limit TIF, `Alo` or `Gtc`
183
+ - `--tp-tif`: TP limit TIF, `Alo` or `Gtc`
184
+ - `--no-market-fallback`: disable remaining-size market entry
185
+ - `--market-slippage`: slippage fraction for market-style helpers
186
+ - `--keep-existing-tpsl`: preserve existing reduce-only TP/SL orders before entry
187
+ - `--tp-reversal-pct`: enable TP-reversal exits after the first TP zone is reached
188
+ - `--tp-reversal-limit-exit`: try a reduce-only limit exit plus protective stop before market fallback
189
+ - `--tp-reversal-stop-buffer-pct`: optional TP-reversal stop buffer
190
+ - `--hide-orders` or `-ho`: keep bracket targets local until they trigger
191
+ - `--testnet`
192
+ - `--no-websocket`
193
+
194
+ ### `watch`
195
+
196
+ Watches for matching positions and attaches TP/SL management. It can also manage positions that already exist at startup.
197
+
198
+ ```bash
199
+ python3 hypertrader.py watch [COIN] [options]
200
+ ```
201
+
202
+ Key options:
203
+
204
+ - `--take-profit-pct`
205
+ - `--stop-loss-pct`
206
+ - `--take-profit-levels`
207
+ - `--trailing-tp`
208
+ - `--trailing-tp-trigger-level`
209
+ - `--trailing-tp-remaining-levels`
210
+ - `--trailing-tp-profit-pct`
211
+ - `--poll-interval`
212
+ - `--manage-existing`
213
+ - `--tp-reversal-pct`
214
+ - `--tp-reversal-limit-exit`
215
+ - `--tp-reversal-stop-buffer-pct`
216
+ - `--tp-tif`
217
+ - `--market-slippage`
218
+ - `--keep-existing-tpsl`
219
+ - `--hide-orders` or `-ho`
220
+ - `--testnet`
221
+ - `--no-websocket`
222
+
223
+ ### `trailing`
224
+
225
+ Runs local trailing-stop management for open positions.
226
+
227
+ ```bash
228
+ python3 hypertrader.py trailing [COIN] [options]
229
+ ```
230
+
231
+ Key options:
232
+
233
+ - `--trail-pct`
234
+ - `--poll-interval`
235
+ - `--hide-orders` or `-ho`
236
+ - `--testnet`
237
+ - `--no-websocket`
238
+
239
+ `trailing` already keeps stops local. The hidden-order flag is accepted for CLI consistency.
240
+
241
+ ### `auto`
242
+
243
+ Scans one coin or the top perp markets using TA-Lib signals from:
244
+
245
+ - MACD
246
+ - Parabolic SAR
247
+ - ADX
248
+ - Bollinger Bands
249
+
250
+ Default intervals are `1h,15m,5m,1m`. With `--min-agreement 0`, all configured intervals must agree.
251
+
252
+ ```bash
253
+ python3 hypertrader.py auto [COIN] (--size SIZE | --size-pct SIZE_PCT) [options]
254
+ ```
255
+
256
+ Key options:
257
+
258
+ - `--size` or `--size-pct`
259
+ - `--top-markets`
260
+ - `--intervals`
261
+ - `--auto-periods`
262
+ - `--scan-interval`
263
+ - `--max-concurrent-scans`
264
+ - `--min-agreement`
265
+ - `--adx-threshold`
266
+ - `--macd-fast`
267
+ - `--macd-slow`
268
+ - `--macd-signal`
269
+ - `--sar-acceleration`
270
+ - `--sar-maximum`
271
+ - `--auto-sar-stop-on-shortest-interval`
272
+ - `--adx-timeperiod`
273
+ - `--bb-timeperiod`
274
+ - `--bb-dev`
275
+ - `--scalp`
276
+ - `--use-live-candle`
277
+ - `--take-profit-pct`: override Bollinger-derived TP
278
+ - `--min-take-profit-pct`
279
+ - `--max-take-profit-pct`
280
+ - `--stop-loss-pct`
281
+ - `--take-profit-levels`
282
+ - `--trailing-tp`
283
+ - `--trailing-tp-trigger-level`
284
+ - `--trailing-tp-remaining-levels`
285
+ - `--trailing-tp-profit-pct`
286
+ - `--entry-retries`
287
+ - `--entry-repost-interval`
288
+ - `--entry-tif`
289
+ - `--tp-tif`
290
+ - `--poll-interval`
291
+ - `--tp-reversal-pct`
292
+ - `--tp-reversal-limit-exit`
293
+ - `--tp-reversal-stop-buffer-pct`
294
+ - `--no-market-fallback`
295
+ - `--market-slippage`
296
+ - `--keep-existing-tpsl`
297
+ - `--dry-run`
298
+ - `--max-trades`
299
+ - `--cooldown-after-trade`
300
+ - `--loop-after-trade`
301
+ - `--exit-after-trade`
302
+ - `--max-coin-trades-per-session`
303
+ - `--coin-session-cooldown-seconds`
304
+ - `--coin-session-profit-target`
305
+ - `--coin-session-min-profit-to-lock`
306
+ - `--coin-session-giveback-pct`
307
+ - `--cooldown-after-loss-following-wins`
308
+ - `--session-profit-target`
309
+ - `--session-max-loss`
310
+ - `--session-giveback-pct`
311
+ - `--risk-session-log`
312
+ - `--ws-candles`
313
+ - `--hide-orders` or `-ho`
314
+ - `--testnet`
315
+ - `--no-websocket`
316
+
317
+ `auto` derives TP from Bollinger Bands unless `--take-profit-pct` overrides it. If TP is set and SL is omitted, SL defaults to half TP. Executions route through the same bracket-entry path used by `enter`.
318
+
319
+ Additional `auto` parameter notes:
320
+
321
+ - `--max-concurrent-scans`: limits how many markets are scanned in parallel in each auto loop.
322
+ - `--auto-sar-stop-on-shortest-interval`: uses the Parabolic SAR from the shortest configured interval as the live stop trigger for auto-managed positions instead of the default pct-based stop behavior.
323
+ - `--scalp`: requires additional shortest-interval Bollinger confirmation before entering.
324
+ - `--max-coin-trades-per-session`: caps completed trade cycles per coin before that coin is cooled down.
325
+ - `--coin-session-cooldown-seconds`: duration of the per-coin cooldown window after a coin-level stop condition triggers.
326
+ - `--coin-session-profit-target`: pauses a coin after it reaches the configured realized PnL target for the current auto session.
327
+ - `--coin-session-min-profit-to-lock`: enables per-coin giveback protection only after realized PnL first reaches this minimum lock threshold.
328
+ - `--coin-session-giveback-pct`: pauses a coin after it gives back the configured fraction from its peak realized PnL.
329
+ - `--cooldown-after-loss-following-wins`: pauses a coin after a losing trade that follows at least N consecutive winning cycles.
330
+ - `--session-profit-target`: stops the entire auto session once total realized PnL reaches the target.
331
+ - `--session-max-loss`: stops the entire auto session once total realized PnL falls to `-N` or below.
332
+ - `--session-giveback-pct`: stops the entire auto session after giving back the configured fraction from peak realized PnL.
333
+ - `--risk-session-log`: writes auto risk-session events to a JSONL file path you provide.
334
+ - `--ws-candles`: experimental candle mode that seeds each `(coin, interval)` via `candleSnapshot`, then keeps them updated from websocket candle messages.
335
+
336
+ Example with newer auto risk controls:
337
+
338
+ ```bash
339
+ python3 hypertrader.py auto SOL --intervals "1m 5m 15m" --size 10 --dry-run --max-concurrent-scans 2 --coin-session-profit-target 25 --coin-session-giveback-pct 0.3 --session-max-loss 50
340
+ ```
341
+
342
+ ### `market_maker`
343
+
344
+ Runs an event-driven maker ladder around a computed center price.
345
+
346
+ ```bash
347
+ python3 hypertrader.py market_maker COIN [options]
348
+ ```
349
+
350
+ Key options:
351
+
352
+ - `--interval`
353
+ - `--periods`
354
+ - `--levels`
355
+ - `--base-size`
356
+ - `--loop-sleep`
357
+ - `--min-edge-pct`
358
+ - `--rebalance-threshold-pct`
359
+ - `--protect-close-pct`
360
+ - `--testnet`
361
+ - `--no-websocket`
362
+
363
+ `market_maker` is intentionally separate from hidden-order bracket behavior.
364
+
365
+ ## Hidden Orders
366
+
367
+ `--hide-orders` keeps TP/SL targets in memory instead of placing exchange-side bracket orders immediately. This prevents
368
+ exchange market maker bots from being able to see where your stops and take profit orders are.
369
+
370
+ When enabled:
371
+
372
+ - no exchange-side stop-loss order is placed when management starts
373
+ - no exchange-side TP ladder is placed when management starts
374
+ - hidden targets are still calculated and displayed
375
+ - a hidden stop hit cancels any reduce-only TP orders and closes the position with `exchange.market_close(...)`
376
+ - a hidden TP level places its reduce-only post-only TP order only when the target is hit
377
+ - scale-ins rebase the hidden TP/SL targets to the new average entry and current size
378
+
379
+ This flag applies to `enter`, `watch`, `trailing`, and `auto`, but not `market_maker`.
380
+
381
+ ## Websocket And HTTP
382
+
383
+ The bot creates `Info` with websocket support enabled unless `--no-websocket` is supplied:
384
+
385
+ ```python
386
+ info = await Info.create(api_url, skip_ws=(not use_websocket))
387
+ ```
388
+
389
+ The websocket cache is used as the fast path for market data such as mids, best bid/offer, and account event streams. HTTP calls remain in place for authoritative snapshots, reconciliation, candles, and trade actions.
390
+
391
+ ## Logging
392
+
393
+ Runtime logs are written to [`logs/hypertrader.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/hypertrader.log).
394
+ Completed auto-trades are appended to [`logs/auto_trades.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/auto_trades.log).
395
+
396
+ ## Validation
397
+
398
+ Minimum validation after changes:
399
+
400
+ ```bash
401
+ python3 -m py_compile hypertrader.py
402
+ python3 hypertrader.py --help
403
+ python3 hypertrader.py enter --help
404
+ python3 hypertrader.py watch --help
405
+ python3 hypertrader.py trailing --help
406
+ python3 hypertrader.py auto --help
407
+ python3 hypertrader.py market_maker --help
408
+ ```
409
+
410
+ Suggested non-live auto check:
411
+
412
+ ```bash
413
+ python3 hypertrader.py auto SOL --intervals "1m 3m 5m" --size 10 --dry-run
414
+ ```
415
+
416
+ Do not run live trading commands unless you intend to trade.
@@ -0,0 +1,16 @@
1
+ hypertrader.py,sha256=A1Zy6s3DTh---75Ng4XdhnqdI8xkxu26gIQCL6-yoKE,42268
2
+ modes/auto_trader.py,sha256=nBtEj9A-h2N7-V8Kg1wHETaUEkeacZZ39XaV88EtKU0,88152
3
+ modes/market_maker.py,sha256=6FXTcO6DsYgHgFOWoeXQyUERkX3WdU31A5CRhxdAf0I,16415
4
+ modes/position_management.py,sha256=wbFm1QCfS6Hji_hDe7uhEeKu_SNRcfKlPwTLTvdSmTk,85565
5
+ modes/position_watcher.py,sha256=Xm1LZkLY3GhI6je61y_TYQAcubN8eykYIrjTGs-wkOI,19131
6
+ modes/trailing_stop.py,sha256=l9NZwq_Xy58C-DroJrRHmVsiSeY1irZ02QDMFtoatdc,12607
7
+ utils/constants.py,sha256=LIXf-XkSqdZDc4v_EHG_7GLfm8Cb-gjV2h-l04DXRCk,728
8
+ utils/helpers.py,sha256=-eR314cblRbdMgvl3f4M4I1y1MB0Sly54a102ob7_N0,36273
9
+ utils/style.py,sha256=aXoScLJXOO3EbD7LW0DdtDpwRPFY3PKK48wgHUuv7_8,5127
10
+ utils/timer.py,sha256=HK1s1isDC3Ti81ZHgd8hP32zRaLzROeXd2qj6jaYafQ,292
11
+ utils/worker.py,sha256=nynb_U8cobWaG03bSqkGT9WLvp2Iz0ZKVE9oszNfaow,6115
12
+ hypertrader-0.1.0.dist-info/METADATA,sha256=3tssNJbW6aoxt1_qprg4u4vQNQlR1NwTAzERg0IFO6g,14073
13
+ hypertrader-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
14
+ hypertrader-0.1.0.dist-info/entry_points.txt,sha256=sK0zqwHQC90755wyHN_Cjf1IzNNIkVeB3JpM9hUyRwA,49
15
+ hypertrader-0.1.0.dist-info/top_level.txt,sha256=WO3FvK8GD6Fgod5OrwvxvAv1ie1xXfeVYeDfiiiJue0,24
16
+ hypertrader-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ hypertrader = hypertrader:main
@@ -0,0 +1,3 @@
1
+ hypertrader
2
+ modes
3
+ utils