677ea37402
Stacked on #315 (the native Binance REST fetcher). Retarget to `main` once #315 merges. Migrates the runnable examples off third-party data-I/O packages onto Wickra's native data layer (`CandleReader`, `Resampler`, `BinanceFeed`, `fetch_*klines`). ## Third-party packages removed (the zero-dep selling point) - **Node**: `ws` (live feed → BinanceFeed) — dropped from package.json + lockfile - **Go**: `github.com/coder/websocket` — dropped from go.mod / go.sum (`go mod tidy`) - **Java**: `jackson-databind` (live feed + REST fetch) — dropped from pom.xml - **R**: `jsonlite` + `websocket` + `later` — dropped from the README notes Each language's CSV loading now goes through `CandleReader`, manual resampling through `Resampler`, the live feed through `BinanceFeed`, and (Java/R) the REST download through the native fetcher. ## Verification Ran the offline examples per language against the bundled data — backtest and multi_timeframe produce identical output across Python / Node / Go / Java / R (e.g. ATR(14) last 345.1010; 1h→5m resamples to 240 bars, →15m to 80 bars). C# / C / WASM (stdlib-only, no third-party deps to remove) follow in this branch. Note: the streaming `strategy_*` examples have pre-existing candle-indicator runtime bugs (CI only syntax-smokes them); the CSV migration preserves their shape and leaves those bugs for a separate fix.
18 lines
773 B
R
18 lines
773 B
R
# Download real BTCUSDT hourly klines from the Binance REST API into a CSV that the
|
|
# other examples can consume, using Wickra's native fetcher — no third-party packages.
|
|
# Requires network access.
|
|
library(wickra)
|
|
|
|
cat("Fetching 500 BTCUSDT 1h klines from Binance...\n")
|
|
# Interval code 6 == 1h. Returns an (n x 6) matrix with columns
|
|
# open, high, low, close, volume, timestamp.
|
|
m <- fetch_binance_klines("BTCUSDT", 6L, 500L)
|
|
|
|
dir.create("data", showWarnings = FALSE)
|
|
df <- data.frame(
|
|
timestamp = m[, "timestamp"], open = m[, "open"], high = m[, "high"],
|
|
low = m[, "low"], close = m[, "close"], volume = m[, "volume"]
|
|
)
|
|
utils::write.csv(df, "data/btcusdt_1h.csv", row.names = FALSE, quote = FALSE)
|
|
cat(sprintf("Wrote %d klines to data/btcusdt_1h.csv\n", nrow(df)))
|