yiii0012/moontalib/base does not have a README file

    TaError

    pub(all) suberror TaError {
    EmptyInput
    MismatchedLength(String)
    InvalidPeriod(String)
    NotEnoughData(String)
    }

    Errors raised by moontalib functions. TaError::to_string gives a human-readable message.

    TaError::to_string

    fn TaError::to_string(self : TaError) -> String

    Human-readable description of the error.

    Candle

    pub(all) struct Candle {
    open : Double
    high : Double
    low : Double
    close : Double
    volume : Double
    }

    A single OHLCV bar (open, high, low, close, volume). Constructible from any package (pub(all)); struct fields are public by default.

    Candles

    pub(all) struct Candles {
    open : Array[Double]
    high : Array[Double]
    low : Array[Double]
    close : Array[Double]
    volume : Array[Double]
    }

    Column-oriented OHLCV series. All five arrays must have equal length; indicator functions validate this and return Err(MismatchedLength) otherwise. Constructible from any package (pub(all)).

    Candles::from_bars

    fn Candles::from_bars(bars : Array[Candle]) -> Candles

    Builds a column-oriented series from a row-oriented bar list.

    Candles::length

    fn Candles::length(self : Candles) -> Int

    Number of bars in the series (taken from the close column).

    MAType

    pub(all) enum MAType {
    Sma
    Ema
    }

    Moving-average flavor used by APO/PPO and the moving_average dispatcher. Constructible from any package (pub(all)).

    is_nan

    fn is_nan(x : Double) -> Bool

    Returns true when the value is NaN.

    isqrt

    fn isqrt(n : Int) -> Int

    Integer square root (floor of the square root), used by HMA to size its final WMA window.

    nan

    fn nan() -> Double

    Quiet NaN used to mark positions where an indicator has no value yet.

    rolling_argmax

    fn rolling_argmax(data : Array[Double], period : Int) -> Array[Int] raise TaError

    Index of the most recent maximum inside each window (0-based), or -1 when the window contains NaN; computed in O(n).

    rolling_argmin

    fn rolling_argmin(data : Array[Double], period : Int) -> Array[Int] raise TaError

    Index of the most recent minimum inside each window (0-based), or -1 when the window contains NaN; computed in O(n).

    rolling_max

    fn rolling_max(data : Array[Double], period : Int) -> Array[Double] raise TaError

    Rolling maximum over a window of period values, computed in O(n). Ties resolve to the most recent bar; a window containing NaN yields NaN; the output has the same length as the input with a period - 1 leading NaN prefix.

    rolling_min

    fn rolling_min(data : Array[Double], period : Int) -> Array[Double] raise TaError

    Rolling minimum over a window of period values, computed in O(n).

    rolling_sum

    fn rolling_sum(data : Array[Double], period : Int) -> Array[Double] raise TaError

    Rolling sum over a window of period values, computed in O(n).

    Implemented as a running sum with an exact re-accumulation every period bars (and whenever a NaN leaves the window), which bounds floating-point drift to roughly one slide. A window containing NaN yields NaN; the output has the same length as the input with a period - 1 leading NaN prefix.

    true_range

    fn true_range(candles : Candles, i : Int) -> Double

    True range of bar i: high - low for the first bar, otherwise the greatest of high - low, |high - prev_close| and |low - prev_close|. Any NaN component yields NaN.

    validate_candles

    fn validate_candles(candles : Candles) -> Unit raise TaError

    Shared validation for a Candles series: non-empty and equal-length columns.

    validate_series

    fn validate_series(data : Array[Double], period : Int) -> Unit raise TaError

    Shared validation for a single price series plus a window length: the input must be non-empty and the period positive and not larger than the input. Indicators are otherwise graceful — positions without a full window are simply NaN in the output.