How do I get the "cost basis" for a given position? I'm trying to replicate behaviour from Quantopian, so I'm looking for the VWAP per share of a given position. Is this something I need to calculate myself?
How do I get the "cost basis" for a given position? I'm trying to replicate behaviour from Quantopian, so I'm looking for the VWAP per share of a given position. Is this something I need to calculate myself?
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.
Shaun
If I've understood your question properly, this is what I've used personally:
C#
BuyPrice = Portfolio["XIV"].AveragePrice;
Python
self.BuyPrice = self.Portfolio["XIV"].AveragePrice
I just very lazily update this every tick.
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.
Thanks. That appears to be what I am looking for. I have tried to follow the docs before, but I tend to get lost when trying to convert between the docs (which appear to be targetted for C#) and python (which I'm trying to write my algo in)
As suggested, I just checked the docs for the SecurityHolding object, but there doesnt appear to be an "AveragePrice" property. I see VolumeWeightedAveragePrice, which appears to be what I'm looking for though.
Shaun Senecal its tricky to find in the generated docs, its clearer in the source -- here is the direct link:
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.
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!