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

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.2.0
File Size Uploaded Provenance Actions
ml4t_live-0.2.0.tar.gz 112.5 kB With provenance Details for ml4t_live-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 243.5 kB

Release files / ml4t_live-0.2.0.tar.gz

Download URL ml4t_live-0.2.0.tar.gz
Size 112.5 kB
Tags Source
SHA-256 checksum
How to use checksums
687fab874ea2129a8c4c732a88d95d6983c2def9e5d5a297ed8a93401738d633
BLAKE2b-256 checksum
How to use checksums
99c56a1ae4b403a821ffd12650168dad772a9f9bdaa739be2de57876204ac3e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

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

Download URL ml4t_live-0.2.0-py3-none-any.whl
Size 131.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6b09c219ae803f5e0efecb8b3926c6726c8d1eb06d46b208a5a1f08c548421d
BLAKE2b-256 checksum
How to use checksums
a677cc17eefa6e535c82a25c4ccde777313d8d80471af2e4ba9c20da4310c20a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

Security for ml4t-live 0.2.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ml4t_live-0.2.0.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 Nov 16, 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