pybroker.indicator module
Contains indicator related functionality.
- class Indicator(name: str, fn: Callable[[...], ndarray[tuple[int, ...], dtype[float64]]], kwargs: dict[str, Any])[源代码]
基类:
object
Class representing an indicator.
- 参数:
name -- Name of indicator.
fn --
Callable
used to compute the series of indicator values.kwargs --
dict
of kwargs to pass tofn
.
- class IndicatorSet[源代码]
-
Computes data for multiple indicators.
- __call__(df: DataFrame, disable_parallel: bool = False) DataFrame [源代码]
Computes indicator data.
- 参数:
df --
pandas.DataFrame
of input data.disable_parallel -- If
True
, indicator data is computed serially. IfFalse
, indicator data is computed in parallel using multiple processes. Defaults toFalse
.
- 返回:
pandas.DataFrame
containing the computed indicator data.
- class IndicatorsMixin[源代码]
基类:
object
Mixin implementing indicator related functionality.
- compute_indicators(df: DataFrame, indicator_syms: Iterable[IndicatorSymbol], cache_date_fields: CacheDateFields | None, disable_parallel: bool) dict[IndicatorSymbol, Series] [源代码]
Computes indicator data for the provided
pybroker.common.IndicatorSymbol
pairs.- 参数:
df --
pandas.DataFrame
used to compute the indicator values.indicator_syms --
Iterable
ofpybroker.common.IndicatorSymbol
pairs of indicators to compute.cache_date_fields -- Date fields used to key cache data. Pass
None
to disable caching.disable_parallel -- If
True
, indicator data is computed serially for allpybroker.common.IndicatorSymbol
pairs. IfFalse
, indicator data is computed in parallel using multiple processes.
- 返回:
dict
mapping eachpybroker.common.IndicatorSymbol
pair to a computedpandas.Series
of indicator values.
- adx(name: str, lookback: int) Indicator [源代码]
Average Directional Movement Index.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
- 返回:
Average Directional Movement Index
Indicator
.
- aroon_diff(name: str, lookback: int) Indicator [源代码]
Aroon Upward Trend minus Aroon Downward Trend.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
- 返回:
Aroon Upward Trend minus Aroon Downward Trend
Indicator
.
- aroon_down(name: str, lookback: int) Indicator [源代码]
Aroon Downward Trend.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
- 返回:
Aroon Downward Trend
Indicator
.
- aroon_up(name: str, lookback: int) Indicator [源代码]
Aroon Upward Trend.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
- 返回:
Aroon Upward Trend
Indicator
.
- close_minus_ma(name: str, lookback: int, atr_length: int, scale: float = 1.0) Indicator [源代码]
Close Minus Moving Average.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
atr_length -- Lookback length used for Average True Range (ATR) normalization.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
1.0
.
- 返回:
Close Minus Moving Average
Indicator
.
- cubic_deviation(name: str, field: str, lookback: int, scale: float = 0.6) Indicator [源代码]
Deviation from Cubic Trend.
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.6
.
- 返回:
Deviation from Cubic Trend
Indicator
.
- cubic_trend(name: str, field: str, lookback: int, atr_length: int, scale: float = 1.0) Indicator [源代码]
Cubic Trend Strength.
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.lookback -- Number of lookback bars.
atr_length -- Lookback length used for Average True Range (ATR) normalization.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
1.0
.
- 返回:
Cubic Trend Strength
Indicator
.
- delta_on_balance_volume(name: str, lookback: int, delta_length: int = 0, scale: float = 0.6) Indicator [源代码]
Delta On-Balance Volume.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
delta_length -- Lag for differencing.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.6
.
- 返回:
Delta On-Balance Volume
Indicator
.
- detrended_rsi(name: str, field: str, short_length: int, long_length: int, reg_length: int) Indicator [源代码]
Detrended Relative Strength Index (RSI).
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.short_length -- Lookback for the short-term RSI.
long_length -- Lookback for the long-term RSI.
reg_length -- Number of bars used for linear regressions.
- 返回:
Detrended RSI
Indicator
.
- highest(name: str, field: str, period: int) Indicator [源代码]
Creates a rolling high
Indicator
.- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field for computing the rolling high.period -- Lookback period.
- 返回:
Rolling high
Indicator
.
- indicator(name: str, fn: Callable[[...], ndarray[tuple[int, ...], dtype[float64]]], **kwargs) Indicator [源代码]
Creates an
Indicator
instance and registers it globally withname
.- 参数:
name -- Name for referencing the indicator globally.
fn --
Callable[[BarData, ...], NDArray[float]]
used to compute the series of indicator values.**kwargs -- Additional arguments to pass to
fn
.
- 返回:
Indicator
instance.
- intraday_intensity(name: str, lookback: int, smoothing: float = 0.0) Indicator [源代码]
Intraday Intensity.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
smoothing -- Amount of smoothing; <= 1 for none. Defaults to
0
.
- 返回:
Intraday Intensity
Indicator
.
- laguerre_rsi(name: str, fe_length: int = 13) Indicator [源代码]
Laguerre Relative Strength Index (RSI).
- 参数:
name -- Indicator name.
fe_length -- Fractal Energy length. Defaults to
13
.
- 返回:
Laguerre RSI
Indicator
.
- linear_deviation(name: str, field: str, lookback: int, scale: float = 0.6) Indicator [源代码]
Deviation from Linear Trend.
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.6
.
- 返回:
Deviation from Linear Trend
Indicator
.
- linear_trend(name: str, field: str, lookback: int, atr_length: int, scale: float = 1.0) Indicator [源代码]
Linear Trend Strength.
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.lookback -- Number of lookback bars.
atr_length -- Lookback length used for Average True Range (ATR) normalization.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
1.0
.
- 返回:
Linear Trend Strength
Indicator
.
- lowest(name: str, field: str, period: int) Indicator [源代码]
Creates a rolling low
Indicator
.- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field for computing the rolling low.period -- Lookback period.
- 返回:
Rolling low
Indicator
.
- macd(name: str, short_length: int, long_length: int, smoothing: float = 0.0, scale: float = 1.0) Indicator [源代码]
Moving Average Convergence Divergence.
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.short_length -- Short-term lookback.
long_length -- Long-term lookback.
smoothing -- Compute MACD minus smoothed if >= 2.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
1.0
.
- 返回:
Moving Average Convergence Divergence
Indicator
.
- money_flow(name: str, lookback: int, smoothing: float = 0.0) Indicator [源代码]
Chaikin's Money Flow.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
smoothing -- Amount of smoothing; <= 1 for none. Defaults to
0
.
- 返回:
Chaikin's Money Flow
Indicator
.
- normalized_negative_volume_index(name: str, lookback: int, scale: float = 0.5) Indicator [源代码]
Normalized Negative Volume Index.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.5
.
- 返回:
Normalized Negative Volume Index
Indicator
.
- normalized_on_balance_volume(name: str, lookback: int, scale: float = 0.6) Indicator [源代码]
Normalized On-Balance Volume.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.6
.
- 返回:
Normalized On-Balance Volume
Indicator
.
- normalized_positive_volume_index(name: str, lookback: int, scale: float = 0.5) Indicator [源代码]
Normalized Positive Volume Index.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.5
.
- 返回:
Normalized Positive Volume Index
Indicator
.
- price_change_oscillator(name: str, short_length: int, multiplier: int, scale: float = 4.0) Indicator [源代码]
Price Change Oscillator.
- 参数:
name -- Indicator name.
short_length -- Number of short lookback bars.
multiplier -- Multiplier used to compute number of long lookback bars =
multiplier * short_length
.scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
4.0
.
- 返回:
Price Change Oscillator
Indicator
.
- price_intensity(name: str, smoothing: float = 0.0, scale: float = 0.8) Indicator [源代码]
Price Intensity.
- 参数:
name -- Indicator name.
smoothing -- Amount of smoothing. Defaults to
0
.scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.8
.
- 返回:
Price Intensity
Indicator
.
- price_volume_fit(name: str, lookback: int, scale: float = 9.0) Indicator [源代码]
Price Volume Fit.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
9.0
.
- 返回:
Price Volume Fit
Indicator
.
- quadratic_deviation(name: str, field: str, lookback: int, scale: float = 0.6) Indicator [源代码]
Deviation from Quadratic Trend.
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.6
.
- 返回:
Deviation from Quadratic Trend
Indicator
.
- quadratic_trend(name: str, field: str, lookback: int, atr_length: int, scale: float = 1.0) Indicator [源代码]
Quadratic Trend Strength.
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.lookback -- Number of lookback bars.
atr_length -- Lookback length used for Average True Range (ATR) normalization.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
1.0
.
- 返回:
Quadratic Trend Strength
Indicator
.
- reactivity(name: str, lookback: int, smoothing: float = 0.0, scale: float = 0.6) Indicator [源代码]
Reactivity.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
smoothing -- Smoothing multiplier.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
0.6
.
- 返回:
Reactivity
Indicator
.
- returns(name: str, field: str, period: int = 1) Indicator [源代码]
Creates a rolling returns
Indicator
.- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field for computing the rolling returns.period -- Returns period. Defaults to 1.
- 返回:
Rolling returns
Indicator
.
- stochastic(name: str, lookback: int, smoothing: int = 0) Indicator [源代码]
Stochastic.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
smoothing -- Number of times the raw stochastic is smoothed, either 0, 1, or 2 times. Defaults to
0
.
- 返回:
Stochastic
Indicator
.
- stochastic_rsi(name: str, field: str, rsi_lookback: int, sto_lookback: int, smoothing: float = 0.0) Indicator [源代码]
Stochastic Relative Strength Index (RSI).
- 参数:
name -- Indicator name.
field --
pybroker.common.BarData
field name.rsi_lookback -- Lookback length for RSI calculation.
sto_lookback -- Lookback length for Stochastic calculation.
smoothing -- Amount of smoothing; <= 1 for none. Defaults to
0
.
- 返回:
Stochastic RSI
Indicator
.
- volume_momentum(name: str, short_length: int, multiplier: int = 2, scale: float = 3.0) Indicator [源代码]
Volume Momentum.
- 参数:
name -- Indicator name.
short_length -- Number of short lookback bars.
multiplier -- Lookback multiplier. Defaults to
2
.scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
3.0
.
- 返回:
Volume Momentum
Indicator
.
- volume_weighted_ma_ratio(name: str, lookback: int, scale: float = 1.0) Indicator [源代码]
Volume-Weighted Moving Average Ratio.
- 参数:
name -- Indicator name.
lookback -- Number of lookback bars.
scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to
1.0
.
- 返回:
Volume-Weighted Moving Average Ratio
Indicator
.