-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstrategy
More file actions
57 lines (45 loc) · 3.28 KB
/
strategy
File metadata and controls
57 lines (45 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
- choose the least amount of stocks possible, in this case 12, so that our portfolio is as un-diversified as possible.
- because we can choose the weighting of each stock, we will also choose to put the most amount of weight in the riskiest stocks
- calculate the std of each stock, then consider correlation between them (closest to 1 as possible)
- make our own version of pearsons correlation formula to find the correlation
- More precisely, we will calculate the correlation between each combination of 12 stocks
kind each combination
S1
S2
S3
...
SN, N > 25
Find each combination of 12 stocks out of N of them, where N is the given amount in the Ticker file
For each combination of 12 stocks, calculate the multivariable correlation between each of them and the standard deviation of a portfolio with
those 12 stocks from January to October 2022
Assign the standard deviation and correlation (where correlation is between -1 and 1) a weight such that their sum is 100%
Find the sum of the weighted standard deviation and correlation
Motivation.
Standard deviation is a measure of risk because it is a calculation of the average absolute distance of a stock's price from its expected value
over some time interval (in this case, January to October), so we want to maximize lt because generally, price patterns are repeated
Main Algorithm:
Let k be the number of stocks we're choosing to be in our portfolio. In this case, we have chosen k = 12.
;; A Portfolio is a
;; (dictof (Ticker : Num))
;; Requires: dictof has k elements
;; Ticker is a Ticker object
;; 1/(2k) <= Num <= 0.25
;; Sum(Nums) = 1
;; main(N, k, listof_stock_portfolio) consumes a number of stocks to select from and a list of a list of k stocks (where each list represents a portfolio of k stocks)
;; and produces a Portfolio
Assume we start with N stocks, where N > 25 and N > k.
1) Base Case (N=k), Return a call of Algorithm 2, passing in the list of k stocks chosen by highest price weighted index standard deviation
2) Call Algorithm 1, passing in a list of N-2 stocks and the two stocks with the highest correlation in the form of a price weighted index
3) Store the list of 12 stocks returned by Algorithm 1 in a list, as well as the standard deviation of the price weighted index formed by those k stocks
2) Apply Main Algorithm recursively, one step closer to the base case, with the stock of lowest standard deviation removed from the list of N stocks
Algorithm 1:
;; algo1(listof_stocks, priceweighted_index) consumes a listof_stocks and a price weighted index, recursively producing a list of 1 less stocks and price weighted index
;; with the stock of highest correlation added to it, until the price weighted reaches enough stocks to form a portfolio of k stocks
Assume we start with M stocks and a price weighted index with L stocks.
1) Base Case: L = k, Return the list of stocks in the price weighted index
1) Calculate the correlation between each of the M stocks and the price weighted index
2) Add the stock with the highest correlation to the price weighted index and remove that same stock from the list of M stocks
3) Recurse on the M-1 stocks and price index of L+1 stocks
# Algorithm 2 calculates the optimal proportion of ownership in a stock
Algorithm 2:
Assume we start with (100/(24))% of the portfolio