Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
1525.579%
Drawdown
23.400%
Expectancy
0
Net Profit
49.963%
Sharpe Ratio
3.89
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.883
Beta
108.913
Annual Standard Deviation
0.766
Annual Variance
0.586
Information Ratio
3.866
Tracking Error
0.766
Treynor Ratio
0.027
Total Fees
$2.27
import numpy as np
from datetime import datetime
import pandas as pd



class VolTrading(QCAlgorithm):

    def __init__(self):
            self.previous = None
            self.position = None
            
            
            

    def Initialize(self):
      
        self.SetStartDate(2018,10,1)  #Set Start Date
        #self.SetEndDate(2018,1,1)    #Set End Date
        self.SetCash(10000)           #Set Strategy Cash
        self.AddEquity("SPY", Resolution.Minute)
        self.AddEquity("VIXY", Resolution.Minute)
        self.SetWarmUp(440)
        

    def OnData(self, data):
        
        
         #history_s = self.History(["SPY"], 1, Resolution.Minute)
         #last_minute_close_s = history_s.loc["SPY"]["close"][-1]
         #history_v = self.History(["IEF"], 1, Resolution.Minute)
         #last_minute_close_v = history_v.loc["IEF"]["close"][-1]
         
         #if self.position == None:
             # return messes everything up
         ##add if statement here if none skip it ##self.Securities["SPY"].Price
         #self.SPercent =  np.log(((float(self.Identity("SPY").Current.Value))/(float(data["SPY"].Open))))
         #self.VPercent =  np.log(((float(self.Identity("VIXY").Current.Value))/(float(data["VIXY"].Open))))
        
         self.SPercent =  np.log(((float(self.Identity("SPY").Current.Value))/(float(data["SPY"].Open))))
         self.VPercent =  np.log(((float(self.Identity("VIXY").Current.Value))/(float(data["VIXY"].Open))))
         
         
         if self.IsWarmingUp:
            return 
        
         #if  self.SPercent is None:
         #    return
         #if  self.VPercent is None:
         #  return
      
         if self.SPercent <= -.005:
             #or VPercent >=.01
             if self.position == None:
                self.SetHoldings("VIXY", 1)
             elif self.position == "SPY":
                  self.Liquidate("SPY")  
                  self.SetHoldings("VIXY", 1)
             self.position = "VIXY"
                  
                  
         elif self.SPercent >= .005:
              #or VPercent <=-.01
             if self.position == None:
                self.SetHoldings("SPY", 1)
             elif self.position == "VIXY":
                  self.Liquidate("VIXY")  
                  self.SetHoldings("SPY", 1)
             self.position = "SPY"
             
             ##1. run time error with the NoneType             
             ##2. when trades are excuted 
             ## 3.error with not buying anyhtng other than vixy may be do to the if
             
             
             #####
import numpy as np
from datetime import datetime
import pandas as pd



class VolTrading(QCAlgorithm):

    def __init__(self):
            self.previous = None
            self.position = None
            
            
            

    def Initialize(self):
      
        self.SetStartDate(2017,3,1)  #Set Start Date
        self.SetEndDate(2017,5,1)    #Set End Date
        self.SetCash(10000)           #Set Strategy Cash
        self.AddEquity("SPY", Resolution.Minute)
        self.AddEquity("VIXY", Resolution.Minute)
        self.SetWarmUp(440)
        

    def OnData(self, data):
        
        
         #history_s = self.History(["SPY"], 1, Resolution.Minute)
         #last_minute_close_s = history_s.loc["SPY"]["close"][-1]
         #history_v = self.History(["IEF"], 1, Resolution.Minute)
         #last_minute_close_v = history_v.loc["IEF"]["close"][-1]
         
         #if self.position == None:
             # return messes everything up
         ##add if statement here if none skip it ##self.Securities["SPY"].Price
         #self.SPercent =  np.log(((float(self.Identity("SPY").Current.Value))/(float(data["SPY"].Open))))
         #self.VPercent =  np.log(((float(self.Identity("VIXY").Current.Value))/(float(data["VIXY"].Open))))
        
         self.SPercent =  np.log(((float(self.Securities["SPY"].Price))/(float(data["SPY"].Open))))
         self.VPercent =  np.log(((float(self.Securities["VIXY"].Price))/(float(data["VIXY"].Open))))
        
        
         if self.IsWarmingUp:
            return 
         #if  self.SPercent is None:
        #    return
         #if  self.VPercent is None:
          #  return
      
         if self.SPercent <= -.005:
             #or VPercent >=.01
             if self.position == None:
                self.SetHoldings("VIXY", 1)
             elif self.position == "SPY":
                  self.Liquidate("SPY")  
                  self.SetHoldings("VIXY", 1)
             self.position = "VIXY"
                  
                  
         elif self.SPercent >= .005:
              #or VPercent <=-.01
             if self.position == None:
                self.SetHoldings("SPY", 1)
             elif self.position == "VIXY":
                  self.Liquidate("VIXY")  
                  self.SetHoldings("SPY", 1)
             self.position = "SPY"
             
             ## run time error with the none
             ## error with not buying anyhtng other than vixy may be do to the if
             ##statemt if statement continues to run then  cant get to elif
             ## check to if else isted of elif
             
             ## and in a stop loss at a certian amount
             ## also add in a "lock in results" for gain above...import numpy as np
from datetime import datetime
import pandas as pd



class VolTrading(QCAlgorithm):

    def __init__(self):
            self.previous = None
            self.position = None
            
            
            

    def Initialize(self):
      
        self.SetStartDate(2018,10,1)  #Set Start Date
        #self.SetEndDate(2017,10,1)    #Set End Date
        self.SetCash(10000)           #Set Strategy Cash
        self.AddEquity("SPY", Resolution.Minute)
        self.AddEquity("VIXY", Resolution.Minute)
        self.SetWarmUp(440)
        

    def OnData(self, data):
         #history_s = self.History(["SPY"], 1, Resolution.Minute)
         #last_minute_close_s = history_s.loc["SPY"]["close"][-1]
         
         #history_v = self.History(["IEF"], 1, Resolution.Minute)
         #last_minute_close_v = history_v.loc["IEF"]["close"][-1]
         self.SPercent =  np.log(abs((float(self.Identity("SPY").Current.Value))/(float(data["SPY"].Open))))
         self.VPercent =  np.log(abs((float(self.Identity("VIXY").Current.Value))/(float(data["VIXY"].Open))))
        
        
         if self.IsWarmingUp:
            return 
      
         if self.SPercent <= -.005:
             #or VPercent >=.01
             if self.position == None:
                self.SetHoldings("VIXY", 1)
             elif self.position == "SPY":
                  self.Liquidate("SPY")  
                  self.SetHoldings("VIXY", 1)
             self.position = "VIXY"
                  
                  
         elif self.SPercent >= .005:
              #or VPercent <=-.01
             if self.position == None:
                self.SetHoldings("SPY", 1)
             elif self.position == "VIXY":
                  self.Liquidate("VIXY")  
                  self.SetHoldings("SPY", 1)
             self.position = "SPY"
             
             
             
             
             ## and in a stop loss at a certian
import numpy as np
from datetime import datetime
import pandas as pd
import math


class VolTrading(QCAlgorithm):

    def __init__(self):
            self.previous = None
            self.position = None
            
            
            

    def Initialize(self):
      
        self.SetStartDate(2012,1,1)  #Set Start Date
        #self.SetEndDate(2018,10,29)    #Set End Date
        self.SetCash(10000)           #Set Strategy Cash
        self.AddEquity("SPY", Resolution.Minute)
        self.AddEquity("VIXY", Resolution.Minute)
        self.SetWarmUp(440)
        

    def OnData(self, data):
         history_s = self.History(["SPY"], 1, Resolution.Minute)
         last_minute_close_s = history_s.loc["SPY"]["close"][-1]
         
         history_v = self.History(["VIXY"], 1, Resolution.Minute)
         last_minute_close_v = history_v.loc["VIXY"]["close"][-1]
         self.SPercent =  math.log((self.Identity("SPY").Current.Value)/(last_minute_close_s))
         self.VPercent =  math.log((self.Identity("VIXY").Current.Value)/(last_minute_close_v))
        
       
         if self.IsWarmingUp:
            return 
      
         if SPercent <= -.01:
             if self.position == None:
                self.SetHoldings("VIXY", 1)
             elif self.position == "SPY":
                  self.Liquidate("SPY")  
                  self.SetHoldings("VIXY", 1)
             self.position = "VIXY"
                  
                  
         elif VPercent <= -.01:
             if self.position == None:
                self.SetHoldings("SPY", 1)
             elif self.position == "VIXY":
                  self.Liquidate("VIXY")  
                  self.SetHoldings("SPY", 1)
             self.position = "SPY"