class datetime.datetime, end_time: datetime.datetime, ticker: qf_lib.common.tickers.tickers.Ticker, pnl: float, commission: float, direction: int, percentage_pnl: float = nan)[source]

Bases: object

Trade is a logical unit representing getting exposure to the market (long or short) finished by closing the position. Trade begins with new position opened and finishes when the position is closed. Note: For futures contracts, automated rolling of the contract will result in closing the existing exposure on the specific ticker, and therefore will generate a trade.

  • start_time (datetime) – Moment when we opened the position corresponding to this trade.

  • end_time (datetime) – Moment when we close the trade.

  • ticker (Ticker) – Ticker defining the security.

  • pnl (float) – Profit or loss associated with a trade expressed in currency units including transaction costs and commissions.

  • commission (float) – All the transaction costs related to the trade. It includes the cost of opening the position and also cost of reducing it. Expressed in currency units.

  • direction (int) – Direction of the position: Long = 1, Short = -1. Defined by the initial transaction.

  • percentage_pnl (float) – Total pnl divided by the most recent value of the portfolio.