pandas-ta icon indicating copy to clipboard operation
pandas-ta copied to clipboard

Possible Bug in Detrended Price Oscillator

Open CMobley7 opened this issue 3 years ago • 2 comments

According to https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/dpo and https://www.investopedia.com/terms/d/detrended-price-oscillator-dpo.asp, the Detrended Price Oscillator: dpo should be close.shift(t) - ma; however, it appears to be reversed in https://github.com/twopirllc/pandas-ta/blob/development/pandas_ta/trend/dpo.py#L52. If I'm right, and you're up for it, I can submit a PR for this and the documentation fix at the same time. Thanks again for such a great library!

CMobley7 avatar May 07 '22 21:05 CMobley7

@CMobley7,

Hmmm... Yeah you may be right. I thought I corrected this in #60. 🤦🏼‍♂️ I will take a look at it again. Thanks for the extra eyes.

KJ

twopirllc avatar May 08 '22 02:05 twopirllc

@twopirllc ,

I read through https://github.com/twopirllc/pandas-ta/issues/60. The new centered version, https://github.com/twopirllc/pandas-ta/blob/development/pandas_ta/trend/dpo.py#L54, appears to be correct, but the non-centered version, https://github.com/twopirllc/pandas-ta/blob/development/pandas_ta/trend/dpo.py#L52, shifts the ma instead of the close. The previous non-centered version, https://github.com/twopirllc/pandas-ta/blob/279423a50675191729f665a801f7ee18323a4efa/pandas_ta/trend/dpo.py#L14, appears to shift correctly, but calculates the ma using pandas's rolling and mean operations instead of the pandas-ta ma function, which I believe better suited for this case.

CMobley7 avatar May 08 '22 03:05 CMobley7