fmilthaler / FinQuant

A program for financial portfolio management, analysis and optimisation.
MIT License
1.34k stars 190 forks source link

Momentum Indicators - RSI, MACD ... (#120) #131

Open fmilthaler opened 11 months ago

fmilthaler commented 11 months ago

Implementation of RSI momentum indicator, thank you @pythonhacker. This closes #119.

pythonhacker commented 10 months ago

Hi @fmilthaler - Any updates on if/when you may merge this ? Thank you.

fmilthaler commented 10 months ago

Hey, sorry for the delay, I was away and then busy otherwise. Anyway, I found several (different) implementations of the RSI, and they all differ from another. I still want to go through them and understand them better and see what can be used here. Funny thing is, they give different results. As for the macd, it might be good to use the example of https://github.com/matplotlib/mplfinance/blob/master/examples/indicators/macd_histogram_gradient.ipynb now rather in a later merge.

pythonhacker commented 10 months ago

Do you want me to modify the code ?

fmilthaler commented 10 months ago

Sorry for the delay @pythonhacker. I had to have a closer look at the RSI itself to understand it first.

~As for the implementation of the rsi relative_strength_index, can you please remove the for loops and use vectorized computations instead for the sake of performance and readability?~ Note: I just realized the dependecy within the for loop, thus a vectorized computation is not possible here. Too bad :(

For the macd, could you make use of the package mplfinance here instead? I don't like reinventing the wheel here. We can simply use one of the following:

to plot the macd.

Again, sorry for the delay in this, I've been busy and pushed this back too many times.

fmilthaler commented 9 months ago

@pythonhacker I've updated the code to be compliant with the recent master and made changes to the macd function to be like the example in mplfinance. Have a look at everything and let me know if you are happy with that. If so, we can then get it checked by Pietropaolo and then merged.

Note: Mypy is not happy yet, thus more changes are required. If you want to have a look at that, please run scripts/run_code_analysis.sh and go through the mypy issues and try to fix them.

This is what the MACD plot looks like now: image

pythonhacker commented 7 months ago

@fmilthaler - I have been out of touch for a while, due to work and just looked back at this. Didn't see the review request my bad. Kindly let me know if I can still review this.