I have four data sets (please bear with me here):
- 1st Table: List of 10 tickers (stock symbols) in one column in txt format in matlab.
- 2nd table: dates in numerical format in one column (10 days in double format).
- 3rd table: I have 10*10 data set of random numbers (assume 0-1 for simplicity). (Earnings Per Share growth EPS for example)–so I want high EPS growth in my ranking for portfolio construction.
- 4th table: I have another 10*10 data set of random numbers (assume 0-1 for simplicity). (Price to earnings ratios for example daily).-so I want low P/E ratio in my ranking for portfolio construction.
NOW: I want to rank portfolio of stocks each day made up of 3 stocks (largest values) from table one for a particular day and bottom three stocks from table 2 (smallest values). The output must be list of tickers for each day (3 in this case) based on combined ranking of the two factors (table 3 & 4 as described).
Any ideas? In short I need to end up with a top bucket with three tickers…
It is not entirely clear from the post what you are trying to achieve. Here is a take based on guessing, with various options.
Your first two “tables” store symbols for stocks and days (irrelevant for ranking). Your third and fourth are scores arranged in a
stock x daymanner. Let’s assume stocks vertical, days horizontal and stocks symbolized with a value in[1:10].Sort the score tables in ascending and descending order (to get upper and lower scores per day, i.e. per column):
Keep three largest and smallest:
IF you need the ones in both (0 is nan):
IF you need the ones in either one (0 is nan):
IF you need a ranking of scores/stocks from the set of largest_of_3 and smallest_of_4:
UPDATE
To get a weighted ranking of the final scores, define the weight vector (1 x scores) and use one of the two options below, before sorting
scoreAllWinstead ofscoreAll: