Modular, well-structured Node.js package for automated trading on Aster DEX. Written in TypeScript, with support for multiple bot strategies, REST + WebSocket integration, configurable risk, and paper trading.
- Modular strategy classes: TrendFollowing, MarketMaking, LiquidationHunter, VolumeGeneration, CopyTrading, Telegram
- Full Aster DEX integration: REST (Spot & Futures) and WebSocket for real-time data
- Secure credentials: API keys via environment variables only
- Config-driven: YAML/JSON config with Zod validation
- Structured logging: Pino with configurable levels
- Error handling & retries: Rate-limit backoff and configurable retries
- Paper trading: Simulate orders without real funds
- CLI: Run any strategy with a single command
- Node.js v18+
- npm or yarn
git clone <repo-url>
cd aster-dex-trading-bots
npm install
npm run buildCopy .env.example to .env and set your Aster DEX API credentials:
cp .env.example .envSpot (HMAC):
ASTER_API_KEY– from Aster API WalletASTER_API_SECRET
Futures (EIP-712 / Pro API):
ASTER_API_KEY,ASTER_API_SECRETASTER_USER– main wallet addressASTER_SIGNER– API wallet addressASTER_SIGNER_PRIVATE_KEY– API wallet private key
Never commit .env or expose private keys.
Use a YAML or JSON file to select the bot type and strategy parameters. Example configs are in configs/.
Example: trend-following (paper trading)
botType: trend_following
product: spot
symbols:
- BTCUSDT
- ETHUSDT
risk:
maxPositionSize: "0.001"
maxDrawdownPercent: 20
maxOpenOrders: 5
paperTrading: true
logLevel: info
strategy:
emaFastPeriod: 12
emaSlowPeriod: 26
rsiPeriod: 14
rsiOversold: 30
rsiOverbought: 70
entryThreshold: 0.5
exitThreshold: 0.5
stopLossPercent: 2
takeProfitPercent: 4CLI (recommended):
# After npm run build
node dist/cli.js start --config ./configs/trend-following.yaml
# Or with npx / npm link
aster-bot start --config ./configs/trend-following.yamlDevelopment (tsx):
npm run cli -- start --config ./configs/trend-following.yamlPaper trading: Set paperTrading: true in the config. No real orders are sent; actions are only logged.
Graceful shutdown: Send SIGINT (Ctrl+C) or SIGTERM to stop the bot and close WebSocket connections.
| Strategy | Description |
|---|---|
| TrendFollowingBot | EMA + RSI + SMA; configurable entry/exit, stop-loss, take-profit. Fetches klines and places trades when conditions are met. |
| MarketMakingBot | Dual-sided limit orders around mid; inventory skew and spread adjustment; order refresh. |
| LiquidationHunterBot | Subscribes to liquidation stream via WebSocket; places trades with VWAP-style protection; supports paper trading. |
| VolumeGenerationBot | Grid of limit orders near market with small take-profit; configurable grid step and max orders. |
| CopyTradingBot | Mirrors a target trader/strategy (e.g. competition AI); copy ratio and max position; extend fetchTargetPositions() for your API. |
| TelegramBot | Wraps another bot; Telegram commands for status, PnL, optional one-click trading; requires node-telegram-bot-api. |
aster-dex-trading-bots/
├── src/
│ ├── api/ # REST client, WebSocket client, auth (HMAC, EIP-712)
│ ├── bots/ # BaseBot + all strategy implementations
│ ├── config/ # Schema (Zod), loader (YAML/JSON)
│ ├── strategies/ # Indicators (EMA, SMA, RSI), risk helpers
│ ├── utils/ # Logger, retry, decimal, errors
│ ├── types/ # API and config types
│ ├── cli.ts # CLI entry (aster-bot start --config)
│ └── index.ts # Package exports
├── configs/ # Example YAML configs per bot type
├── tests/
│ └── unit/ # Jest tests (config, indicators, auth)
├── .env.example
├── package.json
├── tsconfig.json
└── README.md
You can use the clients and bots programmatically:
import { loadConfig } from 'aster-dex-trading-bots';
import { AsterRestClient } from 'aster-dex-trading-bots';
import { createBot } from 'aster-dex-trading-bots';
const config = loadConfig({ path: './configs/trend-following.yaml' });
const rest = new AsterRestClient({
product: config.product,
credentials: {
apiKey: process.env.ASTER_API_KEY!,
apiSecret: process.env.ASTER_API_SECRET!,
},
});
const bot = createBot({ config, rest });
await bot.start();npm testUnit tests cover config loading, indicators (SMA, EMA, RSI), and HMAC auth. Use a testnet config and testnet credentials for any integration tests.
Aster DEX applies per-IP rate limits. The client respects 429 and Retry-After; repeated violations can lead to temporary IP bans. Prefer WebSocket streams where possible to reduce REST load.
This software is for educational and research purposes. Trading cryptocurrencies and derivatives involves substantial risk of loss. Past performance does not guarantee future results. Use paper trading first. The authors are not responsible for any financial losses. Always comply with your jurisdiction’s laws and Aster DEX terms of service.
MIT