- Python 3.12+
- A supported broker or data source for live use
ml4t-backtestis installed automatically as a package dependency
uv add ml4t-liveml4t-live installs the core broker/feed stack used by the package. DataBento is optional and must
be installed separately if you want DataBentoFeed:
uv add databentogit clone https://github.com/ml4t/live.git
cd live
uv sync --dev- Install and launch TWS or IB Gateway
- Enable API access in the IB settings
- Use port
7497for paper trading or7496for live trading
from ml4t.live import IBBroker
broker = IBBroker(
host="127.0.0.1",
port=7497,
client_id=1,
)- Create an Alpaca account
- Generate API credentials
- Start with
paper=True
from ml4t.live import AlpacaBroker
broker = AlpacaBroker(
api_key="YOUR_API_KEY",
secret_key="YOUR_SECRET_KEY",
paper=True,
)from ml4t.live import (
AlpacaBroker,
AlpacaDataFeed,
BarAggregator,
IBBroker,
LiveEngine,
LiveRiskConfig,
SafeBroker,
)
print("ml4t-live imports succeeded")After installation, the recommended first run is:
- Follow the Quickstart in
shadow_mode=True. - Read Backtest to Live if you are porting an existing strategy.
- Configure the broker and feed pages that match your deployment path.
- Use the Book Guide to map chapter examples back to the library APIs.