Skip to content

VtrAha/aster-bot

Repository files navigation

🌟 Aster Trading Bot — Where Automated Strategies Meet the Cosmos

GitHub Aster DEX FAPI


🌱 The Garden of Perpetual Dreams

Source: github.com/VtrAha/aster-bot

In the dense forest of market volatility,
two botanical minds bloom:
    🍉 the Watermellon — steady, patient, rooted
    🍑 the Peach Hybrid — nimble, dual-souled, emergent
Both feed on order flow.
Both seek the sun's warmth (gains).
Both know the soil's bitter truth (losses).

Automated futures trading on Aster DEX — a perpetual paradise built on TypeScript/Node.js. Dual-engine strategies. Risk architecture that sleeps so you don't have to. Production-grade logging that never forgets.

Aster thrives on ASTERUSDT-style perpetual markets. Deploy it anywhere. Backtest in safety. Scale with confidence. Or watch it burn. (We provide the extinguisher.)

⚠️ Danger Zone: Digital asset futures are leverage on fire. Liquidation isn't a warning—it's an eviction notice. Screenshots are dreams. Results are reality. Read the warnings before you press go.


📖 Navigation Map

Section What Lives There
The Visual Oracle Charts, signals, and the evidence of execution
Botanical Arsenal What each strategy eats for breakfast
For Whom This Grows You? Probably. Or maybe not.
The Greenhouse Setup Prerequisites and installation rituals
Cultivating Behavior Every knob, lever, and environment variable
The Art of Running Dry-run, live, and everything between
Risk as Poetry How we keep you from total ruin
The Library File structure that won't make you weep
Deployment Ceremonies PM2, systemd, and the machines that keep running
When Things Go Wrong Debugging your way to enlightenment
The Fine Print Disclaimers that matter

🔮 The Visual Oracle

All prophecies live in data/img/ — not the future, but the past evidence of what happened.

The Tapestry of Signals

The 30-second heartbeat — price dances to the beat of moving averages. Long signals bloom. Short signals wither. On the side: a stats altar displaying trades taken, win rate, P&L percentage, profit factor, and the memory of your best trade.

Short-timeframe chart with V1/V2 long and short signals stacked atop a moving average tapestry

The 2-minute epoch — same language, more context. RSI whispers. Volume shouts. Understand how signal density and timeframe depth interact before you tune VIRTUAL_TIMEFRAME_MS.

Medium-timeframe strategy with V1/V2 signals, RSI, and volume context

The Trade Ledger — Wins & Wounds

The Green Rows Ascending — Sell executions with positive realized profit stacked like coins in a vault. Tight timestamps. Same symbol. The dream we all chase.

ASTERUSDT sells showing positive realized profit in USDT columns

The Bullet Storm — Many fills compressed into seconds. Prices locked in a tight range. Fees visible. Activity metrics that make your heart race.

High-frequency sell executions with visible fees and P&L

The Round Trip — Buy opens. Sell closes. The dance of entry and exit. Buy shows zero realized (unrealized). Sell locks in the truth.

ASTERUSDT buy and sell flow with profit attribution on close

The Control Room — Order book left. Chart center. Equity and margin summary. Trade history on the right. Some rows glow green. Some rows bleed red. Most traders stare at this 24/7.

Full trading workspace: order book, chart, and mixed P&L history

The Session Scroll — Hours of Buy/Sell rows. Small notionals. Fees in USDT. Realized outcomes in your CSV/JSON. This is your archaeological truth.

Session log with many buy, sell, and mixed realized P&L rows

The Consistent Hand — Repeated 20 ASTER per fill. Alternating sides. Small but non-zero P&L on each close. Aligns with your position sizing and leverage settings.

Trade log with fixed quantity per fill and alternating realized P&L

The Scalper's Prayer — Narrow band. Fast flips. Everything happens in the blink of an eye. Compare against MAX_FLIPS_PER_HOUR.

High-turnover ASTERUSDT showing green and red realized outcomes


🌿 Botanical Arsenal

WatermellonThe Patient Gardener

  • EMA Stack: Fast (8) catches movement. Mid (21) sees medium truth. Slow (48) knows the season.
  • RSI Filter: Long needs warmth above threshold. Short needs cold below threshold.
  • ADX Guardian: Won't trade when market is ranging (unless you override).
  • Philosophy: Trend is your friend. Confirmation is your insurance.

Peach HybridThe Dual-Soul Philosopher

V1: The Bias LayerWhat is the market's mood?

  • EMA cascade (fast, mid, slow) establishes direction
  • Micro-EMA (5, 13) detects micro-trends and noise
  • RSI band defines long vs short quality
  • Min bars between: No spamming signals; respect the cooldown
  • Min move %: Ignore tiny flickers; only trade meaningful swings

V2: The Momentum SurgeIs energy building?

  • RSI momentum threshold detects acceleration (sudden RSI jump)
  • Volume lookback & multiplier: Confirm surge with volume spike
  • Fast EMA alignment: Align with short-term trend
  • Philosophy: V1 says "now is the time." V2 says "and here comes the power."

Exit Choreography:

  • RSI-based exits — momentum fades, time to go
  • Volume-based exits — party's over
  • Trailing stops — lock in profits as price runs
  • Emergency stopswhen all else fails, exit with honor

👥 For Whom This Grows

Quant junkies who dream of single pair, single codebase, clear behavior
Global operators in Singapore, New York, Lagos, Tokyo — timezone-agnostic
Developers comfortable with TypeScript, .env files, and reading logs before going large
Risk-aware traders who understand leverage and aren't surprised by losses

Noobs seeking riches — this is a tool, not a lottery ticket
Copy-paste warriors — you need to understand what you're running
Emotional traders — let the bot handle emotions; you handle sleep


🔧 The Greenhouse Setup

What You Need Before Planting

  • Node.js 18+ and npm (the soil)
  • AsterDEX account with API credentials (the seeds)
  • TypeScript literacy if you plan to breed custom strategies

Installation Ritual

# 1. Clone the garden
git clone https://github.com/VtrAha/aster-bot.git
cd aster-bot

# 2. Plant dependencies
npm install

# 3. Copy the template soil
cp env.example .env.local

# 4. Edit .env.local with your secrets (see Cultivating Behavior below)

🌱 Cultivating Behavior

The Essential Seeds (Required)

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
TRADING_WALLET_PRIVATE_KEY=your_64_char_hex_key  # 64 hex chars. NO 0x. Bot validates on startup.
PAIR_SYMBOL=ASTERUSDT-PERP
MODE=dry-run

Risk Guardrails (You Will Lose Without These)

MAX_POSITION_USDT=10000              # Portfolio weight cap
MAX_LEVERAGE=5                        # Must be: 5, 10, 15, or 50
MAX_FLIPS_PER_HOUR=12                # Prevent churn in noise
STOP_LOSS_PCT=0                      # Optional: fixed stop level
TAKE_PROFIT_PCT=0                    # Optional: fixed profit exit
USE_STOP_LOSS=false                  # Enable/disable fixed stops
EMERGENCY_STOP_LOSS_PCT=2.0          # Blow-up circuit breaker
MAX_POSITIONS=1                       # Concurrent open positions
REQUIRE_TRENDING_MARKET=true         # ADX gating
ADX_THRESHOLD=25                     # Minimum ADX to trade

Strategy DNA

Choose your gardener:

STRATEGY_TYPE=peach-hybrid  # or: watermellon

Watermellon Configuration

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

Peach Hybrid — V1 (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

Peach Hybrid — V2 (Momentum)

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 Tuning

VIRTUAL_TIMEFRAME_MS=30000  # 30-second bars. Match your research charts.

The Minimum Price Gate

Before anything runs, the bot checks web3.prc price feed. If price falls below 0.871 USDT, the process halts. This prevents trading during catastrophic crashes.

Override (dev only):

SKIP_MIN_SPOT_CHECK=true

🎬 The Art of Running

Dry-RunThe Rehearsal

npm run bot

No real orders. Full logs. Simulate your strategy on real market data. This is your sandbox. Use it.

Live ModeThe Performance

# 1. Set MODE=live in .env.local
# 2. Review EVERY risk variable
# 3. Check your account balance on AsterDEX
# 4. Start SMALL. (Did we mention small?)
npm run bot

The bot will warn you. Then it will trade with real money. Then you will either celebrate or question your life choices. Probably both.


🛡️ Risk as Poetry

Layer What It Guards How
Position Sizing Total notional exposure MAX_POSITION_USDT hard cap
Leverage Limits Margin call avoidance Only supported values allowed
Flip Control Emotional churn tax MAX_FLIPS_PER_HOUR throttle
Trending Filter Signal noise reduction ADX gating (REQUIRE_TRENDING_MARKET)
Fixed Stops Predetermined exits STOP_LOSS_PCT, TAKE_PROFIT_PCT
Trailing Stops Profit protection during runs Implemented per strategy
Emergency Stop Circuit breaker EMERGENCY_STOP_LOSS_PCT kills position
Consecutive Loss Limits Streak breaking Code-level gates prevent ruin
Loss Streak Logic Recovery time R:R checks reduce unbounded losses

The unspoken rule: Every control exists because someone lost big without it.


📚 The Library

aster-bot/
├── src/
│   ├── bot/
│   │   └── index.ts                 # The beating heart
│   ├── lib/
│   │   ├── bot/                     # Core runner & orchestration
│   │   ├── execution/               # Dry-run vs live order mechanics
│   │   ├── indicators/              # ADX, ATR, EMA, RSI mathematics
│   │   ├── logging/                 # Trade & signal recordkeeping
│   │   ├── rest/                    # REST API polling
│   │   ├── security/                # Key handling & redaction
│   │   ├── state/                   # Position tracking & persistence
│   │   ├── config.ts                # Configuration parser
│   │   ├── peachHybridEngine.ts     # Peach strategy brains
│   │   ├── watermellonEngine.ts     # Watermellon strategy brains
│   │   ├── tickStream.ts            # WebSocket price stream
│   │   ├── types.ts                 # TypeScript definitions
│   │   └── virtualBarBuilder.ts     # OHLCV candle assembly
│   └── app/                         # Next.js web UI (optional)
├── data/
│   ├── img/                         # Screenshot gallery
│   ├── bot-state.json               # Persistent session state
│   └── trades/daily/                # Daily CSV/JSON outputs
├── env.example                      # Template for .env.local
└── package.json

Output Artifacts

Your daily truth lives in data/trades/daily/:

File Purpose Use Case
trades-YYYY-MM-DD.csv Row-by-row trade record Spreadsheet analysis, tax reconciliation
trades-YYYY-MM-DD.json Structured detail (if enabled) Programmatic backtesting, compliance
signals-YYYY-MM-DD.json Signal taken/skipped log Strategy debugging, entry analysis

All timestamps are UTC. All P&L is real.


🚀 Deployment Ceremonies

PM2The Daemon that Never Sleeps

pm2 start ecosystem.config.js
pm2 save
pm2 startup
pm2 logs aster-bot  # Watch in real time

systemdThe Old Guard

Use watermellon-bot.service and adapt for this repo, or create your own:

sudo systemctl enable aster-bot
sudo systemctl start aster-bot
journalctl -u aster-bot -f  # Follow logs

Monitoring Reality

  • Console: Real-time events stream by
  • Files: data/trades/daily/* — your ledger
  • PM2: pm2 monit or pm2 logs
  • systemd: journalctl for the archaeological record

🔥 When Things Go Wrong

Symptom Diagnosis Medicine
Bot crashes on startup Invalid TRADING_WALLET_PRIVATE_KEY (must be 64 hex; bot does NOT read ASTER_PRIVATE_KEY) Verify format: 0x-optional, exactly 64 chars
No trades, just watching REQUIRE_TRENDING_MARKET=true but ADX < threshold Check signals-*.json for "market not trending" skips, or set ADX lower
Position mismatch Manual closes outside the bot; exchange state diverged Reconcile on AsterDEX UI, restart with clean state
Weird P&L numbers Fees, slippage, margin funding—read each trade line Check trades-*.csv per-line detail; cross-reference with exchange history
Memory leak after 48h Stale state file or WebSocket reconnect backlog Restart bot process via PM2/systemd

⚠️ The Gravity of Leverage

THIS IS NOT OPTIONAL READING:

  • Futures aren't stocks. Leverage amplifies everything—profit and loss.
  • Liquidation is real. Your account can evaporate in milliseconds.
  • Backtests lie. Past performance is a dream; future results are unknown.
  • Your money, your risk. The bot is a tool. You are the owner of outcome.
  • Regulatory varies. Tax, KYC, AML obligations differ by country. You handle compliance.
  • API keys are keys to the kingdom. Restrict them: IP whitelist, read-only where possible, rotate regularly.

If you skip this section and lose money, that's on you—not the code.


📜 The Fine Print

License

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

Support Pathway

  1. Re-read Cultivating Behavior and check your .env.local
  2. Inspect logs: signals-*.json (why was entry skipped?) and trades-*.csv (what actually happened?)
  3. Check console for stack traces; check PM2 / systemd logs for process errors
  4. Verify AsterDEX status via official interface: wallet funded? Margin available? API working?

Disclaimer

This software is provided "AS IS" without warranty of any kind.

PAST PERFORMANCE (including screenshots) 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 damages.

Digital asset futures are leveraged instruments. Losses can exceed 
your initial investment.

If you do not accept full responsibility for outcomes, DO NOT run 
in LIVE mode.

🌟 Final Words

The Aster grows because you feed it data, configuration, and capital. It blooms in trending markets. It withers in noise. It never gets tired. It never sleeps. It never regrets.

You are the gardener. The market is the soil. The bot is the tool.

Trade wisely. Risk responsibly. Log obsessively.

May your signals align and your leverage be modest.


Repository: github.com/VtrAha/aster-bot
Aster DEX: www.asterdex.com
FAPI Docs: fapi.asterdex.com

About

asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot, asterDEX trading bot, perp trading, asterDEX auto trading bot,

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors