Class BarSeries

java.lang.Object
com.quantfinlib.core.BarSeries

public final class BarSeries extends Object
Immutable, cache-friendly OHLCV time series backed by primitive arrays (structure-of-arrays layout, no boxing) for ultra-low-latency computation.

Array accessors (opens(), closes(), ...) return the internal arrays without copying for zero-allocation hot paths. Callers must treat them as read-only.

  • Method Details

    • builder

      public static BarSeries.Builder builder(String symbol)
    • of

      public static BarSeries of(String symbol, double[] closes)
      Builds a series from close prices only (open = high = low = close).
    • fromBars

      public static BarSeries fromBars(String symbol, List<Bar> bars)
    • symbol

      public String symbol()
    • size

      public int size()
    • timestamp

      public long timestamp(int i)
    • open

      public double open(int i)
    • high

      public double high(int i)
    • low

      public double low(int i)
    • close

      public double close(int i)
    • volume

      public double volume(int i)
    • lastClose

      public double lastClose()
    • bar

      public Bar bar(int i)
    • timestamps

      public long[] timestamps()
      Zero-copy accessors: internal arrays, treat as read-only.
    • opens

      public double[] opens()
    • highs

      public double[] highs()
    • lows

      public double[] lows()
    • closes

      public double[] closes()
    • volumes

      public double[] volumes()
    • slice

      public BarSeries slice(int from, int toExclusive)
      Copy of the bar range [from, toExclusive) as a new series (for train/test splits).
    • returns

      public double[] returns()
      Simple (arithmetic) returns; length = size - 1.
    • logReturns

      public double[] logReturns()
      Log returns; length = size - 1.