Documentation
Skip to content

Installation

Requirements

  • Linux, macOS, or Windows
  • Python 3.12, 3.13, or 3.14
  • A supported broker or data source for live use
  • ml4t-backtest is installed automatically as a package dependency

The Live 0.2 candidate requires Python >=3.12,<3.15. Its calendar dependencies currently require NumPy <2.5 and Pandas <3.1 under the strict warning contract; NumPy 2.4.6 does not declare Python 3.15 support. Monthly three-OS diagnostic probes resolve the complete dependency set and exercise the public Hong Kong calendar. Those probes do not qualify normal Python 3.15 installation or replace the supported-version, artifact or provider gates. The scoped compatibility decision records the Live 0.2 boundary, expiry and upstream review triggers. Published Live 0.1.3 is unchanged.

Install From PyPI

uv add ml4t-live

Optional Add-Ons

ml4t-live installs the stable-supported broker/feed stack used by the package. The DataBento SDK is available only through the bounded optional extra for deliberate experimental evaluation:

uv add 'ml4t-live[experimental]'

Install From Source

git clone https://github.com/ml4t/live.git
cd live
uv sync --all-extras --dev

Broker Setup

Interactive Brokers

  1. Install and launch TWS or IB Gateway
  2. Enable API access in the IB settings
  3. Use port 7497 for paper trading or 7496 for live trading
from ml4t.live import IBBroker

broker = IBBroker(
    host="127.0.0.1",
    port=7497,
    client_id=1,
)

Alpaca

  1. Create an Alpaca account
  2. Generate API credentials
  3. Start with paper=True
from ml4t.live import AlpacaBroker

broker = AlpacaBroker(
    api_key="YOUR_API_KEY",
    secret_key="YOUR_SECRET_KEY",
    paper=True,
)

Verify Installation

from ml4t.live import (
    AlpacaBroker,
    AlpacaDataFeed,
    BarAggregator,
    IBBroker,
    LiveEngine,
    LiveRiskConfig,
    SafeBroker,
)

print("ml4t-live imports succeeded")

What To Do Next

After installation, the recommended first run is:

  1. Follow the Quickstart with execution_mode="shadow".
  2. Read Backtest to Live if you are porting an existing strategy.
  3. Configure the broker and feed pages that match your deployment path.
  4. Use the Book Guide to map chapter examples back to the library APIs.