Back

Working With Futures Tick Data

I'm working with tick data for /ES and simply trying to print out contract information, but having some issues:

1)  LastPrice is sometimes 0.0.

2)  I can't access other members of the Tick Class, such as Quantity or Suspicious, shown here: https://www.quantconnect.com/lean/documentation/topic24387.html

3.   I thought that OnData should be called for each tick in the backtest, but it is only called once/day.  Is that expected?  Do I have to set the contract fresh everytime OnData is called or some other housekeeping to ensure it is called for each tick?

def OnData(self, data):
for chain in data.FutureChains.Values:
contracts = list(chain.Contracts.Values)
chain_contracts = list(contracts) #[contract for contract in chain]
chain_contracts = sorted(chain_contracts, key=lambda x: x.Expiry)
self.contract = chain_contracts[0] # this is ES19M20


if self.contract != None:
self.Debug("Using contract: {} ".format(self.contract.Symbol.Value))
self.Debug("OnData: " + str(self.Time))
self.Debug(f"Price: {self.contract.LastPrice}") # sometimes gives 0.0
self.Debug(f"QTY: {self.contract.Quantity}") # errors out
self.Debug(f"Type: {self.contract.TickType}") # errors out
self.Debug(f"Suspicious?: {self.contract.Suspicious}") # errors out

Thanks!

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 Ernay, try and avoid "+1" or posts like "anybody" where it's pushing for interaction. The thread can stand on its merits and the community will reply on their own schedule. People volunteer their time to assist so sometimes patience is needed =) 

I noticed you also have not completed much of Boot Camp. Please finish the rest of BC and see if that answers your question. 

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