STY MAINT typing

This commit is contained in:
Kevin Johnson
2022-02-19 17:13:55 -08:00
parent a28d66ed50
commit bcf47ba486
176 changed files with 1133 additions and 799 deletions
+5 -1
View File
@@ -192,7 +192,7 @@ $ pip install pandas_ta[full]
Latest Version
--------------
Best choice! Version: *0.3.51b*
Best choice! Version: *0.3.52b*
* Includes all fixes and updates between **pypi** and what is covered in this README.
```sh
$ pip install -U git+https://github.com/twopirllc/pandas-ta
@@ -1229,8 +1229,12 @@ Back to [Contents](#contents)
<br/>
# **Sources**
### Technical Analysis
[Original TA-LIB](http://ta-lib.org/) | [TradingView](http://www.tradingview.com) | [Sierra Chart](https://search.sierrachart.com/?Query=indicators&submitted=true) | [MQL5](https://www.mql5.com) | [FM Labs](https://www.fmlabs.com/reference/default.htm) | [Pro Real Code](https://www.prorealcode.com/prorealtime-indicators) | [User 42](https://user42.tuxfamily.org/chart/manual/index.html) | [Technical Traders](http://technical.traders.com/tradersonline/FeedTT-2014.html)
### Supplemental
[What Every Computer Scientist Should Know About Floating-Point Arithmetic](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html)
<br/>
# **Support**
+62
View File
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
from decimal import Decimal
from functools import partial
from pathlib import Path
from typing import *
from numpy import argmax, argmin, nan, ndarray, recarray, void
from numpy import bool_ as np_bool_
from numpy import floating as np_floating
from numpy import generic as np_generic
from numpy import integer as np_integer
from numpy import number as np_number
from pandas import DataFrame, Series
from sys import float_info as sflt
# Generic types
T = TypeVar("T")
# Scalars
Scalar = Union[str, float, int, complex, bool, object, np_generic]
Number = Union[int, float, complex, np_number, np_bool_]
Int = Union[int, np_integer]
Float = Union[float, np_floating]
IntFloat = Union[Int, Float]
# Basic sequences
MaybeTuple = Union[T, Tuple[T, ...]]
MaybeList = Union[T, List[T]]
TupleList = Union[List[T], Tuple[T, ...]]
MaybeTupleList = Union[T, List[T], Tuple[T, ...]]
MaybeIterable = Union[T, Iterable[T]]
MaybeSequence = Union[T, Sequence[T]]
ListStr = List[str]
DictLike = Union[None, dict]
DictLikeSequence = MaybeSequence[DictLike]
Args = Tuple[Any, ...]
ArgsLike = Union[None, Args]
Kwargs = Dict[str, Any]
KwargsLike = Union[None, Kwargs]
KwargsLikeSequence = MaybeSequence[KwargsLike]
FileName = Union[str, Path]
DTypeLike = Any
PandasDTypeLike = Any
Shape = Tuple[int, ...]
RelaxedShape = Union[int, Shape]
Array = ndarray # ready to be used for n-dim data
Array1d = ndarray
Array2d = ndarray
Array3d = ndarray
Record = void
RecordArray = ndarray
RecArray = recarray
MaybeArray = Union[T, Array]
SeriesFrame = Union[Series, DataFrame]
MaybeSeries = Union[T, Series]
MaybeSeriesFrame = Union[T, Series, DataFrame]
AnyArray = Union[Array, Series, DataFrame]
AnyArray1d = Union[Array1d, Series]
AnyArray2d = Union[Array2d, DataFrame]
+3 -2
View File
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta.overlap import sma
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, high_low_range, is_percent
from pandas_ta.utils import real_body, verify_series
def cdl_doji(
open_: Series, high: Series, low: Series, close: Series,
length: int = None, factor: float = None, scalar: float = None,
length: Int = None, factor: IntFloat = None, scalar: IntFloat = None,
asint: bool = True,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Candle Type: Doji
+2 -1
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import candle_color, get_offset, verify_series
def cdl_inside(
open_: Series, high: Series, low: Series, close: Series,
asbool: bool = False,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Candle Type: Inside Bar
+8 -13
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from typing import Sequence, Union
from pandas import Series, DataFrame
from pandas_ta._typing import DictLike, Int, IntFloat, List, Union
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
from pandas_ta.candles import cdl_doji, cdl_inside
@@ -24,8 +24,8 @@ ALL_PATTERNS = [
def cdl_pattern(
open_: Series, high: Series, low: Series, close: Series,
name: Union[str, Sequence[str]] = "all", scalar: float = None,
offset: int = None, **kwargs
name: Union[str, List[str]] = "all", scalar: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""TA Lib Candle Patterns
@@ -89,6 +89,8 @@ def cdl_pattern(
if n in pta_patterns:
pattern_result = pta_patterns[n](
open_, high, low, close, offset=offset, scalar=scalar, **kwargs)
if not isinstance(pattern_result,Series):
continue
result[pattern_result.name] = pattern_result
else:
if not Imports["talib"]:
@@ -96,16 +98,10 @@ def cdl_pattern(
f"[X] Please install TA-Lib to use {n}. (pip install TA-Lib)")
continue
pattern_func = tala.Function(f"CDL{n.upper()}")
pf = tala.Function(f"CDL{n.upper()}")
pattern_result = Series(
pattern_func(
open_,
high,
low,
close,
**kwargs) /
100 *
scalar)
0.01 * scalar * pf(open_, high, low, close, **kwargs)
)
pattern_result.index = close.index
# Offset
@@ -130,5 +126,4 @@ def cdl_pattern(
df.category = "candles"
return df
cdl = cdl_pattern # Alias
+5 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.statistics import zscore
from pandas_ta.utils import get_offset, verify_series
def cdl_z(
open_: Series, high: Series, low: Series, close: Series,
length: int = None, full: bool = None, ddof=None,
offset: int = None, **kwargs
length: Int = None, full: bool = None, ddof: Int = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Candle Type: Z
@@ -21,6 +22,8 @@ def cdl_z(
low (pd.Series): Series of 'low's
close (pd.Series): Series of 'close's
length (int): The period. Default: 10
full (bool): Apply to whole DataFrame. Default: False
ddof (int): Degrees of Freedom. Default: 1
Kwargs:
naive (bool, optional): If True, prefills potential Doji less than
+2 -1
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def ha(
open_: Series, high: Series, low: Series, close: Series,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Heikin Ashi Candles (HA)
+185 -173
View File
File diff suppressed because it is too large Load Diff
+16 -14
View File
@@ -8,6 +8,7 @@ from os.path import abspath, join, exists, basename, splitext
from glob import glob
import pandas_ta
from pandas_ta._typing import DictLike
def bind(name: str, f: types.FunctionType):#, method: types.MethodType = None):
@@ -56,9 +57,10 @@ def create_dir(path: str, create_categories: bool = True, verbose: bool = True):
print(f"[i] Created an empty sub-directory '{dirname}'.")
def get_module_functions(module: types.ModuleType) -> dict:
def get_module_functions(module: types.ModuleType) -> DictLike:
"""
Helper function to get the functions of an imported module as a dictionary.
Helper function to get the functions of an imported module
as a dictionary.
Args:
module: python module
@@ -87,14 +89,14 @@ def import_dir(path: str, verbose: bool = True):
path (str): Full path to your indicator tree
verbose (bool): If True verbose output of results
This method allows you to experiment and develop your own technical analysis
indicators in a separate local directory of your choice but use them seamlessly
together with the existing pandas_ta functions just like if they were part of
pandas_ta.
This method allows you to experiment and develop your own technical
analysis indicators in a separate local directory of your choice but
use them seamlessly together with the existing pandas_ta functions just
like if they were part of pandas_ta.
If you at some late point would like to push them into the pandas_ta library
you can do so very easily by following the step by step instruction here
https://github.com/twopirllc/pandas-ta/issues/355.
If you at some late point would like to push them into the pandas_ta
library you can do so very easily by following the step by step
instruction here https://github.com/twopirllc/pandas-ta/issues/355.
A brief example of usage:
@@ -102,9 +104,9 @@ def import_dir(path: str, verbose: bool = True):
>>> import pandas as pd
>>> import pandas_ta as ta
2. Create an empty directory on your machine where you want to work with your
indicators. Invoke pandas_ta.custom.import_dir once to pre-populate it with
sub-folders for all available indicator categories, e.g.:
2. Create an empty directory on your machine where you want to work with
your indicators. Invoke pandas_ta.custom.import_dir once to pre-populate
it with sub-folders for all available indicator categories, e.g.:
>>> import os
>>> from os.path import abspath, join, expanduser
@@ -121,8 +123,8 @@ def import_dir(path: str, verbose: bool = True):
ending with '_method'. E.g. 'ni_method'
In essence these modules should look exactly like the standard indicators
available in categories under the pandas_ta-folder. The only difference will
be an addition of a matching class method.
available in categories under the pandas_ta-folder. The only difference
will be an addition of a matching class method.
For an example of the correct structure, look at the example ni.py in the
examples folder.
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from numpy import cos, exp, mean, nan, pi, roll, sin, sqrt, zeros
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def ebsw(
close: Series, length: int = None, bars: int = None,
close: Series, length: Int = None, bars: Int = None,
initial_version: bool = False,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Even Better SineWave (EBSW)
+9 -7
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import cos, exp, nan, ndarray, sqrt, zeros_like
from numpy import cos, exp, nan, sqrt, zeros_like
from pandas import Series
from pandas_ta._typing import Array, DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
@@ -11,8 +12,9 @@ except ImportError:
@njit
def np_reflex(x: ndarray, n: int, k: int,
alpha: float, pi: float, sqrt2: float):
def np_reflex(
x: Array, n: Int, k: Int, alpha: IntFloat, pi: IntFloat, sqrt2: IntFloat
):
m, ratio = x.size, 2 * sqrt2 / k
a = exp(-pi * ratio)
b = 2 * a * cos(180 * ratio)
@@ -41,10 +43,10 @@ def np_reflex(x: ndarray, n: int, k: int,
def reflex(
close: Series, length: int = None,
smooth: int = None, alpha: float = None,
pi: float = None, sqrt2: float = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
smooth: Int = None, alpha: IntFloat = None,
pi: IntFloat = None, sqrt2: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Reflex (reflex)
+2 -1
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap.dema import dema
from pandas_ta.overlap.ema import ema
from pandas_ta.overlap.fwma import fwma
@@ -19,7 +20,7 @@ from pandas_ta.overlap.vidya import vidya
from pandas_ta.overlap.wma import wma
def ma(name: str = None, source: Series = None, **kwargs) -> Series:
def ma(name: str = None, source: Series = None, **kwargs: DictLike) -> Series:
"""Simple MA Utility for easier MA selection
Available MAs:
+7 -5
View File
@@ -3,6 +3,8 @@ from importlib.util import find_spec
from pathlib import Path
from pkg_resources import get_distribution, DistributionNotFound
from pandas_ta._typing import Dict, IntFloat, ListStr
_dist = get_distribution("pandas_ta")
try:
@@ -16,7 +18,7 @@ except DistributionNotFound:
version = __version__ = _dist.version
Imports = {
Imports: Dict[str, bool] = {
"alphaVantage-api": find_spec("alphaVantageAPI") is not None,
"dotenv": find_spec("dotenv") is not None,
"matplotlib": find_spec("matplotlib") is not None,
@@ -36,7 +38,7 @@ Imports = {
# Not ideal and not dynamic but it works.
# Will find a dynamic solution later.
Category = {
Category: Dict[str, ListStr] = {
# Candles
"candles": [
"cdl_pattern", "cdl_z", "ha"
@@ -88,7 +90,7 @@ Category = {
],
}
CANDLE_AGG = {
CANDLE_AGG: Dict[str, str] = {
"open": "first",
"high": "max",
"low": "min",
@@ -97,7 +99,7 @@ CANDLE_AGG = {
}
# https://www.worldtimezone.com/markets24.php
EXCHANGE_TZ = {
EXCHANGE_TZ: Dict[str, IntFloat] = {
"NZSX": 12, "ASX": 11,
"TSE": 9, "HKE": 8, "SSE": 8, "SGX": 8,
"NSE": 5.5, "DIFX": 4, "RTS": 3,
@@ -106,7 +108,7 @@ EXCHANGE_TZ = {
"GENR": 0 # Generated Data
}
RATE = {
RATE: Dict[str, IntFloat] = {
"DAYS_PER_MONTH": 21,
"MINUTES_PER_HOUR": 60,
"MONTHS_PER_YEAR": 12,
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import sma
from pandas_ta.utils import get_offset, verify_series
def ao(
high: Series, low: Series, fast: int = None, slow: int = None,
offset: int = None, **kwargs
high: Series, low: Series, fast: Int = None, slow: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Awesome Oscillator (AO)
+3 -2
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, tal_ma, verify_series
def apo(
close: Series, fast: int = None, slow: int = None,
close: Series, fast: Int = None, slow: Int = None,
mamode: str = None, talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Absolute Price Oscillator (APO)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.utils import get_offset, verify_series
def bias(
close: Series, length: int = None, mamode: str = None,
offset: int = None, **kwargs
close: Series, length: Int = None, mamode: str = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Bias (BIAS)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, non_zero_range, verify_series
def bop(
open_: Series, high: Series, low: Series, close: Series,
scalar: float = None, talib: bool = None,
offset: int = None, **kwargs
scalar: IntFloat = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Balance of Power (BOP)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_drift, get_offset, non_zero_range, verify_series
def brar(
open_: Series, high: Series, low: Series, close: Series,
length: int = None, scalar: float = None, drift: int = None,
offset: int = None, **kwargs
length: Int = None, scalar: IntFloat = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""BRAR (BRAR)
+4 -3
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.maps import Imports
from pandas_ta.overlap import hlc3, sma
from pandas_ta.statistics import mad
@@ -7,9 +8,9 @@ from pandas_ta.utils import get_offset, verify_series
def cci(
high: Series, low: Series, close: Series, length: int = None,
c: float = None, talib: bool = None,
offset: int = None, **kwargs
high: Series, low: Series, close: Series, length: Int = None,
c: IntFloat = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Commodity Channel Index (CCI)
+4 -3
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.overlap import linreg
from pandas_ta.utils import get_drift, get_offset, verify_series
def cfo(
close: Series, length: int = None,
scalar: float = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
scalar: IntFloat = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Chande Forcast Oscillator (CFO)
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series, weights
def cg(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Center of Gravity (CG)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.maps import Imports
from pandas_ta.overlap import rma
from pandas_ta.utils import get_drift, get_offset, verify_series
def cmo(
close: Series, length: int = None, scalar: float = None,
talib: bool = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, scalar: IntFloat = None,
talib: bool = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Chande Momentum Oscillator (CMO)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import wma
from pandas_ta.utils import get_offset, verify_series
from .roc import roc
def coppock(
close: Series, length: int = None, fast: int = None, slow: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, fast: Int = None, slow: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Coppock Curve (COPC)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import linreg
from pandas_ta.utils import get_offset, verify_series
def cti(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Correlation Trend Indicator (CTI)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series, get_drift, zero
def dm(
high: Series, low: Series, length: int = None,
mamode: str = None, talib: bool = None, drift: int = None,
offset: int = None, **kwargs
high: Series, low: Series, length: Int = None,
mamode: str = None, talib: bool = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Directional Movement (DM)
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, concat, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_drift, get_offset, verify_series, signals
def er(
close: Series, length: int = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Efficiency Ratio (ER)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import ema
from pandas_ta.utils import get_offset, verify_series
def eri(
high: Series, low: Series, close: Series, length: int = None,
offset: int = None, **kwargs
high: Series, low: Series, close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Elder Ray Index (ERI)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from numpy import log, nan
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import hl2
from pandas_ta.utils import get_offset, high_low_range, verify_series
def fisher(
high: Series, low: Series, length: int = None, signal: int = None,
offset: int = None, **kwargs
high: Series, low: Series, length: Int = None, signal: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Fisher Transform (FISHT)
+4 -3
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.overlap import linreg
from pandas_ta.utils import get_drift, get_offset, verify_series
from pandas_ta.volatility import rvi
@@ -7,10 +8,10 @@ from pandas_ta.volatility import rvi
def inertia(
close: Series, high: Series = None, low: Series = None,
length: int = None, rvi_length: int = None, scalar: float = None,
length: Int = None, rvi_length: Int = None, scalar: IntFloat = None,
refined: bool = None, thirds: bool = None,
drift: int = None, mamode: str = None,
offset: int = None, **kwargs
drift: Int = None, mamode: str = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Inertia (INERTIA)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, non_zero_range, rma_pandas, verify_series
def kdj(
high: Series, low: Series, close: Series,
length: int = None, signal: int = None,
offset: int = None, **kwargs
length: Int = None, signal: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""KDJ (KDJ)
+6 -5
View File
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_drift, get_offset, verify_series
from .roc import roc
def kst(
close: Series, signal: int = None,
roc1: int = None, roc2: int = None, roc3: int = None, roc4: int = None,
sma1: int = None, sma2: int = None, sma3: int = None, sma4: int = None,
drift: int = None,
offset: int = None, **kwargs
close: Series, signal: Int = None,
roc1: Int = None, roc2: Int = None, roc3: Int = None, roc4: Int = None,
sma1: Int = None, sma2: Int = None, sma3: Int = None, sma4: Int = None,
drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""'Know Sure Thing' (KST)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import concat, DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.overlap import ema
from pandas_ta.utils import get_offset, verify_series, signals
def macd(
close: Series, fast: int = None, slow: int = None, signal: int = None,
talib: bool = None, offset: int = None, **kwargs
close: Series, fast: Int = None, slow: Int = None, signal: Int = None,
talib: bool = None, offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Moving Average Convergence Divergence (MACD)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
def mom(
close: Series, length: int = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Momentum (MOM)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import ema, sma
from pandas_ta.utils import get_offset, verify_series
from pandas_ta.volatility import atr
def pgo(
high: Series, low: Series, close: Series, length: int = None,
offset: int = None, **kwargs
high: Series, low: Series, close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Pretty Good Oscillator (PGO)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.ma import ma
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, tal_ma, verify_series
def ppo(
close: Series, fast: int = None, slow: int = None, signal: int = None,
scalar: float = None, mamode: str = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, fast: Int = None, slow: Int = None, signal: Int = None,
scalar: IntFloat = None, mamode: str = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Percentage Price Oscillator (PPO)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from numpy import sign
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_drift, get_offset, verify_series
def psl(
close: Series, open_: Series = None,
length: int = None, scalar: float = None, drift: int = None,
offset: int = None, **kwargs
length: Int = None, scalar: IntFloat = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Psychological Line (PSL)
+4 -3
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.overlap import ema
from pandas_ta.utils import get_offset, verify_series
def pvo(
volume: Series, fast: int = None, slow: int = None, signal: int = None,
scalar: float = None,
offset: int = None, **kwargs
volume: Series, fast: Int = None, slow: Int = None,
signal: Int = None, scalar: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Percentage Volume Oscillator (PVO)
+5 -4
View File
@@ -1,16 +1,17 @@
# -*- coding: utf-8 -*-
from numpy import isnan, maximum, minimum, nan
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.ma import ma
from pandas_ta.utils import get_drift, get_offset, verify_series
from .rsi import rsi
def qqe(
close: Series, length: int = None,
smooth: int = None, factor: float = None,
mamode: str = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
smooth: Int = None, factor: IntFloat = None,
mamode: str = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Quantitative Qualitative Estimation (QQE)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
from .mom import mom
def roc(
close: Series, length: int = None,
scalar: float = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
scalar: IntFloat = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Rate of Change (ROC)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, concat, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.maps import Imports
from pandas_ta.overlap import rma
from pandas_ta.utils import get_drift, get_offset, verify_series, signals
def rsi(
close: Series, length: int = None, scalar: float = None,
talib: bool = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, scalar: IntFloat = None,
talib: bool = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Relative Strength Index (RSI)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas_ta._typing import DictLike, Int
from pandas import concat, DataFrame, Series
from pandas_ta.utils import get_drift, get_offset, verify_series, signals
def rsx(
close: Series, length: int = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Relative Strength Xtra (rsx)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import swma
from pandas_ta.utils import get_offset, non_zero_range, verify_series
def rvgi(
open_: Series, high: Series, low: Series, close: Series,
length: int = None, swma_length: int = None,
offset: int = None, **kwargs
length: Int = None, swma_length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Relative Vigor Index (RVGI)
+4 -3
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from numpy import arctan, pi
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def slope(
close: Series, length: int = None,
as_angle=None, to_degrees=None, vertical=None,
offset: int = None, **kwargs
close: Series, length: Int = None,
as_angle: bool = None, to_degrees: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Slope
+4 -3
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
from .tsi import tsi
def smi(
close: Series, fast: int = None, slow: int = None, signal: int = None,
scalar: float = None,
offset: int = None, **kwargs
close: Series, fast: Int = None, slow: Int = None,
signal: Int = None, scalar: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""SMI Ergodic Indicator (SMI)
+6 -5
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.overlap import ema, linreg, sma
from pandas_ta.trend import decreasing, increasing
from pandas_ta.utils import get_offset, simplify_columns, unsigned_differences, verify_series
@@ -10,11 +11,11 @@ from .mom import mom
def squeeze(
high: Series, low: Series, close: Series,
bb_length: int = None, bb_std: float = None,
kc_length: int = None, kc_scalar: float = None,
mom_length: int = None, mom_smooth: int = None,
use_tr=None, mamode: str = None,
offset: int = None, **kwargs
bb_length: Int = None, bb_std: IntFloat = None,
kc_length: Int = None, kc_scalar: IntFloat = None,
mom_length: Int = None, mom_smooth: Int = None,
use_tr: bool = None, mamode: str = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Squeeze (SQZ)
+9 -7
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.momentum import mom
from pandas_ta.overlap import ema, sma
from pandas_ta.trend import decreasing, increasing
@@ -10,12 +11,12 @@ from pandas_ta.utils import get_offset, simplify_columns, unsigned_differences,
def squeeze_pro(
high: Series, low: Series, close: Series,
bb_length: int = None, bb_std: float = None,
kc_length: int = None, kc_scalar_wide: float = None,
kc_scalar_normal: float = None, kc_scalar_narrow: float = None,
mom_length: int = None, mom_smooth: int = None,
use_tr=None, mamode: str = None,
offset: int = None, **kwargs
bb_length: Int = None, bb_std: IntFloat = None,
kc_length: Int = None, kc_scalar_wide: IntFloat = None,
kc_scalar_normal: IntFloat = None, kc_scalar_narrow: IntFloat = None,
mom_length: Int = None, mom_smooth: Int = None,
use_tr: bool = None, mamode: str = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Squeeze PRO(SQZPRO)
@@ -94,7 +95,8 @@ def squeeze_pro(
close = verify_series(close, _length)
offset = get_offset(offset)
valid_kc_scaler = kc_scalar_wide > kc_scalar_normal and kc_scalar_normal > kc_scalar_narrow
valid_kc_scaler = kc_scalar_wide > kc_scalar_normal \
and kc_scalar_normal > kc_scalar_narrow
if not valid_kc_scaler:
return
+6 -4
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.overlap import ema
from pandas_ta.utils import get_offset, non_zero_range, verify_series
def stc(
close: Series, tclength: int = None,
fast: int = None, slow: int = None, factor: float = None,
offset: int = None, **kwargs
close: Series, tclength: Int = None,
fast: Int = None, slow: Int = None, factor: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Schaff Trend Cycle (STC)
@@ -29,7 +30,8 @@ def stc(
extMa2 = df.ta.ema(close=df["close"], length=ma2_interval, append=True)
stc = ta.stc(close=df["close"], tclen=stc_tclen, ma1=extMa1, ma2=extMa2, factor=stc_factor)
The same goes for osc=, which allows the input of an externally calculated oscillator, overriding ma1 & ma2.
The same goes for osc=, which allows the input of an externally
calculated oscillator, overriding ma1 & ma2.
Sources:
Implemented by rengel8 based on work found here:
+3 -2
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, non_zero_range, tal_ma, verify_series
@@ -7,9 +8,9 @@ from pandas_ta.utils import get_offset, non_zero_range, tal_ma, verify_series
def stoch(
high: Series, low: Series, close: Series,
k: int = None, d: int = None, smooth_k: int = None,
k: Int = None, d: Int = None, smooth_k: Int = None,
mamode: str = None, talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Stochastic (STOCH)
+4 -2
View File
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, non_zero_range, tal_ma, verify_series
def stochf(
high: Series, low: Series, close: Series, k: int = None, d: int = None,
high: Series, low: Series, close: Series,
k: Int = None, d: Int = None,
mamode: str = None, talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Fast Stochastic (STOCHF)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.momentum import rsi
from pandas_ta.utils import get_offset, non_zero_range, verify_series
def stochrsi(
close: Series, length: int = None, rsi_length: int = None,
k: int = None, d: int = None, mamode: str = None,
offset: int = None, **kwargs
close: Series, length: Int = None, rsi_length: Int = None,
k: Int = None, d: Int = None, mamode: str = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Stochastic (STOCHRSI)
+2 -1
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from numpy import where
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def td_seq(
close: Series, asint: bool = None, show_all: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""TD Sequential (TD_SEQ)
+4 -4
View File
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# from numpy import isnan
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.overlap.ema import ema
from pandas_ta.utils import get_drift, get_offset, verify_series
def trix(
close: Series, length: int = None, signal: int = None,
scalar: float = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, signal: Int = None,
scalar: IntFloat = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Trix (TRIX)
+5 -3
View File
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.ma import ma
from pandas_ta.overlap import ema
from pandas_ta.utils import get_drift, get_offset, verify_series
def tsi(
close: Series, fast: int = None, slow: int = None, signal: int = None,
scalar: float = None, mamode: str = None, drift: int = None,
offset: int = None, **kwargs
close: Series, fast: Int = None, slow: Int = None,
signal: Int = None, scalar: IntFloat = None,
mamode: str = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""True Strength Index (TSI)
+5 -4
View File
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.maps import Imports
from pandas_ta.utils import get_drift, get_offset, verify_series
def uo(
high: Series, low: Series, close: Series,
fast: int = None, medium: int = None, slow: int = None,
fast_w: float = None, medium_w: float = None, slow_w: float = None,
talib: bool = None, drift: int = None,
offset: int = None, **kwargs
fast: Int = None, medium: Int = None, slow: Int = None,
fast_w: IntFloat = None, medium_w: IntFloat = None, slow_w: IntFloat = None,
talib: bool = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Ultimate Oscillator (UO)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
def willr(
high: Series, low: Series, close: Series,
length: int = None, talib: bool = None,
offset: int = None, **kwargs
length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""William's Percent R (WILLR)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
from .smma import smma
def alligator(
close: Series, jaw: int = None, teeth: int = None, lips: int = None,
close: Series, jaw: Int = None, teeth: Int = None, lips: Int = None,
talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Bill Williams Alligator (ALLIGATOR)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from numpy import append, arange, array, exp, floor, nan, tensordot
from numpy.version import version as npVersion
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas import Series
from pandas_ta.utils import get_offset, strided_window, verify_series
def alma(
close: Series, length: int = None,
sigma: float = None, dist_offset: float = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
sigma: IntFloat = None, dist_offset: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Arnaud Legoux Moving Average (ALMA)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
from .ema import ema
def dema(
close: Series, length: int = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Double Exponential Moving Average (DEMA)
+3 -2
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
@@ -23,9 +24,9 @@ except ImportError:
def ema(
close: Series, length: int = None,
close: Series, length: Int = None,
talib: bool = None, presma: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Exponential Moving Average (EMA)
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import fibonacci, get_offset, verify_series, weights
def fwma(
close: Series, length: int = None, asc: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, asc: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Fibonacci's Weighted Moving Average (FWMA)
+3 -2
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.utils import get_offset, verify_series
def hilo(
high: Series, low: Series, close: Series,
high_length: int = None, low_length: int = None, mamode: str = None,
offset: int = None, **kwargs
high_length: Int = None, low_length: Int = None, mamode: str = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Gann HiLo Activator(HiLo)
+14 -1
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def hl2(
high: Series, low: Series,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""HL2
@@ -16,6 +17,12 @@ def hl2(
low (pd.Series): Series of 'low's
offset (int): How many periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value). Only works if
result is offset.
fill_method (value, optional): Type of fill method. Only works if
result is offset.
Returns:
pd.Series: New feature generated.
"""
@@ -32,6 +39,12 @@ def hl2(
if offset != 0:
hl2 = hl2.shift(offset)
# Fill
if "fillna" in kwargs:
hl2.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
hl2.fillna(method=kwargs["fill_method"], inplace=True)
# Name and Category
hl2.name = "HL2"
hl2.category = "overlap"
+14 -1
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
def hlc3(
high: Series, low: Series, close: Series, talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""HLC3
@@ -18,6 +19,12 @@ def hlc3(
close (pd.Series): Series of 'close's
offset (int): How many periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value). Only works if
result is offset.
fill_method (value, optional): Type of fill method. Only works if
result is offset.
Returns:
pd.Series: New feature generated.
"""
@@ -40,6 +47,12 @@ def hlc3(
if offset != 0:
hlc3 = hlc3.shift(offset)
# Fill
if "fillna" in kwargs:
hlc3.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
hlc3.fillna(method=kwargs["fill_method"], inplace=True)
# Name and Category
hlc3.name = "HLC3"
hlc3.category = "overlap"
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from numpy import sqrt
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
from .wma import wma
def hma(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Hull Moving Average (HMA)
+4 -2
View File
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
def hwma(
close: Series, na: float = None, nb: float = None, nc: float = None,
offset: int = None, **kwargs
close: Series,
na: IntFloat = None, nb: IntFloat = None, nc: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""HWMA (Holt-Winter Moving Average)
+3 -2
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from pandas import date_range, DataFrame, RangeIndex, Timedelta, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
from .midprice import midprice
def ichimoku(
high: Series, low: Series, close: Series,
tenkan: int = None, kijun: int = None, senkou: int = None,
tenkan: Int = None, kijun: Int = None, senkou: Int = None,
include_chikou: bool = True,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Ichimoku Kinkō Hyō (ichimoku)
+3 -2
View File
@@ -3,12 +3,13 @@
from numpy import average, log, nan, sqrt, zeros_like
from numpy import power as np_power
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
def jma(
close: Series, length: int = None, phase: float = None,
offset: int = None, **kwargs
close: Series, length: IntFloat = None, phase: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Jurik Moving Average Average (JMA)
+4 -3
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.utils import get_drift, get_offset, non_zero_range, verify_series
def kama(
close: Series, length: int = None, fast: int = None, slow: int = None,
mamode: str = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, fast: Int = None, slow: Int = None,
mamode: str = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Kaufman's Adaptive Moving Average (KAMA)
+3 -2
View File
@@ -2,13 +2,14 @@
from numpy import arctan, nan, pi, zeros_like
from numpy.version import version
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, strided_window, verify_series
def linreg(
close: Series, length: int = None, talib: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Linear Regression Moving Average (linreg)
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
def mcgd(
close: Series, length: int = None, c: float = None,
offset: int = None, **kwargs
close: Series, length: Int = None, c: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""McGinley Dynamic Indicator
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
def midpoint(
close: Series, length: int = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Midpoint
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
def midprice(
high: Series, low: Series, length: int = None, talib: bool = None,
offset: int = None, **kwargs
high: Series, low: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Midprice
+14 -1
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def ohlc4(
open_: Series, high: Series, low: Series, close: Series,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""OHLC4
@@ -18,6 +19,12 @@ def ohlc4(
close (pd.Series): Series of 'close's
offset (int): How many periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value). Only works if
result is offset.
fill_method (value, optional): Type of fill method. Only works if
result is offset.
Returns:
pd.Series: New feature generated.
"""
@@ -36,6 +43,12 @@ def ohlc4(
if offset != 0:
ohlc4 = ohlc4.shift(offset)
# Fill
if "fillna" in kwargs:
ohlc4.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
ohlc4.fillna(method=kwargs["fill_method"], inplace=True)
# Name and Category
ohlc4.name = "OHLC4"
ohlc4.category = "overlap"
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, pascals_triangle, verify_series, weights
def pwma(
close: Series, length: int = None, asc: bool = None,
offset: bool = None, **kwargs
close: Series, length: Int = None, asc: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Pascal's Weighted Moving Average (PWMA)
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def rma(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""wildeR's Moving Average (RMA)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from numpy import pi, sin
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series, weights
def sinwma(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Sine Weighted Moving Average (SWMA)
+4 -4
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import convolve, ndarray, ones
from pandas import Series
from pandas_ta._typing import Array, DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, np_prepend, verify_series
@@ -12,7 +13,7 @@ except ImportError:
@njit
def np_sma(x: ndarray, n: int):
def np_sma(x: Array, n: Int):
"""https://github.com/numba/numba/issues/4119"""
result = convolve(ones(n) / n, x)[n - 1:1 - n]
return np_prepend(result, n - 1)
@@ -32,9 +33,8 @@ def np_sma(x: ndarray, n: int):
def sma(
close: Series, length: int = None,
talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Simple Moving Average (SMA)
+3 -2
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.ma import ma
from pandas_ta.utils import get_offset, verify_series
def smma(
close: Series, length: int = None,
close: Series, length: Int = None,
mamode: str = None, talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""SMoothed Moving Average (SMMA)
+7 -6
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import copy, cos, exp, ndarray
from numpy import copy, cos, exp
from pandas import Series
from pandas_ta._typing import Array, DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
@@ -11,7 +12,7 @@ except ImportError:
@njit
def np_ssf(x: ndarray, n: int, pi: float, sqrt2: float):
def np_ssf(x: Array, n: Int, pi: IntFloat, sqrt2: IntFloat):
"""Ehler's Super Smoother Filter
http://traders.com/documentation/feedbk_docs/2014/01/traderstips.html
"""
@@ -28,7 +29,7 @@ def np_ssf(x: ndarray, n: int, pi: float, sqrt2: float):
@njit
def np_ssf_everget(x: ndarray, n: int, pi: float, sqrt2: float):
def np_ssf_everget(x: Array, n: Int, pi: IntFloat, sqrt2: IntFloat):
"""John F. Ehler's Super Smoother Filter by Everget (2 poles), Tradingview
https://www.tradingview.com/script/VdJy0yBJ-Ehlers-Super-Smoother-Filter/
"""
@@ -44,9 +45,9 @@ def np_ssf_everget(x: ndarray, n: int, pi: float, sqrt2: float):
def ssf(
close: Series, length: int = None,
everget: bool = None, pi: float = None, sqrt2: float = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
everget: bool = None, pi: IntFloat = None, sqrt2: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Ehler's Super Smoother Filter (SSF) © 2013
+6 -5
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import copy, cos, exp, ndarray
from numpy import copy, cos, exp
from pandas import Series
from pandas_ta._typing import Array, DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
try:
@@ -10,7 +11,7 @@ except ImportError:
@njit
def np_ssf3(x: ndarray, n: int, pi: float, sqrt3: float):
def np_ssf3(x: Array, n: Int, pi: IntFloat, sqrt3: IntFloat):
"""John F. Ehler's Super Smoother Filter by Everget (3 poles), Tradingview
https://www.tradingview.com/script/VdJy0yBJ-Ehlers-Super-Smoother-Filter/"""
m, result = x.size, copy(x)
@@ -31,9 +32,9 @@ def np_ssf3(x: ndarray, n: int, pi: float, sqrt3: float):
def ssf3(
close: Series, length: int = None,
pi: float = None, sqrt3: float = None,
offset=None, **kwargs
close: Series, length: Int = None,
pi: IntFloat = None, sqrt3: IntFloat = None,
offset: Int = None, **kwargs: DictLike
):
"""Ehler's 3 Pole Super Smoother Filter (SSF) © 2013
+3 -2
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.overlap import hl2
from pandas_ta.utils import get_offset, verify_series
from pandas_ta.volatility import atr
@@ -8,8 +9,8 @@ from pandas_ta.volatility import atr
def supertrend(
high: Series, low: Series, close: Series,
length: int = None, multiplier: float = None,
offset: int = None, **kwargs
length: Int = None, multiplier: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Supertrend (supertrend)
+3 -3
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, symmetric_triangle, verify_series, weights
def swma(
close: Series, length: int = None, asc: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Symmetric Weighted Moving Average (SWMA)
@@ -20,7 +21,6 @@ def swma(
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
asc (bool): Recent values weigh more. Default: True
offset (int): How many periods to offset the result. Default: 0
Kwargs:
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
from .ema import ema
def t3(
close: Series, length: int = None, a: float = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, a: IntFloat = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Tim Tillson's T3 Moving Average (T3)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
from .ema import ema
def tema(
close: Series, length: int = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Triple Exponential Moving Average (TEMA)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
from .sma import sma
def trima(
close: Series, length: int = None, talib: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, talib: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Triangular Moving Average (TRIMA)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from numpy import nan
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_drift, get_offset, verify_series
def vidya(
close: Series, length: int = None, drift: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None, drift: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Variable Index Dynamic Average (VIDYA)
+3 -2
View File
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int, List
from pandas_ta.overlap import hlc3
from pandas_ta.utils import get_offset, is_datetime_ordered, verify_series
def vwap(
high: Series, low: Series, close: Series, volume: Series,
anchor: str = None, bands: list = None,
offset: int = None, **kwargs
anchor: str = None, bands: List = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Volume Weighted Average Price (VWAP)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.overlap import sma
from pandas_ta.utils import get_offset, verify_series
def vwma(
close: Series, volume: Series, length: int = None,
offset: int = None, **kwargs
close: Series, volume: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Volume Weighted Moving Average (VWMA)
+2 -1
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
def wcp(
high: Series, low: Series, close: Series, talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Weighted Closing Price (WCP)
+3 -2
View File
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from numpy import arange, dot
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.maps import Imports
from pandas_ta.utils import get_offset, verify_series
def wma(
close: Series, length: int = None,
close: Series, length: Int = None,
asc: bool = None, talib: bool = None,
offset: int = None, **kwargs
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Weighted Moving Average (WMA)
+5 -3
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
from .dema import dema
from .ema import ema
@@ -22,7 +23,7 @@ from .wma import wma
# Not ideal but it works. Submit a PR for a better solution. =)
# This design pattern is undesirable
def _ma(mamode, **kwargs):
def _ma(mamode: str, **kwargs: DictLike):
if mamode == "dema":
return dema(**kwargs)
elif mamode == "fwma":
@@ -58,9 +59,10 @@ def _ma(mamode, **kwargs):
else:
return ema(**kwargs)
def zlma(
close: Series, length: int = None, mamode: str = None,
offset: int = None, **kwargs
close: Series, length: Int = None, mamode: str = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Zero Lag Moving Average (ZLMA)
+2 -1
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from numpy import log, seterr
from pandas import DataFrame, Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def drawdown(
close: Series, offset: int = None, **kwargs
close: Series, offset: Int = None, **kwargs: DictLike
) -> DataFrame:
"""Drawdown (DD)
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from pandas import Series
from numpy import log, nan, roll
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def log_return(
close: Series, length: int = None, cumulative: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, cumulative: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Log Return
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from numpy import nan, roll
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def percent_return(
close: Series, length: int = None, cumulative: bool = None,
offset: int = None, **kwargs
close: Series, length: Int = None, cumulative: bool = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Percent Return
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from numpy import log
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
def entropy(
close: Series, length: int = None, base: float = None,
offset: int = None, **kwargs
close: Series, length: Int = None, base: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Entropy (ENTP)
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def kurtosis(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Rolling Kurtosis
+3 -2
View File
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from numpy import fabs
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def mad(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Rolling Mean Absolute Deviation
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
def median(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Rolling Median
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int, IntFloat
from pandas_ta.utils import get_offset, verify_series
def quantile(
close: Series, length: int = None, q: float = None,
offset: int = None, **kwargs
close: Series, length: Int = None, q: IntFloat = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Rolling Quantile
+3 -2
View File
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from pandas import Series
from pandas_ta._typing import DictLike, Int
from pandas_ta.utils import get_offset, verify_series
def skew(
close: Series, length: int = None,
offset: int = None, **kwargs
close: Series, length: Int = None,
offset: Int = None, **kwargs: DictLike
) -> Series:
"""Rolling Skew

Some files were not shown because too many files have changed in this diff Show More