-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy path02 Method.html
More file actions
25 lines (25 loc) · 1.34 KB
/
02 Method.html
File metadata and controls
25 lines (25 loc) · 1.34 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
<p>
To construct the universe, first we eliminate stocks which don't have fundmental data. In <code>FineSelectionFunction</code>,
we calculate the market cap with PE ratio, earning per shares and shares outstanding and assign the property <code>MarketCap</code>
to each fine fundamental object. The universe is narrowed to top 20% companies with the highest market cap.
</P>
<p>
According to the algorithm, the portfolio is weighted based on market cap. We calculate the weight in <code>FineSelectionFunction</code> and save
them in <code>self.weights</code>.
</P>
<div class="section-example-container">
<pre class="python">
fine = [x for x in fine if (x.ValuationRatios.PBRatio > 0)]
top_market_cap = sorted(fine, key = lambda x:x.MarketCap, reverse=True)[:int(len(fine)*0.2)]
top_bm = sorted(top_market_cap, key = lambda x: 1 / x.ValuationRatios.PBRatio, reverse=True)[:int(len(top_market_cap)*0.2)]
self.sorted_by_bm = [i.Symbol for i in top_bm]
total_market_cap = np.sum([i.MarketCap for i in top_bm])
self.weights = {}
for i in top_bm:
self.weights[str(i.Symbol)] = i.MarketCap/total_market_cap
return self.sorted_by_bm
</pre>
</div>
<p>
In the next step, we sort the stocks with the inverse of P/B ratio by descending order. Quintile portfolios are then formed based on the Book-to-Market ratio and the highest quintile is held for one year.
</p>