README.md

June 5, 2026 · View on GitHub

TradeMux — Unified API for forex trading

TradeMux Examples

Trade MT4 / MT5 from Python. No strategy logic in MQL. No custom bridge to maintain.

PyPI Python versions License Docs


Six runnable scripts that show what a real Python workflow looks like on top of TradeMux — from a one-line account check to a momentum strategy that fires live orders.

from trademux import MTClient

client = MTClient(api_key="sb_tmux_...")

print(client.get_account_info())
print(client.get_ohlc("EURUSD", timeframe="1h", count=200, as_df=True).tail())
print(client.buy_market("EURUSD", lots=0.01, sl=1.0900, tp=1.1000))

That's it. Same code works for MT4 and MT5.


How it fits together

┌──────────────┐        ┌──────────────┐        ┌─────────────────┐
│  Your Python │  HTTPS │   TradeMux   │   EA   │  MT4 / MT5      │
│   strategy   │ ─────▶ │   Gateway    │ ─────▶ │  Terminal       │
└──────────────┘        └──────────────┘        └─────────────────┘
   (this repo)            (mux.skybluefin.tech)    (your broker)

Your code talks to TradeMux over HTTPS while a lightweight EA in MT4/MT5 handles terminal execution and posts results back.


Install

pip install trademux

Grab a free starter key from console.trademux.io and map it to an MT account.

Configure

export TRADEMUX_API_KEY="sb_tmux_..."
export TRADEMUX_SERVER_URL="https://mux.skybluefin.tech"   # optional
export TRADEMUX_TIMEOUT="20"                               # optional

Run

python 01_quick_start.py

The Examples

#FileWhat it shows
0101_quick_start.pyConnect, check server, print account state and a live quote
0202_fetch_ohlc.pyRecent bars or a bounded historical window straight into a DataFrame
0303_place_order.pyMarket BUY / SELL with optional SL/TP — guarded against accidents
0404_monitor_positions.pyPoll account + open positions in a clean loop
0505_kill_switch.pyFlatten everything fast, with explicit confirmation guard
0606_simple_strategy.pyEnd-to-end: OHLC → signal → position check → optional execution

What you'll see

01_quick_start.py:

== Server ==
{'status': 'ok'}

== Account ==
{'balance': 10000.0, 'equity': 10042.5, 'floating_pnl': 42.5, 'open_positions': 1, ...}

== Live Quote: EURUSD ==
{'symbol': 'EURUSD', 'bid': 1.0852, 'ask': 1.0853, 'mid': 1.08525, ...}

02_fetch_ohlc.py returns a pandas DataFrame indexed by UTC time, sorted oldest-first — drop straight into your research notebook.


Safety Rails

The two scripts that can move money are intentionally locked behind explicit opt-ins:

ScriptRequired env var
03_place_order.pyTRADEMUX_ALLOW_LIVE_TRADES=1
05_kill_switch.pyTRADEMUX_CONFIRM_KILL_SWITCH=YES
06_simple_strategy.py (execution path)TRADEMUX_ALLOW_LIVE_TRADES=1

Without the flags, they print what they would do and exit. Test on a demo account first.


Common Patterns

Backfill bounded historical OHLC (capped at 5000 bars per request):

chunk = client.get_ohlc(
    "EURUSD",
    timeframe="1h",
    start_date="2025-01-01",
    end_date="2025-06-01",
    as_df=True,
)

Close every position with one magic number (useful when one strategy needs to bail out):

client.close_magic(122)

Emergency stop everything across all symbols / orders:

client.kill_switch(timeout=60)

If these snippets save you time, a ⭐ on the repo helps other quants find it.


About SkyBlue Fintech

TradeMux is built and operated by SkyBlue Fintech Solutions LLP [corporate site], a Singapore-based Data Analytics and Processing Company and a member of the Singapore FinTech Association.

SkyBlue Fintech logo