Async Hyperliquid trading helper built on the async SDK.
Project description
Hypertrader
Async Hyperliquid trading helper built around the async SDK from darkerego/hyperliquid-python-sdk-async.
The canonical bot file in this repo is hypertrader.py. It provides five modes:
enter: top-of-book limit entry with modify-order repricing, optional market fallback, and TP/SL managementwatch: attach TP/SL management to newly opened or existing positionstrailing: manage local trailing stops for open positionsauto: TA-Lib multi-timeframe signal scanner that routes through the same bracket-entry path asentermarket_maker: event-driven maker ladder that stays separate from the bracket and hidden-order logic
Behavior Summary
- Async SDK only:
InfoandExchangeare created and used asynchronously end-to-end. - Websocket market data is enabled by default. Use
--no-websocketto force HTTP polling only. - HTTP remains the fallback and authoritative path for account state, reconciliation, candles, and trading actions.
- Entry logic uses
exchange.modify_order(...)to move one working limit order instead of cancel/repost on every loop. - Market fallback cleans up stale non-reduce-only entry orders before and after any market entry.
- TP reversal never crosses back through entry into loss territory.
--hide-ordersis available forenter,watch,trailing, andauto. It does not apply tomarket_maker.- Runtime monitors print current uPnL, session realized PnL, and account balance.
Requirements
- Python 3.10+
- Hyperliquid account credentials
- Network access to Hyperliquid APIs
- Account created with referral code DARKEREGO (see account creation [*])
Base dependencies:
python3 -m venv .venv
. .venv/bin/activate
pip install --upgrade pip
pip install python-dotenv eth-account hyperliquid-python-sdk-async
Optional auto mode dependencies:
pip install numpy TA-Lib
auto imports numpy and talib defensively, so the other modes can still run without TA-Lib installed.
Please see TA-Lib documentation if you need help installing the required binary library:
https://ta-lib.org/install/#linux
Configuration
-
Create a hyperliquid account with referral code
DARKEREGOwith this URL: -
Once in HyperLiquid panel, click more -> API and create an API key.
- The API key is a private Ethereum key. Copy to clipboard and continue:
-
Set credentials in the environment or a local
.envfile:
HYPERLIQUID_SECRET_KEY=...
HYPERLIQUID_ACCOUNT_ADDRESS=...
HYPERLIQUID_SECRET_KEY: private key for the trading wallet or API wallet (the API key you just created)HYPERLIQUID_ACCOUNT_ADDRESS: main account address used for the account state
Do not commit real credentials.
Quick Start
Show global help:
python3 hypertrader.py --help
Enter a long with a 1% TP and default half-TP stop:
python3 hypertrader.py enter HYPE long --size 1 --take-profit-pct 0.01
Enter with hidden local TP/SL targets:
python3 hypertrader.py enter ETH short --size 0.25 --take-profit-pct 0.012 --hide-orders
Enter, let TP level 1 fill, then cancel the rest of the ladder and trail the remainder:
python3 hypertrader.py enter BTC long --size 0.1 --take-profit-pct 0.01 --trailing-tp
Watch an existing position and attach management:
python3 hypertrader.py watch BTC --take-profit-pct 0.01 --manage-existing
Watch a position and switch from the TP ladder to a trailing TP after TP level 1 fills:
python3 hypertrader.py watch BTC --take-profit-pct 0.01 --manage-existing --trailing-tp
Run local trailing management:
python3 hypertrader.py trailing BTC --trail-pct 0.01
Dry-run auto mode across short intervals:
python3 hypertrader.py auto SOL --intervals "1m 3m 5m" --size 10 --dry-run
Run the market maker on testnet:
python3 hypertrader.py market_maker HYPE --base-size 0.01 --testnet
Commands
enter
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.
python3 hypertrader.py enter COIN long|short --size SIZE [options]
Key options:
--take-profit-pct: TP target fraction--stop-loss-pct: SL fraction; defaults toTP * 0.5if TP is supplied--take-profit-levels: number of weighted TP ladder levels--trailing-tp: keep the TP ladder live, then switch to a local trailing TP after the configured TP level fills--trailing-tp-trigger-level: TP ladder level that must fill before trailing TP activates--trailing-tp-remaining-levels: switch the remaining ladder to a local trailing TP when this many TP levels are left--trailing-tp-profit-pct: trailing distance as a fraction of favorable unrealized profit--entry-retries: limit modify attempts before fallback--entry-repost-interval: seconds between modify attempts--entry-tif: entry limit TIF,AloorGtc--tp-tif: TP limit TIF,AloorGtc--no-market-fallback: disable remaining-size market entry--market-slippage: slippage fraction for market-style helpers--keep-existing-tpsl: preserve existing reduce-only TP/SL orders before entry--tp-reversal-pct: enable TP-reversal exits after the first TP zone is reached--tp-reversal-limit-exit: try a reduce-only limit exit plus protective stop before market fallback--tp-reversal-stop-buffer-pct: optional TP-reversal stop buffer--hide-ordersor-ho: keep bracket targets local until they trigger--testnet--no-websocket
watch
Watches for matching positions and attaches TP/SL management. It can also manage positions that already exist at startup.
python3 hypertrader.py watch [COIN] [options]
Key options:
--take-profit-pct--stop-loss-pct--take-profit-levels--trailing-tp--trailing-tp-trigger-level--trailing-tp-remaining-levels--trailing-tp-profit-pct--poll-interval--manage-existing--tp-reversal-pct--tp-reversal-limit-exit--tp-reversal-stop-buffer-pct--tp-tif--market-slippage--keep-existing-tpsl--hide-ordersor-ho--testnet--no-websocket
trailing
Runs local trailing-stop management for open positions.
python3 hypertrader.py trailing [COIN] [options]
Key options:
--trail-pct--poll-interval--hide-ordersor-ho--testnet--no-websocket
trailing already keeps stops local. The hidden-order flag is accepted for CLI consistency.
auto
Scans one coin or the top perp markets using TA-Lib signals from:
- MACD
- Parabolic SAR
- ADX
- Bollinger Bands
Default intervals are 1h,15m,5m,1m. With --min-agreement 0, all configured intervals must agree.
python3 hypertrader.py auto [COIN] (--size SIZE | --size-pct SIZE_PCT) [options]
Key options:
--sizeor--size-pct--top-markets--intervals--auto-periods--scan-interval--max-concurrent-scans--min-agreement--adx-threshold--macd-fast--macd-slow--macd-signal--sar-acceleration--sar-maximum--auto-sar-stop-on-shortest-interval--adx-timeperiod--bb-timeperiod--bb-dev--scalp--use-live-candle--take-profit-pct: override Bollinger-derived TP--min-take-profit-pct--max-take-profit-pct--stop-loss-pct--take-profit-levels--trailing-tp--trailing-tp-trigger-level--trailing-tp-remaining-levels--trailing-tp-profit-pct--entry-retries--entry-repost-interval--entry-tif--tp-tif--poll-interval--tp-reversal-pct--tp-reversal-limit-exit--tp-reversal-stop-buffer-pct--no-market-fallback--market-slippage--keep-existing-tpsl--dry-run--max-trades--cooldown-after-trade--loop-after-trade--exit-after-trade--max-coin-trades-per-session--coin-session-cooldown-seconds--coin-session-profit-target--coin-session-min-profit-to-lock--coin-session-giveback-pct--cooldown-after-loss-following-wins--session-profit-target--session-max-loss--session-giveback-pct--risk-session-log--ws-candles--hide-ordersor-ho--testnet--no-websocket
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.
Additional auto parameter notes:
--max-concurrent-scans: limits how many markets are scanned in parallel in each auto loop.--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.--scalp: requires additional shortest-interval Bollinger confirmation before entering.--max-coin-trades-per-session: caps completed trade cycles per coin before that coin is cooled down.--coin-session-cooldown-seconds: duration of the per-coin cooldown window after a coin-level stop condition triggers.--coin-session-profit-target: pauses a coin after it reaches the configured realized PnL target for the current auto session.--coin-session-min-profit-to-lock: enables per-coin giveback protection only after realized PnL first reaches this minimum lock threshold.--coin-session-giveback-pct: pauses a coin after it gives back the configured fraction from its peak realized PnL.--cooldown-after-loss-following-wins: pauses a coin after a losing trade that follows at least N consecutive winning cycles.--session-profit-target: stops the entire auto session once total realized PnL reaches the target.--session-max-loss: stops the entire auto session once total realized PnL falls to-Nor below.--session-giveback-pct: stops the entire auto session after giving back the configured fraction from peak realized PnL.--risk-session-log: writes auto risk-session events to a JSONL file path you provide.--ws-candles: experimental candle mode that seeds each(coin, interval)viacandleSnapshot, then keeps them updated from websocket candle messages.
Example with newer auto risk controls:
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
market_maker
Runs an event-driven maker ladder around a computed center price.
python3 hypertrader.py market_maker COIN [options]
Key options:
--interval--periods--levels--base-size--loop-sleep--min-edge-pct--rebalance-threshold-pct--protect-close-pct--testnet--no-websocket
market_maker is intentionally separate from hidden-order bracket behavior.
Hidden Orders
--hide-orders keeps TP/SL targets in memory instead of placing exchange-side bracket orders immediately. This prevents
exchange market maker bots from being able to see where your stops and take profit orders are.
When enabled:
- no exchange-side stop-loss order is placed when management starts
- no exchange-side TP ladder is placed when management starts
- hidden targets are still calculated and displayed
- a hidden stop hit cancels any reduce-only TP orders and closes the position with
exchange.market_close(...) - a hidden TP level places its reduce-only post-only TP order only when the target is hit
- scale-ins rebase the hidden TP/SL targets to the new average entry and current size
This flag applies to enter, watch, trailing, and auto, but not market_maker.
Websocket And HTTP
The bot creates Info with websocket support enabled unless --no-websocket is supplied:
info = await Info.create(api_url, skip_ws=(not use_websocket))
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.
Logging
Runtime logs are written to logs/hypertrader.log.
Completed auto-trades are appended to logs/auto_trades.log.
Validation
Minimum validation after changes:
python3 -m py_compile hypertrader.py
python3 hypertrader.py --help
python3 hypertrader.py enter --help
python3 hypertrader.py watch --help
python3 hypertrader.py trailing --help
python3 hypertrader.py auto --help
python3 hypertrader.py market_maker --help
Suggested non-live auto check:
python3 hypertrader.py auto SOL --intervals "1m 3m 5m" --size 10 --dry-run
Do not run live trading commands unless you intend to trade.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hypertrader-0.1.0.tar.gz.
File metadata
- Download URL: hypertrader-0.1.0.tar.gz
- Upload date:
- Size: 65.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a65d5483cbad1cbe3a5366cffea0c26fe0ebb9915538822b91b8543915ade34
|
|
| MD5 |
e3757d64833663388076f30affaa434a
|
|
| BLAKE2b-256 |
1c9cfeb02aaf146a877b6f69ee6cc3aa1f246eb5cb46ceff3d7f54b169f8c281
|
File details
Details for the file hypertrader-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hypertrader-0.1.0-py3-none-any.whl
- Upload date:
- Size: 72.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700aabd5de25c461fcff4593e48358c3f85bf4d88008a81fe586dd36b9b1f799
|
|
| MD5 |
9b6c7e799e172b18f94f46a9bc4af514
|
|
| BLAKE2b-256 |
ba5db86047d39de438ac167791af5a173945ef3b678386b4503fc350b3a11c6c
|