Back

Futures updates not firing on a minute resolution

Hi! Sorry if this is a stupid question but i'm using the`FutureUniverseSelectionModel` to manually update indicators based on the current front month. This was working when I was using automatic indicator updates, but since I wanted to update indicators manually based on TradeBars from the current front month this problem came up. 

I'm facing an issue where i'm expecting to see `OnData` fire every minute, but it seems to come only twice a day (one at the open and one at the close). In the attached algo i'm writing a self.Debug where I'm expecting the minutely data to come through, am I missing something?? Thanks!

Here is an example of the output

314 | 20:20:23: 2010-01-04 16:15:00

315 | 20:20:23: 2010-01-04 17:00:00

316 | 20:20:23: 2010-01-05 16:15:00

317 | 20:20:23: 2010-01-05 17:00:00

318 | 20:20:24: 2010-01-06 16:15:00

319 | 20:20:24: 2010-01-06 17:00:00

320 | 20:20:25: 2010-01-07 16:15:00

import math
from datetime import date, timedelta
import numpy as np
from Selection.FutureUniverseSelectionModel import FutureUniverseSelectionModel


FUTURES = [ Futures.Indices.SP500EMini ]


class FuturesUniverseSelectionModel(FutureUniverseSelectionModel):
def __init__(self, select_future_chain_symbols):
super().__init__(timedelta(1), select_future_chain_symbols)

def Filter(self, filter):
return (filter.FrontMonth())


class Security:
def __init__(self, security):
self.Security = security

@property
def Symbol(self):
return self.Security.Symbol


class TurtleSystemAlgo(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2010, 1, 1)
self.SetCash(100000)
self.resolution = Resolution.Minute
self.UniverseSettings.Resolution = self.resolution
self.SetUniverseSelection(FuturesUniverseSelectionModel(self._select_futures_symbols))
self.symbol_data = {}

def _select_futures_symbols(self, utcTime):
return [ Symbol.Create(ticker, SecurityType.Future, Market.USA) for ticker in FUTURES ]

def _init_symbol(self, security):
self.AddSecurity(SecurityType.Future, security.Symbol, self.resolution)
s = Security(security)
self.symbol_data[security.Symbol.Value[:2]] = s

def OnOrderEvent(self, order):
if order.Status == OrderStatus.Filled:
self._plot(order.Symbol, 'Buy' if order.FillQuantity > 0 else 'Sell', order.FillPrice)

def OnSecuritiesChanged(self, changes):
for security in changes.AddedSecurities:
s = self.symbol_data.get(security.Symbol.Value[:2])
if not s:
self._init_symbol(security)

def OnData(self, data):
for s, security in self.symbol_data.items():
symbol = security.Symbol
if symbol not in data.Keys or not data[symbol]:
continue

try:
prc = data[symbol].Price
except:
continue

self.Debug(data[symbol].EndTime)

 

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Daniel,

Your debug messages aren't firing because

prc = data[symbol].Price

is throwing an error. Instead access the price data through the trade bar for ES.

data.Bars[symbol].Close

I also reorganized the way you populate your symbol_data dictionary to a simpler form.

 

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed