Class BarSeries
java.lang.Object
com.quantfinlib.core.BarSeries
Immutable, cache-friendly OHLCV time series backed by primitive arrays
(structure-of-arrays layout, no boxing) so indicators read primitive columns directly.
The column arrays never leave the object. Indexed accessors such as
close(int) read one element without allocating; whole columns are
available as copies (closesCopy(), ...) or copied into a reusable
caller buffer with copyClosesInto(double[], int, int).
A bar can be flagged synthetic: a placeholder created by
alignment (for example data.SeriesAligner.unionForwardFill carrying
the last close across a halt or a listing gap) rather than a bar that
traded. Estimators of volatility, average volume and impact should skip
synthetic bars, since a flat zero-volume bar shrinks both. Series built
without the flag report every bar as real.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbar(int i) static BarSeries.Builderdoubleclose(int i) double[]A fresh copy of the close column.voidcopyClosesInto(double[] dst, int from, int len) Copies closes[from, from + len)intodst[0, len)without allocating.static BarSeriesbooleanfalseguarantees that no bar is synthetic;truemeans some may be.doublehigh(int i) double[]A fresh copy of the high column.booleanisSynthetic(int i) Whether bariis an alignment placeholder rather than a traded bar.doubledouble[]Log returns; length = size - 1.doublelow(int i) double[]lowsCopy()A fresh copy of the low column.static BarSeriesBuilds a series from close prices only (open = high = low = close).doubleopen(int i) double[]A fresh copy of the open column.double[]returns()Simple (arithmetic) returns; length = size - 1.intsize()slice(int from, int toExclusive) Copy of the bar range [from, toExclusive) as a new series (for train/test splits).symbol()longtimestamp(int i) long[]A fresh copy of the timestamp column.doublevolume(int i) double[]A fresh copy of the volume column.
-
Method Details
-
builder
-
of
-
fromBars
-
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
-
isSynthetic
public boolean isSynthetic(int i) Whether bariis an alignment placeholder rather than a traded bar. -
hasSyntheticBars
public boolean hasSyntheticBars()falseguarantees that no bar is synthetic;truemeans some may be. -
timestampsCopy
public long[] timestampsCopy()A fresh copy of the timestamp column. -
opensCopy
public double[] opensCopy()A fresh copy of the open column. -
highsCopy
public double[] highsCopy()A fresh copy of the high column. -
lowsCopy
public double[] lowsCopy()A fresh copy of the low column. -
closesCopy
public double[] closesCopy()A fresh copy of the close column. -
volumesCopy
public double[] volumesCopy()A fresh copy of the volume column. -
copyClosesInto
public void copyClosesInto(double[] dst, int from, int len) Copies closes[from, from + len)intodst[0, len)without allocating.- Parameters:
dst- caller-owned destination, length at leastlenfrom- first bar indexlen- number of bars
-
slice
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.
-