pybroker.vect module

Contains vectorized utility functions.

adx(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], lookback: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Average Directional Movement Index.

参数:
  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • lookback -- Number of lookback bars.

返回:

numpy.ndarray of computed values.

aroon_diff(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], lookback: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Aroon Upward Trend minus Aroon Downward Trend.

参数:
  • high -- High prices.

  • low -- Low prices.

  • lookback -- Number of lookback bars.

返回:

numpy.ndarray of computed values.

aroon_down(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], lookback: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Aroon Downward Trend.

参数:
  • high -- High prices.

  • low -- Low prices.

  • lookback -- Number of lookback bars.

返回:

numpy.ndarray of computed values.

aroon_up(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], lookback: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Aroon Upward Trend.

参数:
  • high -- High prices.

  • low -- Low prices.

  • lookback -- Number of lookback bars.

返回:

numpy.ndarray of computed values.

close_minus_ma(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], lookback: int, atr_length: int, scale: float = 1.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Close Minus Moving Average.

参数:
  • close -- Close prices.

  • high -- High prices.

  • low -- Low prices.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

cross(a: ndarray[tuple[int, ...], dtype[float64]], b: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[bool]][源代码]

Checks for crossover of a above b.

参数:
返回:

numpy.ndarray containing values of 1 when a crosses above b, otherwise values of 0.

cubic_deviation(values: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 0.6) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Deviation from Cubic Trend.

参数:
  • values -- numpy.ndarray of input.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 0.6.

返回:

numpy.ndarray of computed values ranging [-50, 50].

cubic_trend(values: ndarray[tuple[int, ...], dtype[float64]], high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], lookback: int, atr_length: int, scale: float = 1.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Cubic Trend Strength.

参数:
  • values -- numpy.ndarray of input.

  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

delta_on_balance_volume(close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, delta_length: int = 0, scale: float = 0.6) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Delta On-Balance Volume.

参数:
  • close -- Close prices.

  • volume -- Trading volume.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

detrended_rsi(values: ndarray[tuple[int, ...], dtype[float64]], short_length: int, long_length: int, reg_length: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Detrended Relative Strength Index (RSI).

参数:
  • values -- numpy.ndarray of input.

  • 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.

返回:

numpy.ndarray of computed values.

highv(array: ndarray[tuple[int, ...], dtype[float64]], n: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Calculates the highest values for every n period in array.

参数:
返回:

numpy.ndarray of the highest values for every n period in array.

intraday_intensity(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, smoothing: float = 0.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Intraday Intensity.

参数:
  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • volume -- Trading volume.

  • lookback -- Number of lookback bars.

  • smoothing -- Amount of smoothing; <= 1 for none. Defaults to 0.

返回:

numpy.ndarray of computed values.

inverse_normal_cdf(p: float) float[源代码]

Computes the inverse CDF of the standard normal distribution.

laguerre_rsi(open: ndarray[tuple[int, ...], dtype[float64]], high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], fe_length: int = 13) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Laguerre Relative Strength Index (RSI).

参数:
  • open -- Open prices.

  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • fe_length -- Fractal Energy length. Defaults to 13.

返回:

numpy.ndarray of computed values.

linear_deviation(values: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 0.6) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Deviation from Linear Trend.

参数:
  • values -- numpy.ndarray of input.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 0.6.

返回:

numpy.ndarray of computed values ranging [-50, 50].

linear_trend(values: ndarray[tuple[int, ...], dtype[float64]], high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], lookback: int, atr_length: int, scale: float = 1.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Linear Trend Strength.

参数:
  • values -- numpy.ndarray of input.

  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

lowv(array: ndarray[tuple[int, ...], dtype[float64]], n: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Calculates the lowest values for every n period in array.

参数:
返回:

numpy.ndarray of the lowest values for every n period in array.

macd(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], short_length: int, long_length: int, smoothing: float = 0.0, scale: float = 1.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Moving Average Convergence Divergence.

参数:
  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

money_flow(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, smoothing: float = 0.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Chaikin's Money Flow.

参数:
  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • volume -- Trading volume.

  • lookback -- Number of lookback bars.

  • smoothing -- Amount of smoothing; <= 1 for none. Defaults to 0.

返回:

numpy.ndarray of computed values.

normal_cdf(z: float) float[源代码]

Computes the CDF of the standard normal distribution.

normalized_negative_volume_index(close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 0.5) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Normalized Negative Volume Index.

参数:
  • close -- Close prices.

  • volume -- Trading volume.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 0.5.

返回:

numpy.ndarray of computed values ranging [-50, 50].

normalized_on_balance_volume(close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 0.6) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Normalized On-Balance Volume.

参数:
  • close -- Close prices.

  • volume -- Trading volume.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 0.6.

返回:

numpy.ndarray of computed values ranging [-50, 50].

normalized_positive_volume_index(close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 0.5) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Normalized Positive Volume Index.

参数:
  • close -- Close prices.

  • volume -- Trading volume.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 0.5.

返回:

numpy.ndarray of computed values ranging [-50, 50].

price_change_oscillator(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], short_length: int, multiplier: int, scale: float = 4.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Price Change Oscillator.

参数:
  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

price_intensity(open: ndarray[tuple[int, ...], dtype[float64]], high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], smoothing: float = 0.0, scale: float = 0.8) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Price Intensity.

参数:
  • open -- Open prices.

  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

price_volume_fit(close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 9.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Price Volume Fit.

参数:
  • close -- Close prices.

  • volume -- Trading volume.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 9.0.

返回:

numpy.ndarray of computed values ranging [-50, 50].

quadratic_deviation(values: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 0.6) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Deviation from Quadratic Trend.

参数:
  • values -- numpy.ndarray of input.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 0.6.

返回:

numpy.ndarray of computed values ranging [-50, 50].

quadratic_trend(values: ndarray[tuple[int, ...], dtype[float64]], high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], lookback: int, atr_length: int, scale: float = 1.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Quadratic Trend Strength.

参数:
  • values -- numpy.ndarray of input.

  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

reactivity(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, smoothing: float = 0.0, scale: float = 0.6) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Reactivity.

参数:
  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • volume -- Trading volume.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

returnv(array: ndarray[tuple[int, ...], dtype[float64]], n: int = 1) ndarray[tuple[int, ...], dtype[float64]][源代码]

Calculates returns.

参数:

n -- Return period. Defaults to 1.

返回:

numpy.ndarray of returns.

stochastic(high: ndarray[tuple[int, ...], dtype[float64]], low: ndarray[tuple[int, ...], dtype[float64]], close: ndarray[tuple[int, ...], dtype[float64]], lookback: int, smoothing: int = 0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Stochastic.

参数:
  • high -- High prices.

  • low -- Low prices.

  • close -- Close prices.

  • lookback -- Number of lookback bars.

  • smoothing -- Number of times the raw stochastic is smoothed, either 0, 1, or 2 times. Defaults to 0.

返回:

numpy.ndarray of computed values.

stochastic_rsi(values: ndarray[tuple[int, ...], dtype[float64]], rsi_lookback: int, sto_lookback: int, smoothing: float = 0.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Stochastic Relative Strength Index (RSI).

参数:
  • values -- numpy.ndarray of input.

  • rsi_lookback -- Lookback length for RSI calculation.

  • sto_lookback -- Lookback length for Stochastic calculation.

  • smoothing -- Amount of smoothing; <= 1 for none. Defaults to 0.

返回:

numpy.ndarray of computed values.

sumv(array: ndarray[tuple[int, ...], dtype[float64]], n: int) ndarray[tuple[int, ...], dtype[float64]][源代码]

Calculates the sums for every n period in array.

参数:
返回:

numpy.ndarray of the sums for every n period in array.

volume_momentum(volume: ndarray[tuple[int, ...], dtype[float64]], short_length: int, multiplier: int = 2, scale: float = 3.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Volume Momentum.

参数:
  • volume -- Trading volume.

  • 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.

返回:

numpy.ndarray of computed values ranging [-50, 50].

volume_weighted_ma_ratio(close: ndarray[tuple[int, ...], dtype[float64]], volume: ndarray[tuple[int, ...], dtype[float64]], lookback: int, scale: float = 1.0) ndarray[tuple[int, ...], dtype[float64]][源代码]

Computes Volume-Weighted Moving Average Ratio.

参数:
  • close -- Close prices.

  • volume -- Trading volume.

  • lookback -- Number of lookback bars.

  • scale -- Increase > 1.0 for more compression of return values, decrease < 1.0 for less. Defaults to 1.0.

返回:

numpy.ndarray of computed values ranging [-50, 50].