mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-08-15 12:45:08 +08:00
done ?
This commit is contained in:
+37
-2
@@ -6,6 +6,7 @@ name = "pandas_ta"
|
||||
# Dictionaries and version
|
||||
from pandas_ta.maps import EXCHANGE_TZ, RATE, Category, Imports, version
|
||||
from pandas_ta.utils import *
|
||||
from pandas_ta.utils import __all__ as utils_all
|
||||
|
||||
# Flat Structure. Supports ta.ema() or ta.overlap.ema() calls.
|
||||
from pandas_ta.candles import *
|
||||
@@ -18,6 +19,16 @@ from pandas_ta.transform import *
|
||||
from pandas_ta.trend import *
|
||||
from pandas_ta.volatility import *
|
||||
from pandas_ta.volume import *
|
||||
from pandas_ta.candles import __all__ as candles_all
|
||||
from pandas_ta.cycles import __all__ as cycles_all
|
||||
from pandas_ta.momentum import __all__ as momentum_all
|
||||
from pandas_ta.overlap import __all__ as overlap_all
|
||||
from pandas_ta.performance import __all__ as performance_all
|
||||
from pandas_ta.statistics import __all__ as statistics_all
|
||||
from pandas_ta.transform import __all__ as transform_all
|
||||
from pandas_ta.trend import __all__ as trend_all
|
||||
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()
|
||||
from pandas_ta.ma import ma
|
||||
@@ -28,5 +39,29 @@ from pandas_ta.custom import create_dir, import_dir
|
||||
# Enable "ta" DataFrame Extension
|
||||
from pandas_ta.core import AnalysisIndicators
|
||||
|
||||
# Empty DataFrame Alias. Example: df = ta.df vs. df = pd.DataFrame()
|
||||
df = DataFrame()
|
||||
__all__ = [
|
||||
'name',
|
||||
'EXCHANGE_TZ',
|
||||
'RATE',
|
||||
'Category',
|
||||
'Imports',
|
||||
'version',
|
||||
'ma',
|
||||
'create_dir',
|
||||
'import_dir',
|
||||
'AnalysisIndicators',
|
||||
]
|
||||
|
||||
__all__ += (
|
||||
utils_all
|
||||
+ candles_all
|
||||
+ cycles_all
|
||||
+ momentum_all
|
||||
+ overlap_all
|
||||
+ performance_all
|
||||
+ statistics_all
|
||||
+ transform_all
|
||||
+ trend_all
|
||||
+ volatility_all
|
||||
+ volume_all
|
||||
)
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
from pandas import Series
|
||||
from pandas_ta.utils._core import non_zero_range
|
||||
|
||||
__all__ = [
|
||||
'candle_color',
|
||||
'high_low_range',
|
||||
'real_body',
|
||||
]
|
||||
|
||||
|
||||
def candle_color(open_: Series, close: Series) -> Series:
|
||||
"""Candle Change
|
||||
|
||||
@@ -12,6 +12,21 @@ from pandas_ta._typing import Int, IntFloat, ListStr, Union
|
||||
from pandas_ta.utils._validate import v_bool, v_pos_default, v_series
|
||||
from pandas_ta.maps import Imports
|
||||
|
||||
__all__ = [
|
||||
'camelCase2Title',
|
||||
'category_files',
|
||||
'non_zero_range',
|
||||
'recent_maximum_index',
|
||||
'recent_minimum_index',
|
||||
'rma_pandas',
|
||||
'signed_series',
|
||||
'simplify_columns',
|
||||
'tal_ma',
|
||||
'unsigned_differences',
|
||||
'ms2secs',
|
||||
'speed_test',
|
||||
]
|
||||
|
||||
|
||||
def camelCase2Title(x: str):
|
||||
"""https://stackoverflow.com/questions/5020906/python-convert-camel-case-to-space-delimited-using-regex-and-taking-acronyms-in"""
|
||||
|
||||
@@ -20,6 +20,22 @@ from pandas_ta._typing import (
|
||||
from pandas_ta.maps import Imports
|
||||
from pandas_ta.utils._validate import v_series
|
||||
|
||||
__all__ = [
|
||||
'fibonacci',
|
||||
'erf',
|
||||
'combination',
|
||||
'geometric_mean',
|
||||
'hpoly',
|
||||
'linear_regression',
|
||||
'log_geometric_mean',
|
||||
'pascals_triangle',
|
||||
'strided_window',
|
||||
'symmetric_triangle',
|
||||
'weights',
|
||||
'zero',
|
||||
'df_error_analysis',
|
||||
]
|
||||
|
||||
|
||||
def combination(
|
||||
n: Int = 1, r: Int = 0,
|
||||
@@ -40,7 +56,6 @@ def combination(
|
||||
denominator = reduce(mul, range(1, r + 1), 1)
|
||||
return numerator // denominator
|
||||
|
||||
|
||||
def erf(x: IntFloat) -> Float:
|
||||
"""Error Function erf(x)
|
||||
The algorithm comes from Handbook of Mathematical Functions, formula 7.1.26.
|
||||
@@ -63,7 +78,6 @@ def erf(x: IntFloat) -> Float:
|
||||
* t + a1) * t * exp(-x * x)
|
||||
return x_sign * y # erf(-x) = -erf(x)
|
||||
|
||||
|
||||
def fibonacci(
|
||||
n: Int = 2, weighted: bool = False, zero: bool = False
|
||||
) -> Array:
|
||||
@@ -90,7 +104,6 @@ def fibonacci(
|
||||
else:
|
||||
return result
|
||||
|
||||
|
||||
def geometric_mean(series: Series) -> Float:
|
||||
"""Returns the Geometric Mean for a Series of positive values."""
|
||||
n = series.size
|
||||
|
||||
@@ -8,6 +8,20 @@ from pandas_ta.utils._validate import v_series
|
||||
from pandas_ta.utils._math import linear_regression, log_geometric_mean
|
||||
from pandas_ta.utils._time import total_time
|
||||
|
||||
__all__ = [
|
||||
'cagr',
|
||||
'calmar_ratio',
|
||||
'downside_deviation',
|
||||
'jensens_alpha',
|
||||
'log_max_drawdown',
|
||||
'max_drawdown'
|
||||
'volatility',
|
||||
'sortino_ratio',
|
||||
'sharpe_ratio',
|
||||
'pure_profit_score',
|
||||
'optimal_leverage',
|
||||
]
|
||||
|
||||
|
||||
def cagr(close: Series) -> IntFloat:
|
||||
"""Compounded Annual Growth Rate
|
||||
@@ -172,7 +186,6 @@ def optimal_leverage(
|
||||
amount = int(capital * opt_leverage)
|
||||
return amount
|
||||
|
||||
|
||||
def pure_profit_score(close: Series) -> IntFloat:
|
||||
"""Pure Profit Score of a series.
|
||||
|
||||
@@ -189,7 +202,6 @@ def pure_profit_score(close: Series) -> IntFloat:
|
||||
return r * cagr(close)
|
||||
return 0
|
||||
|
||||
|
||||
def sharpe_ratio(
|
||||
close: Series, benchmark_rate: IntFloat = 0.0, log: bool = False,
|
||||
use_cagr: bool = False, period: IntFloat = RATE["TRADING_DAYS_PER_YEAR"]
|
||||
@@ -223,7 +235,6 @@ def sharpe_ratio(
|
||||
period_std = sqrt(period) * returns.std()
|
||||
return (period_mu - benchmark_rate) / period_std
|
||||
|
||||
|
||||
def sortino_ratio(
|
||||
close: Series, benchmark_rate: IntFloat = 0.0, log: bool = False
|
||||
) -> IntFloat:
|
||||
@@ -249,7 +260,6 @@ def sortino_ratio(
|
||||
result /= downside_deviation(returns)
|
||||
return result
|
||||
|
||||
|
||||
def volatility(
|
||||
close: Series, tf: str = "years", returns: bool = False, log: bool = False
|
||||
) -> IntFloat:
|
||||
|
||||
@@ -8,6 +8,12 @@ try:
|
||||
except ImportError:
|
||||
def njit(_): return _
|
||||
|
||||
__all__ = [
|
||||
'np_prepend',
|
||||
'np_rolling',
|
||||
'np_shift',
|
||||
]
|
||||
|
||||
|
||||
# Utilities
|
||||
@njit
|
||||
|
||||
@@ -4,6 +4,16 @@ from pandas_ta._typing import DictLike, Int, IntFloat
|
||||
from pandas_ta.utils._validate import v_offset, v_series
|
||||
from pandas_ta.utils._math import zero
|
||||
|
||||
__all__ = [
|
||||
'above',
|
||||
'above_value',
|
||||
'below',
|
||||
'below_value',
|
||||
'cross',
|
||||
'cross_value',
|
||||
'signals',
|
||||
]
|
||||
|
||||
|
||||
def _above_below(
|
||||
series_a: Series, series_b: Series,
|
||||
|
||||
@@ -4,6 +4,10 @@ from pandas_ta._typing import Array, IntFloat, Number, Union
|
||||
from pandas_ta.maps import Imports
|
||||
from pandas_ta.utils import hpoly
|
||||
|
||||
__all__ = [
|
||||
'inv_norm',
|
||||
]
|
||||
|
||||
|
||||
def _gaussian_poly_coefficients() -> Array:
|
||||
"""Three pairs of Polynomial Approximation Coefficients
|
||||
|
||||
@@ -5,6 +5,15 @@ from dataclasses import dataclass, field
|
||||
from pandas_ta._typing import Int, List
|
||||
from pandas_ta.utils._time import get_time
|
||||
|
||||
__all__ = [
|
||||
'Study',
|
||||
'AllStudy',
|
||||
'CommonStudy',
|
||||
'Strategy',
|
||||
'AllStrategy',
|
||||
'CommonStrategy',
|
||||
]
|
||||
|
||||
|
||||
# Study DataClass
|
||||
@dataclass
|
||||
|
||||
@@ -6,6 +6,21 @@ from pandas import DataFrame, Series, Timestamp, to_datetime
|
||||
from pandas_ta._typing import Float, MaybeSeriesFrame, Optional, Tuple, Union
|
||||
from pandas_ta.maps import EXCHANGE_TZ, RATE
|
||||
|
||||
__all__ = [
|
||||
'df_dates',
|
||||
'df_month_to_date',
|
||||
'df_quarter_to_date',
|
||||
'df_year_to_date',
|
||||
'final_time',
|
||||
'get_time',
|
||||
'total_time',
|
||||
'to_utc',
|
||||
'unix_convert'
|
||||
'mtd',
|
||||
'qtd',
|
||||
'ytd',
|
||||
]
|
||||
|
||||
|
||||
def df_dates(
|
||||
df: DataFrame, dates: Tuple[str, list] = None
|
||||
|
||||
@@ -12,6 +12,28 @@ from pandas_ta._typing import (
|
||||
SeriesFrame
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'is_percent',
|
||||
'v_bool',
|
||||
'v_dataframe',
|
||||
'v_float',
|
||||
'v_int',
|
||||
'v_str',
|
||||
'v_ascending',
|
||||
'v_datetime_ordered',
|
||||
'v_drift',
|
||||
'v_list',
|
||||
'v_lowerbound',
|
||||
'v_mamode',
|
||||
'v_offset',
|
||||
'v_pos_default',
|
||||
'v_scalar',
|
||||
'v_series',
|
||||
'v_talib',
|
||||
'v_tradingview',
|
||||
'v_upperbound',
|
||||
]
|
||||
|
||||
|
||||
def is_percent(x: IntFloat) -> bool:
|
||||
if isinstance(x, (int, float)):
|
||||
|
||||
@@ -18,3 +18,25 @@ from .vp import vp
|
||||
from .vwap import vwap
|
||||
from .vwma import vwma
|
||||
from .wb_tsv import wb_tsv
|
||||
|
||||
__all__ = [
|
||||
'ad',
|
||||
'adosc',
|
||||
'aobv',
|
||||
'cmf',
|
||||
'efi',
|
||||
'eom',
|
||||
'kvo',
|
||||
'mfi',
|
||||
'nvi',
|
||||
'obv',
|
||||
'pvi',
|
||||
'pvo',
|
||||
'pvol',
|
||||
'pvr',
|
||||
'pvt',
|
||||
'vp',
|
||||
'vwap',
|
||||
'vwma',
|
||||
'wb_tsv',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user