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.
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
C# user seeks code snippet for Drawdown and Sharpe Ratio in QuantConnect Paper Trading session.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
How to get Drawdown and Sharpe Ratio for my Live Paper Trading Session?
Aditya Pasumarthi | June 2019
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â„¢ 2025. All Rights Reserved
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.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.
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.)
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.
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).
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
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.
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 - 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.
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.
Critical.Error INVESTOR
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?
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.
Yuri Lopukhov
Based on the code: yes, it will reset, and I don't think there is a way to avoid this.
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.
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.
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!