Skip to content

Anyashprasad/Trading_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ML-Enhanced Binance USDT-M Futures Testnet Bot

A simplified trading bot for Binance USDT-M Futures Testnet with a supervised ML signal (RandomForest), ATR-based risk overlay, CLI for train/backtest/live, exchange filter alignment, and full logging.

Features

  • Market and Limit orders on Futures Testnet (USDT-M) with optional STOP_MARKET protective exit.
  • CLI subcommands: train, backtest, live.
  • ML signal from OHLCV features; ATR-based position sizing and stops.
  • Logging of request payloads, responses, and errors to bot.log.

Requirements

  • Python 3.9+.
  • pip install -r requirements.txt

Environment

Create .env in the project root: BINANCE_API_KEY=xxx BINANCE_API_SECRET=yyy

text Do not commit .env; it is gitignored.

Train

15m model: python main.py --symbol BTCUSDT --interval 15m --limit 1500 train

text

Backtest

Example: python main.py --symbol BTCUSDT --interval 15m --limit 1500 backtest --model models/BTCUSDT_15m.joblib --threshold 0.80 --atr-n 14 --atr-mult 3.0 --risk-usdt 2

text

Live (Testnet)

Continuous loop with protective stop: python main.py --symbol BTCUSDT --interval 15m --limit 500 live --model models/BTCUSDT_15m.joblib --threshold 0.80 --atr-n 14 --atr-mult 3.0 --risk-usdt 2 --protect-stop --leverage 10 --margin ISOLATED --loop --sleep 60

text

Project structure

. ├── main.py ├── trading/ │ ├── bot.py │ ├── strategy.py │ └── utils.py ├── models/ │ └── BTCUSDT_15m.joblib (generated) ├── requirements.txt ├── .env (local only) ├── .gitignore └── bot.log (generated at runtime)

Notes

  • Uses Binance Futures Testnet base URL under the hood when --no-testnet is not set.
  • Expect Testnet fills/latency to differ from production; this is for mock trading only.

Troubleshooting

  • If install issues occur, ensure scikit-learn (not sklearn) is installed in the selected interpreter and that .env is loaded.
  • If backtest shows NaNs, ensure ATR warm-up handling is in place as in main.py.

About

Ml enhanced trading bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages