Skip to content

Commit

Permalink
Use super instead of manually forwarding the call to upper class.
Browse files Browse the repository at this point in the history
  • Loading branch information
gbeced committed Apr 12, 2016
1 parent c17754a commit 678da73
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pyalgotrade/barfeed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BaseBarFeed(feed.BaseFeed):
"""

def __init__(self, frequency, maxLen=None):
feed.BaseFeed.__init__(self, maxLen)
super(BaseBarFeed, self).__init__(maxLen)
self.__frequency = frequency
self.__useAdjustedValues = False
self.__defaultInstrument = None
Expand Down Expand Up @@ -156,7 +156,7 @@ def getDispatchPriority(self):
# and the bars are sent back to workers.
class OptimizerBarFeed(BaseBarFeed):
def __init__(self, frequency, instruments, bars, maxLen=None):
BaseBarFeed.__init__(self, frequency, maxLen)
super(OptimizerBarFeed, self).__init__(frequency, maxLen)
for instrument in instruments:
self.registerInstrument(instrument)
self.__bars = bars
Expand Down
6 changes: 4 additions & 2 deletions pyalgotrade/barfeed/csvfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class BarFeed(membf.BarFeed):
"""

def __init__(self, frequency, maxLen=None):
membf.BarFeed.__init__(self, frequency, maxLen)
super(BarFeed, self).__init__(frequency, maxLen)

self.__barFilter = None
self.__dailyTime = datetime.time(0, 0, 0)

Expand Down Expand Up @@ -200,7 +201,8 @@ class GenericBarFeed(BarFeed):
"""

def __init__(self, frequency, timezone=None, maxLen=None):
BarFeed.__init__(self, frequency, maxLen)
super(GenericBarFeed, self).__init__(frequency, maxLen)

self.__timezone = timezone
# Assume bars don't have adjusted close. This will be set to True after
# loading the first file if the adj_close column is there.
Expand Down
3 changes: 2 additions & 1 deletion pyalgotrade/barfeed/googlefeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def __init__(self, frequency=bar.Frequency.DAY, timezone=None, maxLen=None):
if frequency not in [bar.Frequency.DAY]:
raise Exception("Invalid frequency.")

csvfeed.BarFeed.__init__(self, frequency, maxLen)
super(Feed, self).__init__(frequency, maxLen)

self.__timezone = timezone
self.__sanitizeBars = False

Expand Down
3 changes: 2 additions & 1 deletion pyalgotrade/barfeed/membf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

class BarFeed(barfeed.BaseBarFeed):
def __init__(self, frequency, maxLen=None):
barfeed.BaseBarFeed.__init__(self, frequency, maxLen)
super(BarFeed, self).__init__(frequency, maxLen)

self.__bars = {}
self.__nextPos = {}
self.__started = False
Expand Down
3 changes: 2 additions & 1 deletion pyalgotrade/barfeed/ninjatraderfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def __init__(self, frequency, timezone=None, maxLen=None):
if frequency not in [bar.Frequency.MINUTE, bar.Frequency.DAY]:
raise Exception("Invalid frequency.")

csvfeed.BarFeed.__init__(self, frequency, maxLen)
super(Feed, self).__init__(frequency, maxLen)

self.__timezone = timezone

def barsHaveAdjClose(self):
Expand Down
2 changes: 1 addition & 1 deletion pyalgotrade/barfeed/quandlfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, frequency=bar.Frequency.DAY, timezone=None, maxLen=None):
if frequency not in [bar.Frequency.DAY, bar.Frequency.WEEK]:
raise Exception("Invalid frequency.")

csvfeed.GenericBarFeed.__init__(self, frequency, timezone, maxLen)
super(Feed, self).__init__(frequency, timezone, maxLen)

self.setDateTimeFormat("%Y-%m-%d")
self.setColumnName("datetime", "Date")
Expand Down
2 changes: 1 addition & 1 deletion pyalgotrade/barfeed/resampled.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def getGrouped(self):
class ResampledBarFeed(barfeed.BaseBarFeed):

def __init__(self, barFeed, frequency, maxLen=None):
barfeed.BaseBarFeed.__init__(self, frequency, maxLen)
super(ResampledBarFeed, self).__init__(frequency, maxLen)

if not isinstance(barFeed, barfeed.BaseBarFeed):
raise Exception("barFeed must be a barfeed.BaseBarFeed instance")
Expand Down
3 changes: 2 additions & 1 deletion pyalgotrade/barfeed/sqlitefeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def disconnect(self):

class Feed(membf.BarFeed):
def __init__(self, dbFilePath, frequency, maxLen=None):
membf.BarFeed.__init__(self, frequency, maxLen)
super(Feed, self).__init__(frequency, maxLen)

self.__db = Database(dbFilePath)

def barsHaveAdjClose(self):
Expand Down
3 changes: 2 additions & 1 deletion pyalgotrade/barfeed/yahoofeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def __init__(self, frequency=bar.Frequency.DAY, timezone=None, maxLen=None):
if frequency not in [bar.Frequency.DAY, bar.Frequency.WEEK]:
raise Exception("Invalid frequency.")

csvfeed.BarFeed.__init__(self, frequency, maxLen)
super(Feed, self).__init__(frequency, maxLen)

self.__timezone = timezone
self.__sanitizeBars = False

Expand Down
6 changes: 4 additions & 2 deletions pyalgotrade/feed/csvfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def includeRow(self, dateTime, values):

class BaseFeed(memfeed.MemFeed):
def __init__(self, rowParser, maxLen=None):
memfeed.MemFeed.__init__(self, maxLen)
super(BaseFeed, self).__init__(maxLen)

self.__rowParser = rowParser
self.__rowFilter = None

Expand Down Expand Up @@ -160,7 +161,8 @@ def __init__(self, dateTimeColumn, dateTimeFormat, converter=None, delimiter=","
if converter is None:
converter = float_or_string
self.__rowParser = BasicRowParser(dateTimeColumn, dateTimeFormat, converter, delimiter, timezone)
BaseFeed.__init__(self, self.__rowParser, maxLen)

super(Feed, self).__init__(self.__rowParser, maxLen)

def addValuesFromCSV(self, path):
"""Loads values from a file.
Expand Down
3 changes: 2 additions & 1 deletion pyalgotrade/feed/memfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

class MemFeed(feed.BaseFeed):
def __init__(self, maxLen=None):
feed.BaseFeed.__init__(self, maxLen)
super(MemFeed, self).__init__(maxLen)

self.__values = []
self.__nextIdx = 0

Expand Down

0 comments on commit 678da73

Please sign in to comment.