Novice at python
-
I tried using the snippet of code from main page with a slight edit and I am getting errors...
''' from datetime import datetime
import backtrader as btclass SmaCross(bt.SignalStrategy):
params = (('pfast', 10), ('pslow', 30),)
def init(self):
sma1, sma2 = bt.ind.SMA(period=self.p.pfast), bt.ind.SMA(period=self.p.pslow)
self.signal_add(bt.SIGNAL_LONG, bt.ind.CrossOver(sma1, sma2))cerebro = bt.Cerebro() data = bt.feeds.CCXT(exchange='coinbasepro', symbol='ETH/USD', ohlcv_limit=None, fromdate=datetime(2019, 3, 1), todate=datetime(2019, 3, 18)) #data = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1), # todate=datetime(2012, 12, 31)) cerebro.adddata(data) cerebro.addstrategy(SmaCross) cerebro.run() cerebro.plot()
Errors:
To many positional arguements for constuctor call pylint line 8,41
Unexpected keyword fromdate
Unexpected keyword todate
Undefined variable SMACrossHelp the noob please!
Thanks.
-
@no1uknow Sigh can't edit post? Wanted to fix the code block.
-
@no1uknow said in Novice at python:
Errors:
To many positional arguements for constuctor call pylint line 8,41
Unexpected keyword fromdate
Unexpected keyword todate
Undefined variable SMACrossThose aren't errors. That's
pylint
Do you have any actual error?
-
As an idea - CCXT feed is not in the
bt
module. You might need to install and import it separately.