Skip to content

Commit

Permalink
ENH PERF #774 #771 #526 exhc TST stdev variance DOC speedtest
Browse files Browse the repository at this point in the history
  • Loading branch information
twopirllc committed Mar 27, 2024
1 parent 872a18a commit debfd82
Show file tree
Hide file tree
Showing 190 changed files with 1,962 additions and 2,160 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ env/**
.vscode/**

# zed settings
.zed
.zed/**

# Original Source (Dev)
Expand Down
8 changes: 4 additions & 4 deletions README.md

Large diffs are not rendered by default.

2,650 changes: 1,398 additions & 1,252 deletions examples/Speed_Test.ipynb

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions examples/ni.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def ni(
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: New feature generated.
Expand Down Expand Up @@ -65,8 +64,6 @@ def ni(
# Handle fills
if "fillna" in kwargs:
ni.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
ni.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Categorize it
ni.name = f"ni_{length}"
Expand All @@ -80,4 +77,4 @@ def ni(
def ni_method(self, length=None, offset=None, **kwargs):
close = self._get_column(kwargs.pop("close", "close"))
result = ni(close=close, length=length, offset=offset, **kwargs)
return self._post_process(result, **kwargs)
return self._post_process(result, **kwargs)
3 changes: 2 additions & 1 deletion pandas_ta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from pandas_ta.volatility import __all__ as volatility_all
from pandas_ta.volume import __all__ as volume_all

# Common Averages useful for Indicators with a mamode argument, like ta.adx()
# Common Averages useful for Indicators
# with a mamode argument, like ta.adx()
from pandas_ta.ma import ma

# Custom External Directory Commands. See help(import_dir)
Expand Down
1 change: 1 addition & 0 deletions pandas_ta/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from sys import float_info as sflt



# Generic types
T = TypeVar("T")

Expand Down
4 changes: 1 addition & 3 deletions pandas_ta/candles/cdl_doji.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pandas_ta.utils import v_scalar, v_series



def cdl_doji(
open_: Series, high: Series, low: Series, close: Series,
length: Int = None, factor: IntFloat = None, scalar: IntFloat = None,
Expand Down Expand Up @@ -37,7 +38,6 @@ def cdl_doji(
the length if less than a percentage of it's high-low range.
Default: False
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: CDL_DOJI column.
Expand Down Expand Up @@ -75,8 +75,6 @@ def cdl_doji(
# Fill
if "fillna" in kwargs:
doji.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
doji.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Category
doji.name = f"CDL_DOJI_{length}_{0.01 * factor}"
Expand Down
5 changes: 1 addition & 4 deletions pandas_ta/candles/cdl_inside.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pandas_ta.utils import v_bool, v_offset, v_offset, v_scalar, v_series



@njit
def np_cdl_inside(high, low):
hdiff = where(high - roll(high, 1) < 0, 1, 0)
Expand Down Expand Up @@ -43,7 +44,6 @@ def cdl_inside(
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: New feature
Expand Down Expand Up @@ -76,9 +76,6 @@ def cdl_inside(
# Fill
if "fillna" in kwargs:
inside.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
inside.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Category
inside.name = f"CDL_INSIDE"
inside.category = "candles"
Expand Down
7 changes: 1 addition & 6 deletions pandas_ta/candles/cdl_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pandas_ta.candles import cdl_doji, cdl_inside



ALL_PATTERNS = [
"2crows", "3blackcrows", "3inside", "3linestrike", "3outside",
"3starsinsouth", "3whitesoldiers", "abandonedbaby", "advanceblock",
Expand Down Expand Up @@ -58,8 +59,6 @@ def cdl_pattern(
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.DataFrame: one column for each pattern.
"""
Expand Down Expand Up @@ -117,10 +116,6 @@ def cdl_pattern(
# Fill
if "fillna" in kwargs:
pattern_result.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
pattern_result.fillna(
method=kwargs["fill_method"], inplace=True)

result[f"CDL_{n.upper()}"] = pattern_result

if len(result) == 0:
Expand Down
4 changes: 1 addition & 3 deletions pandas_ta/candles/cdl_z.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pandas_ta.utils import v_bool, v_offset, v_pos_default, v_series



def cdl_z(
open_: Series, high: Series, low: Series, close: Series,
length: Int = None, full: bool = None, ddof: Int = None,
Expand All @@ -30,7 +31,6 @@ def cdl_z(
the length if less than a percentage of it's high-low range.
Default: False
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: CDL_DOJI column.
Expand Down Expand Up @@ -78,8 +78,6 @@ def cdl_z(
# Fill
if "fillna" in kwargs:
df.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
df.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Category
df.name = f"CDL_Z{_props}"
Expand Down
4 changes: 1 addition & 3 deletions pandas_ta/candles/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pandas_ta.utils import v_offset, v_series



@njit
def np_ha(np_open, np_high, np_low, np_close):
ha_close = 0.25 * (np_open + np_high + np_low + np_close)
Expand Down Expand Up @@ -49,7 +50,6 @@ def ha(
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.DataFrame: ha_open, ha_high,ha_low, ha_close columns.
Expand Down Expand Up @@ -82,8 +82,6 @@ def ha(
# Fill
if "fillna" in kwargs:
df.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
df.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Category
df.name = "Heikin-Ashi"
Expand Down
17 changes: 9 additions & 8 deletions pandas_ta/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ def study(self, *args: Args, **kwargs: DictLike) -> dataclass:
Default: Number of cores of the OS
exclude (list): List of indicator names to exclude. Some are
excluded by default for various reasons; they require additional
sources, performance (td_seq), not a time series chart (vp) etc.
sources (tsignals, xsignals), performance, , not a time series
chart (vp) etc.
name (str): Select all indicators or indicators by
Category such as: "candles", "cycles", "momentum", "overlap",
"performance", "statistics", "trend", "volatility", "volume", or
Expand Down Expand Up @@ -962,6 +963,11 @@ def eri(self, length=None, offset=None, **kwargs: DictLike):
result = eri(high=high, low=low, close=close, length=length, offset=offset, **kwargs)
return self._post_process(result, **kwargs)

def exhc(self, length=None, cap=None, asint=None, show_all=None, nozeros=None, offset=None, **kwargs: DictLike):
close = self._get_column(kwargs.pop("close", "close"))
result = exhc(close=close, length=length, cap=cap, asint=asint, show_all=show_all, nozeros=nozeros, offset=offset, **kwargs)
return self._post_process(result, **kwargs)

def fisher(self, length=None, signal=None, offset=None, **kwargs: DictLike):
high = self._get_column(kwargs.pop("high", "high"))
low = self._get_column(kwargs.pop("low", "low"))
Expand Down Expand Up @@ -1110,11 +1116,6 @@ def stochrsi(self, length=None, rsi_length=None, k=None, d=None, mamode=None, of
mamode=mamode, offset=offset, **kwargs)
return self._post_process(result, **kwargs)

def td_seq(self, asint=None, offset=None, show_all=None, **kwargs: DictLike):
close = self._get_column(kwargs.pop("close", "close"))
result = td_seq(close=close, asint=asint, offset=offset, show_all=show_all, **kwargs)
return self._post_process(result, **kwargs)

def tmo(self, tmo_length=None, calc_length=None, smooth_length=None, mamode=None, compute_momentum=False, normalize_signal=False, offset=None, **kwargs: DictLike):
open_ = self._get_column(kwargs.pop("open", "open"))
close = self._get_column(kwargs.pop("close", "close"))
Expand Down Expand Up @@ -1501,9 +1502,9 @@ def dpo(self, length=None, centered=True, offset=None, **kwargs: DictLike):
result = dpo(close=close, length=length, centered=centered, offset=offset, **kwargs)
return self._post_process(result, **kwargs)

def ht_trendline(self, offset=None, **kwargs: DictLike):
def ht_trendline(self, talib=None, prenan=None, offset=None, **kwargs: DictLike):
close = self._get_column(kwargs.pop("close", "close"))
result = ht_trendline(close=close, offset=offset)
result = ht_trendline(close=close, talib=talib, prenan=prenan, offset=offset, **kwargs)
return self._post_process(result, **kwargs)

def increasing(self, length=None, strict=None, asint=None, offset=None, **kwargs: DictLike):
Expand Down
1 change: 1 addition & 0 deletions pandas_ta/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pandas_ta._typing import DictLike



def bind(name: str, f: types.FunctionType, method: types.MethodType = None):
"""
Helper function to bind the function and class method defined in a custom
Expand Down
6 changes: 1 addition & 5 deletions pandas_ta/cycles/ebsw.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pandas_ta.utils import v_offset, v_pos_default, v_series



def ebsw(
close: Series, length: Int = None, bars: Int = None,
initial_version: bool = False,
Expand Down Expand Up @@ -45,8 +46,6 @@ def ebsw(
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: New feature generated.
"""
Expand Down Expand Up @@ -146,9 +145,6 @@ def ebsw(
# Fill
if "fillna" in kwargs:
ebsw.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
ebsw.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Category
ebsw.name = f"EBSW_{length}_{bars}"
ebsw.category = "cycles"
Expand Down
6 changes: 1 addition & 5 deletions pandas_ta/cycles/reflex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pandas_ta.utils import v_offset, v_pos_default, v_series



@njit
def np_reflex(x, n, k, alpha, pi, sqrt2):
m, ratio = x.size, 2 * sqrt2 / k
Expand Down Expand Up @@ -73,8 +74,6 @@ def reflex(
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: New feature generated.
"""
Expand Down Expand Up @@ -105,9 +104,6 @@ def reflex(
# Fill
if "fillna" in kwargs:
result.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
result.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Category
result.name = f"REFLEX_{length}_{smooth}_{alpha}"
result.category = "cycles"
Expand Down
3 changes: 2 additions & 1 deletion pandas_ta/ma.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pandas_ta.overlap.wma import wma



def ma(name: str = None, source: Series = None, **kwargs: DictLike) -> Series:
"""Simple MA Utility for easier MA selection
Expand Down Expand Up @@ -69,4 +70,4 @@ def ma(name: str = None, source: Series = None, **kwargs: DictLike) -> Series:
elif name == "trima": return trima(source, **kwargs)
elif name == "vidya": return vidya(source, **kwargs)
elif name == "wma": return wma(source, **kwargs)
else: return ema(source, **kwargs)
else: return ema(source, **kwargs)
10 changes: 5 additions & 5 deletions pandas_ta/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from pandas_ta._typing import Dict, IntFloat, ListStr


_dist = get_distribution("pandas_ta")
try:
# Normalize case for Windows systems
Expand Down Expand Up @@ -49,10 +48,11 @@
# Momentum
"momentum": [
"ao", "apo", "bias", "bop", "brar", "cci", "cfo", "cg", "cmo",
"coppock", "crsi", "cti", "er", "eri", "fisher", "inertia", "kdj", "kst",
"macd", "mom", "pgo", "ppo", "psl", "qqe", "roc", "rsi", "rsx",
"rvgi", "slope", "smi", "squeeze", "squeeze_pro", "stc", "stoch",
"stochf", "stochrsi", "td_seq", "tmo", "trix", "tsi", "uo", "willr"
"coppock", "crsi", "cti", "er", "eri", "exhc", "fisher", "inertia",
"kdj", "kst", "macd", "mom", "pgo", "ppo", "psl", "qqe", "roc",
"rsi", "rsx", "rvgi", "slope", "smi", "squeeze", "squeeze_pro",
"stc", "stoch", "stochf", "stochrsi", "tmo", "trix", "tsi", "uo",
"willr"
],
# Overlap
"overlap": [
Expand Down
4 changes: 2 additions & 2 deletions pandas_ta/momentum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .dm import dm
from .er import er
from .eri import eri
from .exhc import exhc
from .fisher import fisher
from .inertia import inertia
from .kdj import kdj
Expand All @@ -36,7 +37,6 @@
from .stoch import stoch
from .stochf import stochf
from .stochrsi import stochrsi
from .td_seq import td_seq
from .tmo import tmo
from .trix import trix
from .tsi import tsi
Expand All @@ -59,6 +59,7 @@
"dm",
"er",
"eri",
"exhc",
"fisher",
"inertia",
"kdj",
Expand All @@ -81,7 +82,6 @@
"stoch",
"stochf",
"stochrsi",
"td_seq",
"tmo",
"trix",
"tsi",
Expand Down
5 changes: 1 addition & 4 deletions pandas_ta/momentum/ao.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pandas_ta.utils import v_offset, v_pos_default, v_series



def ao(
high: Series, low: Series, fast: Int = None, slow: Int = None,
offset: Int = None, **kwargs: DictLike
Expand All @@ -28,7 +29,6 @@ def ao(
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: New feature generated.
Expand Down Expand Up @@ -60,9 +60,6 @@ def ao(
# Fill
if "fillna" in kwargs:
ao.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
ao.fillna(method=kwargs["fill_method"], inplace=True)

# Name and Category
ao.name = f"AO_{fast}_{slow}"
ao.category = "momentum"
Expand Down
Loading

0 comments on commit debfd82

Please sign in to comment.