Skip to content

Commit 52b8326

Browse files
LouisSzetoAlexCatarino
authored andcommitted
SmaCrossUniverseSelectionAlgorithm
1 parent a91da2b commit 52b8326

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

Algorithm.Python/SmaCrossUniverseSelectionAlgorithm.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ class SmaCrossUniverseSelectionAlgorithm(QCAlgorithm):
1717
'''Provides an example where WarmUpIndicator method is used to warm up indicators
1818
after their security is added and before (Universe Selection scenario)'''
1919

20-
count = 10
21-
tolerance = 0.01
22-
target_percent = 1 / count
23-
averages = dict()
24-
25-
def initialize(self):
20+
count: int = 10
21+
tolerance: float = 0.01
22+
target_percent: float = 1 / count
23+
averages: Dict[Symbol, SimpleMovingAverage] = dict()
2624

25+
def initialize(self) -> None:
2726
self.universe_settings.leverage = 2
2827
self.universe_settings.resolution = Resolution.DAILY
2928

@@ -54,9 +53,8 @@ def initialize(self):
5453
# reporting that the algorithm manager is trying to add old information
5554
self.set_warm_up(10)
5655

57-
def coarse_sma_selector(self, coarse):
58-
59-
score = dict()
56+
def coarse_sma_selector(self, coarse: List[Fundamental]) -> List[Symbol]:
57+
score: List[Symbol, float] = dict()
6058
for cf in coarse:
6159
if not cf.has_fundamental_data:
6260
continue
@@ -76,7 +74,7 @@ def coarse_sma_selector(self, coarse):
7674
sorted_score = sorted(score.items(), key=lambda kvp: kvp[1], reverse=True)
7775
return [x[0] for x in sorted_score[:self.count]]
7876

79-
def on_securities_changed(self, changes):
77+
def on_securities_changed(self, changes: SecurityChanges) -> None:
8078
for security in changes.removed_securities:
8179
if security.invested:
8280
self.liquidate(security.symbol)

0 commit comments

Comments
 (0)