Skip to content

Commit 87e083f

Browse files
committed
Update PE Anomaly in Strategy Library
1 parent 87fce67 commit 87e083f

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

04 Strategy Library/92 Price Earnings Anomaly/02 Method.html

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
</p>
1010

1111
<div class="section-example-container">
12-
<pre class="python">
12+
<pre class="python">
1313
def CoarseSelectionFunction(self, coarse):
14-
if self.yearly_rebalance:
15-
# drop stocks which have no fundamental data and have low price
16-
CoarseWithFundamental = [x for x in coarse if x.HasFundamentalData and x.Price > 5]
17-
sortedByDollarVolume = sorted(CoarseWithFundamental, key=lambda x: x.DollarVolume, reverse=False)
18-
top = sortedByDollarVolume[:self._NumCoarseStocks]
19-
return [i.Symbol for i in top]
20-
else:
21-
return []
14+
if self.Time.year == self.year: return []
15+
16+
# drop stocks which have no fundamental data or have low price
17+
CoarseWithFundamental = [x for x in coarse if x.HasFundamentalData and x.Price > 5]
18+
sortedByDollarVolume = sorted(CoarseWithFundamental, key=lambda x: x.DollarVolume, reverse=False)
19+
top = sortedByDollarVolume[:self._NumCoarseStocks]
20+
return [i.Symbol for i in top]
2221
</pre>
2322
</div>
2423

@@ -27,19 +26,20 @@
2726
</p>
2827

2928
<div class="section-example-container">
30-
<pre class="python">
29+
<pre class="python">
3130

3231
def FineSelectionFunction(self, fine):
33-
if self.yearly_rebalance:
32+
if self.Time.year == self.year:
33+
self.filtered_fine = []
34+
else:
3435
fine = [x for x in fine if (x.ValuationRatios.PERatio > 0)]
3536
for i in fine:
3637
i.PERatio = float(i.ValuationRatios.PERatio)
37-
sortedPERatio = sorted(fine, key=lambda x: x.PERatio,reverse=True)
38+
sortedPERatio = sorted(fine, key=lambda x: x.PERatio)
39+
3840
self.filtered_fine = [i.Symbol for i in sortedPERatio[:self._NumStocksInPortfolio]]
39-
self.yearly_rebalance = False
40-
return self.filtered_fine
41-
else:
42-
return []
41+
42+
return self.filtered_fine
4343
</pre>
4444
</div>
4545

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
div class="qc-embed-frame" style="display: inline-block; position: relative; width: 100%; min-height: 100px; min-width: 300px;">
22
<div class="qc-embed-dummy" style="padding-top: 56.25%;"></div>
33
<div class="qc-embed-element" style="position: absolute; top: 0; bottom: 0; left: 0; right: 0;">
4-
<iframe class="qc-embed-backtest" height="100%" width="100%" style="border: 1px solid #ccc; padding: 0; margin: 0;" src="https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_28c47727b202b88fd00d9b0b52dadedf.html"></iframe>
4+
<iframe class="qc-embed-backtest" height="100%" width="100%" style="border: 1px solid #ccc; padding: 0; margin: 0;" src="https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_c1c62e5e8782b05cc465c5a503463616.html"></iframe>
55
</div>
66
</div>

04 Strategy Library/92 Price Earnings Anomaly/04 Summary.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p>
2-
The portfolio significantly outperforms the benchmark, S&P 500, during the two years backtest period, from the beginning of the year 2016 to the end of the year 2017.
2+
The portfolio significantly outperforms the benchmark, S&P 500, during the three and half years backtest period, from the beginning of the year 2016 to July of the year 2019.
33
</p>
44
<p>
55
The universe of stocks is filtered using dollar volume and price criteria. Most of the stocks chosen by the algorithm during the backtest period are small market capitalization stocks.

0 commit comments

Comments
 (0)