backtrader.mathsupport module

Math Support Module - Mathematical functions for indicator calculations.

This module provides mathematical utility functions for calculating statistics used in technical indicators, such as average, variance, and standard deviation.

Functions:

average: Calculate arithmetic mean with optional Bessel's correction. variance: Calculate variance from a sequence. standarddev: Calculate standard deviation with Bessel's correction option.

备注

These functions are primarily used for indicator calculations. For large datasets, numpy-based implementations would provide better performance.

backtrader.mathsupport.average(x, bessel=False)[源代码]

:param : param x: iterable with len :param : param bessel: default False, reduces the length of the array for the

division.

返回:

A float with the average of the elements of x

backtrader.mathsupport.variance(x, avgx=None)[源代码]
参数:
  • x -- iterable with len

  • avgx -- average of x

返回:

A list with the variance for each element of x

backtrader.mathsupport.standarddev(x, avgx=None, bessel=False)[源代码]
参数:
  • x -- iterable with len

  • avgx -- average of x

  • bessel -- (default False) to be passed to the average to divide by

  • 1 (N -)

返回:

A float with the standard deviation of the elements of x