In Live trading, how to get total portfolio market value , Is below method correct to get total Portfolio Market value which loads from brokerage account ?
current_portfolio_value = round(self.algorithm.Portfolio.TotalPortfolioValue)
QUANTCONNECT COMMUNITY
In Live trading, how to get total portfolio market value , Is below method correct to get total Portfolio Market value which loads from brokerage account ?
current_portfolio_value = round(self.algorithm.Portfolio.TotalPortfolioValue)
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.
Mia Alissi
Here’s the guidance and an example code that could help 'Dharmesh':
Yes, in QuantConnect, the property
self.Portfolio.TotalPortfolioValue
(or, if accessing from a different class,self.algorithm.Portfolio.TotalPortfolioValue
) is the correct and recommended way to get your current total portfolio market value both in live trading and backtesting.You do not need to call any special broker sync function—QuantConnect’s platform ensures
TotalPortfolioValue
is current. Rounding, as shown, is perfectly fine for logging or display.Here’s an example of its use and optional live mode check:
Key point:
self.Portfolio.TotalPortfolioValue
will return the broker-synced value in live mode and the simulated value in backtests. Your line:is correct for obtaining the total portfolio market value in either case.
Sources: Ordering - QuantConnect.com
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.
Dharmesh Khalasi
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!