Overall Statistics
Total Trades
1029
Average Win
0.12%
Average Loss
-0.11%
Compounding Annual Return
8.348%
Drawdown
3.200%
Expectancy
0.087
Net Profit
4.823%
Sharpe Ratio
1.803
Loss Rate
48%
Win Rate
52%
Profit-Loss Ratio
1.11
Alpha
-0.009
Beta
0.476
Annual Standard Deviation
0.044
Annual Variance
0.002
Information Ratio
-2.285
Tracking Error
0.047
Treynor Ratio
0.168
Total Fees
$2222.71
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));