Monthly Long–Short Portfolios from Return Rankings
Summary
The document explains how to form a monthly long–short portfolio from a universe of ten stocks. At each rebalance, calculate each stock’s average return over the chosen lookback period, rank the results, short the three weakest performers, and go long the three strongest. The example assigns equal weights within each side, producing one-third exposure per selected stock on each side.
The example uses randomly generated returns to demonstrate averaging and sorting; it does not test whether the strategy is profitable. The key implementation choice is the ranking window: the question raises whether rankings should use the previous month, but does not settle that detail. It also does not address transaction costs, portfolio constraints, risk controls, or how to handle ties and missing data. The method is a simple selection rule, not a complete portfolio optimization procedure.
Key ideas
- Rank assets using average returns over a specified lookback period.
- Short the three lowest-ranked stocks and buy the three highest-ranked stocks.
- Equal weighting assigns one-third of each side’s exposure to each selected stock.
- Recalculate the rankings at each monthly rebalance.
- The example illustrates the construction process but provides no evidence of investment performance.
Tags
Full text
# Matlab code for equally weighted portfolio
# Matlab code for equally weighted portfolio
I have daily returns of 10 stocks. I need to construct an equally weighted portfolio that goes long in the 3 highest returns and short in the 3 lowest returns. The portfolio needs to be re-balanced every month. How to tell Matlab about this constraint? I started like following:
1) data=load('mydata'); #loading my data that contains 10 stock market returns
2) port=Portfolio(); # create the portfolio
3) port=port.estimateAssetMoments(R);# calculate the average return for each index
4) I ignore the command that tell Matlab to be short in the 3 lowest returns and long in the 3 long returns. I just find the default command : port=port.setDefaultConstraints();
I can't use it because it doesn't allow short positions... Could you please help me?
Thanks in advance!
## Answer by phdstudent (score 1)
https://quant.stackexchange.com/a/23056
Your question is not clear enough. Go long on 3 highest returns... since when? During the past month? If so, at the end of each month you need to compute the average return on each index, and then find the minimum and maximum returns.
As simple dummy example, I will generate a matrix of 10 stocks and 30 daily returns. Then I will average those and find the 3 lowest and 3 largest.
```
rng(0,'twister');
a = -1;
b = 1;
r = (b-a).*rand(1000,10,30) + a; %Generate a 10x30 matrix of returns
average = mean(r,2);
[~,index] = sort(average);
```
Then you should be short 1/3 on the stocks which index is (1,2,3) and long 1/3 on the stocks in which index is (8,9,10).Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.