| Overall Statistics |
|
Total Trades 49 Average Win 2.63% Average Loss -1.11% Compounding Annual Return 7.332% Drawdown 8.700% Expectancy 0.689 Net Profit 32.690% Sharpe Ratio 0.897 Probabilistic Sharpe Ratio 38.237% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 2.38 Alpha 0.008 Beta 0.504 Annual Standard Deviation 0.058 Annual Variance 0.003 Information Ratio -0.599 Tracking Error 0.057 Treynor Ratio 0.103 Total Fees $49.00 Estimated Strategy Capacity $630000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
from AlgorithmImports import *
class CBOEDataAlgorithmAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2014,1,1)
self.SetEndDate(2018,1,1)
self.SetCash(25000)
self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol
# Define the symbol and "type" of our generic data
self.vix = self.AddData(CBOE, 'VIX', Resolution.Daily).Symbol
self.vxv = self.AddData(CBOE, 'VIX3M', Resolution.Daily).Symbol
# Set up default Indicators, these are just 'identities' of the closing price
self.vix_sma = self.SMA(self.vix, 1, Resolution.Daily)
self.vxv_sma = self.SMA(self.vxv, 1, Resolution.Daily)
# This will create a new indicator whose value is smaVXV / smaVIX
self.ratio = IndicatorExtensions.Over(self.vxv_sma, self.vix_sma)
# Plot indicators each time they update using the PlotIndicator function
self.PlotIndicator("Ratio", self.ratio)
self.PlotIndicator("Data", self.vix_sma, self.vxv_sma)
history = self.History(CBOE, self.vix, 60, Resolution.Daily)
self.Debug(f"We got {len(history.index)} items from our history request");
def OnData(self, data):
# Wait for all indicators to fully initialize
if not (self.vix_sma.IsReady and self.vxv_sma.IsReady and self.ratio.IsReady): return
if not self.Portfolio.Invested and self.ratio.Current.Value > 1:
self.MarketOrder(self.spy, 100)
elif self.ratio.Current.Value < 1:
self.Liquidate()