0
votes

I'm following this documentation: https://buildmedia.readthedocs.org/media/pdf/technical-analysis-library-in-python/latest/technical-analysis-library-in-python.pdf

Specifically page 9 of the PDF. Copying this code I get a type error. I'm not sure if that means I should edit my data file (which is just standard stock data) or edit the fillna portion of the code.

from ta import *

df = pd.read_csv('VRAY.csv', sep=',')
df = utils.dropna(df)

df = add_all_ta_features(df,"Date","Open","High","Low","Close","Adj_Close","Volume", fillna=True)

This is the error:

Traceback (most recent call last): File "/home/toni/PycharmProjects/PyPractice/stockTA/techanal.py", line 7, in df = add_all_ta_features(df,"Date","Open","High","Low","Close","Adj_Close","Volume", fillna=True) TypeError: add_all_ta_features() got multiple values for keyword argument 'fillna'

3

3 Answers

0
votes

The documentation for the ta module gives this example for calling add_all_ta_features():

add_all_ta_features(df, "Open", "High", "Low", "Close", "Volume_BTC", fillna=True)

That call has five columns:

Open
High
Low
Close
Volume_BTC

But your call has seven columns:

Date
Open
High
Low
Close
Adj_Close
Volume

You're trying to use too many columns.

0
votes

From the project repository, the signature of the add_all_ta_features() method is

def add_all_ta_features(df, open, high, low, close, volume, fillna=False, colprefix=""):

By providing so many arguments in your call, you are assigning a value to fillna positionally as "Adj_Close". You cannot subsequently provide another value as a keyword argument.

0
votes

You added one more parameter to it... As you wrote extra parameters (9 parameters), one parameter took place of "fillna"'s parameter. So when you used fillna as keyword argument ("fillna=") it was written twice to the same parameter.

It should be written this way (7 parameters):

add_all_ta_features(df, "Open", "High", "Low", "Close", "Volume_BTC", fillna=True)

You can find more examples on ta's GitHub: https://github.com/bukosabino/ta