Hello hope everyone is fine, I have some questions regarding unrealized profits, what I know is that unrealized profits is basically a theoretical profit that exists on paper because u have not close the positions or liquidate them.
I don’t really understand the unrealized of Quantconnect, because suppose I have a strategy that runs from 2021-01-01 to 2022-01-01 that i attached here and the unrealized profit is $11. but isn’t it supposed to be already 0 the unrrealized cause strategy stop and liquidate all?
I find a question where unrealized was defined as:
“The unrealized profit is calculated using the last close of the Bid (if we open a Long position) or the last close of the Ask (if we open a Short position). In the Plots of the attached backtest, we can see the official calculation of Unrealized Profits match exactly the manually calculated one for Bid/Ask closes.”
But still dont understand it in the context of QC
Thanks
Fred Painchaud
Hi Ro,
If you wonder why there is an unrealized profit at the end of your backtest it is because QC does not automatically liquidate all your positions at the end. So if you have profitable positions at the end (and you can also have unrealized losses), they will be reported as unrealized profit.
If you want, you can, for instance, liquidate all your positions at the end of the backtest by adding that event handler to your algo:
It is the short and “hacky” way, you know. It works for backtests when you absolutely do not want to see unrealized profits and losses. But don't use that while live trading…
Fred
Ro García G
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!