Skip to main content
Ziplime keeps the event-driven strategy model of classic Zipline, but the runtime is not a drop-in replacement. The biggest differences are async strategy functions, Polars data frames, explicit execution styles, and a data-bundle runner built around Ziplime services. Use this page when converting an old Zipline algorithm into a Ziplime algorithm file.

What still feels familiar

The core strategy shape is the same:
In Ziplime, the main functions become async:
The same mental model still applies:
  • Store persistent strategy state on context.
  • Use handle_data for per-bar trading logic.
  • Use schedule_function for periodic rebalances.
  • Use record for custom metrics.
  • Use target order helpers for rebalancing.

Quick conversion table

Imports

Classic Zipline algorithms often import many API functions:
In Ziplime, prefer direct context calls and import only helper classes:
The Zipline-style ziplime.api namespace exists for compatibility, but direct context calls are easier to read in async code:

Lifecycle functions

initialize

Classic Zipline:
Ziplime:
Use initialize to look up assets, set strategy parameters, register scheduled callbacks, attach pipelines, and configure controls.

handle_data

Classic Zipline:
Ziplime:

before_trading_start

Classic Zipline used a synchronous before_trading_start. Ziplime currently does the same.
Do not define it as async def in the current Ziplime runtime. Do not place orders in this hook.

analyze

Classic Zipline usually passed a performance DataFrame to analyze. Ziplime also calls analyze synchronously with the final performance table.

Market data differences

Classic Zipline allowed scalar-style calls:
Ziplime expects lists and returns a Polars DataFrame:
Historical windows are also async:
If your old strategy uses pandas operations, convert the Ziplime result explicitly:
Prefer Polars-native expressions for new code.

Order differences

Classic Zipline often allowed:
Ziplime order calls are async and require an execution style:
Target order helpers do not account for still-open orders. If the old strategy repeatedly submits target orders, add an open-order guard:

Symbol lookup

Classic Zipline usually resolved symbols from an asset database with the simulation lookup date. Ziplime resolves symbols through its asset service:
When a ticker can exist on multiple exchanges, pass mic or use the SYMBOL@MIC form. For named universes:

Scheduling

Classic Zipline:
Ziplime:
In daily simulations, time rules are effectively ignored because the clock emits one bar per session. In minute simulations, time rules matter.

Portfolio and positions

Classic Zipline commonly used:
Ziplime exposes portfolio totals directly, but position storage is nested by exchange and account in the current runtime. Prefer helper methods:
For exact exchange-asset positions:

Recording metrics

This part is close to Zipline:
Recorded values become columns in the final performance table.

Pipeline migration

Ziplime includes a Zipline-like Pipeline API:
Attach the pipeline in initialize:
Read output after initialization:
Pipeline support depends on loaders. Pricing data via EquityPricing is the standard path; custom datasets require custom loaders.

Running migrated algorithms

Classic Zipline examples often call run_algorithm(...) directly with pandas data or bundle names. Ziplime’s standard flow is:
  1. Ingest or load data into a Ziplime bundle.
  2. Load the bundle with bundle_service.load_bundle(...).
  3. Pass the loaded data source to run_simulation(...).
  4. Point algorithm_file at the migrated .py strategy file.

Full before and after

Classic Zipline:
Ziplime:

Migration checklist

  • Replace zipline.api imports with direct context calls and Ziplime helper imports.
  • Make initialize, handle_data, and scheduled callbacks async.
  • Add await to asset lookup, data access, order placement, and order cancellation.
  • Pass lists to data.current and data.history.
  • Update pandas assumptions to Polars or call .to_pandas() explicitly.
  • Add an execution style such as MarketOrder() to order calls.
  • Use def before_trading_start, not async def before_trading_start.
  • Use def analyze, not async def analyze.
  • Replace direct portfolio.positions[asset] access with portfolio helper methods.
  • Pass MIC codes for ambiguous symbols.
  • Move runner setup to run_simulation(...) with Ziplime data bundles.