Skip to content

Commit e95863a

Browse files
committed
Update Python comparisons to None to use "is None" instead of equality
1 parent 7a9fc44 commit e95863a

12 files changed

Lines changed: 16 additions & 16 deletions

Algorithm.Python/Benchmarks/CoarseFineUniverseSelectionBenchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def FineSelectionFunction(self, fine):
5959

6060
def OnData(self, data):
6161
# if we have no changes, do nothing
62-
if self._changes == None: return
62+
if self._changes is None: return
6363

6464
# liquidate removed securities
6565
for security in self._changes.RemovedSecurities:

Algorithm.Python/CoarseFineFundamentalComboAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def FineSelectionFunction(self, fine):
7070

7171
def OnData(self, data):
7272
# if we have no changes, do nothing
73-
if self._changes == None: return
73+
if self._changes is None: return
7474

7575
# liquidate removed securities
7676
for security in self._changes.RemovedSecurities:

Algorithm.Python/CoarseFineFundamentalRegressionAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def FineSelectionFunction(self, fine):
6767

6868
def OnData(self, data):
6969
# if we have no changes, do nothing
70-
if self.changes == None: return
70+
if self.changes is None: return
7171

7272
# liquidate removed securities
7373
for security in self.changes.RemovedSecurities:

Algorithm.Python/CoarseFundamentalTop5Algorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def OnData(self, data):
6262
self.Log(f"OnData({self.UtcTime}): Keys: {', '.join([key.Value for key in data.Keys])}")
6363

6464
# if we have no changes, do nothing
65-
if self._changes == None: return
65+
if self._changes is None: return
6666

6767
# liquidate removed securities
6868
for security in self._changes.RemovedSecurities:

Algorithm.Python/DelistingEventsAlgorithm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def OnData(self, data):
6363

6464
aaa = self.Securities["AAA"];
6565
if aaa.IsDelisted and aaa.IsTradable:
66-
raise Exception("Delisted security must NOT be tradable");
66+
raise Exception("Delisted security must NOT be tradable")
6767

6868
if not aaa.IsDelisted and not aaa.IsTradable:
69-
raise Exception("Securities must be marked as tradable until they're delisted or removed from the universe");
69+
raise Exception("Securities must be marked as tradable until they're delisted or removed from the universe")
7070

7171
for kvp in data.Delistings:
7272
symbol = kvp.Key
@@ -76,13 +76,13 @@ def OnData(self, data):
7676
self.Log("OnData(Delistings): {0}: {1} will be delisted at end of day today.".format(self.Time, symbol))
7777

7878
# liquidate on delisting warning
79-
self.SetHoldings(symbol, 0);
79+
self.SetHoldings(symbol, 0)
8080

8181
if value.Type == DelistingType.Delisted:
8282
self.Log("OnData(Delistings): {0}: {1} has been delisted.".format(self.Time, symbol))
8383

8484
# fails because the security has already been delisted and is no longer tradable
85-
self.SetHoldings(symbol, 1);
85+
self.SetHoldings(symbol, 1)
8686

8787

8888
def OnOrderEvent(self, orderEvent):

Algorithm.Python/DisplacedMovingAverageRibbon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def OnData(self, data):
8787
def IsAscending(self, values):
8888
last = None
8989
for val in values:
90-
if last == None:
90+
if last is None:
9191
last = val
9292
continue
9393
if last < val:
@@ -99,7 +99,7 @@ def IsAscending(self, values):
9999
def IsDescending(self, values):
100100
last = None
101101
for val in values:
102-
if last == None:
102+
if last is None:
103103
last = val
104104
continue
105105
if last > val:

Algorithm.Python/DropboxBaseDataUniverseSelectionAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def stockDataSource(self, data):
5959
def OnData(self, slice):
6060

6161
if slice.Bars.Count == 0: return
62-
if self._changes == None: return
62+
if self._changes is None: return
6363

6464
# start fresh
6565
self.Liquidate()

Algorithm.Python/DropboxUniverseSelectionAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def selector(self, date):
7373
def OnData(self, slice):
7474

7575
if slice.Bars.Count == 0: return
76-
if self.changes == None: return
76+
if self.changes is None: return
7777

7878
# start fresh
7979
self.Liquidate()

Algorithm.Python/RegressionAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def roundTime(self, dt=None, roundTo=60):
7171
dt : datetime object, default now.
7272
roundTo : Closest number of seconds to round to, default 1 minute.
7373
"""
74-
if dt == None : dt = datetime.now()
74+
if dt is None : dt = datetime.now()
7575
seconds = (dt - dt.min).seconds
7676
# // is a floor division, not a comment on following line:
7777
rounding = (seconds+roundTo/2) // roundTo * roundTo

Algorithm.Python/UniverseSelectionDefinitionsAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def Initialize(self):
5656
self.changes = None
5757

5858
def OnData(self, data):
59-
if self.changes == None: return
59+
if self.changes is None: return
6060

6161
# liquidate securities that fell out of our universe
6262
for security in self.changes.RemovedSecurities:

0 commit comments

Comments
 (0)