Back

Issue with the Dual Thrust Trading Algorithm

Hi,
When I try to run the backtest I get an error on this line:

self.high.append(slice.High)

Error message:
Runtime Error: Python.Runtime.PythonException: AttributeError : ‘unicode’ object has no attribute ‘High’

Did I miss something ?

Thanks

Chris

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 Chris, sorry about the confusion. The old version dual thrust algorithm doesn't work on Lean anymore. I've updated the backtest, please check the updated tutorial page or the algorithm attached here.

https://www.quantconnect.com/tutorials/dual-thrust-trading-algorithm/
0


Perfect. Thank you very much Jing.

0

Why in this algo, only selltrig is used? buytrig is not used at all.  I thought in the documentation, it says when price > cap, enter long position, when price < floor, enter short position.

  if self.Portfolio[self.syl].Price >= self.selltrig:

elif self.Portfolio[self.syl].Price < self.selltrig:

0

I think there are mistaks in the codes of the tutorial.

0

Hi David,

Thanks for bringing this to our attention. I've made the necessary changes and opened a Pull Request in GitHub to merge the changes, which you can view here.

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.


With the updated code I still get the following error when paper trading:

 

TypeError : '>=' not supported between instances of 'float' and 'NoneType' at OnData

 

1

Hi Parker,

Generally, a NoneType occurs when the symbol being traded doesn't occur in a data slice, usually due to a data event such as a Dividend, Split, or other. I've modified the code to check for this and you can view the pull request at GitHub here. I've attached the modified backtest so you can view this check at the top of the OnData() method.

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