Skip to main content

ml4t-live

Python 3.12-3.14 PyPI License: MIT

Live trading runtime for ML4T strategies with broker integrations, risk checks, and shadow mode.

Use ml4t-live after a strategy has passed research and backtesting. It runs strategies that follow lifecycle version 1 against Interactive Brokers or Alpaca, applies SafeBroker limits, and supports a staged path from shadow mode to paper trading and live execution.

Installation

ml4t-live supports Python 3.12, 3.13, and 3.14 on Linux, macOS, and Windows.

uv add ml4t-live

The default installation includes the Interactive Brokers, Alpaca, CCXT, and OKX adapters. Install the experimental extra only when evaluating the DataBento feed:

uv add 'ml4t-live[experimental]'

Broker execution requires an account, a configured paper or live environment, and market-data permissions. The credential-free quick start below verifies the installed public API and shadow portfolio behavior without contacting a broker or placing an order.

Quick start

from ml4t.backtest import Order, OrderSide, OrderStatus
from ml4t.live import VirtualPortfolio

portfolio = VirtualPortfolio(initial_cash=100_000)
fill = Order(
    asset="SPY",
    side=OrderSide.BUY,
    quantity=10,
    order_id="shadow-1",
    status=OrderStatus.FILLED,
    filled_price=500.0,
    filled_quantity=10,
)
portfolio.process_fill(fill)

position = portfolio.positions["SPY"]
assert position.quantity == 10
assert portfolio.cash == 95_000
print(f"shadow position: {position.quantity:g} SPY")

Expected output:

shadow position: 10 SPY

Continue with the shadow-mode tutorial before connecting a provider.

Supported boundary

  • LiveEngine, SafeBroker, Interactive Brokers and Alpaca execution adapters, the OKX funding feed, and typed bar aggregation are stable-supported within their documented capabilities.
  • Alpaca, Interactive Brokers, generic CCXT, and DataBento feeds require explicit experimental opt-in with experimental=True. Experimental adapters report their missing guarantees on first use.
  • Shadow mode never routes orders to the wrapped broker. Paper and live modes require explicit execution identity and provider-specific qualification.
  • State and journal files enforce current-user ownership and mode 0600 on POSIX systems. On Windows, restrict the containing directory with service-account ACLs.
  • The package has no hardware-specific acceleration or hardware dependency.

Read the support and qualification boundary before promoting a strategy beyond shadow mode.

Documentation

ml4t-backtest provides the portable Strategy lifecycle used here. ml4t-specs defines the shared lifecycle and canonical intent contracts. See the ML4T libraries page for the broader ecosystem.

Development

git clone https://github.com/ml4t/live.git
cd live
uv sync --all-extras --dev --locked
uv run python scripts/qualification/run_stable_gate.py

The full gate runs lint, formatting, type checking, tests, coverage, stress and performance checks, strict documentation, package builds, clean artifact installs, and security qualification.

Report defects through the issue tracker. Report suspected vulnerabilities through private vulnerability reporting, not a public issue. Release notes and artifacts are available from GitHub Releases.

License

MIT

Metadata

Release files for ml4t-live 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ml4t-live 0.1.2
File Size Uploaded
ml4t_live-0.1.2.tar.gz 107.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ml4t-live 0.1.2
File Interpreter ABI Platform
ml4t_live-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 233.3 kB

Release files / ml4t_live-0.1.2.tar.gz

Download URL ml4t_live-0.1.2.tar.gz
Size 107.7 kB
Tags Source
SHA-256 checksum
How to use checksums
653156bafe6f03231e6b4b722fbb9295eb39890dcc2d248245b79f062b4cddc0
BLAKE2b-256 checksum
How to use checksums
f36e4801047f46759dc254ce6cd975663462257a0b996f152efa7424c7b8f5af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / ml4t_live-0.1.2-py3-none-any.whl

Download URL ml4t_live-0.1.2-py3-none-any.whl
Size 125.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59139dd77c39ef4e5fd68ac4abc91448506605e4a3d1fc234bb270852cf5e0f5
BLAKE2b-256 checksum
How to use checksums
3034fe7f7dfa962a9fa87de6ae31e7212d8bc6b141ae37a5c0ab963291eddb86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page