AI-powered automated perpetual futures trading bot for Aster DEX, using Claude for market analysis and signal generation.
- AI-Driven Signals: Claude analyzes klines, order book depth, funding rates, and generates structured trading signals
- Dynamic Pair Scanning: Automatically selects high-volume, high-volatility trading pairs with anomalous funding rates
- Risk Management: Position sizing, leverage limits, stop-loss/take-profit, daily loss limits, and exposure caps
- Trailing Stops: Partial take-profit at 2:1 R/R, then trailing stop on the remainder
- Real-time Monitoring: WebSocket streams for market data and account/order updates
- Auto-Reconnect: WebSocket connections automatically reconnect on failure
main.py # Entry point & orchestration loop
src/
auth.py # EIP-712 signing for Aster v3 API
client.py # Async REST API client
ws_client.py # WebSocket client (market + user data)
scanner.py # Dynamic pair scanner & ranking
collector.py # Market data aggregation (REST + WS)
ai_analyzer.py # Claude AI analysis & signal generation
order_manager.py # Order execution (entry + SL/TP)
position_manager.py # Position tracking & trailing stops
risk_manager.py # Risk validation engine
models.py # Data models
config/
settings.yaml # Main configuration
pairs_filter.yaml # Pair whitelist/blacklist & filters
- Python 3.11+
- Aster DEX account with API wallet (Pro API)
- Anthropic API key
cd asterBot
pip install -r requirements.txtcp .env.example .envEdit .env with your credentials:
ASTER_USER=0xYourMainWalletAddress
ASTER_SIGNER=0xYourAPIWalletAddress
ASTER_PRIVATE_KEY=0xYourAPIWalletPrivateKey
ANTHROPIC_API_KEY=sk-ant-xxxxx
To create an API wallet (signer), go to https://www.asterdex.com/en/api-wallet and switch to Pro API.
Edit config/settings.yaml:
| Section | Key Parameters |
|---|---|
trading |
mode (hedge/one_way), default_leverage (5-10x) |
risk |
max_position_pct (10%), stop_loss_pct (2%), daily_loss_limit_pct (5%) |
scanner |
min_volume_usdt, top_n_pairs, scan interval |
ai |
Claude model, min_confidence (0.70), analysis interval |
Edit config/pairs_filter.yaml for whitelist/blacklist.
python main.py- Scan - Every 5 min, fetch all 24hr tickers and funding rates, rank by volume + volatility + funding anomaly
- Collect - Fetch klines, order book depth, mark price for top N candidates
- Analyze - Send market data to Claude, receive structured JSON signal (LONG/SHORT/CLOSE/HOLD)
- Validate - Risk manager checks position size, leverage, exposure, daily loss limits
- Execute - Place MARKET entry + STOP_MARKET stop-loss + TAKE_PROFIT_MARKET partial TP
- Monitor - Track positions via WebSocket, activate trailing stop after partial TP fills
| Rule | Default |
|---|---|
| Max position size | 10% of balance |
| Max total exposure | 50% of balance |
| Leverage range | 5-10x |
| Stop loss | 2% per trade |
| Take profit | 2:1 risk/reward ratio |
| Partial TP | 50% at first target |
| Trailing stop | 1% after partial TP |
| Daily loss limit | 5% - pauses trading |
| Max open positions | 5 |
Built on Aster Futures v3 API:
- REST:
https://fapi3.asterdex.com - WebSocket:
wss://fstream.asterdex.com - Auth: EIP-712 Typed Data signature (chainId=1666)
- Docs: https://asterdex.github.io/aster-api-website/
This software is for educational purposes. Cryptocurrency trading involves substantial risk of loss. Use at your own risk. Always test with small amounts first.