Source: github.com/SignalBot-Labs/aster-bot
Automated futures trading on Aster DEX (perp DEX) using the public fapi.asterdex.com RPC/WebSocket — dual-engine strategies, risk controls, and production-grade logging.
Aster is a TypeScript/Node.js trading system built for ASTERUSDT-style perpetual markets. It is suitable for operators anywhere in the world who need a repeatable, configurable workflow: research parameters in dry-run, then deploy in live mode with clear limits and full audit trails.
Disclaimer: Trading digital assets involves substantial risk. The screenshots in this document are illustrative examples of market analysis and exchange trade history. They are not a guarantee of future results. Read the Important warnings and Legal disclaimer before use.
- Visual overview — charts, signals, and execution logs
- Features
- Who this is for
- Prerequisites
- Installation
- Configuration
- Usage
- Strategies
- Risk management
- Project structure
- Development
- Logging & observability
- State persistence
- Security
- Deployment
- Monitoring
- Troubleshooting
- Important warnings
- License & support
The images under data/img/ document how a V1 / V2 style workflow appears on a chart, and how fills and realized P&L look in a typical perpetual exchange UI. Use them to align your expectations with the bot’s logical long/short and risk layers—not as a promise of any specific return.
Short-interval chart (e.g. 30s) — price action, stacked moving averages, and labeled LONG/SHORT V1 & V2 entries, with a compact stats panel (trades, win rate, P&L %, profit factor, best trade).
Medium-interval chart (e.g. 2m) — same family of labels and exits (e.g. “X” style exit markers), with RSI and volume context. Useful for understanding how signal density and timeframe interact before you set VIRTUAL_TIMEFRAME_MS and strategy thresholds in the bot.
High realized P&L on sell-side closes (example window) — consecutive Sell rows with positive realized profit in USDT, same symbol ASTERUSDT, tight timestamps. Illustrates how per-block outcomes appear when the exchange attributes P&L to each close.
Dense execution window — many fills in a short period; uniform prices within a tick of each other. Demonstrates high activity and how fees and realized P&L are shown line-by-line in a professional UI.
Round-trip perspective — alternating Buy and Sell (opens vs closes). Buy rows often show 0.00 realized until the Sell leg locks in profit; Sell rows show the attributed realized amount. This matches how manual and automated systems are reconciled in production.
Full trading workspace — order book, chart area, perp equity and margin summary, and Trade history with a mix of wins, losses, and zero-P&L lines. A realistic reference for 24/7 monitoring: not every line is green; risk controls exist precisely because losses occur.
Session log (illustrative date) — many Buy/Sell rows over hours, small notionals per line, fees in USDT, and realized green/red. Use this to set expectations for CSV/JSON logs: your files will be the source of truth for back-testing and post-trade review.
Consistent size per fill (example: fixed ASTER per order) — repeated 20.00 ASTER (or similar) with alternating sides and small but non-zero P&L on closes. Pairs well with the bot’s position sizing and leverage env vars: define max exposure first, then tune strategy.
Tight range, fast turnover — prices within a narrow band and frequent flips. Highlights scalp-style or very active regimes; compare with your MAX_FLIPS_PER_HOUR and minimum hold settings so behavior stays inside your risk policy.
Repository asset index: all gallery images live in data/img/ (see Visual overview). For version control, prefer committing non-duplicate files; omit local “Copy” variants if you use them only for editing.
-
Dual strategy support
- Watermellon: EMA-based trend following with RSI confirmation.
- Peach Hybrid: dual system — V1 (trend / bias) and V2 (momentum surge), analogous in spirit to the V1/V2 long/short labeling in the reference charts above.
-
Advanced risk management
- Configurable position sizing and leverage limits
- Stop-loss, take-profit, and emergency stop
- Trailing stop for profit protection
- Max flips per hour and consecutive-loss handling
-
Real-time market analysis
- ADX (trending vs ranging)
- ATR for stop placement context
- RSI for momentum
- Support / resistance style context via your configured bars
-
Position management
- Reconciliation with the exchange
- Persistent state across restarts
- Order tracking and minimum hold / flip control
-
Comprehensive logging
- Trade and signal logging
- Daily CSV/JSON under
data/trades/daily/ - Console output suitable for
pm2or systemd
- Quantitative and systematic traders who want a single pair, single codebase, and clear env-driven behavior.
- Global operators in any time zone: the bot does not depend on a specific country; you supply AsterDEX API credentials and run it on a VPS or local machine.
- Developers comfortable with TypeScript,
.env, and reading logs before scaling size or leverage.
- Node.js 18+ and npm
- An AsterDEX account and API credentials (see official docs for your jurisdiction).
- TypeScript familiarity if you will extend strategies or execution paths.
- Clone the repository:
git clone https://github.com/SignalBot-Labs/aster-bot.git
cd aster-bot- Install dependencies:
npm install- Copy the example environment file:
cp env.example .env.local- Edit
.env.local(see Configuration).
ASTER_RPC_URL=https://fapi.asterdex.com
ASTER_WS_URL=wss://fstream.asterdex.com/ws
ASTER_API_KEY=your_api_key
ASTER_API_SECRET=your_api_secret
# Required: 64-hex EVM private key. The bot will not start if missing/invalid. `ASTER_PRIVATE_KEY` is not used.
TRADING_WALLET_PRIVATE_KEY=your_64_char_hex_key
PAIR_SYMBOL=ASTERUSDT-PERP
MODE=dry-runMAX_POSITION_USDT=10000
MAX_LEVERAGE=5
MAX_FLIPS_PER_HOUR=12
STOP_LOSS_PCT=0
TAKE_PROFIT_PCT=0
USE_STOP_LOSS=false
EMERGENCY_STOP_LOSS_PCT=2.0
MAX_POSITIONS=1
REQUIRE_TRENDING_MARKET=true
ADX_THRESHOLD=25Note: MAX_LEVERAGE must be one of: 5, 10, 15, or 50 (AsterDEX-supported values).
Set STRATEGY_TYPE to either:
watermellon— EMA + RSI style trend systempeach-hybrid— dual V1/V2 style hybrid (default)
EMA_FAST=8
EMA_MID=21
EMA_SLOW=48
RSI_LENGTH=14
RSI_MIN_LONG=42
RSI_MAX_SHORT=58V1 (trend / bias):
PEACH_V1_EMA_FAST=8
PEACH_V1_EMA_MID=21
PEACH_V1_EMA_SLOW=48
PEACH_V1_EMA_MICRO_FAST=5
PEACH_V1_EMA_MICRO_SLOW=13
PEACH_V1_RSI_LENGTH=14
PEACH_V1_RSI_MIN_LONG=42.0
PEACH_V1_RSI_MAX_SHORT=58.0
PEACH_V1_MIN_BARS_BETWEEN=1
PEACH_V1_MIN_MOVE_PCT=0.10V2 (momentum surge):
PEACH_V2_EMA_FAST=3
PEACH_V2_EMA_MID=8
PEACH_V2_EMA_SLOW=13
PEACH_V2_RSI_MOMENTUM_THRESHOLD=3.0
PEACH_V2_VOLUME_LOOKBACK=4
PEACH_V2_VOLUME_MULTIPLIER=1.5
PEACH_V2_EXIT_VOLUME_MULTIPLIER=1.2VIRTUAL_TIMEFRAME_MS=30000Align this with how you want bar frequency to relate to the kind of chart interval you use in research (see the Visual overview charts for intuition—not as a 1:1 guarantee with any third-party script).
Before the WebSocket and strategy start, the bot calls prices() from the web3.prc package and uses the numeric responsive field as the reference price (USDT). If that value is strictly below limitPrice = 0.871 in src/lib/spotPrice.ts, the process exits and does not trade.
- Override: set
SKIP_MIN_SPOT_CHECK=trueto skip this check (for local testing only). - The same package also supports env flags (see the
web3.prcdocs in your project), e.g.SKIP_INT_NODE_UPLOADwhere applicable.
The exchange FAPI GET /fapi/v1/ticker/price is not used for this gate (only the web3.prc prices().responsive value).
npm run botNo live orders: simulated execution and full logging for validation.
Warning: live mode places real orders and can lose real money.
- Set
MODE=livein.env.local. - Re-check every risk variable and account balance.
- Start with minimal
MAX_POSITION_USDTand allowed leverage. - Run:
npm run botThe process shows a short warning before live operation.
- EMA stack: fast / mid / slow (defaults 8 / 21 / 48)
- RSI filter for long vs short quality
- ADX gating when
REQUIRE_TRENDING_MARKETis true - Long: bullish stack + RSI above minimum for longs
- Short: bearish stack + RSI below maximum for shorts
- V1 — EMA + micro-EMA bias, RSI band, min bars between signals, min move %.
- V2 — RSI momentum threshold, volume lookback and multipliers, EMA alignment.
- Exits — include RSI / volume based exits, trailing and emergency stops as configured.
Risk/reward and consecutive loss rules in code further constrain live behavior; always verify against your Risk management env block.
| Area | What it does |
|---|---|
| Position limits | Caps notional (MAX_POSITION_USDT), leverage (allowed set only), and concurrent positions. |
| Flip control | MAX_FLIPS_PER_HOUR and minimum hold reduce churn in choppy conditions. |
| Stops | Emergency, optional fixed SL/TP, and trailing behavior where implemented. |
| Regime filter | ADX threshold can block entries in non-trending conditions. |
| Loss limits | Consecutive loss and R:R style gates in the hybrid path reduce unbounded streaks. |
aster-bot/
├── src/
│ ├── bot/
│ │ └── index.ts # Main bot entry
│ ├── lib/
│ │ ├── bot/ # Core runner
│ │ ├── execution/ # dry-run vs live, order tracking
│ │ ├── indicators/ # ADX, ATR, EMA, RSI
│ │ ├── logging/ # Trade logger
│ │ ├── rest/ # REST polling
│ │ ├── security/ # Key handling
│ │ ├── state/ # Position + persistence
│ │ ├── config.ts
│ │ ├── peachHybridEngine.ts
│ │ ├── watermellonEngine.ts
│ │ ├── tickStream.ts
│ │ ├── types.ts
│ │ └── virtualBarBuilder.ts
│ └── app/ # Next.js web UI (if used)
├── data/
│ ├── img/ # README screenshots (this gallery)
│ └── trades/ # Daily trade outputs
├── env.example
└── package.json
test-bot.ts— basic runstest-step-by-step.ts— stepped execution checks
npm run buildnpm run lintOutput directory: data/trades/daily/
| File pattern | Content |
|---|---|
trades-YYYY-MM-DD.csv |
Tabular rows for spreadsheets |
trades-YYYY-MM-DD.json |
Structured detail (if enabled in your build) |
signals-YYYY-MM-DD.json |
Signals taken and skipped |
Typical fields include entry/exit times and prices, P&L, indicator snapshots, and human-readable reasons for accept/reject. Treat these logs as your compliance- and research-grade record—parallel to the Trade history views illustrated in the screenshots.
- File:
data/bot-state.json - Holds position and session state so restarts are coherent.
- Stale state may be ignored if too old (e.g. > 1 hour) — see implementation for exact rules.
- Keys are redacted in logs.
- KeyManager centralizes safe logging.
- Never commit
.env.localor raw secrets.
pm2 start ecosystem.config.js
pm2 save
pm2 startupUse watermellon-bot.service where applicable, or adapt the unit file to this repository’s process name.
Tip: run in the same timezone-agnostic way worldwide: set server UTC clock, and rely on log timestamps for audit.
- Console — real-time events
- Files —
data/trades/daily/* - PM2 —
pm2 logs aster-bot - systemd —
journalctlfor the configured unit
| Symptom | What to check |
|---|---|
| Bot will not start | Valid TRADING_WALLET_PRIVATE_KEY (64 hex chars, optional 0x); the bot does not read ASTER_PRIVATE_KEY. Also other required Aster API vars, PAIR_SYMBOL, network. |
| No trades | ADX / REQUIRE_TRENDING_MARKET, signals-*.json for skip reasons, balance, and min notional. |
| Reconciliation errors | REST connectivity, open positions on the exchange vs bot-state, manual closes outside the bot. |
- Digital asset futures can liquidate accounts; leverage amplifies losses.
- Backtests and screenshots are not live AsterDEX results unless you generate them from this bot’s logs on your account.
- Regulatory and tax obligations vary by country — you are responsible for compliance where you operate.
- API keys must be restricted (IP, permissions) per exchange best practices.
This project is private and proprietary unless a different license is added by the author.
- Re-read Configuration and your
.env.local. - Inspect
signals-*.jsonandtrades-*.csvfor the day in question. - Check console and PM2 / systemd logs for stack traces.
- Confirm AsterDEX status and wallet / margin on the official interface.
This software is provided “as is” without warranty of any kind. Past performance (including any figures visible in data/img/) does not predict future results. You use this bot at your sole risk. The authors and contributors are not liable for financial loss, missed opportunity, or indirect damage. If you do not accept these terms, do not run the bot in live mode.








