Search code examples
pythonpython-3.xpandasta-lib

Williams R Ta-lib getting TypeError with look back period


I have a question about ta-lib from here: My code:

import pandas as pd
# import matplotlib
from pandas_datareader import data as web
import ta


df = web.DataReader('F', 'yahoo')

williams1 = ta.momentum.WilliamsRIndicator(
        high = df['High'], 
        low = df['Low'], 
        close = df['Close'], 
        fillna = False
        )

williams1.wr()

On the website it mentions look back period: enter image description here

How can one add this parameter? I tried to add int =14 but get error:

TypeError: __init__() got an unexpected keyword argument 'int'

If i don't include this the code works but i assume i need to add a number for period.


Solution

  • You're misreading the signature, it's lbp=14:

    williams1 = ta.momentum.WilliamsRIndicator(
        high=df["High"],
        low=df["Low"],
        close=df["Close"],
        lbp=14,
        fillna=False,
    )