AttributeError: module 'oandapy' has no attribute 'OandaError'
-
when run the 'backtrader' example, it shows the error,
do anyone have the solution to it?python code:
from datetime import datetime import backtrader as bt # Create a subclass of Strategy to define the indicators and logic class SmaCross(bt.Strategy): # list of parameters which are configurable for the strategy params = dict( pfast=10, # period for the fast moving average pslow=30 # period for the slow moving average ) def __init__(self): sma1 = bt.ind.SMA(period=self.p.pfast) # fast moving average sma2 = bt.ind.SMA(period=self.p.pslow) # slow moving average self.crossover = bt.ind.CrossOver(sma1, sma2) # crossover signal def next(self): if not self.position: # not in the market if self.crossover > 0: # if fast crosses slow to the upside self.buy() # enter long elif self.crossover < 0: # in the market & cross to the downside self.close() # close long position cerebro = bt.Cerebro() # create a "Cerebro" engine instance # Create a data feed data = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1), todate=datetime(2012, 12, 31)) cerebro.adddata(data) # Add the data feed cerebro.addstrategy(SmaCross) # Add the trading strategy cerebro.run() # run it all cerebro.plot() # and plot it with a single command
it shows error:
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.IPython 7.10.2 -- An enhanced Interactive Python.
runfile('D:/Python Project/MT5/test3.py', wdir='D:/Python Project/MT5')
Traceback (most recent call last):File "D:\Python Project\MT5\test3.py", line 9, in <module>
import backtrader as btFile "d:\winpython\python-3.7.6.amd64\lib\site-packages\backtrader_init_.py", line 62, in <module>
from .cerebro import *File "d:\winpython\python-3.7.6.amd64\lib\site-packages\backtrader\cerebro.py", line 35, in <module>
from .brokers import BackBrokerFile "d:\winpython\python-3.7.6.amd64\lib\site-packages\backtrader\brokers_init_.py", line 35, in <module>
from .vcbroker import VCBrokerFile "d:\winpython\python-3.7.6.amd64\lib\site-packages\backtrader\brokers\vcbroker.py", line 35, in <module>
from backtrader.stores import vcstoreFile "d:\winpython\python-3.7.6.amd64\lib\site-packages\backtrader\stores_init_.py", line 38, in <module>
from .oandastore import OandaStoreFile "d:\winpython\python-3.7.6.amd64\lib\site-packages\backtrader\stores\oandastore.py", line 41, in <module>
class OandaRequestError(oandapy.OandaError):AttributeError: module 'oandapy' has no attribute 'OandaError'
anyone can help this?? Many thanks.
Nick
-
Please take a look at the following post: https://community.backtrader.com/topic/1879/backtrader-oandapy-and-oandaerror-issues
Could it be relevant ?
-
:), Many thanks. It indeed solved the issue!!