Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bukosabino committed Dec 8, 2019
1 parent c1b29d9 commit 88c17ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions ta/momentum.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def tsi(self) -> pd.Series:
return pd.Series(tsi, name='tsi')


class UltimateOscillatorIndicator(IndicatorMixin):
class UltimateOscillator(IndicatorMixin):
"""Ultimate Oscillator
Larry Williams' (1976) signal, a momentum oscillator designed to capture
Expand Down Expand Up @@ -225,15 +225,15 @@ def uo(self) -> pd.Series:
return pd.Series(uo, name='uo')


class StochIndicator(IndicatorMixin):
class StochasticOscillator(IndicatorMixin):
"""Stochastic Oscillator
Developed in the late 1950s by George Lane. The stochastic
oscillator presents the location of the closing price of a
stock in relation to the high and low range of the price
of a stock over a period of time, typically a 14-day period.
https://www.investopedia.com/terms/s/stochasticoscillator.asp
https://school.stockcharts.com/doku.php?id=technical_indicators:stochastic_oscillator_fast_slow_and_full
Args:
close(pandas.Series): dataset 'Close' column.
Expand Down Expand Up @@ -605,7 +605,7 @@ def uo(high, low, close, s=7, m=14, len=28, ws=4.0, wm=2.0, wl=1.0, fillna=False
pandas.Series: New feature generated.
"""
return UltimateOscillatorIndicator(
return UltimateOscillator(
high=high, low=low, close=close, s=7, m=14, len=28, ws=4.0, wm=2.0, wl=1.0, fillna=fillna).uo()


Expand All @@ -630,7 +630,7 @@ def stoch(high, low, close, n=14, fillna=False):
pandas.Series: New feature generated.
"""

return StochIndicator(high=high, low=low, close=close, n=n, d_n=3, fillna=fillna).stoch()
return StochasticOscillator(high=high, low=low, close=close, n=n, d_n=3, fillna=fillna).stoch()


def stoch_signal(high, low, close, n=14, d_n=3, fillna=False):
Expand All @@ -651,7 +651,7 @@ def stoch_signal(high, low, close, n=14, d_n=3, fillna=False):
Returns:
pandas.Series: New feature generated.
"""
return StochIndicator(high=high, low=low, close=close, n=n, d_n=d_n, fillna=fillna).stoch_signal()
return StochasticOscillator(high=high, low=low, close=close, n=n, d_n=d_n, fillna=fillna).stoch_signal()


def wr(high, low, close, lbp=14, fillna=False):
Expand Down
8 changes: 4 additions & 4 deletions ta/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from ta.momentum import (AwesomeOscillatorIndicator, KAMAIndicator,
MFIIndicator, ROCIndicator, RSIIndicator,
StochIndicator, TSIIndicator,
UltimateOscillatorIndicator, WilliamsRIndicator)
StochasticOscillator, TSIIndicator,
UltimateOscillator, WilliamsRIndicator)
from ta.others import (CumulativeReturnIndicator, DailyLogReturnIndicator,
DailyReturnIndicator)
from ta.trend import (MACD, ADXIndicator, AroonIndicator, CCIIndicator,
Expand Down Expand Up @@ -238,12 +238,12 @@ def add_momentum_ta(df: pd.DataFrame, high: str, low: str, close: str, volume: s
df[f'{colprefix}momentum_tsi'] = TSIIndicator(close=df[close], r=25, s=13, fillna=fillna).tsi()

# Ultimate Oscillator
df[f'{colprefix}momentum_uo'] = UltimateOscillatorIndicator(
df[f'{colprefix}momentum_uo'] = UltimateOscillator(
high=df[high], low=df[low], close=df[close], s=7, m=14, len=28, ws=4.0, wm=2.0, wl=1.0,
fillna=fillna).uo()

# Stoch Indicator
indicator = StochIndicator(high=df[high], low=df[low], close=df[close], n=14, d_n=3, fillna=fillna)
indicator = StochasticOscillator(high=df[high], low=df[low], close=df[close], n=14, d_n=3, fillna=fillna)
df[f'{colprefix}momentum_stoch'] = indicator.stoch()
df[f'{colprefix}momentum_stoch_signal'] = indicator.stoch_signal()

Expand Down

0 comments on commit 88c17ea

Please sign in to comment.