feat(data): native live Binance kline feed in 9 languages (+ 3d/1M intervals) (#313)

* feat(data): C-ABI Binance feed + Go binding (F4 wip)

C ABI exposes the existing async BinanceKlineStream (tokio + TLS, auto-reconnect,
mock-server-tested in wickra-data) through a blocking poll: wickra_binance_connect
/ _next(out, timeout_ms) -> {1 event, 0 timeout, -1 closed} / _close / _free over
an opaque BinanceStream that owns a current-thread runtime. WickraKlineEvent
carries OHLCV + open_time + is_closed + a 16-byte symbol buffer. `live-binance`
is now a default feature of wickra-c (the published DLL ships the feed; the wasm
build drops it via --no-default-features).

Go: NewBinanceFeed(symbols, interval, baseURL) + Next(timeout) + Close, with a
deterministic error-path smoke (the connect->event pipeline is covered by the
Rust mock-WS-server tests).

* feat(data): Binance feed C# + Java bindings (F4 wip)

C#: BinanceFeed(symbols, interval, baseUrl?) + Next(timeout) -> KlineEvent? +
Dispose; bespoke WickraKlineEvent native struct (fixed symbol buffer + byte
is_closed) since the scalar struct parser can't model it. `char` maps to `byte`
for the const char* params.

Java: BinanceFeed + KlineEvent record + BinanceInterval enum over Panama FFM;
the event is read at hand-computed offsets (symbol@0, doubles@16..48,
open_time@56, is_closed@64; 72-byte struct). Both with deterministic error-path
smokes (pipeline covered by the Rust mock-WS-server tests).

* feat(data): Binance feed R binding (F4 wip)

R: BinanceFeed(symbols, interval, base_url) + binance_next(feed, timeout_ms) ->
named list | NULL + binance_close, via bespoke .Call glue (wk_binance_*). The
glue + its registration entries are gated out of the Emscripten/wasm build
(#ifndef __EMSCRIPTEN__) since r-universe/webR has no raw sockets. NAMESPACE
exports added by hand (roxygen2 not installed locally). Deterministic error-path
smoke; pipeline covered by the Rust mock-WS-server tests.

* feat(data): native Binance feed for Node + Python; CHANGELOG (F4 complete)

Node (napi) BinanceFeed: new(symbols, interval, baseUrl?) + next(timeoutMs) ->
KlineEvent | null + close. Python (pyo3) BinanceFeed: same, with next releasing
the GIL (py.detach) while it waits. Both drive the mock-server-tested async
BinanceKlineStream on a single-thread tokio runtime (blocking poll); wickra-data
gains the live-binance feature + tokio in each binding.

Completes F4: the live Binance kline feed is now native in all 9 languages
(WASM excluded), with no third-party WebSocket client in any of them.
This commit is contained in:
kingchenc
2026-06-16 02:01:37 +02:00
committed by GitHub
parent baf4d0ff47
commit 3a709d9a66
30 changed files with 1127 additions and 5 deletions
+35
View File
@@ -603,6 +603,17 @@ export interface CandleValue {
volume: number
timestamp: number
}
/** One event from the live Binance feed. */
export interface KlineEvent {
symbol: string
open: number
high: number
low: number
close: number
volume: number
openTime: number
isClosed: boolean
}
export type SmaNode = SMA
export declare class SMA {
constructor(period: number)
@@ -5939,6 +5950,30 @@ export declare class VolumeWeightedMacd {
isReady(): boolean
warmupPeriod(): number
}
export type BinanceFeedNode = BinanceFeed
/**
* A live Binance kline feed. `next` is a blocking poll (it waits up to the
* timeout on the calling thread) driving the mock-server-tested wickra-data
* `BinanceKlineStream` on a single-thread tokio runtime — use a short timeout in
* a loop, or run it on a Worker thread, to keep the event loop responsive.
*/
export declare class BinanceFeed {
/**
* Connect to Binance's live kline stream for the given comma-separated
* `symbols` (case-insensitive) at the given `interval` code (`0..=15`).
* `baseUrl` overrides the endpoint (omit for production; pass a `ws://` URL
* to target a test server).
*/
constructor(symbols: string, interval: number, baseUrl?: string | undefined | null)
/**
* Poll for the next kline event, waiting up to `timeoutMs` milliseconds.
* Returns the event, or `null` on timeout (call again). Throws once the
* stream is closed.
*/
next(timeoutMs: number): KlineEvent | null
/** Close the stream; subsequent `next` calls throw. */
close(): void
}
export type TickAggregatorNode = TickAggregator
/** Roll trade ticks up into fixed-timeframe OHLCV candles. */
export declare class TickAggregator {