Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asterbot

A momentum-based trading bot for Aster DEX BTC/USDT perpetual futures.

Features

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

Prerequisites

  • Python 3.8+
  • Aster DEX account with API/Agent wallet

Installation

  1. Clone the repository:
git clone https://github.com/Signal-Six/Asterbot.git
cd Asterbot
  1. Install Python dependencies:
pip install -r requirements.txt

Getting Your API Credentials

  1. Go to Aster DEX API Dashboard
  2. Connect your main wallet (MetaMask)
  3. Create an "Agent" (API wallet) - this generates a separate wallet for API access
  4. Copy the Agent wallet address - this is your "Main Wallet Address"
  5. 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

Running the Bot

  1. Start the backend server:
cd Asterbot/backend
python app.py

Or simply run:

run.bat

The server will start on http://localhost:8000 and automatically open the terminal in your browser.

Terminal Configuration

  1. Main Wallet Address (user): Enter your Agent wallet address (from the API dashboard)
  2. Agent Wallet Private Key (signer): Enter the Agent wallet's private key
  3. Position Amount (USDT): Enter the amount in USDT (e.g., 100)

Click "Configure" to save your settings, then "Test Connection" to verify.

Trading Logic

  • 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

Terminal Status Display

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

API Endpoints

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

Warning

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.

Project Structure

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

About

A simple, browser-based terminal for managing a trade bot that initiates and closes trades algorithmically with definable position size.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages