mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-08-16 11:25:01 +08:00
both performance and statistics indicators fully typed
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from numpy import log as nplog
|
||||
from numpy import seterr
|
||||
from pandas import DataFrame
|
||||
from pandas import DataFrame, Series
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
|
||||
def drawdown(close, offset=None, **kwargs) -> DataFrame:
|
||||
def drawdown(close: Series, offset: int = None, **kwargs) -> DataFrame:
|
||||
"""Drawdown (DD)
|
||||
|
||||
Drawdown is a peak-to-trough decline during a specific period for an investment,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from numpy import log as nplog
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def log_return(close, length=None, cumulative=None, offset=None, **kwargs):
|
||||
def log_return(close: Series, length: int = None, cumulative: bool = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Log Return
|
||||
|
||||
Calculates the logarithmic return of a Series.
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def percent_return(close, length=None, cumulative=None, offset=None, **kwargs):
|
||||
def percent_return(close: Series, length: int = None, cumulative: bool = None, offset: int = None,
|
||||
**kwargs) -> Series:
|
||||
"""Percent Return
|
||||
|
||||
Calculates the percent return of a Series.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from numpy import log as npLog
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def entropy(close, length=None, base=None, offset=None, **kwargs):
|
||||
def entropy(close: Series, length: int = None, base: float = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Entropy (ENTP)
|
||||
|
||||
Introduced by Claude Shannon in 1948, entropy measures the unpredictability
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def kurtosis(close, length=None, offset=None, **kwargs):
|
||||
def kurtosis(close: Series, length: int = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Rolling Kurtosis
|
||||
|
||||
Calculates the Kurtosis over a rolling period.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from numpy import fabs as npfabs
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def mad(close, length=None, offset=None, **kwargs):
|
||||
def mad(close: Series, length: int = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Rolling Mean Absolute Deviation
|
||||
|
||||
Calculates the Mean Absolute Deviation over a rolling period.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def median(close, length=None, offset=None, **kwargs):
|
||||
def median(close: Series, length: int = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Rolling Median
|
||||
|
||||
Calculates the Median over a rolling period. Sibling of a Simple Moving Average.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def quantile(close, length=None, q=None, offset=None, **kwargs):
|
||||
def quantile(close: Series, length: int = None, q: float = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Rolling Quantile
|
||||
|
||||
Calculates the Quantile over a rolling period.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def skew(close, length=None, offset=None, **kwargs):
|
||||
def skew(close: Series, length: int = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Rolling Skew
|
||||
|
||||
Calculates the Skew over a rolling period.
|
||||
|
||||
@@ -3,9 +3,11 @@ from numpy import sqrt as npsqrt
|
||||
from .variance import variance
|
||||
from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def stdev(close, length=None, ddof=None, talib=None, offset=None, **kwargs):
|
||||
def stdev(close: Series, length: int = None, ddof: int = None, talib: bool = None, offset: int = None,
|
||||
**kwargs) -> Series:
|
||||
"""Rolling Standard Deviation
|
||||
|
||||
Calculates the Standard Deviation over a rolling period.
|
||||
|
||||
@@ -7,7 +7,9 @@ from pandas import DataFrame, DatetimeIndex, Series
|
||||
from .stdev import stdev as stdev
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
def tos_stdevall(close, length=None, stds=None, ddof=None, offset=None, **kwargs):
|
||||
|
||||
def tos_stdevall(close: Series, length: int = None, stds: list = None, ddof: int = None, offset: int = None,
|
||||
**kwargs) -> DataFrame:
|
||||
"""TD Ameritrade's Think or Swim Standard Deviation All (TOS_STDEV)
|
||||
|
||||
A port of TD Ameritrade's Think or Swim Standard Deviation All indicator which
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pandas_ta import Imports
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def variance(close, length=None, ddof=None, talib=None, offset=None, **kwargs):
|
||||
def variance(close: Series, length: int = None, ddof: int = None, talib: bool = None, offset: int = None,
|
||||
**kwargs) -> Series:
|
||||
"""Rolling Variance
|
||||
|
||||
Calculates the Variance over a rolling period.
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
from pandas_ta.overlap import sma
|
||||
from .stdev import stdev
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
from pandas import Series
|
||||
|
||||
|
||||
def zscore(close, length=None, std=None, offset=None, **kwargs):
|
||||
def zscore(close: Series, length: int = None, std: float = None, offset: int = None, **kwargs) -> Series:
|
||||
"""Rolling Z Score
|
||||
|
||||
Calculates the Z Score over a rolling period.
|
||||
|
||||
Reference in New Issue
Block a user