b7ef63400d
Adds an R binding (`bindings/r`) over the C ABI hub — the third language stecker after C# and Go, reaching the hub through R's native `.Call` interface (not extendr). ## What's here - **`bindings/r`** — an R package exposing all 514 indicators as constructors that return a `wickra_indicator` object with generic `update`/`batch`/`reset` methods. The C glue (`src/wickra.c`) and R wrappers (`R/indicators.R`) are generated from `bindings/c/include/wickra.h` (same archetype taxonomy as the C#/Go generators: scalar/batch, multi-output, bars, profile, profile-values, array-input). The opaque handle is an R external pointer freed by a registered finalizer; multi-output returns a named vector (`NA` at warmup), bars a matrix, profiles a list. - **`examples/r`** — the full example suite mirroring C/C#/Go: streaming, backtest, multi_timeframe, parallel_assets (`mclapply`), three strategies, and `fetch_btcusdt`/`live_binance`. - **CI** — an `r` job builds the C ABI library, installs the package, runs the `testthat` suite and the offline examples on Linux, macOS and Windows (`R CMD check` is clean: 0 warnings, 0 notes). - **Docs** — R added to the README languages table, project layout, building/testing, CONTRIBUTING binding table + regenerate note, ARCHITECTURE, examples index, issue/PR templates, the About-description template, and the other binding READMEs. ## Linking / distribution The package compiles a thin `.Call` glue layer against the prebuilt C ABI library (header via `WICKRA_INCLUDE_DIR`, library via `WICKRA_LIB_DIR`). On Windows the package's own `wickra.dll` would collide with the C ABI's `wickra.dll`, so `configure.win` stages a renamed copy (`wickra_abi.dll`) and builds an import library referencing it; `install.libs.R` bundles the DLL and `.onLoad` puts it on the load path. On Linux/macOS the rpath locates the shared library. No `release.yml` change — R is distributed via r-universe / source install (gated). No Rust crate or `Cargo.toml` change — the R package is standalone and additive.
Wickra examples — R
Runnable R examples for the Wickra R binding. Each example is
a small script; they share the deterministic synthetic data, CSV loader, and
equity summary in _common.R.
Install the binding first (it compiles against the C ABI library — see the binding README), then run any example from this directory:
cargo build -p wickra-c --release
WICKRA_INCLUDE_DIR="$PWD/bindings/c/include" WICKRA_LIB_DIR="$PWD/target/release" \
R CMD INSTALL bindings/r
cd examples/r
Rscript streaming.R
| Example | What it does | Run |
|---|---|---|
streaming.R |
Feed a synthetic price series through SMA / EMA / RSI / MACD tick by tick. | Rscript streaming.R |
backtest.R |
Compute a basket of indicators over an OHLCV series and print a summary. | Rscript backtest.R <ohlcv.csv> |
multi_timeframe.R |
Resample a 1-minute series into 5m / 15m and print an indicator per timeframe. | Rscript multi_timeframe.R |
parallel_assets.R |
SMA(20) batch over a panel, serial vs mclapply, with speedup. |
Rscript parallel_assets.R 200 5000 |
strategy_rsi_mean_reversion.R |
RSI(14) mean-reversion with a PnL / Sharpe / max-DD summary. | Rscript strategy_rsi_mean_reversion.R |
strategy_macd_adx.R |
MACD crossover entries gated by ADX(14) > 20. | Rscript strategy_macd_adx.R |
strategy_bollinger_squeeze.R |
Bollinger-squeeze breakout with an ATR(14) trailing stop. | Rscript strategy_bollinger_squeeze.R |
fetch_btcusdt.R |
Download real BTCUSDT klines from the Binance REST API into a CSV (jsonlite). |
Rscript fetch_btcusdt.R |
live_binance.R |
Stream live Binance klines through EMA(20) over a WebSocket (websocket). |
Rscript live_binance.R |
fetch_btcusdt.R and live_binance.R require network access (and the
jsonlite / websocket packages); the rest run offline on deterministic
synthetic data. parallel_assets.R forks via parallel::mclapply on Unix and
runs serially on Windows.