Overall Statistics
Total Trades
451
Average Win
0.64%
Average Loss
-0.42%
Compounding Annual Return
7.234%
Drawdown
16.700%
Expectancy
0.112
Net Profit
14.969%
Sharpe Ratio
0.459
Probabilistic Sharpe Ratio
19.390%
Loss Rate
56%
Win Rate
44%
Profit-Loss Ratio
1.52
Alpha
0.059
Beta
0.055
Annual Standard Deviation
0.157
Annual Variance
0.025
Information Ratio
-0.636
Tracking Error
0.267
Treynor Ratio
1.317
Total Fees
$451.00
Estimated Strategy Capacity
$69000000.00
Lowest Capacity Asset
PEP R735QTJ8XC9X
class HyperActiveAsparagusAlligator(QCAlgorithm):
   
   
   def Initialize(self):
        self.SetStartDate(2019, 1, 3)
        self.SetEndDate(2021, 1, 3)
        self.SetCash(100000)
        spy = self.AddEquity("SPY", Resolution.Daily)
        spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
        aapl = self.AddEquity("PEP", Resolution.Daily)
        aapl.SetDataNormalizationMode(DataNormalizationMode.Raw)


        self.ratioEarliest = 0
        self.ratioMiddle = 0
        self.ratioLatest = 0

   def OnData(self, data):
       
  
       self.ratio = self.Securities["SPY"].Price / self.Securities["PEP"].Price
       # self.Debug (self.Ratio)
       
       #Update the 3 ratio variables
       self.ratioEarliest = self.ratioMiddle
       self.ratioMiddle = self.ratioLatest
       self.ratioLatest = self.ratio
       
       #Plot the ratio
       self.Plot("Data Chart", "Ratio", self.ratio)
       #self.Plot("Data Chart", "Asset Price", data["AAPL"].Close)
    
       #If ratio has increased 3 times, sell a and buy b
       if self.ratioEarliest < self.ratioMiddle and self.ratioMiddle < self.ratioLatest:
           #check that there has been a 3 down since the last buy
           #sell a and buy b
           self.MarketOrder("SPY", 100)
           self.MarketOrder("PEP", -100)
               
       #If ratio has decreased 3 times, buy a and sell b
       if self.ratioEarliest > self.ratioMiddle and self.ratioMiddle > self.ratioLatest:
               #check that 1 day has passed since last trade
               #check that there has been a 3 up since the last buy
               #buy a and sell b
               self.MarketOrder("SPY", -100)
               self.MarketOrder("PEP", 100)