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?
QUANTCONNECT COMMUNITY
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.
Tim Butler
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.
Jared Broad
Checkout the SecurityHolding object for all the available helper properties.
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 Senecal
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.
Jared Broad
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.
Shaun Senecal
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!