ursatoro/util

Types

pub type IndicatorError {
  InsufficientData(required: Int, got: Int)
  InvalidPeriod(period: Int)
  DivisionByZero
}

Constructors

  • InsufficientData(required: Int, got: Int)
  • InvalidPeriod(period: Int)
  • DivisionByZero

Values

pub fn bd_mean(
  values: List(bigdecimal.BigDecimal),
) -> Result(bigdecimal.BigDecimal, IndicatorError)
pub fn bd_sqrt(
  value: bigdecimal.BigDecimal,
) -> bigdecimal.BigDecimal

Square root via Newton’s method (Babylonian method). Returns zero for zero/negative inputs.

pub fn bd_stddev_population(
  values: List(bigdecimal.BigDecimal),
) -> Result(bigdecimal.BigDecimal, IndicatorError)
pub fn bd_to_float(value: bigdecimal.BigDecimal) -> Float
pub fn bds_to_floats(
  values: List(bigdecimal.BigDecimal),
) -> List(Float)
pub fn float_to_bd(value: Float) -> bigdecimal.BigDecimal
pub fn int_to_bd(value: Int) -> bigdecimal.BigDecimal
pub fn sma_values(
  values: List(bigdecimal.BigDecimal),
  period: Int,
) -> Result(List(bigdecimal.BigDecimal), IndicatorError)
pub fn true_range(
  prev: candle.Candle,
  current: candle.Candle,
) -> bigdecimal.BigDecimal
pub fn validate_length(
  items: List(a),
  required: Int,
) -> Result(Nil, IndicatorError)
pub fn validate_period(
  period: Int,
) -> Result(Nil, IndicatorError)
Search Document