Home / Libraries / ML4T Live / Docs
ML4T Live
ML4T Live Documentation
Production trading with broker integrations
Skip to content

Installation

Requirements

  • Python 3.11+
  • A supported broker or data source for live use
  • ml4t-backtest is installed automatically as a package dependency

Install From PyPI

pip install ml4t-live

Optional Add-Ons

ml4t-live installs the core broker/feed stack used by the package. DataBento is optional and must be installed separately if you want DataBentoFeed:

pip install databento

Install From Source

git clone https://github.com/ml4t/live.git
cd live
uv sync --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")