Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOBV uses SMA but any smoother from MAFactory could probably be used #146

Open
femtotrader opened this issue Jul 6, 2024 · 4 comments · May be fixed by #147
Open

SOBV uses SMA but any smoother from MAFactory could probably be used #146

femtotrader opened this issue Jul 6, 2024 · 4 comments · May be fixed by #147

Comments

@femtotrader
Copy link
Contributor

return sum(self.obv[-self.period:]) / float(self.period)

@femtotrader
Copy link
Contributor Author

femtotrader commented Jul 7, 2024

Maybe we could even have something more general (let's call this a smoother) which could take the following parameters:

  • period of moving average
  • kind of moving average
  • indicator class to smooth

whom role is to "smooth" values of an indicator

SOBV will be defined like so (for example)

SOBV = Smoother(OBV, 20, ma_type=MAType.SMA)

and could be used like so

ind = SOBV()  # or SOBV(*obv_args, **obv_kwargs)

Smoothing indicators which have several values will need to pass a value extractor

@femtotrader femtotrader linked a pull request Jul 7, 2024 that will close this issue
@femtotrader
Copy link
Contributor Author

femtotrader commented Jul 7, 2024

#147

implements such an idea... but with a slightly different API idea

We have now in this PR

SOBV = IndicatorFactory.get_smoother(OBV, MAType.SMA)
indicator = SOBV(20)

Smoother and MAFactory seems to be very close concepts but Smoother contains an internal indicator whom output values are smoothed while MAFactory just return a moving average indicator set for a given period.

@nardew
Copy link
Owner

nardew commented Jul 12, 2024

Hi @femtotrader , first, sorry for not following up on all the discussions you opened. It's very appreciated but currently I cannot allocate time for this project. I will return to them as soon as possible.

Regarding a generic smoother, we can instantiate any MA object directly and pass another indicator into it via indicator chaining like bellow:

sma1 = SMA(3)
sma2 = SMA(3, input_indicator = sma1)

This way you can smooth anything via any MA without need for any new object. Does it fit what you are proposing?

@femtotrader
Copy link
Contributor Author

femtotrader commented Jul 12, 2024

Hi @nardew ,

We all have life outside GH! no problem.

My idea was to create SOBV class from OBV class and a moving average class... without setting period neither instantiating the classes.
So we can create appropriate classes and only instantiate them as needed.

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants