bwentzloff / trading-bot

Code seen in Cryptocurrency Trading YouTube video here: https://youtu.be/fpqzXgZjSqM
400 stars 262 forks source link

SyntaxError: 'return' outside function #11

Closed crack00r closed 6 years ago

crack00r commented 6 years ago

root@j314793:/trading-bot/part 3# python backtest.py Traceback (most recent call last): File "backtest.py", line 4, in from botstrategy import BotStrategy File "/root/trading-bot/part 3/botstrategy.py", line 2, in from botindicators import BotIndicators File "/root/trading-bot/part 3/botindicators.py", line 23 return a SyntaxError: 'return' outside function root@j314793:/trading-bot/part 3#

Menox10 commented 6 years ago

I had the same problem. The error is in the EMA and MACD functions. When you comment them out the code runs because they are not used (yet) in backtest.py

def EMA(self, prices, period):

#   x = numpy.asarray(prices)
#   weights = None
#   weights = numpy.exp(numpy.linspace(-1., 0., period))
#   weights /= weights.sum()

#   a = numpy.convolve(x, weights, mode='full')[:len(x)]
#   a[:period] = a[period]

#       return a

#def MACD(self, prices, nslow=26, nfast=12):
#   emaslow = self.EMA(prices, nslow)
#   emafast = self.EMA(prices, nfast)

#       return emaslow, emafast, emafast - emaslow  
bwentzloff commented 6 years ago

Sorry about that. I'll get that fixed this weekend.