Back

'ForexHolding' object has no attribute 'Islong' error

Hello!

I am having a problem when trying to use the "Trail Stop" function below. It seems like I am not able to check if a Forex trade is long or short to update the stop loss accrodingly. When I run it with my algorithm, I get the runtime error: 'ForexHolding' object has no attribute 'Islong'. When I read the documentation I see that "IsLong" and "IsShort" are both members of ForexHolding. (Added the link below). 

Documentation link: https://www.quantconnect.com/lean/documentation/topic27441.html

This is the line I use to pass the values to the function:

 

if self.Portfolio.Invested:
            self.TrailingStop(base_SL, self.Portfolio[self.symb])

Where "base_SL" is a calculation of X amount of pips from current price. "self.sym" is a string with a forex pair (ex: EURUSD)

 

Am I doing something wrong with my implementation? Do I need to reference the order instead of the pair somehow? Is there another way I can check if my forex trade is long or short? 

Thank you in advance for the help!

Pablo

 

 

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 Pablo Dominguez ,

Please share the algorithm (it can be a simplified version) that we can use to reproduce the problem.
You haven't added the statement that raises the exception. I guess that there is a typo because the message says
'ForexHolding' object has no attribute 'Islong'
and the attribute is not Islong, it is IsLong.

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