Overall Statistics
Total Trades
2
Average Win
4.95%
Average Loss
0%
Compounding Annual Return
84.892%
Drawdown
1.700%
Expectancy
0
Net Profit
4.945%
Sharpe Ratio
10.377
Probabilistic Sharpe Ratio
94.487%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.061
Beta
0.962
Annual Standard Deviation
0.086
Annual Variance
0.007
Information Ratio
5.222
Tracking Error
0.005
Treynor Ratio
0.93
Total Fees
$2.00
class Volatility(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 2)  # Set Start Date
        self.SetCash(10000)  # Set Strategy Cash
        # self.AddEquity("SPY", Resolution.Minute)
        self.ziv = self.AddEquity("ZIV", Resolution.Daily)
        self.ziv.SetDataNormalizationMode(DataNormalizationMode.Raw)
    
        self.roc = self.ROC("ZIV", 5, Resolution.Daily)
        self.SetWarmUp(5)
        
        
    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
            Arguments:
                data: Slice object keyed by symbol containing the stock data
        '''
        if self.IsWarmingUp:
            return
        
        if self.roc.Current.Value > 0:
            self.SetHoldings("ZIV",1)
        else:
            self.Liquidate("ZIV")
class NadionHorizontalCircuit(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 2)  # Set Start Date
        self.SetEndDate(2018, 1, 30)
        self.SetCash(10000)  # Set Strategy Cash
        # self.AddEquity("SPY", Resolution.Minute)
        self.spy = self.AddEquity("SPY", Resolution.Minute)
        self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
    
        self.roc = RateOfChange(5)
        
        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 5), self.Rebalance)
        
    def Rebalance(self):
        
        if not self.roc.IsReady:
            history = self.History("SPY", 5, Resolution.Daily)
            for bar in history:
                self.roc.Update(bar.EndTime, bar.Close)
        
        self.roc.Update(self.Time, self.Securities["SPY"].Close)
        
        if self.roc.Current.Value > 0:
            self.SetHoldings("SPY",1)
        else:
            self.Liquidate("SPY")