Overall Statistics
class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017,1,1)   # Set Start Date
        self.AddEquity("SPY", Resolution.Hour)

    def OnData(self, data):
        if not self.Portfolio.Invested:
            self.SetHoldings("SPY", 1)
        else:
            self.Liquidate()

    def OnEndOfAlgorithm(self):
        for trade in self.TradeBuilder.ClosedTrades:
            self.Log("Symbol: {0} Quantity: {1} EntryTime: {2} EntryPrice: {3} ExitTime: {4} ExitPrice: {5}, ProfitLoss: {6}, TotalFees: {7}, MAE: {8}, MFE: {9}, Duration: {10}, EndTradeDrawdown: {11}"
                .format(trade.Symbol, trade.Quantity, trade.EntryTime, trade.EntryPrice, trade.ExitTime, trade.ExitPrice, trade.ProfitLoss, trade.TotalFees, trade.MAE, trade.MFE, trade.Duration, trade.EndTradeDrawdown));