Back

Invested flag isn't working

Hi Does anyone know why my holdings flag is always False?  Or atleast its never true when the debug function triggers. 

Thanks in advance

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.


Sorry if this was your intention but the invested section is all commented out. Was that intentional? 

'''
This is a python comment.
'''

PS: Thank you for all the other community support you give back to others in the community! 

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

Yes that was on purpose. I am only focused on testing the first trading function. It should say Def twoforty . My holdings flag is what I'm focused on. I'm also trying to work on a  cost management strategy that only enters the trade if 4% of my portfolio isn't already tied up in a trade but I'm having trouble finding the right self.portfolio helpers to represent 4% of my portfolio already invested in an asset.  You are welcome !! 

0

Hi Apollos,

On Line 41, you're setting holdings to False right before your if statements.

holdings = False
if holdings == False:
....

Maybe instead you meant

holdings = self.Portfolio.Invested

Best
Rahul

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

Thanks for a different suggestion but i want to invest in the same currency multiple times so this won't work because it will only allow me to invest if i'm not already invested. 

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