Skip to main content

fastest python trading bot

Project description

nexustrader Logo

NexusTrader

Make every trade deterministic.


License Python Version Stars


NexusTrader is built for one thing: making live trading execution reliable.

And now, with NexusTrader MCP, AI agents can trade through the same execution-safe stack.

If you care about reliable trading, a star helps others discover the project.

Links

The Problem

If you trade live, you have probably seen at least one of these failures:

  • An order was sent, but you were not sure whether it was actually confirmed.
  • Network jitter, retries, or replayed signals created duplicate trades.
  • A WebSocket disconnect left balances, positions, or open orders out of sync.
  • A fast market exposed race conditions that looked fine in backtests.
  • Debugging execution failures turned into guesswork.

What Is NexusTrader?

NexusTrader is an execution reliability layer for live trading systems.

It is designed to help a strategy remain correct under delayed ACKs, reconnects, retries, and exchange-side uncertainty.

It is not just an exchange connector. It is the layer that keeps execution correct when markets, networks, and APIs behave badly.

AI-Native Trading With MCP

NexusTrader MCP exposes NexusTrader through the Model Context Protocol so AI systems can trade through the same deterministic execution layer.

What this means in practice:

  • Trade from AI agents
  • Trigger trades from natural language workflows
  • Connect the same trading backend to multiple MCP-compatible tools

Works with:

  • OpenClaw
  • Cursor
  • Codex
  • Claude Code

Example intent:

"Buy BTC if funding rate < 0 and log it."

With MCP in the loop, AI can analyze the condition, generate the signal, submit the order through NexusTrader, and log the result through one connected workflow.

Core Capabilities

  • Deterministic Order Execution: WebSocket orders are tracked until ACK, and ACK timeout triggers REST confirmation before the system decides the request failed.
  • Idempotent Orders: client_oid and idempotency_key help suppress duplicate creates and make retries safe.
  • Auto-Recovery After Disconnect: Private WS reconnect can automatically resync balances, positions, and open orders, then emit a diff to the strategy layer.
  • Safer Failure Handling: WS send failure, ACK timeout, and explicit rejection are surfaced as different failure paths instead of being mixed together.
  • Observable Execution State: Failed orders carry a reason, WS lifecycle events are published, and pending ACK state is tracked explicitly.
  • MCP-Friendly AI Integration: The NexusTrader MCP layer lets you connect the trading stack to MCP-compatible assistants such as Codex, Claude Code, Cursor, and OpenClaw without building a separate adapter for each tool.

Why Not Other Tools?

Capability CCXT Hummingbot NexusTrader
Order confirmation path
Duplicate order protection
Reconnect reconciliation ⚠️
WS ACK timeout recovery
AI trading support via MCP
Natural language trading workflows
Multi-exchange live trading ⚠️

One-Liner

Others let you trade. NexusTrader helps ensure the trade is correct, even when AI is part of the loop.

Architecture

Strategy
   ↓
NexusTrader
   ↓
Exchange APIs

Use Cases

  • Cross-exchange arbitrage
  • Market making
  • High-frequency trading
  • Multi-symbol strategies
  • Fully automated live trading systems
  • TradFi workflows via Bybit TradFi (MT5)

Performance Highlights

  • uvloop for a faster event loop on non-Windows systems
  • picows for low-latency WebSocket handling
  • msgspec for fast serialization and structured models
  • Batched subscriptions and inflight tracking for high-symbol-count strategies
  • Lightweight pure-Python runtime plus loguru (zero build requirements, built-in time-based log rotation)

Installation

pip install nexustrader

TradFi support on Windows:

pip install "nexustrader[tradfi]"

Quick Start

Inside a strategy, submit orders with deterministic identifiers:

from decimal import Decimal
from nexustrader.constants import OrderSide, OrderType

self.create_order_ws(
    symbol="BTCUSDT-PERP.OKX",
    side=OrderSide.BUY,
    type=OrderType.LIMIT,
    amount=Decimal("0.001"),
    price=Decimal("90000"),
    client_oid="entry_001",
    idempotency_key="signal:btc:entry",
)

Why this matters:

  • The strategy makes the decision.
  • NexusTrader makes execution safer.
  • MCP lets AI systems access the same trading workflow.

Start Here

Supported Exchanges

  • Binance
  • Bybit
  • OKX
  • Bitget
  • HyperLiquid
  • Bybit TradFi (MT5)

Bybit TradFi

NexusTrader also supports traditional financial markets through Bybit TradFi with MetaTrader 5 as the execution backend.

  • Windows only; base installs on Linux/macOS do not install MetaTrader5
  • Supports Forex, Gold, Indices, and Stocks
  • Symbol mapping is normalized into NexusTrader format such as XAUUSD_s.BYBIT_TRADFI

See the docs for installation, credentials, and runnable examples.

Contributing

Contributions are welcome.

  • Open an issue first if you are planning a feature or non-trivial change.
  • Read CONTRIBUTING.md before opening a pull request.
  • Target the main branch for pull requests.

Social

X (Twitter) Discord Telegram

License

NexusTrader is released under the MIT License. See LICENSE for details.

Star History

Star History Chart

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexustrader-0.3.28.tar.gz (250.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexustrader-0.3.28-py3-none-any.whl (303.4 kB view details)

Uploaded Python 3

File details

Details for the file nexustrader-0.3.28.tar.gz.

File metadata

  • Download URL: nexustrader-0.3.28.tar.gz
  • Upload date:
  • Size: 250.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for nexustrader-0.3.28.tar.gz
Algorithm Hash digest
SHA256 cf99ec96b035527e10c489a79e1966ad2007589b00ea3d9822d10afa389b9dd2
MD5 7ad37efa3454cee20cf719a03d18428b
BLAKE2b-256 d66efc4e6460264752cfe163adb88ac3fc502a07a9f63245d98ab047cd9716bd

See more details on using hashes here.

File details

Details for the file nexustrader-0.3.28-py3-none-any.whl.

File metadata

  • Download URL: nexustrader-0.3.28-py3-none-any.whl
  • Upload date:
  • Size: 303.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for nexustrader-0.3.28-py3-none-any.whl
Algorithm Hash digest
SHA256 a782aee3ddaa99e817aac9edc62e36de8ff37b8c48b0995258b71ab2e963d271
MD5 68e86d48c9177792821254730487715d
BLAKE2b-256 cc302b24660ef5db476047e943862c84dbb1ccc484afc59dcab99551935dcbd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page