nardew / talipp

talipp - incremental technical analysis library for python
https://nardew.github.io/talipp
MIT License
368 stars 59 forks source link

BB indicator has different output from TaLib for last 2 elements #70

Closed hl200 closed 1 year ago

hl200 commented 1 year ago

I compared talib.BBANDS vs talipp.indicators.BB output. observe the following differences:

  1. (Cosmetic) taLib has None for first few bars, while talipp omitted them. It would be nice if there is a member variable to indicate how many bars will be missing, for BB, I know it is period-1. but ideally it would be great to expose that as output 2 (Severe), talipp's last two value are diferrent from talib, it actually has one extra value than talib and orginal data source. so here is data I saw
    
    <<input>>
    original price   [.. 284.77, 284.29, 283.99, 284.01, 283.97, 283.5  ]
    <<output>>
    talib.bb.middle  [.. 284.79, 284.7 , 284.5 , 284.36, 284.21, 283.95 ]
    talipp.bb.central[.. 284.79, 284.7 , 284.5 , 284.36, 284.21, 284.98, 285.84]

3. Here is the code I am using

price = QQQ minute close for 9/20-9/21. (around 700 elements) the above output correspond to 9/21 before market close

upper, middle, low = talib.BBANDS(price,  timeperiod = 5, nbdevup = 1  , nbdevdn = 1 , matype=MA_Type.SMA)

talippCB = BB(period=5 ,std_dev_multiplier=1, input_values=price).central_band

        for bn in range(floor(len(price)/20)+1):
            print (str(bn) + "th:" + " src  vs Talib.middle vs TalippCentralBand")
            b20 = bn*20
            print (price[b20:b20+20])
            print (middle[b20:b20+20])
            print (talippCB[b20:b20+20])
nardew commented 1 year ago

Hi @hl200 , if you run both indicators with just 5 last from your input, are the results identical?

hl200 commented 1 year ago

@nardew , thanks for following up, sorry, my code changed so much since my post. could not get the code to a working state around this quickly now. you can close the issue now, if I ever get to this again, I will post a more self-contained test code at that time.