FinQuant icon indicating copy to clipboard operation
FinQuant copied to clipboard

Momentum Indicators - RSI, MACD

Open pythonhacker opened this issue 2 years ago • 8 comments

First of all thanks for the great work. This package is amazing!

I think apart from moving averages and related bollinger bands, indicators like RSI would add relative strength to the package (pun intended). Let me know what you think.

This issue is about adding a feature for plotting RSI indicators using a 14 day window as suggested using the approach here -> https://www.alpharithms.com/relative-strength-index-rsi-in-python-470209/

Update: Edited the issue and generalized it over a number of momentum indicators. I can go ahead and implement them all or we can discuss it if you have suggestions.

pythonhacker avatar Jul 31 '23 07:07 pythonhacker

I have completed an implementation of this in my fork of the project - https://github.com/pythonhacker/FinQuant/tree/feature/rsi-indicator. Screenshot_2023-07-31_17-50-07

pythonhacker avatar Jul 31 '23 12:07 pythonhacker

Hey @pythonhacker :) Awesome, appreciate both, the suggestion as well as your work on the implementation. I'll look over the PR in the next few days. :)

fmilthaler avatar Jul 31 '23 19:07 fmilthaler

I am right now using this project on a jupyter notebook to make decisions over stocks to invest in the highly bullish stock market of my country (India), so I am bullish on this project as well.

pythonhacker avatar Aug 01 '23 08:08 pythonhacker

Here is an implementation of MACD in the same PR. See attached figure. Screenshot_2023-08-02_00-00-57

pythonhacker avatar Aug 01 '23 18:08 pythonhacker

Man, really love this. :) And happy to hear that you are using FinQuant to invest and making the project even better.

And feel free to add more such indicators if you please.

Just a friendly reminder:

While FinQuant has tests in place that are run automatically by GitHub Actions, it cannot guarantee to be bug free, nor that the analysis or optimised portfolio yield to wealth. Please use at your own discretion and refer to the License.

Source: FinQuant's documentation ;)

fmilthaler avatar Aug 01 '23 19:08 fmilthaler

@fmilthaler - Added documentation and unit test. Let me know if this looks good.

pythonhacker avatar Aug 06 '23 13:08 pythonhacker

Hey, thank you for adding those. I've already merged your branch into FinQuant's branch feature/rsi-indicator so that I could play around with it myself. Could you open a new PR and set it up to be merged into said branch? Thanks for adding those. On a related note though, I stumbled upon this project: https://github.com/matplotlib/mplfinance It adds support for all kinds of financial indicators. All you need to feed it is data in form of a dataframe. I haven't tried yet, but I believe this would work nicely in combination with FinQuant, as in you have your data in a Portfolio instance from FinQuant, and then feed that (example: pf.data) into the functions provided by mplfinance.

fmilthaler avatar Aug 06 '23 16:08 fmilthaler

Hey, thank you for adding those. I've already merged your branch into FinQuant's branch feature/rsi-indicator so that I could play around with it myself. Could you open a new PR and set it up to be merged into said branch? Thanks for adding those. On a related note though, I stumbled upon this project: https://github.com/matplotlib/mplfinance It adds support for all kinds of financial indicators. All you need to feed it is data in form of a dataframe. I haven't tried yet, but I believe this would work nicely in combination with FinQuant, as in you have your data in a Portfolio instance from FinQuant, and then feed that (example: pf.data) into the functions provided by mplfinance.

Looks good, may I suggest we look into this as an enhancement over the current code ? Let us merge this first and in another set of feature issues, refactor the code to use mplfinance . Meanwhile I will create the 2nd PR.

pythonhacker avatar Aug 07 '23 04:08 pythonhacker