You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Fixes the issue on the Universe Selection function returning different
lists of symbols. We need to keep a single list that reflects the final
selection at Fine Fundamental.
- Refactors the algorithm to use a dictionary of `Momentum` instead of a
`SymbolData` and use an integer to track the month change instead of Schedule Events.
- Fixes the securities selection based on momentum: instead of buying
those with the hightest momentum, the algorithm was buying those with
the lowest.
Dictionary <code>self.symbolDataDict</code> is used to save the momentum class instance <code>SymbolData</code> for each symbol.
26
-
In <code>OnSecuritiesChanged</code> event method, we add the newly selected symbol to the dictionary and initialize the momentum indicator with the history request. For symbols removed from the universe, we remove it from the dictionary. Each day in <code>OnData</code>, the
27
-
Momentum indicator for all symbols in the dictionary will be updated with the latest closing price.
10
+
Dictionary <code>self.mom</code> is used to save the LEAN Momentum class instance <code>Momentum</code> for each symbol.
11
+
In <code>OnSecuritiesChanged</code> event method, we add the newly selected symbol to the dictionary and initialize the momentum indicator with the history request. For symbols removed from the universe, we remove it from the dictionary and liquidate its positions. Each day in <code>OnData</code>, the Momentum indicator for all symbols in the dictionary will be updated with the latest closing price.
28
12
</p>
29
13
<p>
30
14
We choose a period of 12 months for the momentum indicator. Stocks with the best 12-month momentum (12-month performance) are then added to our portfolio and are weighted equally.
31
15
</p>
32
16
33
17
<h4> Monthly Rebalance</h4>
34
18
<p>
35
-
The portfolio is rebalanced once a month. The coarse and fine universe selection is set to default to run at midnight once a day. To make the universe selection run at the first trading day each month, we use the bool variable
36
-
<code>self.monthly_rebalance</code> to manage the universe selection. At the start of each month, the universe selection will filter new stocks. On all other days, the universe selection function will return the same symbols. In contrast to returning an empty list, returning the same symbols as before is a better way for monthly rebalance universe selection. Since if there are no open positions for certain symbol, returning empty list will stop the data subscription of that symbol halt updates of the indicator.
19
+
The portfolio is rebalanced once a month. The coarse and fine universe selection is set to default to run at midnight once a day. To make the universe selection run at the first trading day each month, we use the int variable <code>self.month</code> that tracks the current month to manage the universe selection. At the start of each month, the universe selection will filter new stocks. On all other days, the universe selection function will return the same symbols <code>self.symbols</code>. In contrast to returning an empty list, returning the same symbols as before is a better way for monthly rebalance universe selection. Since if there are no open positions for certain symbol, returning empty list will stop the data subscription of that symbol halt updates of the indicator.
0 commit comments