thetadatadx 11.0.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # thetadatadx (Node.js / TypeScript)
2
2
 
3
- Node.js SDK for ThetaData market data. napi-rs bindings over the `thetadatadx` Rust crate, shipped as pre-built native addons for Linux x64, macOS Apple Silicon, and Windows x64 (no Rust toolchain required on the consumer).
3
+ Drop-in Node.js SDK for ThetaData market data. Speaks ThetaData's
4
+ wire protocols directly — historical gRPC, streaming TCP, and the
5
+ native flat-file distribution for bulk pulls — without a JVM or a
6
+ local proxy. Pre-built native addons for Linux x64, macOS Apple
7
+ Silicon, and Windows x64; no Rust toolchain required on the
8
+ consumer.
4
9
 
5
- Every call crosses the napi boundary into compiled Rust: gRPC, protobuf, zstd, FIT decoding, and TCP streaming run inside the `thetadatadx` crate.
10
+ Every call crosses the napi boundary into compiled Rust: gRPC,
11
+ protobuf, zstd, FIT decoding, and TCP streaming all run natively.
6
12
 
7
- > **Surface coverage:** the TypeScript binding exposes all three ThetaData surfaces — MDDS (historical), FPSS (streaming), and FLATFILES (whole-universe daily blobs). Flat files land via `tdx.flatFiles.*()` with `.toArrowIpc()` and `.toJson()` terminals plus a `tdx.flatFileToPath(...)` raw-bytes helper — see the [Flat Files](#flat-files) section for the full method list.
8
- >
9
- > **REST routing escape hatch:** `FallbackPolicy.restAlways` + `Config.withRestFallback` + four `optionHistory*WithFallback` async methods on `ThetaDataDxClient` route the historical-quote endpoints over a locally-running Terminal's REST surface when the caller wants a single transport for every quote-bearing call. See [channel pool design](../../docs-site/docs/channel-pool-design.md) for the connection-recovery story.
13
+ > **Surface coverage:** the TypeScript binding exposes all three ThetaData surfaces — historical request/response, real-time streaming, and whole-universe daily blobs. Flat files land via `tdx.flatFiles.*()` with `.toArrowIpc()` and `.toJson()` terminals plus a `tdx.flatFileToPath(...)` raw-bytes helper — see the [Flat Files](#flat-files) section for the full method list.
10
14
 
11
15
  ## Install
12
16
 
@@ -84,44 +88,11 @@ tdx.stopStreaming();
84
88
  // Drain barrier: by the time `awaitDrain(5000)` resolves, the
85
89
  // consumer thread is guaranteed to have finished firing the
86
90
  // callback, so the JS closure can be released without a
87
- // use-after-free race against the LMAX Disruptor consumer.
91
+ // use-after-free race against the dispatcher thread.
88
92
  const drained = await tdx.awaitDrain(5000);
89
93
  if (!drained) console.warn('drain timed out');
90
94
  ```
91
95
 
92
- ### Pull-iter delivery — `for await (const event of iter)` (high-throughput drain)
93
-
94
- Push-callback (`tdx.streaming(callback)` above) is the recommended
95
- default for low-latency single-event reaction. Pull-iter is the
96
- sibling delivery mode for high-throughput batch processing where
97
- the dominant cost is per-event JS work rather than per-event vendor
98
- latency:
99
-
100
- ```ts
101
- const iter = tdx.startStreamingIter();
102
- tdx.subscribe(SecType.option().fullTrades());
103
- for await (const event of iter) {
104
- if (event.kind === 'trade') {
105
- buf.push([event.trade.price, event.trade.size]);
106
- }
107
- }
108
- // Stop the streaming session when done. The async-iterator
109
- // protocol handles `break` cleanly via `return()`, which calls
110
- // `iter.close()` so the worker thread stops blocking on the queue.
111
- tdx.stopStreaming();
112
- await tdx.awaitDrain(5000);
113
- ```
114
-
115
- The Disruptor consumer pushes events into a per-client bounded
116
- queue; the `for await` loop drains the queue from the Node main
117
- thread in batches, with the actual queue wait happening on
118
- `tokio::task::spawn_blocking` so the event loop is never blocked.
119
-
120
- Mode is chosen at start. Push and pull are mutually exclusive on a
121
- given client; switch by calling `stopStreaming()` first. Backpressure
122
- surfaces on the same `droppedEventCount()` counter as the callback
123
- path.
124
-
125
96
  ## TypeScript types
126
97
 
127
98
  Every tick type and FPSS event is emitted as a `#[napi(object)]` struct on
@@ -171,10 +142,10 @@ fires and accounted on the `thetadatadx.fpss.decode_failures` metric
171
142
  counter on the Rust side; they never surface as an `FpssEvent`.
172
143
 
173
144
  The `kind` field is typed as a string-literal union narrowed by the
174
- generated `index.d.ts` — plain strings, not a TS `enum` (the previous
175
- `const enum FpssEventKind` was removed in #376 because it broke
176
- downstream consumers with `"isolatedModules": true`), so it works in
177
- every toolchain including Vite, esbuild, ts-jest, and Next.js.
145
+ generated `index.d.ts` — plain strings, not a TS `const enum`, so the
146
+ type information stays self-contained under
147
+ `"isolatedModules": true` and works in every toolchain including
148
+ Vite, esbuild, ts-jest, and Next.js.
178
149
 
179
150
  Each typed control payload mirrors the corresponding `FpssControl::*`
180
151
  Rust variant one-for-one — `Disconnected.reason` / `Reconnecting.reason`