| Title: | Streaming-First Technical Indicators |
|---|---|
| Description: | R bindings for the Wickra technical-analysis library over its C ABI hub. Exposes 515 indicators, each an incremental streaming state machine shared with the Rust core and the other language bindings, so that live and historical evaluation use the exact same implementation. |
| Authors: | kingchenc [aut, cre] |
| Maintainer: | kingchenc <[email protected]> |
| License: | MIT + file LICENSE | Apache License 2.0 |
| Version: | 2.1.1 |
| Built: | 2026-11-03 13:51:56 UTC |
| Source: | https://github.com/wickra-lib/wickra |
The result is identical to feeding the same inputs through update() one at a
time, with NA at warmup positions.
batch(object, ...) ## S3 method for class 'wickra_indicator' batch(object, ...)batch(object, ...) ## S3 method for class 'wickra_indicator' batch(object, ...)
object |
A |
... |
The input columns, and for the snapshot families the per-bar width as a named argument. |
Most indicators take one column per input field, all the same length. The
cross-section and order-book families take a per-bar snapshot instead: each
field arrives as one flat column with bar i at [i*width, (i+1)*width), and
the width is passed as a named argument in the position the native routine
declares it (members for a cross-section, n_bids / n_asks for an order
book). Naming it is what distinguishes a width from a column, so the rule that
keeps a short column from being read past its end still applies to the rest.
A numeric vector for a scalar indicator; an n x k matrix for a
multi-output or profile indicator, with the field names as columns; and for
a bar builder the bars the series completed, which is as many as the data
makes it rather than one per input row.
batch(Sma(3), c(1, 2, 3, 4, 5)) # NA NA 2 3 4batch(Sma(3), c(1, 2, 3, 4, 5)) # NA NA 2 3 4
The opt-in fast form of batch(). Where the indicator has a SIMD kernel
(moving averages, RSI, ATR, MACD, Bollinger, Chaikin, skewness, Pearson and
more), the kernel reassociates the arithmetic, so each value agrees with
batch() to within a few units in the last place rather than bit for bit;
NA placement and the shape are identical, and the result is the same on
every platform. Where there is no kernel it is exactly batch().
batch_fast(object, ...) ## S3 method for class 'wickra_indicator' batch_fast(object, ...)batch_fast(object, ...) ## S3 method for class 'wickra_indicator' batch_fast(object, ...)
object |
A |
... |
The input columns, and for the snapshot families the per-bar width as a named argument. |
The same shape as batch().
batch_fast(Ema(3), c(1, 2, 3, 4, 5))batch_fast(Ema(3), c(1, 2, 3, 4, 5))
Emit the final, still-open candle a Resampler() is aggregating (the partial
higher-timeframe bar that no later input has closed yet). Extends the base
generic base::flush().
## S3 method for class 'wickra_indicator' flush(con)## S3 method for class 'wickra_indicator' flush(con)
con |
A |
A named numeric vector (open, high, low, close, volume,
timestamp), or NULL if nothing is pending.
r <- Resampler(5) for (t in 0:6) push(r, 100 + t, 101 + t, 99 + t, 100 + t, 10, t) flush(r)r <- Resampler(5) for (t in 0:6) push(r, 100 + t, 101 + t, 99 + t, 100 + t, 10, t) flush(r)
Not available for the alt-chart bar builders, which have no warmup.
is_ready(object) ## S3 method for class 'wickra_indicator' is_ready(object)is_ready(object) ## S3 method for class 'wickra_indicator' is_ready(object)
object |
A |
A single logical.
sma <- Sma(3) is_ready(sma) # FALSE for (x in c(1, 2, 3)) update(sma, x) is_ready(sma) # TRUEsma <- Sma(3) is_ready(sma) # FALSE for (x in c(1, 2, 3)) update(sma, x) is_ready(sma) # TRUE
Returns the stable, human-readable name of the indicator (the same name
reported by every other Wickra binding), e.g. "SMA" for Sma().
name(object) ## S3 method for class 'wickra_indicator' name(object)name(object) ## S3 method for class 'wickra_indicator' name(object)
object |
A |
A single character string.
name(Sma(14)) # "SMA"name(Sma(14)) # "SMA"
Feeds a TickAggregator() one trade tick (price, size, timestamp) or a
Resampler() one candle (open, high, low, close, volume,
timestamp), and returns the candles it closed as a numeric matrix with
columns open, high, low, close, volume, timestamp. The matrix has
zero rows while the open bar merely grows, and more than one row when gap
filling emits placeholders for skipped buckets.
push(object, ...) ## S3 method for class 'wickra_indicator' push(object, ...)push(object, ...) ## S3 method for class 'wickra_indicator' push(object, ...)
object |
A |
... |
The input fields, in the order that object takes them: a tick is
|
A numeric matrix with six named columns (possibly zero rows).
agg <- TickAggregator(1000, FALSE) push(agg, 100, 1, 0) push(agg, 102, 1, 1000) # closes the first bucket r <- Resampler(5, TRUE) push(r, 100, 101, 99, 100, 10, 0)agg <- TickAggregator(1000, FALSE) push(agg, 100, 1, 0) push(agg, 102, 1, 1000) # closes the first bucket r <- Resampler(5, TRUE) push(r, 100, 101, 99, 100, 10, 0)
Returns all the candles a CandleReader() parsed from its CSV, as a numeric
matrix with columns open, high, low, close, volume, timestamp.
read(object) ## S3 method for class 'wickra_indicator' read(object)read(object) ## S3 method for class 'wickra_indicator' read(object)
object |
A |
A numeric matrix with six named columns (zero rows for an empty CSV).
r <- CandleReader("timestamp,open,high,low,close,volume\n0,100,101,99,100.5,10\n") read(r)r <- CandleReader("timestamp,open,high,low,close,volume\n0,100,101,99,100.5,10\n") read(r)
Reset an indicator to its warmup state
reset(object) ## S3 method for class 'wickra_indicator' reset(object)reset(object) ## S3 method for class 'wickra_indicator' reset(object)
object |
A |
The indicator, invisibly.
sma <- Sma(3) update(sma, 1) reset(sma)sma <- Sma(3) update(sma, 1) reset(sma)
A deterministic, synthetic daily OHLCV (open / high / low / close / volume)
price series for use in the examples, the Getting started vignette, and
tests. It is a seeded random walk, not real market data. Regenerate with
data-raw/sample_ohlcv.R.
sample_ohlcvsample_ohlcv
A data frame with 250 rows and 6 columns:
Trading date (Date).
Opening price.
Session high.
Session low.
Closing price.
Traded volume.
Update an indicator with one observation
## S3 method for class 'wickra_indicator' update(object, ...)## S3 method for class 'wickra_indicator' update(object, ...)
object |
A |
... |
The observation: a single value for scalar indicators, the OHLCV fields plus a timestamp for candle indicators, or two values for pairwise indicators. |
The indicator value: a numeric scalar; a named numeric vector for
multi-output indicators (NA during warmup); a matrix of completed bars for
bar builders; or a list / numeric vector for profile indicators
(NULL during warmup).
sma <- Sma(3) for (x in c(1, 2, 3, 4, 5)) v <- update(sma, x) v # 4sma <- Sma(3) for (x in c(1, 2, 3, 4, 5)) v <- update(sma, x) v # 4
Not available for the alt-chart bar builders (RenkoBars(), KagiBars(),
PointAndFigureBars(), …), which have no warmup.
warmup_period(object) ## S3 method for class 'wickra_indicator' warmup_period(object)warmup_period(object) ## S3 method for class 'wickra_indicator' warmup_period(object)
object |
A |
A single integer: the warmup period.
warmup_period(Sma(14)) # 14warmup_period(Sma(14)) # 14