data is a BarData object passed to handle_data, scheduled callbacks, and before_trading_start. It gives you current values and trailing history from the market data source and optional custom data sources.
Ziplime data access is async and returns Polars data frames.
Current values
await data.current(assets, fields, data_source=None)
Read the latest available values at the current simulation timestamp.
Historical windows
await data.history(assets, bar_count, frequency=timedelta(days=1), fields=None, data_source=None)
Read a trailing window ending before the current bar.
include_end_date=False, so history is best used for completed previous bars. If your signal needs the current bar too, read it separately with data.current(...).
Fields
Common market-data fields:| Field | Meaning |
|---|---|
"open" | Bar open price |
"high" | Bar high price |
"low" | Bar low price |
"close" | Bar close price |
"volume" | Bar volume |
"price" | Last known price, when supported by the data source |
"last_traded" | Last traded datetime, when supported by the data source |
data_source if you need a non-default source:
Working with Polars
Ziplime returnspolars.DataFrame, so normal Polars operations apply.
Data clock helpers
data.current_dt returns the current simulation datetime.
data.current_session returns the current trading session label.
Tradability checks
data.can_trade(assets) exists for Zipline compatibility and is intended to check asset liveness, exchange hours, restrictions, and available price data.
For portable strategy code in the current Ziplime runtime, prefer checking the data you actually need before ordering: