Skip to main content
context is the persistent algorithm object passed into lifecycle functions. Store your strategy state on it and call its methods to look up assets, trade, schedule work, inspect portfolio state, and configure controls.

Direct context style

Prefer direct method calls on context:
Ziplime also exposes Zipline-style functions through ziplime.api, but context calls are clearer inside async algorithm code.

Asset lookup

await context.symbol(symbol, mic=None, asset_type=AssetType.EQUITY)

Look up an exchange-listed asset by ticker.
If the symbol string contains @, the part after @ is interpreted as the MIC exchange code.

Multiple symbols

Recommended pattern:
context.symbols(*symbols) exists for compatibility, but in the current implementation it returns a list of awaitables. If you use it, gather or await each item:

await context.symbols_universe(name, dt=None)

Load a named symbol universe from the asset service.
If dt is omitted, Ziplime uses the current simulation datetime.

await context.sid(sid)

Look up an asset by numeric SID.

await context.future_symbol(symbol, exchange_name=None)

Look up a futures contract.

Time and configuration

context.get_datetime()

Return the current simulation datetime.
context.simulation_dt holds the same current simulation timestamp.

context.algorithm.config

Access a typed algorithm config loaded from JSON.
See Algorithm file for the config class pattern.

Available methods

Exchange names

Most order methods accept an optional exchange_name. If omitted, Ziplime uses the default exchange configured by the simulation runner. The examples in this repository commonly use "LIME" as the simulation exchange name. Use explicit exchange names when:
  • You run multiple exchanges.
  • You inspect or cancel an order with get_order or cancel_order.
  • You query portfolio helper methods by exchange.