daishangona
binance-futures-trading-bot
TypeScriptโœจ New

This is simple future trading bot for Binance USD-M, Bybit linear and OKX swap markets: binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot binance trading bot

Last updated Jul 10, 2026
253
Stars
707
Forks
7
Issues
+36
Stars/day
Attention Score
97
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Multi-Exchange Futures Trading Bot

A production-style TypeScript futures trading bot supporting Binance USD-M, Bybit Linear, and OKX Swap markets with exchange-agnostic architecture, Kelly position sizing, and institutional-grade risk management.

TypeScript Node.js Binance Bybit OKX License


Features

  • โšก Multi-exchange architecture
  • ๐Ÿ“ˆ Momentum breakout strategy
  • ๐Ÿ’ฐ Kelly Criterion position sizing
  • ๐Ÿ›ก Advanced risk management
  • ๐Ÿ”„ Exchange-agnostic execution engine
  • ๐Ÿ“Š Funding rate awareness
  • ๐Ÿ“‰ Stop-loss & take-profit lifecycle
  • ๐Ÿšจ Daily loss kill switch
  • ๐Ÿ”’ API failure circuit breaker
  • ๐Ÿ“ Structured logging
  • ๐Ÿš€ Production-ready TypeScript codebase

Supported Exchanges

| Exchange | Market | | ---------- | ---------------- | | ๐ŸŸก Binance | USD-M Futures | | โšซ Bybit | Linear Perpetual | | โšช OKX | USDT Swap |

Switch exchanges simply by changing:

EXCHANGE=binance

or

EXCHANGE=bybit

or

EXCHANGE=okx

No strategy code needs to change.


Strategy

The trading engine follows a modular pipeline.

Market Data
      โ”‚
      โ–ผ
Momentum Strategy
      โ”‚
      โ–ผ
Funding Bias Filter
      โ”‚
      โ–ผ
Kelly Position Sizing
      โ”‚
      โ–ผ
Risk Validation
      โ”‚
      โ–ผ
Execution Engine
      โ”‚
      โ–ผ
Exchange Adapter
      โ”‚
      โ–ผ
Portfolio & State Store

Each layer has a single responsibility, making the system easy to extend and maintain.


Architecture

Market Data
                    โ”‚
                    โ–ผ
               Strategy Engine
                    โ”‚
                    โ–ผ
              Risk Management
                    โ”‚
                    โ–ผ
             Execution Engine
                    โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ           โ–ผ            โ–ผ
    Binance      Bybit         OKX
        โ”‚           โ”‚            โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚
                    โ–ผ
               State Store

Every exchange implements the same normalized interface.

The strategy never communicates directly with exchange-specific APIs.


Risk Management

The trading engine includes multiple independent safety systems.

  • Kelly-based position sizing
  • Maximum leverage limits
  • Maximum position notional
  • Daily loss kill switch
  • Consecutive API error protection
  • Per-symbol cooldown timers
  • Minimum and maximum position sizing
  • Funding-aware execution
The objective is to preserve capital first and pursue profits second.

Kelly Position Sizing

Position sizing uses STAKE-MATH.

import { computeFuturesKellyStake } from "./risk/position-sizing.js";

const stakeUsd = computeFuturesKellyStake({ winProbability: 0.58, riskRewardRatio: 2, bankroll: 10000, maxStakeUsd: 500, minStakeUsd: 10, kellyFraction: 0.5 });

Inputs include:

  • Win probability
  • Risk/Reward ratio
  • Current bankroll
  • Fractional Kelly
  • Minimum stake
  • Maximum stake
Default configuration uses Half Kelly (0.5) to reduce volatility while maintaining long-term growth.

Exchange Adapters

Every supported exchange is normalized behind a common interface.

| Exchange | REST | WebSocket | Notes | | -------- | ------------ | --------------------- | ---------------------- | | Binance | /fapi/v1/* | fstream.binance.com | Hedge mode, reduceOnly | | Bybit | /v5/* | V5 Public & Private | Unified Account | | OKX | /api/v5/* | V5 Public & Private | Demo & Production |

Adapters return normalized objects including:

  • Orders
  • Positions
  • Tickers
  • Funding Rates
  • Balances
  • Fills
This allows strategies to remain completely exchange-independent.

Project Structure

src/

โ”œโ”€โ”€ strategy/ โ”‚ โ””โ”€โ”€ Momentum breakout

โ”œโ”€โ”€ market/ โ”‚ โ””โ”€โ”€ WebSocket market data

โ”œโ”€โ”€ execution/ โ”‚ โ””โ”€โ”€ Order lifecycle

โ”œโ”€โ”€ risk/ โ”‚ โ””โ”€โ”€ Kelly sizing & protection

โ”œโ”€โ”€ exchange/ โ”‚ โ”œโ”€โ”€ Binance โ”‚ โ”œโ”€โ”€ Bybit โ”‚ โ””โ”€โ”€ OKX

โ”œโ”€โ”€ state/ โ”‚ โ””โ”€โ”€ Portfolio & persistence

โ”œโ”€โ”€ util/ โ”‚ โ””โ”€โ”€ Logging & helpers

โ””โ”€โ”€ index.ts


Quick Start

cp .env.example .env

npm install

npm run paper

Paper trading is enabled by default.

Switch exchanges through:

EXCHANGE=binance

or

EXCHANGE=bybit

or

EXCHANGE=okx

Available Scripts

| Command | Description | | --------------- | ------------------------ | | npm run build | Compile TypeScript | | npm run dev | Run with tsx | | npm run paper | Paper trading | | npm start | Run compiled application |


My Recommendation

If you're building automated trading systems:

  • start with paper trading
  • verify every signal manually
  • validate execution under different market conditions
  • backtest before deploying live capital
  • increase position size gradually
  • never trade with money you cannot afford to lose
Longevity is far more valuable than short-term gains.

Happy Trading โค๏ธ


Contributing

Contributions are welcome.

Whether you're interested in:

  • quantitative trading
  • exchange integrations
  • TypeScript
  • distributed systems
  • software architecture
  • performance optimization
feel free to open an Issue or Pull Request.

Disclaimer

This repository is provided for educational purposes only.

Nothing contained here should be interpreted as financial advice.

Futures trading carries substantial financial risk and the potential for significant losses.

Always validate strategies through extensive backtesting and paper trading before deploying real capital.

Never risk funds you cannot afford to lose.


Built with โค๏ธ for quantitative traders and TypeScript developers.

If this repository helped you learn something new, consider giving it a โญ.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท daishangona/binance-futures-trading-bot ยท Updated daily from GitHub