| Overall Statistics |
|
Total Orders 49 Average Win 2.55% Average Loss -1.07% Compounding Annual Return 7.127% Drawdown 8.400% Expectancy 0.688 Start Equity 25000 End Equity 32920.16 Net Profit 31.681% Sharpe Ratio 0.713 Sortino Ratio 0.787 Probabilistic Sharpe Ratio 38.252% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 2.38 Alpha 0.003 Beta 0.489 Annual Standard Deviation 0.056 Annual Variance 0.003 Information Ratio -0.615 Tracking Error 0.058 Treynor Ratio 0.082 Total Fees $49.00 Estimated Strategy Capacity $640000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X Portfolio Turnover 2.13% |
from AlgorithmImports import *
from QuantConnect.DataSource import *
class CBOEDataAlgorithmAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2014,1,1)
self.set_end_date(2018,1,1)
self.set_cash(25000)
self.spy = self.add_equity("SPY", Resolution.DAILY).symbol
# Define the symbol and "type" of our generic data
self.vix = self.add_data(CBOE, 'VIX', Resolution.DAILY).symbol
self.vxv = self.add_data(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.plot_indicator("Ratio", self.ratio)
self.plot_indicator("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 on_data(self, slice: Slice) -> None:
# Wait for all indicators to fully initialize
if not (self.vix_sma.is_ready and self.vxv_sma.is_ready and self.ratio.is_ready): return
if not self.portfolio.invested and self.ratio.current.value > 1:
self.market_order(self.spy, 100)
elif self.ratio.current.value < 1:
self.liquidate()