Now, this is what I do, and I think it's not very efficient any suggestions?
for inst in self.Portfolio:
if self.Portfolio[ inst.Key ].Invested :
#;do some stuff
QUANTCONNECT COMMUNITY
Now, this is what I do, and I think it's not very efficient any suggestions?
for inst in self.Portfolio:
if self.Portfolio[ inst.Key ].Invested :
#;do some stuff
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.
Xin Wei
Hi Gil,
Please provide more information on your strategy so that we can better assist you. Making it more efficient would depend on what the strategy is.
Gil Sapir
I want a function that given a ticker, ex. AMZL,
returns True if I'm invested in this stock in any way (if I have a put option of this stock - it's also returns True ! )
Daniel Chen
Hi Gil,
Thank you for your question. We recommend you use the Symbol of the equity to achieve your function. For example, you could find out whether this equity is traded by using self.Portfolio[symbol].Invested.
Gil Sapir
this is not what I"m looking for, because if I have only an option of AMZN
and I ask if self.Portfolio["AMZN"].Invested. it will return false
Daniel Chen
Hi Gil,
If possible, please provide the full algorithm so that we can better help you. Thanks!
Gil Sapir
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!