Hi,
I'm using C# algo, and have a strategy running. I want to get the Drawdown and Sharpe Ratio for my Live Paper Trading Session (QuantConnect Paper Trading)?
Can someone please help me with a code snippet?
Thanks & Regards,
Aditya.
QUANTCONNECT COMMUNITY
Hi,
I'm using C# algo, and have a strategy running. I want to get the Drawdown and Sharpe Ratio for my Live Paper Trading Session (QuantConnect Paper Trading)?
Can someone please help me with a code snippet?
Thanks & Regards,
Aditya.
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.
Douglas Stridsberg
Hi Aditya,
As far as I know, this isn't possible to do directly right now.
I do the following to get runtime statistics:
- Go to your main terminal window, open up Chrome developer console (F12), navitage to Network and refresh the page.
- Watch for a XHR request for a file beginning with /read.... This is the chart data being sent from the API.
- Open this data, copy-paste it into a JSON file.
- The chart data you need will be under the Results node. You can import this into Python or Excel or whatever other software you're comfortable with and do the calculations necessary to get Sharpe and DD.
A bit cumbersome but works for me.Petter Hansson
Drawdown is pretty easy to keep track of with a few lines of code if you're fine with using intermittent data points rather than checking price bars high/low for true minimum, Sharpe ratio is marginally harder. This is basically a good candidate for "write once" reusable utility code. (Actually, I should start doing that, if I end up doing it this week I'll attach to this thread.)
Petter Hansson
Attaching an informal implementation of max drawdown from some code (verifying whether this works on IB was however a bit more difficult as probably QC muted by SetRuntimeStatistic calls after calling them too much in backtest, so if there's a mismatch you will have to look into it yourself).
Aditya Pasumarthi
Thanks Petter. This helps. However I did not understand the multiplication with -100 in SetRuntimeStatistics method call. If I use this., I'm getting drawdown in negative. So I changed it to 100. Then the drawdown is almost matching with the drawdown in backtest summary. Any light on the -100 will help.
Douglas Stridsberg
Hi Aditya - the -100 is so that the drawdown is expressed as a negative number as it is a drawdown, meaning it's a measure of how far something has fallen from the top. It makes to display this as a negative number but it's obviously up to you what to do with it.
Â
Critical.Error
Very helpful Peter, thank you!Â
Does anyone know if the custom Runtime statistics get reset if we ever have to redeploy the algorithm or will it continue in the same manner the equity curve persists across redeployments?Â
Â
Yuri Lopukhov
Based on the code: yes, it will reset, and I don't think there is a way to avoid this.
Louis Szeto
Hi Critical.Error and Yuri
Thank you for your answer, Yuri.
We suggest cloning the project and deploying the new one if you wish to have the original results wiped.
Best
Louis
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.
Aditya Pasumarthi
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!