Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
femtotrader committed Jul 7, 2024
1 parent 46faae2 commit 10c2884
Showing 1 changed file with 2 additions and 50 deletions.
52 changes: 2 additions & 50 deletions talipp/indicators/SOBV.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,6 @@
from typing import Any

from talipp.indicator_util import has_valid_values
from talipp.indicators.Indicator import Indicator, InputModifierType
from talipp.indicators.OBV import OBV
from talipp.ma import MAFactory, MAType


class SmoothedIndicator(Indicator):
def __init__(self, indicator_class, ma_type: MAType):
super().__init__()

self.indicator_class = indicator_class
self.ma_type = ma_type

def __call__(
self,
smoothing_period: int,
input_values=None,
input_indicator=None,
*args: Any,
**kwargs
) -> Any:
self.ma = MAFactory.get_ma(self.ma_type, smoothing_period)

self.internal_indicator = self.indicator_class(*args, **kwargs)
self.add_sub_indicator(self.internal_indicator)

self.initialize(input_values, input_indicator)

return self

def _calculate_new_value(self) -> Any:
self.ma.add(self.internal_indicator.output_values)
return self.ma.output_values[-1]


class SmootherFactory:
"""Smoother factory."""

@staticmethod
def get_smoother(indicator_class, ma_type: MAType = MAType.SMA):
"""
Return a smoother indicator
Args:
indicator_class: indicator class
smoothing_period: Smoothing period.
ma_type: Moving average type.
"""
return SmoothedIndicator(indicator_class, ma_type)
from talipp.indicators.Smoother import SmootherFactory
from talipp.ma import MAType


"""Smoothed On Balance Volume.
Expand Down

0 comments on commit 10c2884

Please sign in to comment.