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

Read the contribution guide before opening an issue or pull request.

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

uv run ruff check --no-fix src tests
uv run ruff format --check src tests
uv run ty check
uv run pytest

Run the repository's full release qualification before preparing a release:

uv run python scripts/qualification/run_stable_gate.py

The qualification script is the authoritative definition of the full release gate.

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.3

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.3
File Size Uploaded Provenance
ml4t_live-0.1.3.tar.gz 108.1 kB With provenance Details

Built distribution (wheel)

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

Total release size: 234.1 kB

Release files / ml4t_live-0.1.3.tar.gz

Download URL ml4t_live-0.1.3.tar.gz
Size 108.1 kB
Tags Source
SHA-256 checksum
How to use checksums
57a5b871f8e0faf8d6c868c0581f5d983e44f176ce81adc288aca2fefcee4b3b
BLAKE2b-256 checksum
How to use checksums
9034777c1d61ce8f4266cad40886fa0f7c64d701c24606649b561a15214d77cc
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 Oct 23, 2026.

Transparency log

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

Download URL ml4t_live-0.1.3-py3-none-any.whl
Size 126.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
868c09beae590c74e83a867cbbdac59b01e9ca70a6d1c332152783dddc90bbcf
BLAKE2b-256 checksum
How to use checksums
9b981fcced4308f13a42419dddd549f7f950db0be0ac3b9240ef874df15145ee
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 Oct 23, 2026.

Transparency log

Security for ml4t-live 0.1.3

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ml4t_live-0.1.3.tar.gz

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 Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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