Lean  $LEAN_TAG$
QuantConnect.Statistics.TradeStatistics Class Reference

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

Public Member Functions

 TradeStatistics (IEnumerable< Trade > trades)
 Initializes a new instance of the TradeStatistics class More...
 
 TradeStatistics ()
 Initializes a new instance of the TradeStatistics class More...
 

Properties

DateTime? StartDateTime [get, set]
 The entry date/time of the first trade More...
 
DateTime? EndDateTime [get, set]
 The exit date/time of the last trade More...
 
int TotalNumberOfTrades [get, set]
 The total number of trades More...
 
int NumberOfWinningTrades [get, set]
 The total number of winning trades More...
 
int NumberOfLosingTrades [get, set]
 The total number of losing trades More...
 
decimal TotalProfitLoss [get, set]
 The total profit/loss for all trades (as symbol currency) More...
 
decimal TotalProfit [get, set]
 The total profit for all winning trades (as symbol currency) More...
 
decimal TotalLoss [get, set]
 The total loss for all losing trades (as symbol currency) More...
 
decimal LargestProfit [get, set]
 The largest profit in a single trade (as symbol currency) More...
 
decimal LargestLoss [get, set]
 The largest loss in a single trade (as symbol currency) More...
 
decimal AverageProfitLoss [get, set]
 The average profit/loss (a.k.a. Expectancy or Average Trade) for all trades (as symbol currency) More...
 
decimal AverageProfit [get, set]
 The average profit for all winning trades (as symbol currency) More...
 
decimal AverageLoss [get, set]
 The average loss for all winning trades (as symbol currency) More...
 
TimeSpan AverageTradeDuration [get, set]
 The average duration for all trades More...
 
TimeSpan AverageWinningTradeDuration [get, set]
 The average duration for all winning trades More...
 
TimeSpan AverageLosingTradeDuration [get, set]
 The average duration for all losing trades More...
 
TimeSpan MedianTradeDuration [get, set]
 The median duration for all trades More...
 
TimeSpan MedianWinningTradeDuration [get, set]
 The median duration for all winning trades More...
 
TimeSpan MedianLosingTradeDuration [get, set]
 The median duration for all losing trades More...
 
int MaxConsecutiveWinningTrades [get, set]
 The maximum number of consecutive winning trades More...
 
int MaxConsecutiveLosingTrades [get, set]
 The maximum number of consecutive losing trades More...
 
decimal ProfitLossRatio [get, set]
 The ratio of the average profit per trade to the average loss per trade More...
 
decimal WinLossRatio [get, set]
 The ratio of the number of winning trades to the number of losing trades More...
 
decimal WinRate [get, set]
 The ratio of the number of winning trades to the total number of trades More...
 
decimal LossRate [get, set]
 The ratio of the number of losing trades to the total number of trades More...
 
decimal AverageMAE [get, set]
 The average Maximum Adverse Excursion for all trades More...
 
decimal AverageMFE [get, set]
 The average Maximum Favorable Excursion for all trades More...
 
decimal LargestMAE [get, set]
 The largest Maximum Adverse Excursion in a single trade (as symbol currency) More...
 
decimal LargestMFE [get, set]
 The largest Maximum Favorable Excursion in a single trade (as symbol currency) More...
 
decimal MaximumClosedTradeDrawdown [get, set]
 The maximum closed-trade drawdown for all trades (as symbol currency) More...
 
decimal MaximumIntraTradeDrawdown [get, set]
 The maximum intra-trade drawdown for all trades (as symbol currency) More...
 
decimal ProfitLossStandardDeviation [get, set]
 The standard deviation of the profits/losses for all trades (as symbol currency) More...
 
decimal ProfitLossDownsideDeviation [get, set]
 The downside deviation of the profits/losses for all trades (as symbol currency) More...
 
decimal ProfitFactor [get, set]
 The ratio of the total profit to the total loss More...
 
decimal SharpeRatio [get, set]
 The ratio of the average profit/loss to the standard deviation More...
 
decimal SortinoRatio [get, set]
 The ratio of the average profit/loss to the downside deviation More...
 
decimal ProfitToMaxDrawdownRatio [get, set]
 The ratio of the total profit/loss to the maximum closed trade drawdown More...
 
decimal MaximumEndTradeDrawdown [get, set]
 The maximum amount of profit given back by a single trade before exit (as symbol currency) More...
 
decimal AverageEndTradeDrawdown [get, set]
 The average amount of profit given back by all trades before exit (as symbol currency) More...
 
TimeSpan MaximumDrawdownDuration [get, set]
 The maximum amount of time to recover from a drawdown (longest time between new equity highs or peaks) More...
 
decimal TotalFees [get, set]
 The sum of fees for all trades More...
 

Detailed Description

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

Definition at line 26 of file TradeStatistics.cs.

Constructor & Destructor Documentation

◆ TradeStatistics() [1/2]

QuantConnect.Statistics.TradeStatistics.TradeStatistics ( IEnumerable< Trade trades)

Initializes a new instance of the TradeStatistics class

Parameters
tradesThe list of closed trades

Definition at line 276 of file TradeStatistics.cs.

◆ TradeStatistics() [2/2]

QuantConnect.Statistics.TradeStatistics.TradeStatistics ( )

Initializes a new instance of the TradeStatistics class

Definition at line 438 of file TradeStatistics.cs.

Property Documentation

◆ StartDateTime

DateTime? QuantConnect.Statistics.TradeStatistics.StartDateTime
getset

The entry date/time of the first trade

Definition at line 31 of file TradeStatistics.cs.

◆ EndDateTime

DateTime? QuantConnect.Statistics.TradeStatistics.EndDateTime
getset

The exit date/time of the last trade

Definition at line 36 of file TradeStatistics.cs.

◆ TotalNumberOfTrades

int QuantConnect.Statistics.TradeStatistics.TotalNumberOfTrades
getset

The total number of trades

Definition at line 41 of file TradeStatistics.cs.

◆ NumberOfWinningTrades

int QuantConnect.Statistics.TradeStatistics.NumberOfWinningTrades
getset

The total number of winning trades

Definition at line 46 of file TradeStatistics.cs.

◆ NumberOfLosingTrades

int QuantConnect.Statistics.TradeStatistics.NumberOfLosingTrades
getset

The total number of losing trades

Definition at line 51 of file TradeStatistics.cs.

◆ TotalProfitLoss

decimal QuantConnect.Statistics.TradeStatistics.TotalProfitLoss
getset

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

Definition at line 57 of file TradeStatistics.cs.

◆ TotalProfit

decimal QuantConnect.Statistics.TradeStatistics.TotalProfit
getset

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

Definition at line 63 of file TradeStatistics.cs.

◆ TotalLoss

decimal QuantConnect.Statistics.TradeStatistics.TotalLoss
getset

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

Definition at line 69 of file TradeStatistics.cs.

◆ LargestProfit

decimal QuantConnect.Statistics.TradeStatistics.LargestProfit
getset

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

Definition at line 75 of file TradeStatistics.cs.

◆ LargestLoss

decimal QuantConnect.Statistics.TradeStatistics.LargestLoss
getset

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

Definition at line 81 of file TradeStatistics.cs.

◆ AverageProfitLoss

decimal QuantConnect.Statistics.TradeStatistics.AverageProfitLoss
getset

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

Definition at line 87 of file TradeStatistics.cs.

◆ AverageProfit

decimal QuantConnect.Statistics.TradeStatistics.AverageProfit
getset

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

Definition at line 93 of file TradeStatistics.cs.

◆ AverageLoss

decimal QuantConnect.Statistics.TradeStatistics.AverageLoss
getset

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

Definition at line 99 of file TradeStatistics.cs.

◆ AverageTradeDuration

TimeSpan QuantConnect.Statistics.TradeStatistics.AverageTradeDuration
getset

The average duration for all trades

Definition at line 104 of file TradeStatistics.cs.

◆ AverageWinningTradeDuration

TimeSpan QuantConnect.Statistics.TradeStatistics.AverageWinningTradeDuration
getset

The average duration for all winning trades

Definition at line 109 of file TradeStatistics.cs.

◆ AverageLosingTradeDuration

TimeSpan QuantConnect.Statistics.TradeStatistics.AverageLosingTradeDuration
getset

The average duration for all losing trades

Definition at line 114 of file TradeStatistics.cs.

◆ MedianTradeDuration

TimeSpan QuantConnect.Statistics.TradeStatistics.MedianTradeDuration
getset

The median duration for all trades

Definition at line 119 of file TradeStatistics.cs.

◆ MedianWinningTradeDuration

TimeSpan QuantConnect.Statistics.TradeStatistics.MedianWinningTradeDuration
getset

The median duration for all winning trades

Definition at line 124 of file TradeStatistics.cs.

◆ MedianLosingTradeDuration

TimeSpan QuantConnect.Statistics.TradeStatistics.MedianLosingTradeDuration
getset

The median duration for all losing trades

Definition at line 129 of file TradeStatistics.cs.

◆ MaxConsecutiveWinningTrades

int QuantConnect.Statistics.TradeStatistics.MaxConsecutiveWinningTrades
getset

The maximum number of consecutive winning trades

Definition at line 134 of file TradeStatistics.cs.

◆ MaxConsecutiveLosingTrades

int QuantConnect.Statistics.TradeStatistics.MaxConsecutiveLosingTrades
getset

The maximum number of consecutive losing trades

Definition at line 139 of file TradeStatistics.cs.

◆ ProfitLossRatio

decimal QuantConnect.Statistics.TradeStatistics.ProfitLossRatio
getset

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

If the average loss is zero, ProfitLossRatio is set to 0

Definition at line 146 of file TradeStatistics.cs.

◆ WinLossRatio

decimal QuantConnect.Statistics.TradeStatistics.WinLossRatio
getset

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

If the total number of trades is zero, WinLossRatio is set to zero

If the number of losing trades is zero and the number of winning trades is nonzero, WinLossRatio is set to 10

Definition at line 154 of file TradeStatistics.cs.

◆ WinRate

decimal QuantConnect.Statistics.TradeStatistics.WinRate
getset

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

If the total number of trades is zero, WinRate is set to zero

Definition at line 161 of file TradeStatistics.cs.

◆ LossRate

decimal QuantConnect.Statistics.TradeStatistics.LossRate
getset

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

If the total number of trades is zero, LossRate is set to zero

Definition at line 168 of file TradeStatistics.cs.

◆ AverageMAE

decimal QuantConnect.Statistics.TradeStatistics.AverageMAE
getset

The average Maximum Adverse Excursion for all trades

Definition at line 174 of file TradeStatistics.cs.

◆ AverageMFE

decimal QuantConnect.Statistics.TradeStatistics.AverageMFE
getset

The average Maximum Favorable Excursion for all trades

Definition at line 180 of file TradeStatistics.cs.

◆ LargestMAE

decimal QuantConnect.Statistics.TradeStatistics.LargestMAE
getset

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

Definition at line 186 of file TradeStatistics.cs.

◆ LargestMFE

decimal QuantConnect.Statistics.TradeStatistics.LargestMFE
getset

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

Definition at line 192 of file TradeStatistics.cs.

◆ MaximumClosedTradeDrawdown

decimal QuantConnect.Statistics.TradeStatistics.MaximumClosedTradeDrawdown
getset

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

The calculation only takes into account the profit/loss of each trade

Definition at line 199 of file TradeStatistics.cs.

◆ MaximumIntraTradeDrawdown

decimal QuantConnect.Statistics.TradeStatistics.MaximumIntraTradeDrawdown
getset

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

The calculation takes into account MAE and MFE of each trade

Definition at line 206 of file TradeStatistics.cs.

◆ ProfitLossStandardDeviation

decimal QuantConnect.Statistics.TradeStatistics.ProfitLossStandardDeviation
getset

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

Definition at line 212 of file TradeStatistics.cs.

◆ ProfitLossDownsideDeviation

decimal QuantConnect.Statistics.TradeStatistics.ProfitLossDownsideDeviation
getset

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

This metric only considers deviations of losing trades

Definition at line 219 of file TradeStatistics.cs.

◆ ProfitFactor

decimal QuantConnect.Statistics.TradeStatistics.ProfitFactor
getset

The ratio of the total profit to the total loss

If the total profit is zero, ProfitFactor is set to zero

if the total loss is zero and the total profit is nonzero, ProfitFactor is set to 10

Definition at line 227 of file TradeStatistics.cs.

◆ SharpeRatio

decimal QuantConnect.Statistics.TradeStatistics.SharpeRatio
getset

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

Definition at line 233 of file TradeStatistics.cs.

◆ SortinoRatio

decimal QuantConnect.Statistics.TradeStatistics.SortinoRatio
getset

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

Definition at line 239 of file TradeStatistics.cs.

◆ ProfitToMaxDrawdownRatio

decimal QuantConnect.Statistics.TradeStatistics.ProfitToMaxDrawdownRatio
getset

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

If the total profit/loss is zero, ProfitToMaxDrawdownRatio is set to zero

if the drawdown is zero and the total profit is nonzero, ProfitToMaxDrawdownRatio is set to 10

Definition at line 247 of file TradeStatistics.cs.

◆ MaximumEndTradeDrawdown

decimal QuantConnect.Statistics.TradeStatistics.MaximumEndTradeDrawdown
getset

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

Definition at line 253 of file TradeStatistics.cs.

◆ AverageEndTradeDrawdown

decimal QuantConnect.Statistics.TradeStatistics.AverageEndTradeDrawdown
getset

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

Definition at line 259 of file TradeStatistics.cs.

◆ MaximumDrawdownDuration

TimeSpan QuantConnect.Statistics.TradeStatistics.MaximumDrawdownDuration
getset

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

Definition at line 264 of file TradeStatistics.cs.

◆ TotalFees

decimal QuantConnect.Statistics.TradeStatistics.TotalFees
getset

The sum of fees for all trades

Definition at line 270 of file TradeStatistics.cs.


The documentation for this class was generated from the following file: