A momentum-based trading bot for Aster DEX BTC/USDT perpetual futures.
- Momentum-based trading signals using second derivative (acceleration) of price
- Automatic long/short position opening based on momentum threshold
- Take profit at +10% and stop loss at -5%
- Browser-based terminal for control and monitoring
- Real-time position tracking with PnL display
- Portfolio value tracking
- Position amounts specified in USDT (automatically converted to BTC)
- Python 3.8+
- Aster DEX account with API/Agent wallet
- Clone the repository:
git clone https://github.com/Signal-Six/Asterbot.git
cd Asterbot- Install Python dependencies:
pip install -r requirements.txt- Go to Aster DEX API Dashboard
- Connect your main wallet (MetaMask)
- Create an "Agent" (API wallet) - this generates a separate wallet for API access
- Copy the Agent wallet address - this is your "Main Wallet Address"
- Copy the Agent's private key - this is your "Secret Key"
Make sure your Agent wallet has:
- Futures trading permissions enabled
- Enough USDT balance for the position amount you want to trade
- Start the backend server:
cd Asterbot/backend
python app.pyOr simply run:
run.batThe server will start on http://localhost:8000 and automatically open the terminal in your browser.
- Main Wallet Address (user): Enter your Agent wallet address (from the API dashboard)
- Agent Wallet Private Key (signer): Enter the Agent wallet's private key
- Position Amount (USDT): Enter the amount in USDT (e.g., 100)
Click "Configure" to save your settings, then "Test Connection" to verify.
- Momentum Calculation: Uses the second derivative (acceleration) of price changes over 100 1-minute klines
- Signal Generation:
- If normalized acceleration >= 0.1 → Open LONG
- If normalized acceleration < 0.1 → Open SHORT
- Position Sizing: USDT amount is converted to BTC quantity based on current price
- Take Profit: Closes position at +10% PnL
- Stop Loss: Closes position at -5% PnL
- Recovery: After stop loss, waits 60 seconds before taking new signals
The Status panel shows:
- Bot Status: Running/Not Running
- Connection: Connected/Disconnected to Aster DEX
- Current BTC Price: Real-time BTC/USDT price
- Portfolio Value: Total account value in USD
- Position: Current position (LONG/SHORT), entry price, and PnL (in USDT and %)
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | API info |
/terminal.html |
GET | Web terminal |
/config |
POST | Configure API keys and position (USDT) |
/ping |
GET | Test connection |
/price |
GET | Get current BTC price and momentum data |
/signal |
GET | Get current trading signal |
/order |
POST | Place manual order |
/close |
POST | Close current position |
/position |
GET | Get position status |
/balance |
GET | Get account balance |
/portfolio |
GET | Get total portfolio value |
/start |
POST | Start automated trading |
/stop |
POST | Stop trading |
/status |
GET | Get bot status |
This bot is for educational purposes. Cryptocurrency trading involves substantial risk. Always test with small amounts first and never trade more than you can afford to lose.
Asterbot/
├── backend/
│ ├── app.py # FastAPI backend server
│ ├── aster_client.py # Aster DEX API client (EIP-712 auth)
│ ├── trading_logic.py # Trading logic and momentum calculation
│ └── config.py # Configuration settings
├── frontend/
│ └── terminal.html # Browser-based trading terminal
├── requirements.txt # Python dependencies
└── run.bat # Quick start script