Skip to content

TradeStatistics

QuantConnect.Statistics.TradeStatistics

TradeStatistics(trades: List[Trade])
TradeStatistics()

Bases: Object

The TradeStatistics class represents a set of statistics calculated from a list of closed trades

Initializes a new instance of the TradeStatistics class

Parameters:

Name Type Description Default
trades Optional[List[Trade]]

The list of closed trades

None

start_date_time

start_date_time: Optional[datetime]

The entry date/time of the first trade

end_date_time

end_date_time: Optional[datetime]

The exit date/time of the last trade

total_number_of_trades

total_number_of_trades: int

The total number of trades

number_of_winning_trades

number_of_winning_trades: int

The total number of winning trades

number_of_losing_trades

number_of_losing_trades: int

The total number of losing trades

total_profit_loss

total_profit_loss: float

The total profit/loss for all trades (as symbol currency)

total_profit

total_profit: float

The total profit for all winning trades (as symbol currency)

total_loss

total_loss: float

The total loss for all losing trades (as symbol currency)

largest_profit

largest_profit: float

The largest profit in a single trade (as symbol currency)

largest_loss

largest_loss: float

The largest loss in a single trade (as symbol currency)

average_profit_loss

average_profit_loss: float

The average profit/loss (a.k.a. Expectancy or Average Trade) for all trades (as symbol currency)

average_profit

average_profit: float

The average profit for all winning trades (as symbol currency)

average_loss

average_loss: float

The average loss for all winning trades (as symbol currency)

average_trade_duration

average_trade_duration: timedelta

The average duration for all trades

average_winning_trade_duration

average_winning_trade_duration: timedelta

The average duration for all winning trades

average_losing_trade_duration

average_losing_trade_duration: timedelta

The average duration for all losing trades

median_trade_duration

median_trade_duration: timedelta

The median duration for all trades

median_winning_trade_duration

median_winning_trade_duration: timedelta

The median duration for all winning trades

median_losing_trade_duration

median_losing_trade_duration: timedelta

The median duration for all losing trades

max_consecutive_winning_trades

max_consecutive_winning_trades: int

The maximum number of consecutive winning trades

max_consecutive_losing_trades

max_consecutive_losing_trades: int

The maximum number of consecutive losing trades

profit_loss_ratio

profit_loss_ratio: float

The ratio of the average profit per trade to the average loss per trade

win_loss_ratio

win_loss_ratio: float

The ratio of the number of winning trades to the number of losing trades

win_rate

win_rate: float

The ratio of the number of winning trades to the total number of trades

loss_rate

loss_rate: float

The ratio of the number of losing trades to the total number of trades

average_mae

average_mae: float

The average Maximum Adverse Excursion for all trades

average_mfe

average_mfe: float

The average Maximum Favorable Excursion for all trades

largest_mae

largest_mae: float

The largest Maximum Adverse Excursion in a single trade (as symbol currency)

largest_mfe

largest_mfe: float

The largest Maximum Favorable Excursion in a single trade (as symbol currency)

maximum_closed_trade_drawdown

maximum_closed_trade_drawdown: float

The maximum closed-trade drawdown for all trades (as symbol currency)

maximum_intra_trade_drawdown

maximum_intra_trade_drawdown: float

The maximum intra-trade drawdown for all trades (as symbol currency)

profit_loss_standard_deviation

profit_loss_standard_deviation: float

The standard deviation of the profits/losses for all trades (as symbol currency)

profit_loss_downside_deviation

profit_loss_downside_deviation: float

The downside deviation of the profits/losses for all trades (as symbol currency)

profit_factor

profit_factor: float

The ratio of the total profit to the total loss

sharpe_ratio

sharpe_ratio: float

The ratio of the average profit/loss to the standard deviation

sortino_ratio

sortino_ratio: float

The ratio of the average profit/loss to the downside deviation

profit_to_max_drawdown_ratio

profit_to_max_drawdown_ratio: float

The ratio of the total profit/loss to the maximum closed trade drawdown

maximum_end_trade_drawdown

maximum_end_trade_drawdown: float

The maximum amount of profit given back by a single trade before exit (as symbol currency)

average_end_trade_drawdown

average_end_trade_drawdown: float

The average amount of profit given back by all trades before exit (as symbol currency)

maximum_drawdown_duration

maximum_drawdown_duration: timedelta

The maximum amount of time to recover from a drawdown (longest time between new equity highs or peaks)

total_fees

total_fees: float

The sum of fees for all trades