Trade
Order into.
Construction is two-phase. __init__ records what was filled; Portfolio.add_trade then
calls init_stats, which reads the opening mark off the datafeed and sets the prices, greeks,
notional and history lists. Until it has run the trade cannot be pulsed and none of that marked
state can be read. pulse marks the trade once per pulse thereafter, skipping the pulse it
opened on.
Parameters
Trade.trade_id
property
Trade.order_id
property
Trade.open_price
property
Trade.open_quantity
property
Trade.fill_price
property
Trade.settlement_price_at_open
property
Trade.close_price
property
Trade.instrument
property
Trade.quantity
property
Trade.is_lots
property
Trade.contract_size
property
Trade.price_format_multiplier
property
Trade.units
property
contract_size).
Trade.sign
property
Trade.open_datetime
property
Trade.close_datetime
property
Trade.is_open
property
Trade.tags
property
Trade.source_id
property
pulse.core.order.Order that filled into this trade. None for trades not
attributed to a sleeve (e.g. classic single-strategy use).
Trade.pnl
property
Trade.pnl_pct
property
pnl / abs(equity_at_open). Sizing-aware - tells you how this trade
moved the account at the moment it was taken. Denominator is wrapped
in abs so a gain on a negative-equity account still reads
positive. Returns 0.0 if equity_at_open is 0.
Trade.initial_equity
property
Portfolio.add_trade.
Trade.equity_at_open
property
current_equity at the pulse this trade opens on,
captured by Portfolio.add_trade.
Trade.pnl_pct_of_initial_equity
property
pnl / abs(initial_equity). Stable denominator across the run -
directly comparable across trades. Returns 0.0 if
initial_equity is 0.
Trade.pulse_abs_pnl
property
Trade.pulse_pct_pnl
property
Trade.datetimes
property
Trade.abs_pnl_history
property
Trade.pct_pnl_history
property
Trade.pulse_abs_pnl_history
property
datetimes (one entry per pulse).
Trade.pulse_pct_pnl_history
property
datetimes (one entry per pulse).
Trade.daily_datetimes
property
Trade.daily_abs_pnl_history
property
Trade.daily_pct_pnl_history
property
Trade.daily_abs_pnl
property
datetimes[-1].date()).
For daily cadence this equals pulse_abs_pnl.
Trade.daily_pct_pnl
property
Trade.quantity_history
property
Trade.price_history
property
Trade.notional_history
property
Trade.delta
property
Trade.gamma
property
Trade.theta
property
Trade.vega
property
Trade.delta_contract
property
Trade.gamma_contract
property
Trade.theta_contract
property
Trade.vega_contract
property
Trade.delta_history
property
datetimes (one entry per pulse).
Trade.gamma_history
property
datetimes (one entry per pulse).
Trade.theta_history
property
datetimes (one entry per pulse).
Trade.vega_history
property
datetimes (one entry per pulse).
Trade.delta_contract_history
property
datetimes (one entry per pulse).
Trade.gamma_contract_history
property
datetimes (one entry per pulse).
Trade.theta_contract_history
property
datetimes (one entry per pulse).
Trade.vega_contract_history
property
datetimes (one entry per pulse).
Trade.underlying_price_history
property
price_format_multiplier.
Length matches datetimes (one entry per pulse).
Trade.iv_history
property
None for a future or spot.
Length matches datetimes (one entry per pulse).
Trade.init_stats
Trade.values_at
_mark) and summarising
(Strategy.calculate_trades_summary) cannot disagree about what a data gap means. Because
the carried value is the record the data layer actually returned, a dark futures or spot leg
keeps its real shape: it has no delta attribute, exactly as on a healthy pulse, so it
stays out of the greek aggregates instead of being pulled into them by a stand-in.
strict=True re-raises instead, for a caller that needs a real row: opening a trade needs
a real price, and the framework’s shadow repricer wants an unpriceable leg to surface.
Only the data layer’s own LookupError counts as “this contract is absent”. KeyError
and IndexError are subclasses of it raised by faults inside the reader (a missing column,
a bisect off a truncated file), so those propagate rather than being carried forward as a
flat mark for the rest of the run.
Trade.add_tag
Trade.has_tag
Trade has tag or list of tags.
Parameters
Returns
Trade.rebalance
Raises
Trade.pulse
Trade.close
expiration_date_of
None for spot, which never expires.
The data-layer Instrument base carries no expiry (only the subtypes that have one do), so this
is the one place the engine asks “does this contract expire, and when”.
has_expired
instrument is past its expiry at as_of_time. Spot never expires.
The single definition of the expiry predicate for the engine: Trade.pulse and
Portfolio.__close_trades both ask through here, so they cannot drift apart on the boundary.
