defining a feed. Error message: Unexpected keyword argument 'dataname' in constructor call"
I am new to Backtrader and I am stucking now for more than 2 weeks on this F*** problem.. I don't know why the compiler gives me back an error every time.. So now to my Code.
import pandas as pd import backtrader as bt from Strategien.GoldenCross import GoldenCross import datetime cerebro = bt.Cerebro() cerebro.broker.setcash(100000) pathIndex = "/Users/me/Desktop/allgemein/Visual Studio/Stock Data/Index EOD Data/^GSPC.csv" # read csv, parse date, use dates col as index stock_prices = pd.read_csv(pathIndex, index_col=, parse_dates=) print(stock_prices) # create data feed pandas df feed = bt.feeds.PandasData(dataname=stock_prices) # add feed cerebro.adddata(feed) cerebro.addstrategy(GoldenCross) cerebro.run() cerebro.plot(style='bar')
Now my compiler gives me back this error message: "Unexpected keyword argument 'dataname' in constructor call" I now tried pretty much everything, but it doesn't work!! Why does the compiler underlines the "bt." in this line:
feed = bt.feeds.PandasData(dataname=stock_prices)
and say, that the argument "dataname" is wrong?? In every script I saw, everybody write it exactly like this... Please help me!
Switch to terminal window in your VS Code, type
python your_script_name.py, and work with the errors returned by
python. Skip what
Hey @ab_trader, if I type python run.py in the MacBook terminal, the terminal gives me back "can't open file 'run.py': [Errno 2] No such file or directory
". Baby that's, because on the MacBook on standard there is python 2.7, but I use python 3.8...
I never used the terminal window for running a code before..
Terminal window should be open in the folder with the python script. Anyway, google how to run python script in VS Code.
@ab_trader Sorry I do not get what you want to say to me.. Do you know that's the problem in my case? My visual studio works fine and I already wrote a lot of other python scripts with it.. Why should I now run this sciript with the terminal? And why should running with the terminal solve my problem?
@ab_trader I can run the script in visual studio as well.. And than there comes the already named problem.. And the OUTPUT says: "AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Strateg' object has no attribute 'bt'"
@chhrissi2909 what @ab_trader tried to explain to you is that you would see your errors better when using a terminal or setup debugging in vscode or the dev environment you use. also he showed you your error when executing your script, since you run python in a wrong directory.
There is an issue in your strategy, which causes your problems. You would just have better informations about what is going on in your code.
Anyway, look for
self.bt. ...code in your strategy and remove the self.