feat(data): expose CandleReader (CSV) natively in all 10 languages (#311)
Add the data-layer CSV candle reader to every binding so loading OHLCV candles from a CSV no longer needs a per-language CSV/dataframe dependency. - C ABI: wickra_candle_reader_new(bytes, len) / _count / _read / _free over an opaque CandleReader handle (parse the whole buffer up front, then drain). - Native: Node/WASM CandleReader.read() -> Candle[], Python read() -> list[tuple]. - C-ABI languages: Go Read() []Candle, C# Candle[] Read(), Java Candle[] read(), R read() S3 generic (n x 6 matrix); C / C++ call the C ABI directly. - Cross-language golden testdata/golden/data_csv*.csv pins the parsed candles bit-for-bit across every binding. Verified locally across Rust (test+clippy+fmt), Node, WASM, Python, C#, Go, Java, R, and the C/C++ cmake parity suite.
This commit is contained in:
@@ -189,3 +189,26 @@ flush.wickra_indicator <- function(con) {
|
||||
out <- .Call(paste0("wk_", con$prefix, "_flush"), con$ptr, PACKAGE = "wickra")
|
||||
out
|
||||
}
|
||||
|
||||
#' Read every candle parsed by a CSV candle reader
|
||||
#'
|
||||
#' Returns all the candles a [CandleReader()] parsed from its CSV, as a numeric
|
||||
#' matrix with columns `open`, `high`, `low`, `close`, `volume`, `timestamp`.
|
||||
#'
|
||||
#' @param object A `wickra_indicator` created by [CandleReader()].
|
||||
#' @return A numeric matrix with six named columns (zero rows for an empty CSV).
|
||||
#' @examples
|
||||
#' r <- CandleReader("timestamp,open,high,low,close,volume\n0,100,101,99,100.5,10\n")
|
||||
#' read(r)
|
||||
#' @export
|
||||
read <- function(object) {
|
||||
UseMethod("read")
|
||||
}
|
||||
|
||||
#' @rdname read
|
||||
#' @export
|
||||
read.wickra_indicator <- function(object) {
|
||||
out <- .Call(paste0("wk_", object$prefix, "_read"), object$ptr, PACKAGE = "wickra")
|
||||
colnames(out) <- c("open", "high", "low", "close", "volume", "timestamp")
|
||||
out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user