Skip to content

Commit

Permalink
Fixed broken testcases related to changes in Travis images
Browse files Browse the repository at this point in the history
  • Loading branch information
gbeced committed Jan 24, 2018
1 parent a8ab04d commit 6d7d6dd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 deletions.
10 changes: 5 additions & 5 deletions samples/tutorial-2.output
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
2000-01-19 00:00:00 strategy [INFO] 57.13 None
2000-01-20 00:00:00 strategy [INFO] 59.25 None
2000-01-21 00:00:00 strategy [INFO] 59.69 None
2000-01-24 00:00:00 strategy [INFO] 54.19 94.3973333333
2000-01-25 00:00:00 strategy [INFO] 56.44 90.2866666667
2000-01-24 00:00:00 strategy [INFO] 54.19 94.4
2000-01-25 00:00:00 strategy [INFO] 56.44 90.29
.
.
.
2000-12-27 00:00:00 strategy [INFO] 30.69 29.9886666667
2000-12-28 00:00:00 strategy [INFO] 31.06 30.0466666667
2000-12-29 00:00:00 strategy [INFO] 29.06 30.0966666667
2000-12-27 00:00:00 strategy [INFO] 30.69 29.99
2000-12-28 00:00:00 strategy [INFO] 31.06 30.05
2000-12-29 00:00:00 strategy [INFO] 29.06 30.1
9 changes: 8 additions & 1 deletion samples/tutorial-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
from pyalgotrade.technical import ma


def safe_round(value, digits):
if value is not None:
value = round(value, digits)
return value


class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
super(MyStrategy, self).__init__(feed)
Expand All @@ -12,7 +18,8 @@ def __init__(self, feed, instrument):

def onBars(self, bars):
bar = bars[self.__instrument]
self.info("%s %s" % (bar.getClose(), self.__sma[-1]))
self.info("%s %s" % (bar.getClose(), safe_round(self.__sma[-1], 2)))


# Load the bar feed from the CSV file
feed = quandlfeed.Feed()
Expand Down
38 changes: 19 additions & 19 deletions samples/tutorial-3.output
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
2000-01-19 00:00:00 strategy [INFO] 57.13 None None
2000-01-20 00:00:00 strategy [INFO] 59.25 None None
2000-01-21 00:00:00 strategy [INFO] 59.69 None None
2000-01-24 00:00:00 strategy [INFO] 54.19 23.5974551764 None
2000-01-25 00:00:00 strategy [INFO] 56.44 25.0970471496 None
2000-01-26 00:00:00 strategy [INFO] 55.06 24.7758475067 None
2000-01-27 00:00:00 strategy [INFO] 51.81 23.9969202637 None
2000-01-28 00:00:00 strategy [INFO] 47.38 22.9383129352 None
2000-01-31 00:00:00 strategy [INFO] 49.95 25.0052364605 None
2000-02-01 00:00:00 strategy [INFO] 54.0 28.2702989666 None
2000-02-02 00:00:00 strategy [INFO] 54.31 28.5268035435 None
2000-02-03 00:00:00 strategy [INFO] 56.69 30.5793120144 None
2000-02-04 00:00:00 strategy [INFO] 57.81 31.5751334285 None
2000-02-07 00:00:00 strategy [INFO] 59.94 33.5280217825 None
2000-02-08 00:00:00 strategy [INFO] 59.56 33.3451759165 None
2000-02-09 00:00:00 strategy [INFO] 59.94 33.7343557463 None
2000-02-10 00:00:00 strategy [INFO] 62.31 36.2349923621 None
2000-02-11 00:00:00 strategy [INFO] 59.69 34.6770824477 29.0587997134
2000-02-14 00:00:00 strategy [INFO] 62.19 37.4410139074 29.9817036287
2000-01-24 00:00:00 strategy [INFO] 54.19 23.6 None
2000-01-25 00:00:00 strategy [INFO] 56.44 25.1 None
2000-01-26 00:00:00 strategy [INFO] 55.06 24.78 None
2000-01-27 00:00:00 strategy [INFO] 51.81 24.0 None
2000-01-28 00:00:00 strategy [INFO] 47.38 22.94 None
2000-01-31 00:00:00 strategy [INFO] 49.95 25.01 None
2000-02-01 00:00:00 strategy [INFO] 54.0 28.27 None
2000-02-02 00:00:00 strategy [INFO] 54.31 28.53 None
2000-02-03 00:00:00 strategy [INFO] 56.69 30.58 None
2000-02-04 00:00:00 strategy [INFO] 57.81 31.58 None
2000-02-07 00:00:00 strategy [INFO] 59.94 33.53 None
2000-02-08 00:00:00 strategy [INFO] 59.56 33.35 None
2000-02-09 00:00:00 strategy [INFO] 59.94 33.73 None
2000-02-10 00:00:00 strategy [INFO] 62.31 36.23 None
2000-02-11 00:00:00 strategy [INFO] 59.69 34.68 29.06
2000-02-14 00:00:00 strategy [INFO] 62.19 37.44 29.98
.
.
.
2000-12-27 00:00:00 strategy [INFO] 30.69 51.312419753 49.8489966965
2000-12-28 00:00:00 strategy [INFO] 31.06 52.1567099204 49.9957842035
2000-12-29 00:00:00 strategy [INFO] 29.06 47.3744750057 50.0774570242
2000-12-27 00:00:00 strategy [INFO] 30.69 51.31 49.85
2000-12-28 00:00:00 strategy [INFO] 31.06 52.16 50.0
2000-12-29 00:00:00 strategy [INFO] 29.06 47.37 50.08
11 changes: 10 additions & 1 deletion samples/tutorial-3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from pyalgotrade.technical import rsi


def safe_round(value, digits):
if value is not None:
value = round(value, digits)
return value


class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
super(MyStrategy, self).__init__(feed)
Expand All @@ -13,7 +19,10 @@ def __init__(self, feed, instrument):

def onBars(self, bars):
bar = bars[self.__instrument]
self.info("%s %s %s" % (bar.getClose(), self.__rsi[-1], self.__sma[-1]))
self.info("%s %s %s" % (
bar.getClose(), safe_round(self.__rsi[-1], 2), safe_round(self.__sma[-1], 2)
))


# Load the bar feed from the CSV file
feed = quandlfeed.Feed()
Expand Down

0 comments on commit 6d7d6dd

Please sign in to comment.