Back

How to get Drawdown and Sharpe Ratio for my Live Paper Trading Session?

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.

Update Backtest







0

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.


Hi Aditya,

As far as I know, this isn't possible to do directly right now.

I do the following to get runtime statistics:

  1. Go to your main terminal window, open up Chrome developer console (F12), navitage to Network and refresh the page.
  2. Watch for a XHR request for a file beginning with /read.... This is the chart data being sent from the API.
  3. Open this data, copy-paste it into a JSON file.
  4. 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.
0

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.)

0

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).

0


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.

0

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.

 

0

Update Backtest





0

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.


Loading...

This discussion is closed