Click here to Login

Trading System: Buy Stocks based on their Sharpe Ratio Rank

Updated on 2011-05-03

Here is how to implement a trading system based on ranking stocks by their Sharpe measure. The strategy is not difficult to implement, although it use advanced techniques.

Sharpe Ratio

This ratio measures the excess return or risk premium per unit of risk of an asset or trading strategy. In this strategy, we will use the Sharpe ratio to measure individual stocks. The technical indicator that calculates the Sharpe ratio is already available in QuantShare and its name is "Sharpe".

Trading Strategy

The idea is to rank stocks daily based on their one-month Sharpe ratio. The stock that has the highest Sharpe ratio will get a score of one, the next one will get a score of two...

Here are the different trading rules of our trading system:
- Ignore illiquid stocks and stocks from OTC exchanges
- Buy the top 20 stocks (Sharpe score lower than 20)
- Sell the ones that no longer belong to our top 20
- Market Timing: Enter new positions only if the average Sharpe ratio of all stocks (not including illiquid stocks) is higher than 0.4

Trading System Backtesting Report

The backtest report shows that our strategy produced an annual return of 24.16% for the 2001-2011 period. The maximum drawdown is equal to 25.83% and the trading system Sharpe ratio is 1.01.

The overall performance of the strategy can be highly improved by adding new buy/sell rules, adding stop rules, optimizing the different trading indicator variables, adding some money management rules...


There are several variables you can optimize; you can for example calculate the Sharpe ratio of the last year or 10 days instead of the last month; or you can increase the maximum number of positions and buy the top 30 or 50 stocks.

Here is an example that shows you how to optimize the lookback parameter of the Sharpe ratio:
Optimize("param1", 10, 50, 10);
sp = Sharpe(close, param1);

We specified that the variable "param1" should be optimized with the following settings: Min=10, Max=50, Step=10. This will create five trading systems.


Here is the complete formula that we used to implement this strategy: (In Symbols Selection control, do not include OTC stocks)

filter1 = close > 2 and close*sma(volume, 30) > 500000;
sp = sharpe(close, 25);
market1 = Comp(sp, "avg", 1, filter1);
rank1 = Comp(sp, "rank", 1, filter1);
buy = rank1 < 20 and market1 > 0.4;
sell = rank1 >= 20;

2 comments (Log in)

QuantShare Blog
Search Posts

Recent Posts

Create Graphs using the Grid Tool
Posted 1272 days ago

Profile Graphs
Posted 1377 days ago

Previous Posts

More Posts


Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2024
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.