Skip to content

contango.trading.execution.engine.events.types

contango.trading.execution.engine.events.types

AcceptedFillEvent

Bases: NamedTuple

A single filled trade event (an order that has been processed) that has been accepted.

Attributes:

Name Type Description
timestamp time_unix_ms

When the trade was filled (unix ms).

market_event MarketDataEvent

The market event in which the trade was filled at.

order_event OrderEvent

The underlying order that was filled.

fill_price USD

The price that the order was filled at (per unit).

total_cost USD

The total cost (including slippage & commission) for the entire trade.

MarketDataEvent

Bases: NamedTuple

Immutable event snapshot of OHLCV data for a single bar.

Attributes:

Name Type Description
timestamp time_unix_ms

Time unix (ms) of the bar.

symbol str

Ticker symbol.

open USD

Opening price in USD.

high USD

Highest price in USD.

low USD

Lowest price in USD.

close USD

Closing price in USD.

volume units

Number of units traded.

OrderEvent

Bases: NamedTuple

A single trade event emitted by a strategy.

Attributes:

Name Type Description
timestamp time_unix_ms

The time (unix ms) which the order event was created.

quantity units

Number of units (i.e. shares) to trade (signed for buys versus sells).

reason str | None

Optional description on why the trade was made.

PortfolioSnapshotEvent

Bases: NamedTuple

A single event snapshot of an account portfolio.

Attributes:

Name Type Description
timestamp time_unix_ms

The timestamp in which the portfolio snapshot was made (unix ms).

cash USD

The cash available for trading in the account.

position units

The current amount of units held in the account.

equity USD | None

The total equity (cash + units) in the account, or None if it cannot be derived (e.g. initial snapshot).

RejectedFillEvent

Bases: NamedTuple

A single filled trade event (an order that has been processed) that has been rejected.

Attributes:

Name Type Description
timestamp time_unix_ms

When the rejected trade was attempted to be filled (unix ms).

market_event MarketDataEvent

The market event in which the rejected trade was made at.

order_event OrderEvent

The underlying order that was rejected.

reason str | None

The reasoning for the rejection.

StoplossOrderEvent

Bases: NamedTuple

A single trade event with a stop loss emitted by a strategy.

Attributes:

Name Type Description
timestamp time_unix_ms

The time (unix ms) which the order event was created.

quantity units

Number of units (i.e. shares) to trade (signed for buys versus sells).

stop_price USD
reason str | None

Optional description on why the trade was made.