Hi!
I want to calculate single instrument's Sharpe Ratio and use this score to filter elements in the dynamic universe
I've started coding using one of your examples:
QUANTCONNECT COMMUNITY
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.
Emiliano Fraticelli
This is my implementation so far;Â
Â
Emiliano Fraticelli
As you can deduce by looking at my code,
I would like to consider a stock's Sharpe Ratio as its total return over the last 6 months (excluded the last 10 trading days) minus the risk free rate, all divided by the stock's Standard Deviation over the last 6 months.
Varad Kabade
Hi Emiliano Fraticelli,
We can improve the speed by using built-in indicators for the above strategy. The STD indicator is never updated in the above algorithm, so the logic to calculate the Sharpe ratio incorrect. We have made the following changes to the algorithm
Â
Refer to the attached backtest.
Best,
Varad Kabade
Emiliano Fraticelli
Well, I ended up making it by myself and calculating returns by loading a RollingWindow with the daily prices…
But this solution might come handy…I will ask more things if needed….for now, thank.
Â
p.s: Do I have to accept this answer? Accepting it won't allow me to give updates….
Varad Kabade
Hi Emiliano Fraticelli,
To speed up the backtest times we recommend using the in-built Sharpe ratio indicator. Refer to the attached backtest for example regarding above.
Best,
Varad Kabade
Emiliano Fraticelli
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!