Skip to content

Commit

Permalink
Fixes some python algorithms
Browse files Browse the repository at this point in the history
CustomCharting: did not initialize self.lastprice
QuandFuturesData: algorithm file name and class didn't match
UpdateOrderRegression: did not cast quantity (int) to decimal
UserDefinedUniverse: selector function returns C# List
  • Loading branch information
AlexCatarino committed Sep 29, 2017
1 parent 7d2a67c commit 489e117
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions Algorithm.Python/CustomChartingAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ def Initialize(self):

self.fastMA = 0
self.slowMA = 0
self.lastPrice = 0
self.resample = datetime.min
self.resamplePeriod = (self.EndDate - self.StartDate) / 2000

def OnData(self, slice):
if slice["SPY"] is None:
self.lastPrice = 0
return
if slice["SPY"] is None: return

self.lastPrice = slice["SPY"].Close
if self.fastMA == 0: self.fastMA = self.lastPrice
Expand Down
2 changes: 1 addition & 1 deletion Algorithm.Python/QuandlFuturesDataAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
### <meta name="tag" content="quandl" />
### <meta name="tag" content="custom data" />
### <meta name="tag" content="futures" />
class QCUQuandlFutures(QCAlgorithm):
class QuandlFuturesDataAlgorithm(QCAlgorithm):

def Initialize(self):
''' Initialize the data and resolution you require for your strategy '''
Expand Down
2 changes: 1 addition & 1 deletion Algorithm.Python/UpdateOrderRegressionAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def OnData(self, data):
if len(ticket.UpdateRequests) == 0 and ticket.Status is not OrderStatus.Filled:
self.Log("TICKET:: {0}".format(ticket))
updateOrderFields = UpdateOrderFields()
updateOrderFields.Quantity = ticket.Quantity + copysign(self.delta_quantity, self.quantity)
updateOrderFields.Quantity = ticket.Quantity + d.Decimal(copysign(self.delta_quantity, self.quantity))
updateOrderFields.Tag = "Change quantity: {0}".format(self.Time)
ticket.Update(updateOrderFields)

Expand Down
4 changes: 1 addition & 3 deletions Algorithm.Python/UserDefinedUniverseAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def Initialize(self):

def selection(self, time):
index = time.hour%len(self.symbols)
list = List[String]()
list.Add(self.symbols[index])
return list
return self.symbols[index]

def OnData(self, slice):
pass
Expand Down

0 comments on commit 489e117

Please sign in to comment.