Core
All functions · nseries package
Append
func (s Series) Append(s2 Series) Series
Append appends a series.
At
func (s Series) At(n int) Series
At is an alias for Lookback
Bool
func (s Series) Bool(lookback ...int) bool
Bool is an alias for ValueBool
Copy
func (s Series) Copy() Series
Copy makes a copy of a series.
LookBack
func (s Series) LookBack(n int) Series
LookBack removes the last n values from the series. A negative n returns the series unchanged.
New
func New(in []float64) Series
New creates a new Series from a slice of float64 values.
Ratio
func (s Series) Ratio(s2 Series) Series
Ratio returns a series where the specified series s is divided by the series s2. The two series are right-aligned at the most recent bar: the last value of s is divided by the last value of s2, the second-last by the second-last, and so on over the min(len(s), len(s2)) bars they share. The result has the length of s, with zeros before that overlap, so an empty s2 gives a zero-filled series. A zero divisor, or a quotient that is not finite (NaN, or an overflow to an infinity), gives zero. Series are paired by position only; see “Time alignment” in the manual.
SAverage
func (s Series) SAverage(ss ...Series) Series
SAverage returns a series where the receiver is averaged, bar by bar, with an arbitrary number of provided series. All of the series are right-aligned at the most recent bar: with m the length of the shortest of them, the last m values of each are averaged, and the first len(s)-m positions of the result are zero, so an empty provided series gives a zero-filled series of the receiver’s length. At each position the values are summed in argument order, receiver first, and the sum is divided by the number of series. With no provided series the result is a copy of the receiver, and an empty receiver is returned as it is. Series are paired by position only; see “Time alignment” in the manual.
SetN
func (s Series) SetN(n int, val float64) Series
SetN sets the first n values of a series to the specified value.
Shift
func (s Series) Shift(n int) Series
Shift shifts a series by the specified number of elements. Where the shift amount is a positive number, that many entries are removed from the right-hand end of the series, and the start of the series is padded with zeros to maintain the same length as the input. Where the shift amount is a negative number, that many entries are removed from the left-hand end of the series, and the end of the series is passed with zeros to maintain the same length as the input. A shift of zero returns a copy of the series unchanged.
Sum
func (s Series) Sum(n int) Series
Sum returns the sum of the most recent n observations, using all available observations during startup. Values of n below one return aligned zeros.
Value
func (s Series) Value(lookback ...int) float64
Value returns the last value in the series (or zero if the series is empty). An optional lookback may be provided; a lookback outside the bounds of the series returns zero.
ValueAverage
func (s Series) ValueAverage(n ...int) float64
ValueAverage returns the average of the values in the series. Optionally, a value n may be provided, in which case only the last n values will be averaged (unless n == 0, in which case all values will be averaged). An empty series returns zero.
ValueBool
func (s Series) ValueBool(lookback ...int) bool
ValueBool returns a boolean based on whether the last value in the series is greater than zero. An optional lookback may be provided; a lookback outside the bounds of the series returns false.
ValueSum
func (s Series) ValueSum(n ...int) float64
ValueSum returns the sum of the values in the series. Optionally, a value n may be provided, in which case only the last n values will be summed (unless n == 0, in which case all values will be summed).
Window
func (s Series) Window(n int) Series
Window returns the last n values from the series if n is positive or all but the first n values if n is negative.