hypertrader 0.1.8__tar.gz → 0.1.9__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.
Files changed (42) hide show
  1. {hypertrader-0.1.8 → hypertrader-0.1.9}/PKG-INFO +54 -7
  2. {hypertrader-0.1.8 → hypertrader-0.1.9}/README.md +53 -6
  3. {hypertrader-0.1.8 → hypertrader-0.1.9}/hypertrader.egg-info/PKG-INFO +54 -7
  4. {hypertrader-0.1.8 → hypertrader-0.1.9}/hypertrader.egg-info/SOURCES.txt +5 -0
  5. {hypertrader-0.1.8 → hypertrader-0.1.9}/hypertrader.py +92 -11
  6. {hypertrader-0.1.8 → hypertrader-0.1.9}/modes/auto_trader.py +234 -61
  7. {hypertrader-0.1.8 → hypertrader-0.1.9}/modes/position_management.py +27 -1
  8. {hypertrader-0.1.8 → hypertrader-0.1.9}/setup.py +1 -1
  9. hypertrader-0.1.9/strategies/fib_reversal.py +444 -0
  10. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/registry.py +4 -0
  11. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/reversal.py +1 -1
  12. hypertrader-0.1.9/tests/test_auto_dry_run.py +83 -0
  13. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_auto_strategy_registry.py +31 -3
  14. hypertrader-0.1.9/tests/test_fib_reversal_strategy.py +319 -0
  15. hypertrader-0.1.9/tests/test_simulated_logging.py +170 -0
  16. {hypertrader-0.1.8 → hypertrader-0.1.9}/utils/constants.py +1 -0
  17. hypertrader-0.1.9/utils/simulated_logging.py +26 -0
  18. {hypertrader-0.1.8 → hypertrader-0.1.9}/hypertrader.egg-info/dependency_links.txt +0 -0
  19. {hypertrader-0.1.8 → hypertrader-0.1.9}/hypertrader.egg-info/entry_points.txt +0 -0
  20. {hypertrader-0.1.8 → hypertrader-0.1.9}/hypertrader.egg-info/requires.txt +0 -0
  21. {hypertrader-0.1.8 → hypertrader-0.1.9}/hypertrader.egg-info/top_level.txt +0 -0
  22. {hypertrader-0.1.8 → hypertrader-0.1.9}/modes/market_maker.py +0 -0
  23. {hypertrader-0.1.8 → hypertrader-0.1.9}/modes/position_watcher.py +0 -0
  24. {hypertrader-0.1.8 → hypertrader-0.1.9}/modes/trailing_stop.py +0 -0
  25. {hypertrader-0.1.8 → hypertrader-0.1.9}/setup.cfg +0 -0
  26. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/__init__.py +0 -0
  27. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/base.py +0 -0
  28. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/default.py +0 -0
  29. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/orderflow_metrics.py +0 -0
  30. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/orderflow_models.py +0 -0
  31. {hypertrader-0.1.8 → hypertrader-0.1.9}/strategies/orderflow_pullback.py +0 -0
  32. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_async_hyperliquid.py +0 -0
  33. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_auto_trader_logging.py +0 -0
  34. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_market_ids.py +0 -0
  35. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_orderflow_metrics.py +0 -0
  36. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_orderflow_pullback_lifecycle.py +0 -0
  37. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_reversal_strategy.py +0 -0
  38. {hypertrader-0.1.8 → hypertrader-0.1.9}/tests/test_trailing_stop.py +0 -0
  39. {hypertrader-0.1.8 → hypertrader-0.1.9}/utils/helpers.py +0 -0
  40. {hypertrader-0.1.8 → hypertrader-0.1.9}/utils/style.py +0 -0
  41. {hypertrader-0.1.8 → hypertrader-0.1.9}/utils/timer.py +0 -0
  42. {hypertrader-0.1.8 → hypertrader-0.1.9}/utils/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypertrader
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Async Hyperliquid trading helper built on the async SDK.
5
5
  Author: darkerego
6
6
  License: MIT
@@ -66,10 +66,10 @@ The canonical bot file in this repo is [`hypertrader.py`](/media/anon/developmen
66
66
  - Network access to Hyperliquid APIs
67
67
  - Account created with referral code [DARKEREGO](https://app.hyperliquid.xyz/join/DARKEREGO) (see account creation [*])
68
68
 
69
- Install from pip:
69
+ Install from pip: https://pypi.org/project/hypertrader
70
70
 
71
71
  <pre>
72
- pip install hypertrader[auto]
72
+ pip install hypertrader[auto] --upgrade
73
73
  </pre>
74
74
 
75
75
  Base dependencies:
@@ -282,6 +282,7 @@ Key options:
282
282
 
283
283
  - `default`: the existing MACD/SAR/ADX/Bollinger auto trader and the implicit default when `--strategy` is omitted
284
284
  - `orderflow_pullback`: order-flow-confirmed trend pullback scalp strategy, also available as `of_pullback` and `orderflow`
285
+ - `fib_reversal`: Fibonacci pullbacks in the original impulse direction; aliases `fib` and `fibonacci`
285
286
  - `reversal`: a closed-candle trend-exhaustion, structure-break, and retest strategy
286
287
 
287
288
  The strategy selection changes the signal engine only. Shared sizing, risk controls, modify-order entry, market-fallback cleanup, hidden-order behavior, and bracket management still run through the same common auto execution path.
@@ -301,8 +302,7 @@ python3 hypertrader.py auto [COIN] (--size SIZE | --size-pct SIZE_PCT) [options]
301
302
 
302
303
  Key options:
303
304
 
304
- - `--strategy {default,reversal}`
305
- - `--strategy {default,orderflow_pullback,reversal}` with aliases `of_pullback` and `orderflow`
305
+ - `--strategy {default,fib_reversal,orderflow_pullback,reversal}` with aliases `fib`, `fibonacci`, `of_pullback`, and `orderflow`
306
306
  - `--size` or `--size-pct`
307
307
  - `--top-markets`
308
308
  - `--intervals`
@@ -341,7 +341,7 @@ Key options:
341
341
  - `--no-market-fallback`
342
342
  - `--market-slippage`
343
343
  - `--keep-existing-tpsl`
344
- - `--dry-run`
344
+ - `--dry-run`: assume 10,000 cUSDC for account balance and percentage sizing; simulate positions without placing exchange orders. Percentage sizing uses public market prices and maximum leverage from market metadata, without querying account collateral or configured leverage.
345
345
  - `--max-trades`
346
346
  - `--cooldown-after-trade`
347
347
  - `--loop-after-trade`
@@ -363,6 +363,51 @@ Key options:
363
363
 
364
364
  `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`.
365
365
 
366
+ Fibonacci pullback strategy:
367
+
368
+ ```bash
369
+ python3 hypertrader.py auto BTC --size-pct 10 --strategy fib_reversal
370
+ ```
371
+
372
+ `fib_reversal` detects an ATR-qualified impulse on the trend timeframe,
373
+ waits for a 38.2%/50%/61.8% Fibonacci retracement, then scores MACD
374
+ reversal, DMI/ADX trend strength, optional ROC, price rejection, and
375
+ higher-timeframe EMA alignment. It trades a pullback reversal in the original
376
+ impulse direction. Anchors use confirmed symmetric pivots (default width 2),
377
+ with at least 5 bars and a 2 ATR move inside the last 120 trend candles.
378
+
379
+ ```bash
380
+ python3 hypertrader.py auto \
381
+ --size-pct 10 \
382
+ --top-markets 20 \
383
+ --strategy fib_reversal \
384
+ --trend-interval 1h \
385
+ --entry-interval 15m \
386
+ --fib-entry-levels "0.382,0.5,0.618" \
387
+ --fib-min-impulse-atr 2.0 \
388
+ --fib-min-score 5 \
389
+ --fib-min-rr 1.5
390
+ ```
391
+
392
+ - Zone contact is required. Rejection, MACD histogram rotation/crossover, DMI,
393
+ rising ADX, ROC, and HTF EMA alignment contribute a weighted score (default
394
+ threshold 5/10). `--no-fib-roc` removes ROC and lowers the maximum to 9.
395
+ - `--fib-zone-atr 0.15` sets zone tolerance. Confirmation expires after
396
+ `--fib-confirm-timeout 4` entry intervals and cannot trigger farther than
397
+ `--fib-max-entry-distance-atr 0.50` from the touched level.
398
+ - Stops use the 0.786 retracement plus `--fib-stop-atr-buffer 0.25` ATR.
399
+ Closes beyond 0.786 plus `--fib-invalidation-atr 0.10` invalidate structure.
400
+ Explicitly including 0.786 moves invalidation to the impulse start; a 0.786
401
+ entry also places its stop beyond that start.
402
+ - TP1 is the impulse extreme; TP2/TP3 are 1.272/1.618 extensions with
403
+ 40%/35%/25% allocations. `--fib-min-rr 1.5` gates RR to **TP2**.
404
+ - Each impulse can emit once per session. Entry references use completed candle
405
+ closes by default; actual fills remain owned by smart entry. Trend pivots
406
+ always require closed right-side candles. Timeouts use elapsed entry intervals.
407
+ - Indicator defaults: ATR 14, MACD 12/26/9, ADX/DMI 14 with strength thresholds
408
+ 18/25, ROC 9, trend EMAs 20/50. See `auto --help` for all `--fib-*` options.
409
+ TA-Lib period parameters requiring at least 2 are validated before launch.
410
+
366
411
  Reversal strategy notes:
367
412
 
368
413
  - All confirmations use closed candles only.
@@ -521,7 +566,9 @@ The websocket cache is used as the fast path for market data such as mids, best
521
566
 
522
567
  ## Logging
523
568
 
524
- Runtime logs are written to [`logs/hypertrader.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/hypertrader.log).
569
+ Dry-run console output, runtime messages, risk events, and simulated trades are written to `logs/simulated.log`. Simulation fills at observed market mid prices. Plans with explicit take-profit allocations, including `fib_reversal`, close the allocated portion of the original size at each reached target (40% at TP1, 35% at TP2, and 25% at TP3 for Fibonacci). Each fill logs a `simulated_take_profit_filled` event with its size and PnL. Position records track remaining size, cumulative realized PnL, and unrealized PnL on the remaining position; a stop closes only that remainder. Completed-trade PnL includes all partial exits. Plans without explicit allocations exit the full position at the stop or final target. Fees, funding, slippage, and dynamic stop adjustments are not modeled. Open positions at shutdown are logged with realized partial profits and their remaining unrealized PnL.
570
+
571
+ Runtime logs for live runs are written to [`logs/hypertrader.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/hypertrader.log).
525
572
  Completed auto-trades are appended to [`logs/auto_trades.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/auto_trades.log).
526
573
 
527
574
  ## Validation
@@ -35,10 +35,10 @@ The canonical bot file in this repo is [`hypertrader.py`](/media/anon/developmen
35
35
  - Network access to Hyperliquid APIs
36
36
  - Account created with referral code [DARKEREGO](https://app.hyperliquid.xyz/join/DARKEREGO) (see account creation [*])
37
37
 
38
- Install from pip:
38
+ Install from pip: https://pypi.org/project/hypertrader
39
39
 
40
40
  <pre>
41
- pip install hypertrader[auto]
41
+ pip install hypertrader[auto] --upgrade
42
42
  </pre>
43
43
 
44
44
  Base dependencies:
@@ -251,6 +251,7 @@ Key options:
251
251
 
252
252
  - `default`: the existing MACD/SAR/ADX/Bollinger auto trader and the implicit default when `--strategy` is omitted
253
253
  - `orderflow_pullback`: order-flow-confirmed trend pullback scalp strategy, also available as `of_pullback` and `orderflow`
254
+ - `fib_reversal`: Fibonacci pullbacks in the original impulse direction; aliases `fib` and `fibonacci`
254
255
  - `reversal`: a closed-candle trend-exhaustion, structure-break, and retest strategy
255
256
 
256
257
  The strategy selection changes the signal engine only. Shared sizing, risk controls, modify-order entry, market-fallback cleanup, hidden-order behavior, and bracket management still run through the same common auto execution path.
@@ -270,8 +271,7 @@ python3 hypertrader.py auto [COIN] (--size SIZE | --size-pct SIZE_PCT) [options]
270
271
 
271
272
  Key options:
272
273
 
273
- - `--strategy {default,reversal}`
274
- - `--strategy {default,orderflow_pullback,reversal}` with aliases `of_pullback` and `orderflow`
274
+ - `--strategy {default,fib_reversal,orderflow_pullback,reversal}` with aliases `fib`, `fibonacci`, `of_pullback`, and `orderflow`
275
275
  - `--size` or `--size-pct`
276
276
  - `--top-markets`
277
277
  - `--intervals`
@@ -310,7 +310,7 @@ Key options:
310
310
  - `--no-market-fallback`
311
311
  - `--market-slippage`
312
312
  - `--keep-existing-tpsl`
313
- - `--dry-run`
313
+ - `--dry-run`: assume 10,000 cUSDC for account balance and percentage sizing; simulate positions without placing exchange orders. Percentage sizing uses public market prices and maximum leverage from market metadata, without querying account collateral or configured leverage.
314
314
  - `--max-trades`
315
315
  - `--cooldown-after-trade`
316
316
  - `--loop-after-trade`
@@ -332,6 +332,51 @@ Key options:
332
332
 
333
333
  `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`.
334
334
 
335
+ Fibonacci pullback strategy:
336
+
337
+ ```bash
338
+ python3 hypertrader.py auto BTC --size-pct 10 --strategy fib_reversal
339
+ ```
340
+
341
+ `fib_reversal` detects an ATR-qualified impulse on the trend timeframe,
342
+ waits for a 38.2%/50%/61.8% Fibonacci retracement, then scores MACD
343
+ reversal, DMI/ADX trend strength, optional ROC, price rejection, and
344
+ higher-timeframe EMA alignment. It trades a pullback reversal in the original
345
+ impulse direction. Anchors use confirmed symmetric pivots (default width 2),
346
+ with at least 5 bars and a 2 ATR move inside the last 120 trend candles.
347
+
348
+ ```bash
349
+ python3 hypertrader.py auto \
350
+ --size-pct 10 \
351
+ --top-markets 20 \
352
+ --strategy fib_reversal \
353
+ --trend-interval 1h \
354
+ --entry-interval 15m \
355
+ --fib-entry-levels "0.382,0.5,0.618" \
356
+ --fib-min-impulse-atr 2.0 \
357
+ --fib-min-score 5 \
358
+ --fib-min-rr 1.5
359
+ ```
360
+
361
+ - Zone contact is required. Rejection, MACD histogram rotation/crossover, DMI,
362
+ rising ADX, ROC, and HTF EMA alignment contribute a weighted score (default
363
+ threshold 5/10). `--no-fib-roc` removes ROC and lowers the maximum to 9.
364
+ - `--fib-zone-atr 0.15` sets zone tolerance. Confirmation expires after
365
+ `--fib-confirm-timeout 4` entry intervals and cannot trigger farther than
366
+ `--fib-max-entry-distance-atr 0.50` from the touched level.
367
+ - Stops use the 0.786 retracement plus `--fib-stop-atr-buffer 0.25` ATR.
368
+ Closes beyond 0.786 plus `--fib-invalidation-atr 0.10` invalidate structure.
369
+ Explicitly including 0.786 moves invalidation to the impulse start; a 0.786
370
+ entry also places its stop beyond that start.
371
+ - TP1 is the impulse extreme; TP2/TP3 are 1.272/1.618 extensions with
372
+ 40%/35%/25% allocations. `--fib-min-rr 1.5` gates RR to **TP2**.
373
+ - Each impulse can emit once per session. Entry references use completed candle
374
+ closes by default; actual fills remain owned by smart entry. Trend pivots
375
+ always require closed right-side candles. Timeouts use elapsed entry intervals.
376
+ - Indicator defaults: ATR 14, MACD 12/26/9, ADX/DMI 14 with strength thresholds
377
+ 18/25, ROC 9, trend EMAs 20/50. See `auto --help` for all `--fib-*` options.
378
+ TA-Lib period parameters requiring at least 2 are validated before launch.
379
+
335
380
  Reversal strategy notes:
336
381
 
337
382
  - All confirmations use closed candles only.
@@ -490,7 +535,9 @@ The websocket cache is used as the fast path for market data such as mids, best
490
535
 
491
536
  ## Logging
492
537
 
493
- Runtime logs are written to [`logs/hypertrader.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/hypertrader.log).
538
+ Dry-run console output, runtime messages, risk events, and simulated trades are written to `logs/simulated.log`. Simulation fills at observed market mid prices. Plans with explicit take-profit allocations, including `fib_reversal`, close the allocated portion of the original size at each reached target (40% at TP1, 35% at TP2, and 25% at TP3 for Fibonacci). Each fill logs a `simulated_take_profit_filled` event with its size and PnL. Position records track remaining size, cumulative realized PnL, and unrealized PnL on the remaining position; a stop closes only that remainder. Completed-trade PnL includes all partial exits. Plans without explicit allocations exit the full position at the stop or final target. Fees, funding, slippage, and dynamic stop adjustments are not modeled. Open positions at shutdown are logged with realized partial profits and their remaining unrealized PnL.
539
+
540
+ Runtime logs for live runs are written to [`logs/hypertrader.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/hypertrader.log).
494
541
  Completed auto-trades are appended to [`logs/auto_trades.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/auto_trades.log).
495
542
 
496
543
  ## Validation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypertrader
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Async Hyperliquid trading helper built on the async SDK.
5
5
  Author: darkerego
6
6
  License: MIT
@@ -66,10 +66,10 @@ The canonical bot file in this repo is [`hypertrader.py`](/media/anon/developmen
66
66
  - Network access to Hyperliquid APIs
67
67
  - Account created with referral code [DARKEREGO](https://app.hyperliquid.xyz/join/DARKEREGO) (see account creation [*])
68
68
 
69
- Install from pip:
69
+ Install from pip: https://pypi.org/project/hypertrader
70
70
 
71
71
  <pre>
72
- pip install hypertrader[auto]
72
+ pip install hypertrader[auto] --upgrade
73
73
  </pre>
74
74
 
75
75
  Base dependencies:
@@ -282,6 +282,7 @@ Key options:
282
282
 
283
283
  - `default`: the existing MACD/SAR/ADX/Bollinger auto trader and the implicit default when `--strategy` is omitted
284
284
  - `orderflow_pullback`: order-flow-confirmed trend pullback scalp strategy, also available as `of_pullback` and `orderflow`
285
+ - `fib_reversal`: Fibonacci pullbacks in the original impulse direction; aliases `fib` and `fibonacci`
285
286
  - `reversal`: a closed-candle trend-exhaustion, structure-break, and retest strategy
286
287
 
287
288
  The strategy selection changes the signal engine only. Shared sizing, risk controls, modify-order entry, market-fallback cleanup, hidden-order behavior, and bracket management still run through the same common auto execution path.
@@ -301,8 +302,7 @@ python3 hypertrader.py auto [COIN] (--size SIZE | --size-pct SIZE_PCT) [options]
301
302
 
302
303
  Key options:
303
304
 
304
- - `--strategy {default,reversal}`
305
- - `--strategy {default,orderflow_pullback,reversal}` with aliases `of_pullback` and `orderflow`
305
+ - `--strategy {default,fib_reversal,orderflow_pullback,reversal}` with aliases `fib`, `fibonacci`, `of_pullback`, and `orderflow`
306
306
  - `--size` or `--size-pct`
307
307
  - `--top-markets`
308
308
  - `--intervals`
@@ -341,7 +341,7 @@ Key options:
341
341
  - `--no-market-fallback`
342
342
  - `--market-slippage`
343
343
  - `--keep-existing-tpsl`
344
- - `--dry-run`
344
+ - `--dry-run`: assume 10,000 cUSDC for account balance and percentage sizing; simulate positions without placing exchange orders. Percentage sizing uses public market prices and maximum leverage from market metadata, without querying account collateral or configured leverage.
345
345
  - `--max-trades`
346
346
  - `--cooldown-after-trade`
347
347
  - `--loop-after-trade`
@@ -363,6 +363,51 @@ Key options:
363
363
 
364
364
  `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`.
365
365
 
366
+ Fibonacci pullback strategy:
367
+
368
+ ```bash
369
+ python3 hypertrader.py auto BTC --size-pct 10 --strategy fib_reversal
370
+ ```
371
+
372
+ `fib_reversal` detects an ATR-qualified impulse on the trend timeframe,
373
+ waits for a 38.2%/50%/61.8% Fibonacci retracement, then scores MACD
374
+ reversal, DMI/ADX trend strength, optional ROC, price rejection, and
375
+ higher-timeframe EMA alignment. It trades a pullback reversal in the original
376
+ impulse direction. Anchors use confirmed symmetric pivots (default width 2),
377
+ with at least 5 bars and a 2 ATR move inside the last 120 trend candles.
378
+
379
+ ```bash
380
+ python3 hypertrader.py auto \
381
+ --size-pct 10 \
382
+ --top-markets 20 \
383
+ --strategy fib_reversal \
384
+ --trend-interval 1h \
385
+ --entry-interval 15m \
386
+ --fib-entry-levels "0.382,0.5,0.618" \
387
+ --fib-min-impulse-atr 2.0 \
388
+ --fib-min-score 5 \
389
+ --fib-min-rr 1.5
390
+ ```
391
+
392
+ - Zone contact is required. Rejection, MACD histogram rotation/crossover, DMI,
393
+ rising ADX, ROC, and HTF EMA alignment contribute a weighted score (default
394
+ threshold 5/10). `--no-fib-roc` removes ROC and lowers the maximum to 9.
395
+ - `--fib-zone-atr 0.15` sets zone tolerance. Confirmation expires after
396
+ `--fib-confirm-timeout 4` entry intervals and cannot trigger farther than
397
+ `--fib-max-entry-distance-atr 0.50` from the touched level.
398
+ - Stops use the 0.786 retracement plus `--fib-stop-atr-buffer 0.25` ATR.
399
+ Closes beyond 0.786 plus `--fib-invalidation-atr 0.10` invalidate structure.
400
+ Explicitly including 0.786 moves invalidation to the impulse start; a 0.786
401
+ entry also places its stop beyond that start.
402
+ - TP1 is the impulse extreme; TP2/TP3 are 1.272/1.618 extensions with
403
+ 40%/35%/25% allocations. `--fib-min-rr 1.5` gates RR to **TP2**.
404
+ - Each impulse can emit once per session. Entry references use completed candle
405
+ closes by default; actual fills remain owned by smart entry. Trend pivots
406
+ always require closed right-side candles. Timeouts use elapsed entry intervals.
407
+ - Indicator defaults: ATR 14, MACD 12/26/9, ADX/DMI 14 with strength thresholds
408
+ 18/25, ROC 9, trend EMAs 20/50. See `auto --help` for all `--fib-*` options.
409
+ TA-Lib period parameters requiring at least 2 are validated before launch.
410
+
366
411
  Reversal strategy notes:
367
412
 
368
413
  - All confirmations use closed candles only.
@@ -521,7 +566,9 @@ The websocket cache is used as the fast path for market data such as mids, best
521
566
 
522
567
  ## Logging
523
568
 
524
- Runtime logs are written to [`logs/hypertrader.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/hypertrader.log).
569
+ Dry-run console output, runtime messages, risk events, and simulated trades are written to `logs/simulated.log`. Simulation fills at observed market mid prices. Plans with explicit take-profit allocations, including `fib_reversal`, close the allocated portion of the original size at each reached target (40% at TP1, 35% at TP2, and 25% at TP3 for Fibonacci). Each fill logs a `simulated_take_profit_filled` event with its size and PnL. Position records track remaining size, cumulative realized PnL, and unrealized PnL on the remaining position; a stop closes only that remainder. Completed-trade PnL includes all partial exits. Plans without explicit allocations exit the full position at the stop or final target. Fees, funding, slippage, and dynamic stop adjustments are not modeled. Open positions at shutdown are logged with realized partial profits and their remaining unrealized PnL.
570
+
571
+ Runtime logs for live runs are written to [`logs/hypertrader.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/hypertrader.log).
525
572
  Completed auto-trades are appended to [`logs/auto_trades.log`](/media/anon/development/anon/PycharmProjects/hypertrader/logs/auto_trades.log).
526
573
 
527
574
  ## Validation
@@ -15,21 +15,26 @@ modes/trailing_stop.py
15
15
  strategies/__init__.py
16
16
  strategies/base.py
17
17
  strategies/default.py
18
+ strategies/fib_reversal.py
18
19
  strategies/orderflow_metrics.py
19
20
  strategies/orderflow_models.py
20
21
  strategies/orderflow_pullback.py
21
22
  strategies/registry.py
22
23
  strategies/reversal.py
23
24
  tests/test_async_hyperliquid.py
25
+ tests/test_auto_dry_run.py
24
26
  tests/test_auto_strategy_registry.py
25
27
  tests/test_auto_trader_logging.py
28
+ tests/test_fib_reversal_strategy.py
26
29
  tests/test_market_ids.py
27
30
  tests/test_orderflow_metrics.py
28
31
  tests/test_orderflow_pullback_lifecycle.py
29
32
  tests/test_reversal_strategy.py
33
+ tests/test_simulated_logging.py
30
34
  tests/test_trailing_stop.py
31
35
  utils/constants.py
32
36
  utils/helpers.py
37
+ utils/simulated_logging.py
33
38
  utils/style.py
34
39
  utils/timer.py
35
40
  utils/worker.py
@@ -23,6 +23,7 @@ import os
23
23
  import sys
24
24
  from typing import Any, Dict, List, Optional
25
25
 
26
+ from strategies.fib_reversal import validate_fib_config
26
27
  from strategies.registry import available_strategy_names, available_strategies, normalize_strategy_name
27
28
 
28
29
  from hyperliquid.info import Info
@@ -31,7 +32,7 @@ from modes.market_maker import run_market_maker
31
32
  from modes.position_management import run_bracket_entry
32
33
  from modes.position_watcher import run_position_watcher
33
34
  from modes.trailing_stop import trailing_stop_for_all_positions
34
- from utils.constants import DEFAULT_LOG_FILE, INTERVAL_TO_MS
35
+ from utils.constants import DEFAULT_LOG_FILE, SIMULATED_LOG_FILE, INTERVAL_TO_MS
35
36
  from utils.helpers import parse_fractional_pct, normalize_hyperliquid_market_id, split_hyperliquid_market_id
36
37
  from utils.style import install_pretty_stdout
37
38
 
@@ -335,7 +336,7 @@ def build_arg_parser() -> argparse.ArgumentParser:
335
336
  help="Slippage fraction for market-style entry/exit. Default: 0.05.")
336
337
  auto_parser.add_argument("--keep-existing-tpsl", action="store_true",
337
338
  help="Do not cancel existing reduce-only TP/SL orders before entry.")
338
- auto_parser.add_argument("--dry-run", action="store_true", help="Print auto signals but do not enter trades.")
339
+ auto_parser.add_argument("--dry-run", action="store_true", help="Simulate positions using 10,000 cUSDC assumed collateral and log to logs/simulated.log.")
339
340
  auto_parser.add_argument("--max-trades", type=int, default=0,
340
341
  help="Maximum completed auto trades before exit. 0 means unlimited. Default: 0.")
341
342
  auto_parser.add_argument("--cooldown-after-trade", type=float, default=60.0,
@@ -372,6 +373,31 @@ def build_arg_parser() -> argparse.ArgumentParser:
372
373
  help="Disable ws for kline data (not recommended): ")
373
374
  auto_parser.add_argument("--hide-orders", "-ho", action="store_true",
374
375
  help="Keep auto-mode TP/SL targets private; no exchange-side bracket orders are placed until targets trigger.")
376
+ fib_group = auto_parser.add_argument_group("Fibonacci reversal strategy")
377
+ fib_group.add_argument("--fib-entry-levels", type=str, default='0.382,0.5,0.618')
378
+ fib_group.add_argument("--fib-pivot-width", type=int, default=2)
379
+ fib_group.add_argument("--fib-impulse-lookback", type=int, default=120)
380
+ fib_group.add_argument("--fib-min-impulse-atr", type=float, default=2.0)
381
+ fib_group.add_argument("--fib-min-impulse-bars", type=int, default=5)
382
+ fib_group.add_argument("--fib-zone-atr", type=float, default=0.15)
383
+ fib_group.add_argument("--fib-invalidation-atr", type=float, default=0.1)
384
+ fib_group.add_argument("--fib-stop-atr-buffer", type=float, default=0.25)
385
+ fib_group.add_argument("--fib-max-entry-distance-atr", type=float, default=0.5)
386
+ fib_group.add_argument("--fib-atr-period", type=int, default=14)
387
+ fib_group.add_argument("--fib-macd-fast", type=int, default=12)
388
+ fib_group.add_argument("--fib-macd-slow", type=int, default=26)
389
+ fib_group.add_argument("--fib-macd-signal", type=int, default=9)
390
+ fib_group.add_argument("--fib-adx-period", type=int, default=14)
391
+ fib_group.add_argument("--fib-min-adx", type=float, default=18.0)
392
+ fib_group.add_argument("--fib-strong-adx", type=float, default=25.0)
393
+ fib_group.add_argument("--fib-roc-period", type=int, default=9)
394
+ fib_group.add_argument("--no-fib-roc", dest="fib_roc", action="store_false", default=True)
395
+ fib_group.add_argument("--fib-trend-ema-fast", type=int, default=20)
396
+ fib_group.add_argument("--fib-trend-ema-slow", type=int, default=50)
397
+ fib_group.add_argument("--fib-confirm-timeout", type=int, default=4)
398
+ fib_group.add_argument("--fib-min-score", type=int, default=5)
399
+ fib_group.add_argument("--fib-min-rr", type=float, default=1.5)
400
+
375
401
  reversal_group = auto_parser.add_argument_group("Reversal strategy")
376
402
  reversal_group.add_argument("--trend-interval", type=str, default="1h",
377
403
  help="Higher timeframe used for reversal trend classification. Default: 1h.")
@@ -716,6 +742,18 @@ async def async_main(argv: Optional[List[str]] = None) -> None:
716
742
  if args.ws_candles and args.no_websocket:
717
743
  print("[ERROR] --ws-candles requires websocket market data; remove --no-websocket.")
718
744
  sys.exit(1)
745
+ try:
746
+ validate_fib_config(args)
747
+ except ValueError as exc:
748
+ print(f"[ERROR] {exc}")
749
+ sys.exit(1)
750
+ if args.strategy == "fib_reversal":
751
+ if args.trend_interval not in INTERVAL_TO_MS or args.entry_interval not in INTERVAL_TO_MS:
752
+ print("[ERROR] Unsupported Fibonacci trend/entry interval.")
753
+ sys.exit(1)
754
+ if INTERVAL_TO_MS[args.entry_interval] >= INTERVAL_TO_MS[args.trend_interval]:
755
+ print("[ERROR] --entry-interval must be shorter than --trend-interval for fib_reversal.")
756
+ sys.exit(1)
719
757
  if args.strategy == "reversal":
720
758
  if args.trend_interval not in INTERVAL_TO_MS:
721
759
  print(f"[ERROR] Unsupported --trend-interval {args.trend_interval!r}.")
@@ -858,6 +896,29 @@ async def async_main(argv: Optional[List[str]] = None) -> None:
858
896
  risk_session_log=args.risk_session_log,
859
897
  trend_interval=args.trend_interval,
860
898
  entry_interval=args.entry_interval,
899
+ fib_entry_levels=args.fib_entry_levels,
900
+ fib_pivot_width=args.fib_pivot_width,
901
+ fib_impulse_lookback=args.fib_impulse_lookback,
902
+ fib_min_impulse_atr=args.fib_min_impulse_atr,
903
+ fib_min_impulse_bars=args.fib_min_impulse_bars,
904
+ fib_zone_atr=args.fib_zone_atr,
905
+ fib_invalidation_atr=args.fib_invalidation_atr,
906
+ fib_stop_atr_buffer=args.fib_stop_atr_buffer,
907
+ fib_max_entry_distance_atr=args.fib_max_entry_distance_atr,
908
+ fib_atr_period=args.fib_atr_period,
909
+ fib_macd_fast=args.fib_macd_fast,
910
+ fib_macd_slow=args.fib_macd_slow,
911
+ fib_macd_signal=args.fib_macd_signal,
912
+ fib_adx_period=args.fib_adx_period,
913
+ fib_min_adx=args.fib_min_adx,
914
+ fib_strong_adx=args.fib_strong_adx,
915
+ fib_roc_period=args.fib_roc_period,
916
+ fib_roc=args.fib_roc,
917
+ fib_trend_ema_fast=args.fib_trend_ema_fast,
918
+ fib_trend_ema_slow=args.fib_trend_ema_slow,
919
+ fib_confirm_timeout=args.fib_confirm_timeout,
920
+ fib_min_score=args.fib_min_score,
921
+ fib_min_rr=args.fib_min_rr,
861
922
  reversal_ema_fast=args.reversal_ema_fast,
862
923
  reversal_ema_confirm=args.reversal_ema_confirm,
863
924
  reversal_ema_trend_fast=args.reversal_ema_trend_fast,
@@ -971,26 +1032,46 @@ async def async_main(argv: Optional[List[str]] = None) -> None:
971
1032
 
972
1033
 
973
1034
  def main(argv: Optional[List[str]] = None) -> None:
974
- log_path = configure_runtime_logging()
975
- try:
976
- loop = asyncio.new_event_loop()
977
- asyncio.set_event_loop(loop)
978
- install_asyncio_exception_logging(loop)
1035
+ from utils.simulated_logging import LoggedConsole
1036
+ def start():
1037
+ _loop = asyncio.new_event_loop()
1038
+ asyncio.set_event_loop(_loop)
1039
+ install_asyncio_exception_logging(_loop)
979
1040
  print(f"[LOG] Writing runtime logs to {log_path}")
980
1041
  print(f"[START] argv={argv if argv is not None else sys.argv[1:]}")
981
- loop.run_until_complete(async_main(argv))
1042
+ _loop.run_until_complete(async_main(argv))
1043
+
1044
+ args = argv if argv is not None else sys.argv[1:]
1045
+ dry_run = "--dry-run" in args
1046
+ log_path = configure_runtime_logging(SIMULATED_LOG_FILE if dry_run else None)
1047
+ original_stdout, original_stderr = sys.stdout, sys.stderr
1048
+ restart = False
1049
+ if dry_run:
1050
+ sys.stdout = LoggedConsole(original_stdout)
1051
+ # sys.stderr = LoggedConsole(original_stderr)
1052
+ try:
1053
+ start()
982
1054
  except KeyboardInterrupt:
983
1055
  print("\n[!] Interrupted.")
984
- except Exception:
985
- logging.getLogger("hypertrader").exception("[FATAL] Unhandled main() exception.")
986
- sys.exit(1)
1056
+ except Exception as err:
1057
+ logging.getLogger("hypertrader").exception("[FATAL] Unhandled main() exception: %s" % err)
1058
+ restart = True
1059
+
1060
+
987
1061
  finally:
1062
+ if dry_run:
1063
+ sys.stdout.flush()
1064
+ sys.stderr.flush()
1065
+ sys.stdout, sys.stderr = original_stdout, original_stderr
988
1066
  try:
989
1067
  loop = asyncio.get_event_loop()
990
1068
  except RuntimeError:
991
1069
  loop = None
992
1070
  if loop is not None and not loop.is_closed():
993
1071
  loop.close()
1072
+ if restart:
1073
+ print('[!] Restarting ... ')
1074
+ start()
994
1075
 
995
1076
 
996
1077
  if __name__ == "__main__":