Back

How to generate the Rolling Window of 4-TradeBars

Hi,

   I am trying to generate a rollingwindow of 4-TradeBars for hourly-time frame. I am getting following Error on BackTest:

 

Backtest deployed in 14.605 seconds

13 | 17:07:40:

Runtime Error: AttributeError : 'NoneType' object has no attribute 'Open'
at OnData in main.py:line 98
AttributeError : 'NoneType' object has no attribute 'Open' (Open Stacktrace)

14 | 17:07:50:

Algorithm Id:(e619b785f730a393eb8acd9b7f269eee) completed in 10.74 seconds at 0k data points per second. Processing total of 954 data points

 

Can you please help to fix the issue?

Update Backtest







To obtain the bar open price in OnData(self, data),

def OnData(self, data):
if data.Bars.ContainsKey(symbol):
open = data[symbol].Open

In your case, you can add a None type check before retrieving the open price like "if object is not None:". For better support, please share the algorithm with the "Attach Backtest".

0

Thanks for your suggestion. The check for 'if object is not None' helped.

Though I was wondering what would cause the TradeBar to be None.

0

Could you please attach the backest?
We will be able to find out what is the cause for TradeBar being None.

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.


attached backtest, please take a look for None TradeBars

0


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