thetadatadx 7.3.0 → 8.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.
Files changed (5) hide show
  1. package/README.md +87 -31
  2. package/index.d.ts +505 -0
  3. package/index.js +579 -5
  4. package/package.json +22 -10
  5. package/src/types.ts +0 -209
package/README.md CHANGED
@@ -1,59 +1,115 @@
1
1
  # thetadatadx (Node.js / TypeScript)
2
2
 
3
- Node.js SDK for ThetaData market data, powered by the `thetadatadx` Rust crate via napi-rs.
3
+ Node.js SDK for ThetaData market data, powered by compiled Rust via napi-rs. Pre-built native binaries for Linux x64, macOS Apple Silicon, and Windows x64 — no Rust toolchain required.
4
4
 
5
- Every call goes through compiled Rust -- gRPC, protobuf, zstd, FIT decoding, and TCP streaming all happen at native speed. Node.js is just the interface.
5
+ Every call goes through compiled Rust gRPC, protobuf, zstd, FIT decoding, and TCP streaming all happen at native speed. Node.js is just the interface.
6
6
 
7
- ## Prerequisites
8
-
9
- - Node.js >= 18
10
- - Rust stable toolchain (for building from source)
11
- - `protoc` (Protocol Buffers compiler)
12
-
13
- ## Build from source
7
+ ## Install
14
8
 
15
9
  ```bash
16
- cd sdks/typescript
17
- npm install
18
- npm run build # release build -> thetadatadx.node
10
+ npm install thetadatadx
19
11
  ```
20
12
 
13
+ Pre-built binaries are downloaded automatically for your platform. Supported:
14
+ - Linux x64 (glibc)
15
+ - macOS arm64 (Apple Silicon)
16
+ - Windows x64 (MSVC)
17
+
21
18
  ## Usage
22
19
 
23
20
  ```js
24
21
  const { ThetaDataDx } = require('thetadatadx');
25
22
 
26
- // Connect (requires ThetaData credentials)
27
- const tdx = await ThetaDataDx.connect('user@example.com', 'password');
28
- // Or from file: const tdx = await ThetaDataDx.connectFromFile('creds.txt');
23
+ async function main() {
24
+ // Connect (requires ThetaData credentials)
25
+ const tdx = ThetaDataDx.connectFromFile('creds.txt');
26
+ // Or: const tdx = ThetaDataDx.connect('user@example.com', 'password');
27
+
28
+ // Historical endpoints return an array of typed tick objects
29
+ // (`OhlcTick[]`, `QuoteTick[]`, ...). Index into the array to
30
+ // read a per-row field.
31
+ const ohlc = tdx.stockHistoryOHLC('AAPL', '20240315', '60000');
32
+ console.log(ohlc.length, ohlc[0].close);
33
+
34
+ // With timeout
35
+ const snap = tdx.stockSnapshotQuote(['AAPL', 'MSFT'], null, null, 5000);
36
+
37
+ // Streaming — `nextEvent` is async; `await` it or you'll get a
38
+ // `Promise` object back and `event.kind` will be `undefined`.
39
+ tdx.startStreaming();
40
+ tdx.subscribeQuotes('AAPL');
41
+ const event = await tdx.nextEvent(1000); // poll with 1s timeout
42
+ if (event && event.kind === 'quote') {
43
+ console.log(event.quote.bid, event.quote.ask);
44
+ }
45
+ tdx.stopStreaming();
46
+ }
47
+
48
+ main().catch(console.error);
49
+ ```
29
50
 
30
- // Historical: returns columnar object { close: number[], volume: number[], ... }
31
- const ohlc = tdx.stockHistoryOHLC('AAPL', '20240315', '60000');
32
- console.log(ohlc.close);
51
+ ## TypeScript types
33
52
 
34
- // With timeout
35
- const snap = tdx.stockSnapshotQuote(['AAPL', 'MSFT'], null, null, 5000);
53
+ Every tick type and FPSS event is emitted as a `#[napi(object)]` struct on
54
+ the Rust side, so the full typed surface lives in `index.d.ts`
55
+ (auto-generated by napi-rs). Import directly from the package:
36
56
 
37
- // Streaming
38
- tdx.startStreaming();
39
- tdx.subscribeQuotes('AAPL');
40
- const event = tdx.nextEvent(1000); // poll with 1s timeout
41
- tdx.stopStreaming();
57
+ ```ts
58
+ import type { OhlcTick, GreeksTick, Quote, Trade, FpssEvent } from 'thetadatadx';
42
59
  ```
43
60
 
44
- ## TypeScript types
45
-
46
- Generated interfaces for every tick type live in `src/types.ts`:
61
+ Historical endpoints return `Tick[]`; `nextEvent()` is async and resolves
62
+ to a discriminated `FpssEvent | null` union, narrowed on `event.kind`:
47
63
 
48
64
  ```ts
49
- import type { OhlcTickColumnar, GreeksTickColumnar } from 'thetadatadx/src/types';
65
+ const event = await tdx.nextEvent(1000);
66
+ if (!event) return; // timeout
67
+ switch (event.kind) {
68
+ case 'quote': /* event.quote is Quote */ break;
69
+ case 'trade': /* event.trade is Trade */ break;
70
+ case 'ohlcvc': /* event.ohlcvc is Ohlcvc */ break;
71
+ case 'open_interest': /* event.openInterest is OpenInterest */ break;
72
+ case 'simple': /* event.simple is FpssSimplePayload */ break;
73
+ case 'raw_data': /* event.rawData is FpssRawDataPayload */ break;
74
+ }
50
75
  ```
51
76
 
52
- Full type declarations for the `ThetaDataDx` class are in `index.d.ts` (auto-generated by napi-rs on build).
77
+ The `kind` field is typed as the string-literal union
78
+ `'ohlcvc' | 'open_interest' | 'quote' | 'trade' | 'simple' | 'raw_data'`
79
+ — plain strings, not a TS `enum` (the previous `const enum FpssEventKind`
80
+ was removed in #376 because it broke downstream consumers with
81
+ `"isolatedModules": true`), so it works in every toolchain
82
+ including Vite, esbuild, ts-jest, and Next.js.
83
+
84
+ ### `bigint` fields
85
+
86
+ Anywhere a Rust `u64` or `i64` crosses the napi boundary it surfaces as
87
+ JavaScript `bigint` (not `number`): `volume` and `count` on every
88
+ OHLC / EOD tick, `droppedEvents()` on the streaming client, and
89
+ `received_at_ns` on every FPSS event. Use `bigint` literal syntax
90
+ (`42n`) for comparisons or widen to `Number(x)` at the point of
91
+ display (watch for loss of precision beyond 2^53).
92
+
93
+ `FpssSimplePayload.eventType` carries the concrete control-event name
94
+ (`"login_success"`, `"contract_assigned"`, `"disconnected"`,
95
+ `"market_open"`, `"market_close"`, ...). The wire tag set matches the
96
+ Python SDK's `next_event` pyclasses byte-for-byte — both surfaces are
97
+ generated from `fpss_event_schema.toml`, so consumer code ports between
98
+ the two languages without a discriminator rewrite.
99
+
100
+ ## Building from source
101
+
102
+ Only needed if your platform doesn't have a pre-built binary or you want to develop locally:
103
+
104
+ ```bash
105
+ cd sdks/typescript
106
+ npm install
107
+ npm run build # requires Rust stable + protoc
108
+ ```
53
109
 
54
110
  ## API reference
55
111
 
56
- All 61 endpoints from `endpoint_surface.toml` are exposed as camelCase methods on `ThetaDataDx`. See `index.d.ts` after building for the complete method list with JSDoc comments.
112
+ All 61 endpoints from `endpoint_surface.toml` are exposed as camelCase methods on `ThetaDataDx`. See `index.d.ts` for the complete method list with JSDoc comments.
57
113
 
58
114
  ## Docs
59
115
 
package/index.d.ts ADDED
@@ -0,0 +1,505 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare class ThetaDataDx {
4
+ /**
5
+ * Connect to ThetaData. Historical (MDDS/gRPC) only; call startStreaming()
6
+ * to begin FPSS real-time data.
7
+ */
8
+ static connect(email: string, password: string): ThetaDataDx
9
+ /** Connect with a credentials file (line 1 = email, line 2 = password). */
10
+ static connectFromFile(path: string): ThetaDataDx
11
+ /**
12
+ * Cumulative count of FPSS events dropped because the JS polling
13
+ * side disconnected before the FPSS callback could hand them off.
14
+ *
15
+ * Counter lives on the client instance (not inside the
16
+ * `start_streaming` / `reconnect` closures), so the value survives
17
+ * reconnect and is observable at any point — before streaming,
18
+ * during, or after `shutdown()`.
19
+ *
20
+ * Returned as `bigint` so it can represent the full `u64` range
21
+ * (Number would top out at 2^53).
22
+ */
23
+ droppedEvents(): bigint
24
+ /** List all available stock ticker symbols. */
25
+ stockListSymbols(timeoutMs?: number | undefined | null): Array<string>
26
+ /** List available dates for a stock by request type (EOD, TRADE, QUOTE, etc.). */
27
+ stockListDates(requestType: string, symbol: string, timeoutMs?: number | undefined | null): Array<string>
28
+ /** Get the latest OHLC snapshot for one or more stocks. */
29
+ stockSnapshotOHLC(symbols: Array<string>, venue?: string | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OhlcTick>
30
+ /** Get the latest trade snapshot for one or more stocks. */
31
+ stockSnapshotTrade(symbols: Array<string>, venue?: string | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<TradeTick>
32
+ /** Get the latest NBBO quote snapshot for one or more stocks. */
33
+ stockSnapshotQuote(symbols: Array<string>, venue?: string | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<QuoteTick>
34
+ /** Get the latest market value snapshot for one or more stocks. */
35
+ stockSnapshotMarketValue(symbols: Array<string>, venue?: string | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<MarketValueTick>
36
+ /** Fetch end-of-day stock data for a date range. Returns OHLCV + bid/ask per trading day. */
37
+ stockHistoryEOD(symbol: string, startDate: string, endDate: string, timeoutMs?: number | undefined | null): Array<EodTick>
38
+ /** Fetch intraday OHLC bars for a stock on a single date. */
39
+ stockHistoryOHLC(symbol: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, venue?: string | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OhlcTick>
40
+ /** Fetch all trades for a stock on a given date. */
41
+ stockHistoryTrade(symbol: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, venue?: string | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<TradeTick>
42
+ /** Fetch NBBO quotes for a stock on a given date at a given interval. */
43
+ stockHistoryQuote(symbol: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, venue?: string | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<QuoteTick>
44
+ /** Fetch combined trade + quote ticks for a stock on a given date. Returns raw DataTable. */
45
+ stockHistoryTradeQuote(symbol: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, exclusive?: boolean | undefined | null, venue?: string | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<TradeQuoteTick>
46
+ /** Fetch the trade at a specific time of day across a date range. */
47
+ stockAtTimeTrade(symbol: string, startDate: string, endDate: string, timeOfDay: string, venue?: string | undefined | null, timeoutMs?: number | undefined | null): Array<TradeTick>
48
+ /** Fetch the quote at a specific time of day across a date range. */
49
+ stockAtTimeQuote(symbol: string, startDate: string, endDate: string, timeOfDay: string, venue?: string | undefined | null, timeoutMs?: number | undefined | null): Array<QuoteTick>
50
+ /** List all available option underlying symbols. */
51
+ optionListSymbols(timeoutMs?: number | undefined | null): Array<string>
52
+ /** List available dates for an option contract by request type. */
53
+ optionListDates(requestType: string, symbol: string, expiration: string, strike: string, right: string, timeoutMs?: number | undefined | null): Array<string>
54
+ /** List available expiration dates for an option underlying. */
55
+ optionListExpirations(symbol: string, timeoutMs?: number | undefined | null): Array<string>
56
+ /** List available strike prices for an option at a given expiration. */
57
+ optionListStrikes(symbol: string, expiration: string, timeoutMs?: number | undefined | null): Array<string>
58
+ /** List all option contracts for a symbol on a given date. */
59
+ optionListContracts(requestType: string, symbol: string, date: string, maxDte?: number | undefined | null, timeoutMs?: number | undefined | null): Array<OptionContract>
60
+ /** Get the latest OHLC snapshot for an option contract. */
61
+ optionSnapshotOHLC(symbol: string, expiration: string, strike: string, right: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OhlcTick>
62
+ /** Get the latest trade snapshot for an option contract. */
63
+ optionSnapshotTrade(symbol: string, expiration: string, strike: string, right: string, strikeRange?: number | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<TradeTick>
64
+ /** Get the latest NBBO quote snapshot for an option contract. */
65
+ optionSnapshotQuote(symbol: string, expiration: string, strike: string, right: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<QuoteTick>
66
+ /** Get the latest open interest snapshot for an option contract. */
67
+ optionSnapshotOpenInterest(symbol: string, expiration: string, strike: string, right: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OpenInterestTick>
68
+ /** Get the latest market value snapshot for an option contract. */
69
+ optionSnapshotMarketValue(symbol: string, expiration: string, strike: string, right: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<MarketValueTick>
70
+ /** Get implied volatility snapshot for an option contract (from ThetaData server). */
71
+ optionSnapshotGreeksImpliedVolatility(symbol: string, expiration: string, strike: string, right: string, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, stockPrice?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, useMarketValue?: boolean | undefined | null, timeoutMs?: number | undefined | null): Array<IvTick>
72
+ /** Get all Greeks snapshot for an option contract (from ThetaData server). */
73
+ optionSnapshotGreeksAll(symbol: string, expiration: string, strike: string, right: string, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, stockPrice?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, useMarketValue?: boolean | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
74
+ /** Get first-order Greeks snapshot (delta, theta, rho) for an option contract. */
75
+ optionSnapshotGreeksFirstOrder(symbol: string, expiration: string, strike: string, right: string, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, stockPrice?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, useMarketValue?: boolean | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
76
+ /** Get second-order Greeks snapshot (gamma, vanna, charm) for an option contract. */
77
+ optionSnapshotGreeksSecondOrder(symbol: string, expiration: string, strike: string, right: string, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, stockPrice?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, useMarketValue?: boolean | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
78
+ /** Get third-order Greeks snapshot (speed, color, ultima) for an option contract. */
79
+ optionSnapshotGreeksThirdOrder(symbol: string, expiration: string, strike: string, right: string, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, stockPrice?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, minTime?: string | undefined | null, useMarketValue?: boolean | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
80
+ /** Fetch end-of-day option data for a contract over a date range. */
81
+ optionHistoryEOD(symbol: string, expiration: string, strike: string, right: string, startDate: string, endDate: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, timeoutMs?: number | undefined | null): Array<EodTick>
82
+ /** Fetch intraday OHLC bars for an option contract. */
83
+ optionHistoryOHLC(symbol: string, expiration: string, strike: string, right: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OhlcTick>
84
+ /** Fetch all trades for an option contract on a given date. */
85
+ optionHistoryTrade(symbol: string, expiration: string, strike: string, right: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<TradeTick>
86
+ /** Fetch NBBO quotes for an option contract on a given date. */
87
+ optionHistoryQuote(symbol: string, expiration: string, strike: string, right: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<QuoteTick>
88
+ /** Fetch combined trade + quote ticks for an option contract. */
89
+ optionHistoryTradeQuote(symbol: string, expiration: string, strike: string, right: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, exclusive?: boolean | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<TradeQuoteTick>
90
+ /** Fetch open interest history for an option contract. */
91
+ optionHistoryOpenInterest(symbol: string, expiration: string, strike: string, right: string, date: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OpenInterestTick>
92
+ /** Fetch end-of-day Greeks history for an option contract. */
93
+ optionHistoryGreeksEOD(symbol: string, expiration: string, strike: string, right: string, startDate: string, endDate: string, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, underlyerUseNbbo?: boolean | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
94
+ /** Fetch all Greeks history for an option contract (intraday, sampled by interval). */
95
+ optionHistoryGreeksAll(symbol: string, expiration: string, strike: string, right: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
96
+ /** Fetch all Greeks on each trade for an option contract. */
97
+ optionHistoryTradeGreeksAll(symbol: string, expiration: string, strike: string, right: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
98
+ /** Fetch first-order Greeks history (intraday, sampled by interval). */
99
+ optionHistoryGreeksFirstOrder(symbol: string, expiration: string, strike: string, right: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
100
+ /** Fetch first-order Greeks on each trade for an option contract. */
101
+ optionHistoryTradeGreeksFirstOrder(symbol: string, expiration: string, strike: string, right: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
102
+ /** Fetch second-order Greeks history (intraday, sampled by interval). */
103
+ optionHistoryGreeksSecondOrder(symbol: string, expiration: string, strike: string, right: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
104
+ /** Fetch second-order Greeks on each trade for an option contract. */
105
+ optionHistoryTradeGreeksSecondOrder(symbol: string, expiration: string, strike: string, right: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
106
+ /** Fetch third-order Greeks history (intraday, sampled by interval). */
107
+ optionHistoryGreeksThirdOrder(symbol: string, expiration: string, strike: string, right: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
108
+ /** Fetch third-order Greeks on each trade for an option contract. */
109
+ optionHistoryTradeGreeksThirdOrder(symbol: string, expiration: string, strike: string, right: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<GreeksTick>
110
+ /** Fetch implied volatility history (intraday, sampled by interval). */
111
+ optionHistoryGreeksImpliedVolatility(symbol: string, expiration: string, strike: string, right: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<IvTick>
112
+ /** Fetch implied volatility on each trade for an option contract. */
113
+ optionHistoryTradeGreeksImpliedVolatility(symbol: string, expiration: string, strike: string, right: string, date: string, startTime?: string | undefined | null, endTime?: string | undefined | null, annualDividend?: number | undefined | null, rateType?: string | undefined | null, rateValue?: number | undefined | null, version?: string | undefined | null, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<IvTick>
114
+ /** Fetch the trade at a specific time of day across a date range for an option. */
115
+ optionAtTimeTrade(symbol: string, expiration: string, strike: string, right: string, startDate: string, endDate: string, timeOfDay: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, timeoutMs?: number | undefined | null): Array<TradeTick>
116
+ /** Fetch the quote at a specific time of day across a date range for an option. */
117
+ optionAtTimeQuote(symbol: string, expiration: string, strike: string, right: string, startDate: string, endDate: string, timeOfDay: string, maxDte?: number | undefined | null, strikeRange?: number | undefined | null, timeoutMs?: number | undefined | null): Array<QuoteTick>
118
+ /** List all available index symbols. */
119
+ indexListSymbols(timeoutMs?: number | undefined | null): Array<string>
120
+ /** List available dates for an index symbol. */
121
+ indexListDates(symbol: string, timeoutMs?: number | undefined | null): Array<string>
122
+ /** Get the latest OHLC snapshot for one or more indices. */
123
+ indexSnapshotOHLC(symbols: Array<string>, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OhlcTick>
124
+ /** Get the latest price snapshot for one or more indices. */
125
+ indexSnapshotPrice(symbols: Array<string>, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<PriceTick>
126
+ /** Get the latest market value snapshot for one or more indices. */
127
+ indexSnapshotMarketValue(symbols: Array<string>, minTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<MarketValueTick>
128
+ /** Fetch end-of-day index data for a date range. */
129
+ indexHistoryEOD(symbol: string, startDate: string, endDate: string, timeoutMs?: number | undefined | null): Array<EodTick>
130
+ /** Fetch intraday OHLC bars for an index. */
131
+ indexHistoryOHLC(symbol: string, startDate: string, endDate: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OhlcTick>
132
+ /** Fetch intraday price history for an index. */
133
+ indexHistoryPrice(symbol: string, date: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, startDate?: string | undefined | null, endDate?: string | undefined | null, timeoutMs?: number | undefined | null): Array<PriceTick>
134
+ /** Fetch the index price at a specific time of day across a date range. */
135
+ indexAtTimePrice(symbol: string, startDate: string, endDate: string, timeOfDay: string, timeoutMs?: number | undefined | null): Array<PriceTick>
136
+ /** Check whether the market is open today. */
137
+ calendarOpenToday(timeoutMs?: number | undefined | null): Array<CalendarDay>
138
+ /** Get calendar information for a specific date. */
139
+ calendarOnDate(date: string, timeoutMs?: number | undefined | null): Array<CalendarDay>
140
+ /** Get calendar information for an entire year. */
141
+ calendarYear(year: string, timeoutMs?: number | undefined | null): Array<CalendarDay>
142
+ /** Fetch end-of-day interest rate history. */
143
+ interestRateHistoryEOD(symbol: string, startDate: string, endDate: string, timeoutMs?: number | undefined | null): Array<InterestRateTick>
144
+ /** Fetch intraday OHLC bars across a date range. */
145
+ stockHistoryOHLCRange(symbol: string, startDate: string, endDate: string, interval: string, startTime?: string | undefined | null, endTime?: string | undefined | null, venue?: string | undefined | null, timeoutMs?: number | undefined | null): Array<OhlcTick>
146
+ /** Start FPSS streaming. Events are buffered; poll with next_event(). */
147
+ startStreaming(): void
148
+ /** Whether the streaming connection is active. */
149
+ isStreaming(): boolean
150
+ /** Subscribe to real-time quote data for a stock symbol. */
151
+ subscribeQuotes(symbol: string): void
152
+ /** Subscribe to real-time trade data for a stock symbol. */
153
+ subscribeTrades(symbol: string): void
154
+ /** Subscribe to open interest data for a stock symbol. */
155
+ subscribeOpenInterest(symbol: string): void
156
+ /** Subscribe to quote data for an option contract. */
157
+ subscribeOptionQuotes(symbol: string, expiration: string, strike: string, right: string): void
158
+ /** Subscribe to trade data for an option contract. */
159
+ subscribeOptionTrades(symbol: string, expiration: string, strike: string, right: string): void
160
+ /** Subscribe to open interest data for an option contract. */
161
+ subscribeOptionOpenInterest(symbol: string, expiration: string, strike: string, right: string): void
162
+ /** Subscribe to all trades for a security type. */
163
+ subscribeFullTrades(secType: string): void
164
+ /** Subscribe to all open interest for a security type. */
165
+ subscribeFullOpenInterest(secType: string): void
166
+ /** Unsubscribe from quote data for a stock symbol. */
167
+ unsubscribeQuotes(symbol: string): void
168
+ /** Unsubscribe from trade data for a stock symbol. */
169
+ unsubscribeTrades(symbol: string): void
170
+ /** Unsubscribe from open interest data for a stock symbol. */
171
+ unsubscribeOpenInterest(symbol: string): void
172
+ /** Unsubscribe from quote data for an option contract. */
173
+ unsubscribeOptionQuotes(symbol: string, expiration: string, strike: string, right: string): void
174
+ /** Unsubscribe from trade data for an option contract. */
175
+ unsubscribeOptionTrades(symbol: string, expiration: string, strike: string, right: string): void
176
+ /** Unsubscribe from open interest data for an option contract. */
177
+ unsubscribeOptionOpenInterest(symbol: string, expiration: string, strike: string, right: string): void
178
+ /** Unsubscribe from all trades for a security type. */
179
+ unsubscribeFullTrades(secType: string): void
180
+ /** Unsubscribe from all open interest for a security type. */
181
+ unsubscribeFullOpenInterest(secType: string): void
182
+ /** Get the current contract map keyed by server-assigned contract ID. */
183
+ contractMap(): Record<string, string>
184
+ /** Look up a single contract by its server-assigned ID. */
185
+ contractLookup(id: number): string | null
186
+ /** Get a snapshot of currently active subscriptions. */
187
+ activeSubscriptions(): any
188
+ /** Poll for the next FPSS event. */
189
+ nextEvent(timeoutMs: number): Promise<({ kind: 'ohlcvc'; ohlcvc: Ohlcvc } | { kind: 'open_interest'; openInterest: OpenInterest } | { kind: 'quote'; quote: Quote } | { kind: 'trade'; trade: Trade } | { kind: 'simple'; simple: FpssSimplePayload } | { kind: 'raw_data'; rawData: FpssRawDataPayload }) | null>
190
+ /** Reconnect streaming and re-subscribe all previous subscriptions. */
191
+ reconnect(): void
192
+ /** Stop streaming while keeping the historical client usable. */
193
+ stopStreaming(): void
194
+ /** Shut down the FPSS streaming connection. */
195
+ shutdown(): void
196
+ }
197
+
198
+ /** Calendar day. Market open/close schedule. */
199
+ export interface CalendarDay {
200
+ date: number
201
+ isOpen: number
202
+ openTime: number
203
+ closeTime: number
204
+ status: number
205
+ }
206
+
207
+ /** End-of-day tick. Full EOD snapshot with OHLC + quote. */
208
+ export interface EodTick {
209
+ msOfDay: number
210
+ msOfDay2: number
211
+ open: number
212
+ high: number
213
+ low: number
214
+ close: number
215
+ volume: bigint
216
+ count: bigint
217
+ bidSize: number
218
+ bidExchange: number
219
+ bid: number
220
+ bidCondition: number
221
+ askSize: number
222
+ askExchange: number
223
+ ask: number
224
+ askCondition: number
225
+ date: number
226
+ expiration: number
227
+ strike: number
228
+ right: string
229
+ }
230
+
231
+ /**
232
+ * A single FPSS event surfaced to JS/TS.
233
+ *
234
+ * `kind` is the discriminator — switch on it and read the matching
235
+ * payload field. The shape is stable and every payload is typed, so
236
+ * consumers never fall back to untyped `any`.
237
+ */
238
+ export interface FpssEvent {
239
+ /**
240
+ * Discriminator matching one of the typed payload fields below.
241
+ * Narrowed to a literal union in TS so `switch (event.kind)`
242
+ * correctly narrows the optional payload fields.
243
+ */
244
+ kind: 'ohlcvc' | 'open_interest' | 'quote' | 'raw_data' | 'simple' | 'trade'
245
+ ohlcvc?: Ohlcvc
246
+ openInterest?: OpenInterest
247
+ quote?: Quote
248
+ trade?: Trade
249
+ simple?: FpssSimplePayload
250
+ rawData?: FpssRawDataPayload
251
+ }
252
+
253
+ /** FPSS raw-bytes payload for frames the decoder did not recognise. */
254
+ export interface FpssRawDataPayload {
255
+ code: number
256
+ payload: Array<number>
257
+ }
258
+
259
+ /**
260
+ * FPSS simple / diagnostic payload (login, disconnect, market open,
261
+ * unknown-data fallback, ...). Mirrors `BufferedEvent::Simple`.
262
+ */
263
+ export interface FpssSimplePayload {
264
+ /**
265
+ * Concrete event kind (e.g. "login_success", "disconnected",
266
+ * "unknown_data", "unknown_control").
267
+ */
268
+ eventType: string
269
+ /** Free-form diagnostic detail; empty when the event carries no payload. */
270
+ detail?: string
271
+ /** Optional event id (req_id for ReqResponse, contract id for ContractAssigned). */
272
+ id?: number
273
+ }
274
+
275
+ /** Greeks tick. Full set of option greeks. */
276
+ export interface GreeksTick {
277
+ msOfDay: number
278
+ impliedVolatility: number
279
+ delta: number
280
+ gamma: number
281
+ theta: number
282
+ vega: number
283
+ rho: number
284
+ ivError: number
285
+ vanna: number
286
+ charm: number
287
+ vomma: number
288
+ veta: number
289
+ speed: number
290
+ zomma: number
291
+ color: number
292
+ ultima: number
293
+ d1: number
294
+ d2: number
295
+ dualDelta: number
296
+ dualGamma: number
297
+ epsilon: number
298
+ lambda: number
299
+ vera: number
300
+ date: number
301
+ expiration: number
302
+ strike: number
303
+ right: string
304
+ }
305
+
306
+ /** Interest rate tick. End-of-day interest rate. */
307
+ export interface InterestRateTick {
308
+ msOfDay: number
309
+ rate: number
310
+ date: number
311
+ }
312
+
313
+ /** Implied volatility tick. */
314
+ export interface IvTick {
315
+ msOfDay: number
316
+ impliedVolatility: number
317
+ ivError: number
318
+ date: number
319
+ expiration: number
320
+ strike: number
321
+ right: string
322
+ }
323
+
324
+ /** Market value tick -- quoted bid/ask/price for a symbol. */
325
+ export interface MarketValueTick {
326
+ msOfDay: number
327
+ marketBid: number
328
+ marketAsk: number
329
+ marketPrice: number
330
+ date: number
331
+ expiration: number
332
+ strike: number
333
+ right: string
334
+ }
335
+
336
+ /** OHLC tick. Aggregated bar data. */
337
+ export interface OhlcTick {
338
+ msOfDay: number
339
+ open: number
340
+ high: number
341
+ low: number
342
+ close: number
343
+ volume: bigint
344
+ count: bigint
345
+ date: number
346
+ expiration: number
347
+ strike: number
348
+ right: string
349
+ }
350
+
351
+ /** FPSS OHLCVC bar. Mirrors `FpssData::Ohlcvc`. */
352
+ export interface Ohlcvc {
353
+ contractId: number
354
+ msOfDay: number
355
+ open: number
356
+ high: number
357
+ low: number
358
+ close: number
359
+ volume: bigint
360
+ count: bigint
361
+ date: number
362
+ receivedAtNs: bigint
363
+ }
364
+
365
+ /** FPSS OpenInterest tick. Mirrors `FpssData::OpenInterest`. */
366
+ export interface OpenInterest {
367
+ contractId: number
368
+ msOfDay: number
369
+ openInterest: number
370
+ date: number
371
+ receivedAtNs: bigint
372
+ }
373
+
374
+ /** Open interest tick. */
375
+ export interface OpenInterestTick {
376
+ msOfDay: number
377
+ openInterest: number
378
+ date: number
379
+ expiration: number
380
+ strike: number
381
+ right: string
382
+ }
383
+
384
+ /** Option contract. Contract specification. */
385
+ export interface OptionContract {
386
+ root: string
387
+ expiration: number
388
+ strike: number
389
+ right: string
390
+ }
391
+
392
+ /** Price tick. Generic price data point. */
393
+ export interface PriceTick {
394
+ msOfDay: number
395
+ price: number
396
+ date: number
397
+ }
398
+
399
+ /** FPSS Quote tick. Mirrors `FpssData::Quote` (symbol-less — `contract_id` is the stable key). */
400
+ export interface Quote {
401
+ contractId: number
402
+ msOfDay: number
403
+ bidSize: number
404
+ bidExchange: number
405
+ bid: number
406
+ bidCondition: number
407
+ askSize: number
408
+ askExchange: number
409
+ ask: number
410
+ askCondition: number
411
+ date: number
412
+ receivedAtNs: bigint
413
+ }
414
+
415
+ /** Quote tick. NBBO quote data. */
416
+ export interface QuoteTick {
417
+ msOfDay: number
418
+ bidSize: number
419
+ bidExchange: number
420
+ bid: number
421
+ bidCondition: number
422
+ askSize: number
423
+ askExchange: number
424
+ ask: number
425
+ askCondition: number
426
+ date: number
427
+ midpoint: number
428
+ expiration: number
429
+ strike: number
430
+ right: string
431
+ }
432
+
433
+ /** FPSS Trade tick. Mirrors `FpssData::Trade`. */
434
+ export interface Trade {
435
+ contractId: number
436
+ msOfDay: number
437
+ sequence: number
438
+ extCondition1: number
439
+ extCondition2: number
440
+ extCondition3: number
441
+ extCondition4: number
442
+ condition: number
443
+ size: number
444
+ exchange: number
445
+ price: number
446
+ conditionFlags: number
447
+ priceFlags: number
448
+ volumeType: number
449
+ recordsBack: number
450
+ date: number
451
+ receivedAtNs: bigint
452
+ }
453
+
454
+ /** Combined trade + quote tick. */
455
+ export interface TradeQuoteTick {
456
+ msOfDay: number
457
+ sequence: number
458
+ extCondition1: number
459
+ extCondition2: number
460
+ extCondition3: number
461
+ extCondition4: number
462
+ condition: number
463
+ size: number
464
+ exchange: number
465
+ price: number
466
+ conditionFlags: number
467
+ priceFlags: number
468
+ volumeType: number
469
+ recordsBack: number
470
+ quoteMsOfDay: number
471
+ bidSize: number
472
+ bidExchange: number
473
+ bid: number
474
+ bidCondition: number
475
+ askSize: number
476
+ askExchange: number
477
+ ask: number
478
+ askCondition: number
479
+ date: number
480
+ expiration: number
481
+ strike: number
482
+ right: string
483
+ }
484
+
485
+ /** Trade tick. Core unit of trade data. */
486
+ export interface TradeTick {
487
+ msOfDay: number
488
+ sequence: number
489
+ extCondition1: number
490
+ extCondition2: number
491
+ extCondition3: number
492
+ extCondition4: number
493
+ condition: number
494
+ size: number
495
+ exchange: number
496
+ price: number
497
+ conditionFlags: number
498
+ priceFlags: number
499
+ volumeType: number
500
+ recordsBack: number
501
+ date: number
502
+ expiration: number
503
+ strike: number
504
+ right: string
505
+ }