Overall Statistics
Total Trades
96
Average Win
3.90%
Average Loss
-1.53%
Compounding Annual Return
39.588%
Drawdown
44.400%
Expectancy
0.257
Net Profit
18.053%
Sharpe Ratio
1.214
Probabilistic Sharpe Ratio
44.910%
Loss Rate
65%
Win Rate
35%
Profit-Loss Ratio
2.55
Alpha
1.044
Beta
1.787
Annual Standard Deviation
0.911
Annual Variance
0.829
Information Ratio
1.902
Tracking Error
0.563
Treynor Ratio
0.619
Total Fees
$648.71
Estimated Strategy Capacity
$62000000.00
Lowest Capacity Asset
AAPL R735QTJ8XC9X

class GeekyYellowGreenArmadillo(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)
        self.SetEndDate(2020, 6, 30)
        self.SetCash(100000) 
        
        equity = self.AddEquity("AAPL", Resolution.Hour)
        
        equity.SetDataNormalizationMode(DataNormalizationMode.Adjusted)
        
        self.symbol = equity.Symbol
        self.SetBenchmark(self.AddEquity("SPY").Symbol)
        
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
        
        self.fillPrice = 0
        self.stopPrice = 0
        self.exitPrice = 0
        self.fillQty = 0
        self.period = timedelta(hours=1)
        self.nextEntryTime = self.Time
        self.stopOrderId = 0
        
        
    def OnData(self, data):
        if not self.symbol in data:
            return
        
        price = self.Securities[self.symbol].Close
        
        if not self.Portfolio[self.symbol].Invested:
           if self.nextEntryTime <= self.Time:
               self.SetHoldings(self.symbol, 1)
               self.stopPrice = round(self.fillPrice * 0.99, 2)
               self.exitPrice = round(self.fillPrice * 1.03, 2)
               self.stopOrderId = self.StopMarketOrder(self.symbol, -self.fillQty, self.stopPrice) #stop order
               self.Log("BUY " + self.symbol.Value + " @ " + str(self.fillPrice) + " STOP ORDER @ " + str(self.stopPrice) + " TARGET EXIT @ " + str(self.exitPrice) )

        elif price > self.exitPrice:       #profit taker
            self.Liquidate()   #stop order cancelled
            self.Log("PROFIT " + self.symbol.Value + " @ " + str(self.fillPrice) + " STOP ORDER CANCELLED " + " NEXT ENTRY TIME " + str(self.nextEntryTime))
        
    
    def OnOrderEvent(self, orderEvent):
        if orderEvent.Status == OrderStatus.Filled: 
            self.fillPrice = orderEvent.FillPrice
            self.fillQty = orderEvent.FillQuantity
            self.nextEntryTime = self.Time + self.period
        
            if orderEvent.OrderId == self.stopOrderId: #upon stop order
                self.Log("STOP ORDER FILLED @ " + str(self.fillPrice) + " NEXT ENTRY TIME " + str(self.nextEntryTime))