twopirllc / pandas-ta

Technical Analysis Indicators - Pandas TA is an easy to use Python 3 Pandas Extension with 150+ Indicators
https://twopirllc.github.io/pandas-ta/
MIT License
5.31k stars 1.04k forks source link

PPO returns same values as MACD not percentages #508

Closed CitizenBruceLee closed 2 years ago

CitizenBruceLee commented 2 years ago

Percentage Price Oscillator: ppo indicator should generate % (or range between -1 to +1) values. Now it generates the same values as MACD

Screenshot 2022-03-29 at 13 29 11
twopirllc commented 2 years ago

Hello @CitizenBruceLee,

Thanks for the sample code, please complete the following:

Which version are you running? The lastest version is on Github. Pip is for major releases.

import pandas_ta as ta
print(ta.version)

Do you have TA Lib also installed in your environment?

$ pip list

Did you upgrade? Did the upgrade resolve the issue?

$ pip install -U git+https://github.com/twopirllc/pandas-ta

Please provide an example of PPO and MACD values side by side.

Thanks KJ

CitizenBruceLee commented 2 years ago

Thanks for your quick answer KJ. Here is the list of the requested info. I run the update and get the same version as I had.

import pandas_ta as ta print(ta.version)

0.3.14b0

pip list

Package Version


absl-py 0.14.1 aiodns 2.0.0 aiohttp 3.7.4.post0 aiohttp-cors 0.7.0 aioredis 1.3.1 aiosignal 1.2.0 amqp 5.0.5 anaconda-client 1.9.0 anaconda-navigator 2.1.2 anyio 3.5.0 appnope 0.1.2 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 arrow 1.1.1 astroid 2.9.0 astunparse 1.6.3 async-timeout 3.0.1 attrs 21.4.0 autopep8 1.6.0 Babel 2.9.1 backcall 0.2.0 backports.functools-lru-cache 1.6.4 backports.tempfile 1.0 backports.weakref 1.0.post1 backtrader 1.9.76.123 beautifulsoup4 4.10.0 beepy 1.0.7 billiard 3.6.3.0 black 22.1.0 bleach 4.1.0 blessed 1.19.1 blinker 1.4 boto3 1.21.18 botocore 1.24.18 Bottleneck 1.3.2 brotlipy 0.7.0 bt 0.2.9 cachetools 4.2.1 ccxt 1.51.94 celery 5.0.5 certifi 2021.10.8 cffi 1.15.0 chardet 4.0.0 charset-normalizer 2.0.4 clang 5.0 click 8.0.4 click-didyoumean 0.0.3 click-plugins 1.1.1 click-repl 0.1.6 cloudpickle 2.0.0 clyent 1.2.2 colorful 0.5.4 conda 4.11.0 conda-build 3.21.8 conda-content-trust 0+unknown conda-package-handling 1.7.3 conda-repo-cli 1.0.4 conda-token 0.3.0 conda-verify 3.4.2 contextlib2 0.6.0.post1 crontab 0.22.9 crypto-empyrical 1.0.4 cryptography 3.4.8 cssselect 1.1.0 cssutils 2.2.0 cycler 0.11.0 dask 2022.2.1 dateparser 1.0.0 debugpy 1.5.1 decorator 5.1.1 defusedxml 0.7.1 Deprecated 1.2.13 dill 0.3.4 distributed 2022.2.1 docutils 0.18.1 empyrical 0.5.5 entrypoints 0.3 ffn 0.3.6 filelock 3.6.0 flake8 4.0.1 Flask 1.1.2 flatbuffers 1.12 fonttools 4.25.0 frozenlist 1.3.0 fsspec 2022.2.0 future 0.18.2 gast 0.4.0 glob2 0.7 google-api-core 2.7.1 google-auth 1.35.0 google-auth-oauthlib 0.4.6 google-pasta 0.2.0 googleapis-common-protos 1.55.0 gpustat 1.0.0b1 grpcio 1.41.0 h5py 3.1.0 HeapDict 1.0.1 hiredis 2.0.0 idna 3.3 imageio 2.16.1 importlib-metadata 4.8.2 int-date 0.1.8 ipykernel 6.9.1 ipython 7.31.1 ipython-genutils 0.2.0 ipywidgets 7.6.5 isort 5.9.3 itsdangerous 2.0.1 jedi 0.18.1 Jinja2 2.11.3 jmespath 0.10.0 joblib 1.1.0 json5 0.9.6 jsonschema 3.2.0 jupyter 1.0.0 jupyter-client 7.1.2 jupyter-console 6.4.3 jupyter-core 4.9.2 jupyter-server 1.13.5 jupyterlab 3.2.9 jupyterlab-pygments 0.1.2 jupyterlab-server 2.10.3 jupyterlab-widgets 1.0.2 jupyterthemes 0.20.0 kaleido 0.2.1 keras 2.6.0 Keras-Preprocessing 1.1.2 kiwisolver 1.3.2 kneed 0.7.0 kombu 5.0.2 lazy-object-proxy 1.6.0 lesscpy 0.15.0 libarchive-c 2.9 llvmlite 0.38.0 locket 0.2.1 lxml 4.6.4 Markdown 3.3.4 MarkupSafe 2.0.1 matplotlib 3.5.1 matplotlib-inline 0.1.2 mccabe 0.6.1 mistune 0.8.4 mkl-fft 1.3.1 mkl-random 1.2.2 mkl-service 2.4.0 modin 0.13.2 modin-spreadsheet 0.1.2 mplfinance 0.12.7a12 msgpack 1.0.3 multidict 5.1.0 multitasking 0.0.9 munkres 1.1.4 mypy-extensions 0.4.3 nanoleafapi 2.1.1 navigator-updater 0.2.1 nb-black 1.0.7 nbclassic 0.3.5 nbclient 0.5.11 nbconvert 6.3.0 nbformat 5.1.3 nest-asyncio 1.5.1 newtulipy 0.4.6 notebook 6.4.8 numba 0.55.1 numexpr 2.8.1 numpy 1.21.2 nvidia-ml-py3 7.352.0 oauthlib 3.1.1 opencensus 0.8.0 opencensus-context 0.1.2 opt-einsum 3.3.0 packaging 21.3 pandas 1.4.1 pandas-datareader 0.9.0 pandas-ta 0.3.14b0 pandocfilters 1.5.0 parso 0.8.3 partd 1.2.0 pathspec 0.9.0 patsy 0.5.2 peewee 3.14.4 pexpect 4.8.0 phue 1.1 pickleshare 0.7.5 Pillow 9.0.1 pip 21.2.4 pkginfo 1.8.2 platformdirs 2.4.1 playsound 1.3.0 plotly 5.6.0 plumbum 1.7.2 ply 3.11 premailer 3.7.0 prometheus-client 0.13.1 prompt-toolkit 3.0.20 protobuf 3.18.0 psutil 5.8.0 psycopg2-binary 2.9.1 ptyprocess 0.7.0 py-spy 0.3.11 pyarrow 7.0.0 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycares 4.0.0 pycodestyle 2.7.0 pycosat 0.6.3 pycparser 2.21 pyflakes 2.3.1 Pygments 2.11.2 PyJWT 2.1.0 pylint 2.12.2 pyOpenSSL 21.0.0 pyparsing 3.0.4 PyPrind 2.11.3 pyrsistent 0.18.0 PySocks 1.7.1 python-binance 1.0.12 python-bitvavo-api 1.2.2 python-dateutil 2.8.2 pytimeparse 1.1.8 pytz 2021.3 PyYAML 6.0 pyzmq 22.3.0 qtconsole 5.2.2 QtPy 1.11.2 ray 1.11.0 redis 4.1.4 requests 2.27.1 requests-oauthlib 1.3.0 rpyc 4.1.5 rsa 4.7.2 ruamel-yaml-conda 0.15.100 runipy 0.1.5 s3transfer 0.5.2 schedule 1.1.0 scikit-learn 1.0.2 scipy 1.7.3 Send2Trash 1.8.0 setuptools 58.0.4 simpleaudio 1.0.4 six 1.16.0 skippy 0.1.0 sklearn 0.0 smart-open 5.2.1 sniffio 1.2.0 sortedcontainers 2.4.0 soupsieve 2.3.1 spyder-kernels 2.2.1 sseclient 0.0.27 statsmodels 0.13.0 stockstats 0.3.2 ta 0.7.0 tabulate 0.8.9 tblib 1.7.0 tenacity 8.0.1 tensorboard 2.6.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.0 tensorflow 2.6.0 tensorflow-estimator 2.6.0 termcolor 1.1.0 terminado 0.13.1 testpath 0.5.0 TFANN 1.0.1 threadpoolctl 3.0.0 tiingo 0.14.0 timeloop 1.0.2 toml 0.10.2 tomli 2.0.0 toolz 0.11.2 tornado 6.1 tqdm 4.62.3 traitlets 5.1.1 twelvedata 1.2.1 typing_extensions 4.0.1 tzlocal 2.1 ujson 4.2.0 urllib3 1.26.8 vectorbt 0.18.2 vine 5.0.0 wcwidth 0.2.5 webencodings 0.5.1 websocket-client 0.58.0 websockets 9.1 Werkzeug 2.0.3 wheel 0.37.1 widgetsnbextension 3.5.2 wrapt 1.13.3 wurlitzer 3.0.2 xeus-python-shell 0.1.7 xgboost 1.3.3 xmltodict 0.12.0 yarl 1.6.3 yfinance 0.1.54 zict 2.1.0 zipp 3.7.0

pip install -U git+https://github.com/twopirllc/pandas-ta

Collecting git+https://github.com/twopirllc/pandas-ta Cloning https://github.com/twopirllc/pandas-ta to /private/var/folders/4k/pn1_7k850dq0hx3hj1m6zh6c0000gn/T/pip-req-build-bzbyw9lm Running command git clone -q https://github.com/twopirllc/pandas-ta /private/var/folders/4k/pn1_7k850dq0hx3hj1m6zh6c0000gn/T/pip-req-build-bzbyw9lm Resolved https://github.com/twopirllc/pandas-ta to commit 720bbcf0196d363d621beeced8fba711990d075d Requirement already satisfied: pandas in /Users/Dali/opt/anaconda3/lib/python3.8/site-packages (from pandas-ta==0.3.14b0) (1.4.1) Requirement already satisfied: python-dateutil>=2.8.1 in /Users/Dali/opt/anaconda3/lib/python3.8/site-packages (from pandas->pandas-ta==0.3.14b0) (2.8.2) Requirement already satisfied: pytz>=2020.1 in /Users/Dali/opt/anaconda3/lib/python3.8/site-packages (from pandas->pandas-ta==0.3.14b0) (2021.3) Requirement already satisfied: numpy>=1.18.5 in /Users/Dali/opt/anaconda3/lib/python3.8/site-packages (from pandas->pandas-ta==0.3.14b0) (1.21.2) Requirement already satisfied: six>=1.5 in /Users/Dali/opt/anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.8.1->pandas->pandas-ta==0.3.14b0) (1.16.0) Note: you may need to restart the kernel to use updated packages.

import pandas_ta as ta print(ta.version)

0.3.14b0

twopirllc commented 2 years ago

@CitizenBruceLee,

Thanks. Well ppo is not the same as macd except their first operation: ema(fast) - ema(slow). The code is similar but not the same either after the first operation. The only thing that was incorrect was the Source: in the documentation 🤦🏼‍♂️ .

MACD

Screen Shot 2022-03-29 at 8 35 44 AM

PPO

Screen Shot 2022-03-29 at 8 35 57 AM


Value Comparisons

Screen Shot 2022-03-29 at 8 29 17 AM

In any case, please update to the development version.

$ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development


KJ

CitizenBruceLee commented 2 years ago

Thank you KJ! The code is correct as it indeed devides the ppo by the slowma for the final relative results. You have been great help!

Cheers!

twopirllc commented 2 years ago

@CitizenBruceLee,

Sure. 🍀

KJ