Back

When I backtest I got error: "Received type of Tick but expected QuoteBar"

I have Algorithm which handle usdjpy's tick and M30 candle, it works a month ago, but when I run it today, I got this error: "Received type of Tick but expected QuoteBar", anything changed?

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 Gary,

Can you attach a backtest or provide enough code so that we can recreate the issue? This will help us better understand the issue and offer a solution.

1

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.


        self.instrument_id = "USDJPY"
        self.N1,self.N2= 150, 20
        self.SetStartDate(2016,1,1)  #Set Start Date
        self.SetEndDate(2019,1,20)    #Set End Date
        self.SetCash(10000)           #Set Strategy Cash
        self.SetBrokerageModel(BrokerageName.OandaBrokerage, AccountType.Margin)
        self.AddForex(self.instrument_id, Resolution.Tick)
        self.AddForex(self.instrument_id, Resolution.Minute)
        self.SetBenchmark(self.instrument_id)
        self.Securities[self.instrument_id].SetLeverage(50)
        consolidator = QuoteBarConsolidator(30)
        consolidator.DataConsolidated += self.OnCandle
        self.SubscriptionManager.AddConsolidator(self.instrument_id, consolidator)

 

I think the cause is that I call the self.AddForex for two times, I need tick and the M30 candle, If I can't call AddForex twice, How can I do?

 

0

I think I see what the issue is. By subscribing to tick and minute data, there is some confusion about which data type if being processed when, since Tick and QuoteBar are of different types. Rather than subscribing to minute data, I would suggest rewriting the consolidator so that it is a 30-minute Tick Consolidator, which you can read more about here. The way it is right now (i.e., when the consolidator is passed just an integer argument) it defaults to the resolution of the data, but you can force it to act as a 30-min consolidator even when subscribed to tick data, and then you won't need to subscribe to the minute resolution data. Have at look at the backtest I've attached and hopefully this will help you get the algorithm functioning as you want it to.

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.


I will try, thank you!

BTW, why don't provide different event handler for different data, like  OnCandle for candle data, and OnTick for tick data, 

0

It's a design choice. The C# implementation has methods like OnData(TradeBar) or OnData(Ticks), but this information is all contained in the Slice object for Python which we feel makes everything simpler on both ends.

1

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