| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.787 Tracking Error 0.149 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class ContinuousFutureRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.SetCash(1000000)
self.SetStartDate(2009, 1, 1)
self.SetEndDate(2021, 10, 18)
self._lastDateLog = -1
self._continuousContract = self.AddFuture(Futures.Indices.VIX,
dataNormalizationMode = DataNormalizationMode.BackwardsRatio,
dataMappingMode = DataMappingMode.OpenInterest,
contractDepthOffset = 0)
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.Midnight, self.PlotPrices)
self._lastPrice = None
self._startTime = None
self._gap = False
def PlotPrices(self):
if self._continuousContract.HasData:
self.Plot(self._continuousContract.Symbol.ID.Symbol, self._continuousContract.Symbol.ID.Symbol, self._continuousContract.Price)
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
'''
for changedEvent in data.SymbolChangedEvents.Values:
if changedEvent.Symbol == self._continuousContract.Symbol:
self.Log(f"SymbolChanged event: {changedEvent}")
if self._lastPrice is None:
self._lastPrice = self._continuousContract.Price
self._startTime = self.Time
else:
if self._lastPrice != self._continuousContract.Price:
self._lastPrice = self._continuousContract.Price
if self._gap:
self.Log(f"Gap from {self._startTime} to {self.Time}")
self._startTime = self.Time
self._gap = False
else:
if self.Time - self._startTime > timedelta( days = 3 ):
self._gap = True