0

I was trying to call an external python library 'talib' and one of its functions is giving me an error, 'Bad Parameter' - I thought I was passing in all arguments correctly, but perhaps not?

I think the problem might be in the function definition, but I'm not sure because I'm unfamiliar with this python syntax. The function definition shows brackets in the input.

I'm not sure if this is an error with the imported package and its function ADOSC, else I don't know how to use the function given this syntax:

The function definition is as follows (note ADOSC function inputs):

Help on function ADOSC in module talib._ta_lib:

ADOSC(...)
    ADOSC(high, low, close, volume[, fastperiod=?, slowperiod=?])

    Chaikin A/D Oscillator (Volume Indicators)

    Inputs:
        prices: ['high', 'low', 'close', 'volume']
    Parameters:
        fastperiod: 3
        slowperiod: 10
    Outputs:
        real

I'm using the function like this, which should simply return the dataframe columns I'm after (similar loop is working with other functions):

for d in [1, 2, 3, 4, 5]:
        df['ADOSC'+str(d)] = talib.ADOSC(df.High, df.Low, df.Close, df.Vol, fastperiod=d, slowperiod=10)

But this is the end of the error message that I get back (seems like a broken function definition as mentioned above, no?)

_func.pxi in talib._ta_lib.ADOSC()

_common.pxi in talib._ta_lib._ta_check_success()

Exception: TA_ADOSC function failed with error code 2: Bad Parameter (TA_BAD_PARAM)
cadig
  • 101
  • 2
  • 8
  • 1
    What are `df.High`, `df.Low`, etc? Are those single values, or entire columns? Also, brackets indicate that the `fastperiod` and `slowperiod` parameters are optional. – John Gordon Sep 01 '19 at 18:15
  • df.High and df.Low are entire columns, but they seem to work just fine with other talib functions. Good to know about the brackets, but I am wondering if the implementation of the function is wrong, with the first bracket including the comma ? – cadig Sep 01 '19 at 18:18
  • 1
    That's just help text; it doesn't affect the actual execution of the function. Have you tried calling the function with different arguments to see if you can isolate which argument is causing the problem? i.e. try omitting `fastperiod` and `slowperiod`, and also try passing single values for high, low, etc., instead of df columns. – John Gordon Sep 01 '19 at 18:46
  • It was indeed a bad parameter as the message suggested.. the ones I was using could not be lower than 3 in my for loop. Thanks for taking a look John. Silly me. – cadig Sep 01 '19 at 20:47

0 Answers0