75eefbbd08
The strategy_* examples were only syntax-smoked in CI, never run, which hid two classes of problem: 1. Python strategy_macd_adx / strategy_bollinger_squeeze passed three separate arguments to the candle indicators ADX/ATR, whose .update() takes a single candle — a TypeError at runtime — and read the ADX tuple at index 0 (plus_di) instead of 2 (adx). Both fixed. 2. The Go / C# / R / Java strategies defaulted to synthetic data and used a different (annualised) one-line summary, so they printed wildly different numbers from the Rust/Python/Node/C/WASM suite. Rewrite them to the shared per-trade backtest (load the bundled BTCUSDT CSV by default, same entry/exit logic, same print_summary output). All nine runnable bindings now print byte-identical backtest summaries on the same data (MACD+ADX 246 trades / -47.19%, RSI 37 / -17.84%, Bollinger 1 / -7.82%), verified by diffing each language's output against the Python reference. WASM shares the same logic and bundled dataset (browser-rendered).
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 (native fetch_binance_klines). |
Rscript fetch_btcusdt.R |
live_binance.R |
Stream live Binance klines through EMA(20) via the native BinanceFeed. |
Rscript live_binance.R |
fetch_btcusdt.R and live_binance.R require network access but no third-party
packages — they use Wickra's native REST fetcher and live feed; the rest run
offline on deterministic synthetic data. parallel_assets.R forks via
parallel::mclapply on Unix and runs serially on Windows.