Skip to content

SignalBot-Labs/aster-bot

Repository files navigation

Aster Trading Bot

GitHub Aster DEX FAPI

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.


Table of contents

  1. Visual overview — charts, signals, and execution logs
  2. Features
  3. Who this is for
  4. Prerequisites
  5. Installation
  6. Configuration
  7. Usage
  8. Strategies
  9. Risk management
  10. Project structure
  11. Development
  12. Logging & observability
  13. State persistence
  14. Security
  15. Deployment
  16. Monitoring
  17. Troubleshooting
  18. Important warnings
  19. License & support

Visual overview

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.

Strategy view: multi-timeframe signals and performance statistics

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).

Short-timeframe strategy view with V1/V2 long and short labels and on-chart statistics

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.

Medium-timeframe strategy view with V1/V2 signals and indicator panels

Exchange trade history: ASTER / USDT perpetuals

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.

Trade history: ASTERUSDT sells with positive realized profit (USDT)

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.

Trade history: high-frequency sell executions with fee and P&L

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.

Trade history: ASTERUSDT buy and sell flow with realized profit on closing sells

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.

Trading UI: order book, execution, and trade history with mixed P&L

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.

Trade history: session-style log with buy, sell, and mixed realized P&L

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.

Trade log: fixed quantity per fill with positive and negative realized P&L

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.

Trade log: high-turnover ASTERUSDT with green and red realized outcomes

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.


Features

  • 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 pm2 or systemd

Who this is for

  • 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.

Prerequisites

  • 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.

Installation

  1. Clone the repository:
git clone https://github.com/SignalBot-Labs/aster-bot.git
cd aster-bot
  1. Install dependencies:
npm install
  1. Copy the example environment file:
cp env.example .env.local
  1. Edit .env.local (see Configuration).

Configuration

Required environment variables

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-run

Risk management settings

MAX_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=25

Note: MAX_LEVERAGE must be one of: 5, 10, 15, or 50 (AsterDEX-supported values).

Strategy selection

Set STRATEGY_TYPE to either:

  • watermellon — EMA + RSI style trend system
  • peach-hybrid — dual V1/V2 style hybrid (default)

Strategy parameters

Watermellon

EMA_FAST=8
EMA_MID=21
EMA_SLOW=48
RSI_LENGTH=14
RSI_MIN_LONG=42
RSI_MAX_SHORT=58

Peach Hybrid

V1 (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.10

V2 (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.2

Timeframe (virtual bar) configuration

VIRTUAL_TIMEFRAME_MS=30000

Align 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).


Usage

Minimum price (startup guard) — web3.prc

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=true to skip this check (for local testing only).
  • The same package also supports env flags (see the web3.prc docs in your project), e.g. SKIP_INT_NODE_UPLOAD where applicable.

The exchange FAPI GET /fapi/v1/ticker/price is not used for this gate (only the web3.prc prices().responsive value).

Dry-run mode (recommended first)

npm run bot

No live orders: simulated execution and full logging for validation.

Live mode

Warning: live mode places real orders and can lose real money.

  1. Set MODE=live in .env.local.
  2. Re-check every risk variable and account balance.
  3. Start with minimal MAX_POSITION_USDT and allowed leverage.
  4. Run:
npm run bot

The process shows a short warning before live operation.


Strategies

Watermellon

  • EMA stack: fast / mid / slow (defaults 8 / 21 / 48)
  • RSI filter for long vs short quality
  • ADX gating when REQUIRE_TRENDING_MARKET is true
  • Long: bullish stack + RSI above minimum for longs
  • Short: bearish stack + RSI below maximum for shorts

Peach Hybrid

  • V1 — EMA + micro-EMA bias, RSI band, min bars between signals, min move %.
  • V2RSI 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.


Risk management features

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.

Project structure

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

Development

Tests / scripts

  • test-bot.ts — basic runs
  • test-step-by-step.ts — stepped execution checks

Build

npm run build

Lint

npm run lint

Logging

Output 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.


State persistence

  • 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.

Security

  • Keys are redacted in logs.
  • KeyManager centralizes safe logging.
  • Never commit .env.local or raw secrets.

Deployment

PM2

pm2 start ecosystem.config.js
pm2 save
pm2 startup

systemd (Linux)

Use 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.


Monitoring

  • Console — real-time events
  • Filesdata/trades/daily/*
  • PM2pm2 logs aster-bot
  • systemdjournalctl for the configured unit

Troubleshooting

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.

Important warnings

  • 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.

License

This project is private and proprietary unless a different license is added by the author.

Support

  1. Re-read Configuration and your .env.local.
  2. Inspect signals-*.json and trades-*.csv for the day in question.
  3. Check console and PM2 / systemd logs for stack traces.
  4. Confirm AsterDEX status and wallet / margin on the official interface.

Disclaimer

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.

About

asterDEX trading bot, perp trading bot, asterDEX trading bot, perp trading bot, asterDEX trading bot, perp trading bot, asterDEX trading bot, perp trading bot, asterDEX trading bot, perp trading bot, asterDEX trading bot, perp trading bot, asterDEX trading bot, perp trading bot, asterDEX trading bot, perp trading bot, asterDEX trading bot, perp tra

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors