Skip to main content
A finished run leaves every trade on the strategy. strategy.trades is the full list (open and closed); each item is a Trade. To slice and aggregate them, pull the list into a pandas DataFrame.

Trades to a DataFrame

trades_to_dataframe serialises each Trade into one row. The frame has one column per serialized field plus two object columns you can fall back to:
  • Identity and instrument: trade_id, order_id, instrument, quantity, tags.
  • Open and close state: fill_price, settlement_price_at_open, open_price, open_quantity, open_datetime, close_datetime, close_price, is_open, close_on_pulse_end.
  • PnL: pnl, pnl_pct, pulse_abs_pnl, pulse_pct_pnl, initial_equity, equity_at_open, open_notional, current_notional.
  • Greeks (scalar): delta, gamma, theta, vega and their *_contract counterparts.
  • History lists (one value per pulse the trade was open): datetimes, abs_pnl_history, pct_pnl_history, pulse_abs_pnl_history, pulse_pct_pnl_history, quantity_history, price_history, notional_history, delta_history, gamma_history, theta_history, vega_history, their *_contract_history counterparts, and underlying_price_history / iv_history (the raw underlying price and the option’s IV the greeks were taken against). set_quantity_after_pulse is also present.
  • trade_object (the live Trade) and trade_serialized (the raw dict), for anything the columns above do not cover.
Datetimes are ISO stringsopen_datetime, close_datetime, and the entries of datetimes are serialized to ISO-8601 strings. Call pd.to_datetime(df["open_datetime"]) before doing date math.

Filter, group, sort

Standard pandas from here. Closed trades only, grouped by the leg type tag, sorted by total PnL:
To rank individual trades, sort the frame directly:

Tagged summaries on a live strategy

While the strategy still has positions on, two helpers read groups by tag straight off the strategy:
get_trades_summary_by_tags returns a TradesSummary aggregating the group: trades_count, open_notional, current_notional, pnl, pnl_pct, pnl_pct_of_initial_equity, min_dte, and the option greeks iv, delta, delta_contract, quick_delta, quick_delta_contract, gamma, gamma_contract, theta, vega (greeks are None for futures-only groups). See Portfolio, equity and PnL for what each PnL base means.
These two helpers look at open trades onlyget_trades_by_tags and get_trades_summary_by_tags filter strategy.open_trades, and the summary helper raises ValueError when the group is empty. They are meant for use during the run (for example inside on_update). After a run where everything has been closed, filter the DataFrame on its tags column instead, as shown above.
Both helpers take match_all (default False): with False a trade matches if it carries any of the tags, with True it must carry all of them. Related: Portfolio, equity and PnL · Reading results · Charts
Last modified on November 4, 2026