@orangecharts/wrun-chart-host 0.7.1 → 0.9.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 +27 -4
- package/dist/constants/feature-flags.constants.d.ts +5 -0
- package/dist/constants/feature-flags.constants.js +32 -0
- package/dist/constants/marketCapabilities.constants.d.ts +14 -9
- package/dist/constants/marketCapabilities.constants.js +36 -13
- package/dist/constants/opra-compliance.constants.d.ts +14 -0
- package/dist/constants/opra-compliance.constants.js +14 -0
- package/dist/constants/option-venues.constants.d.ts +29 -6
- package/dist/constants/option-venues.constants.js +19 -2
- package/dist/constants/venue-presets.constants.d.ts +17 -3
- package/dist/constants/venue-presets.constants.js +17 -3
- package/dist/host-env.d.ts +34 -4
- package/dist/host-env.js +21 -0
- package/dist/host-ports.types.d.ts +51 -3
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
- package/dist/indicators/controls/tpo-session.util.js +138 -14
- package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
- package/dist/interfaces/opra-realtime.interface.js +10 -10
- package/dist/interfaces/option-instrument.interface.d.ts +6 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +57 -10
- package/dist/kscript-data/controls/live-trades-merge.util.js +85 -16
- package/dist/market-data/billing.interface.d.ts +138 -17
- package/dist/market-data/billing.interface.js +25 -8
- package/dist/market-data/venues/index.d.ts +3 -3
- package/dist/market-data/venues/opra.contract.copy.json +5 -3
- package/dist/market-data/venues/opra.d.ts +3 -3
- package/dist/market-data/venues/opra.js +5 -4
- package/dist/replay/replayLadder.js +3 -1
- package/dist/settings-templates/footprint-rows.d.ts +25 -0
- package/dist/settings-templates/footprint-rows.js +127 -0
- package/dist/settings-templates/form-rows.d.ts +56 -0
- package/dist/settings-templates/form-rows.js +19 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/index.d.ts +10 -1
- package/dist/settings-templates/index.js +11 -2
- package/dist/settings-templates/indicator-fields.js +78 -0
- package/dist/settings-templates/tool-rules.d.ts +35 -9
- package/dist/settings-templates/tool-rules.js +42 -8
- package/dist/settings-templates/tool-tables.generated.js +13 -2
- package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
- package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
- package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
- package/dist/utility/chart/crypto-index.leaf.js +2 -2
- package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
- package/dist/utility/chart/footprint-columns.util.js +106 -0
- package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
- package/dist/utility/chart/footprint-display-mode.util.js +62 -0
- package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
- package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
- package/dist/utility/chart/index-mode-admission.util.js +9 -1
- package/dist/utility/chart/index-mode.util.d.ts +5 -2
- package/dist/utility/chart/index-mode.util.js +23 -13
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
- package/dist/utility/chart/kscript-venue-policy.util.js +34 -26
- package/dist/utility/chart/marketKind.util.d.ts +12 -10
- package/dist/utility/chart/marketKind.util.js +17 -7
- package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
- package/dist/utility/chart/om-panel-push-style.util.js +17 -15
- package/dist/utility/chart/om-panel.util.d.ts +11 -0
- package/dist/utility/chart/om-panel.util.js +65 -6
- package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
- package/dist/utility/chart/profile-block-size.util.js +7 -0
- package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
- package/dist/utility/chart/quote-perp.leaf.js +20 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
- package/dist/utility/chart/window-geometry.leaf.js +78 -6
- package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
- package/dist/utility/chart/window-owner.leaf.js +5 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
- package/dist/utility/chart/wrun-run-result.util.js +4 -1
- package/dist/utility/common/transformations.util.d.ts +7 -0
- package/dist/utility/common/transformations.util.js +11 -0
- package/dist/utility/options/cme-options-root.util.d.ts +25 -0
- package/dist/utility/options/cme-options-root.util.js +40 -0
- package/dist/utility/options/option-book.util.d.ts +27 -0
- package/dist/utility/options/option-book.util.js +76 -0
- package/dist/utility/options/option-trade-date.util.d.ts +50 -0
- package/dist/utility/options/option-trade-date.util.js +120 -0
- package/dist/utility/options/option-venue.util.d.ts +3 -3
- package/dist/utility/options/option-venue.util.js +3 -3
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
- package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
- package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
- package/dist/utility/wrun/sources/row-lane-registry.js +10 -5
- package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +25 -1
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +161 -30
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -1
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +83 -2
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +17 -1
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +33 -2
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +51 -5
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +136 -3
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +42 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +146 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +111 -20
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +291 -48
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
- package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
- package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
- package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
- package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
- package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
- package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
- package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +22 -9
- package/dist/utility/wrun/wrun-color-settings.util.js +57 -23
- package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
- package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
- package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
- package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +10 -3
- package/dist/utility/wrun/wrun-draft-overlay.util.js +63 -6
- package/dist/utility/wrun/wrun-frames.js +5 -5
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +11 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
- package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
- package/dist/utility/wrun/wrun-live-tick.util.js +130 -44
- package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
- package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +224 -0
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +342 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +88 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +471 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +172 -3
- package/dist/utility/wrun/wrun-option-prints.util.js +394 -17
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +99 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +218 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +365 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +797 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +231 -7
- package/dist/utility/wrun/wrun-option-views.util.js +643 -23
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
- package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -1
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +32 -3
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
- package/dist/utility/wrun/wrun-overlay-run.util.js +527 -180
- package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
- package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +13 -8
- package/dist/utility/wrun/wrun-pack.util.js +38 -21
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +41 -14
- package/dist/utility/wrun/wrun-panel-style.util.js +86 -26
- package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
- package/dist/utility/wrun/wrun-param-map.util.js +8 -5
- package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
- package/dist/utility/wrun/wrun-param-values.util.js +2 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
- package/dist/utility/wrun/wrun-refusal.util.js +17 -2
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +20 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +133 -48
- package/dist/utility/wrun/wrun-tape-source.util.js +205 -62
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
- package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
- package/dist/workers/utils/volume-profile.worker.util.js +5 -2
- package/dist/workers/wrun/wrun-abi-host.js +3 -2
- package/package.json +11 -11
|
@@ -648,6 +648,11 @@ export interface WrunRunResultOptions {
|
|
|
648
648
|
* at or after it and is merged row by row (wrun-batched-marks.util `tailFromTs`). Full runs,
|
|
649
649
|
* reseeds and pans leave it absent: every child builds its whole window under the cell budget. */
|
|
650
650
|
batchedTailFromTs?: number;
|
|
651
|
+
/** The chart market's dollar unit (wrunMarketDollarUnit when proven), handed to the batched children: a marks
|
|
652
|
+
* child carries it on its settings and readout, where the `units` caption and hover divide a record's dollar value
|
|
653
|
+
* by it (wrun-batched-marks.util `valuePerUnit`). Every build passes the one its market proves, a live tick's
|
|
654
|
+
* tail the same as its full run; absent where none is proven. */
|
|
655
|
+
valuePerUnit?: number;
|
|
651
656
|
/** WRUN-STYLE: the mounted overlay's id, handed to the levels child
|
|
652
657
|
* builders (absent = the sheet id stands in). */
|
|
653
658
|
overlayId?: string;
|
|
@@ -3590,7 +3590,10 @@ function buildWrunRunResultWithSelection(options, memo) {
|
|
|
3590
3590
|
// The batched marks (WRUN-BATCHED-MARKS): one row-backed child per marks, spans and rays section,
|
|
3591
3591
|
// its rows read off the run's own rows by output index; a full build charges the cell budget
|
|
3592
3592
|
// before any row is copied, a live tick builds its changed tail only.
|
|
3593
|
-
childOverlays.push(...wrunBatchedMarksChildren(metadata, rows,
|
|
3593
|
+
childOverlays.push(...wrunBatchedMarksChildren(metadata, rows, {
|
|
3594
|
+
...(options.batchedTailFromTs !== undefined ? { tailFromTs: options.batchedTailFromTs } : {}),
|
|
3595
|
+
...(options.valuePerUnit !== undefined ? { valuePerUnit: options.valuePerUnit } : {}),
|
|
3596
|
+
}));
|
|
3594
3597
|
childOverlays.push(...wrunProfileChildren(metadata, options.cellRows, {
|
|
3595
3598
|
intervalMs: rowIntervalMs,
|
|
3596
3599
|
outputRows: rows,
|
|
@@ -40,6 +40,13 @@ export declare function extractTokensFromTransformations(transformations: string
|
|
|
40
40
|
symbol?: string;
|
|
41
41
|
token: string;
|
|
42
42
|
}[];
|
|
43
|
+
/**
|
|
44
|
+
* Whether any `EX|SYM` leg of a series formula sits on a venue `isVenue` accepts. The legs are walked the way the
|
|
45
|
+
* fetch path reads them (extractTokensFromTransformations), so a leg the chart loads is a leg this sees. It is the one
|
|
46
|
+
* leg walk the licence doors share: the chart-read and export policy, and the OPRA display boundary, for a main
|
|
47
|
+
* series formula and an overlay's alike. False for a missing or blank formula.
|
|
48
|
+
*/
|
|
49
|
+
export declare function transformationsTouchVenue(transformations: unknown, isVenue: (exchange: string) => boolean): boolean;
|
|
43
50
|
export declare function subscribeOverlayToLiveFeed(subscribeToEachLiveFeed: Function, params: {
|
|
44
51
|
exchange: string;
|
|
45
52
|
symbol: string;
|
|
@@ -299,6 +299,17 @@ export function extractTokensFromTransformations(transformations, allowDuplicate
|
|
|
299
299
|
});
|
|
300
300
|
return tokens;
|
|
301
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Whether any `EX|SYM` leg of a series formula sits on a venue `isVenue` accepts. The legs are walked the way the
|
|
304
|
+
* fetch path reads them (extractTokensFromTransformations), so a leg the chart loads is a leg this sees. It is the one
|
|
305
|
+
* leg walk the licence doors share: the chart-read and export policy, and the OPRA display boundary, for a main
|
|
306
|
+
* series formula and an overlay's alike. False for a missing or blank formula.
|
|
307
|
+
*/
|
|
308
|
+
export function transformationsTouchVenue(transformations, isVenue) {
|
|
309
|
+
if (typeof transformations !== 'string' || !transformations.trim())
|
|
310
|
+
return false;
|
|
311
|
+
return extractTokensFromTransformations(transformations, true).some(({ exchange }) => typeof exchange === 'string' && isVenue(exchange));
|
|
312
|
+
}
|
|
302
313
|
export function subscribeOverlayToLiveFeed(subscribeToEachLiveFeed, params, overlayId) {
|
|
303
314
|
const multiSymbolExchanges = params?.multiSymbolExchanges;
|
|
304
315
|
const tokens = isNil(multiSymbolExchanges) || multiSymbolExchanges.length === 0
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CME futures roots whose charts read their options on another root. Since 2026-06-29 CME lists the financially
|
|
3
|
+
* settled Monday to Friday micro E-mini options (MS*, MN*) on settlement-only reference futures, MESF<q> and MNQF<q>,
|
|
4
|
+
* which never trade and expire with MES<q> and MNQ<q>. An MES or MNQ chart reads that chain (MESZ6 reads MESFZ6's),
|
|
5
|
+
* never the physically settled MES and MNQ options, which end on 2026-12-18 and stay in the Options tab as their own
|
|
6
|
+
* roots. The gateway and streamd group and price each MESF/MNQF option under its effective coin, the root's future
|
|
7
|
+
* with the earliest expiry not before the option's (OPTIONS-PORT brief 5a-EFFECTIVE-COIN): a chain is an expiry window.
|
|
8
|
+
*
|
|
9
|
+
* LOCKSTEP: the inverse of the gateway's priced-on roots (tsdb-gateway internal/cmeoption/cmeoption.go, `rules`
|
|
10
|
+
* `pricedOn`), which price these options on the future of the same month of the chart's root.
|
|
11
|
+
* tests/utility/options/cme-options-root.util.spec.ts pins the pairs: a pair changed there changes this table.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CME_OPTIONS_ROOT_OF: Readonly<Record<string, string>>;
|
|
14
|
+
/** The root a chart of `root`'s futures reads its options on: MESF for MES, the root itself for every other. */
|
|
15
|
+
export declare function cmeOptionsRootOf(root: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The root whose charts read `optionsRoot`'s options: MES for MESF (a reference future, which never trades and so
|
|
18
|
+
* charts nothing), the root itself for every other.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cmeChartRootOf(optionsRoot: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The contract a chart of `contract` reads its options on: its options root's contract of the same month (MESFZ6 for
|
|
23
|
+
* MESZ6), or `contract` itself for every other root and for a code that is no dated contract (a continuous alias).
|
|
24
|
+
*/
|
|
25
|
+
export declare function cmeOptionsContract(contract: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CME futures roots whose charts read their options on another root. Since 2026-06-29 CME lists the financially
|
|
3
|
+
* settled Monday to Friday micro E-mini options (MS*, MN*) on settlement-only reference futures, MESF<q> and MNQF<q>,
|
|
4
|
+
* which never trade and expire with MES<q> and MNQ<q>. An MES or MNQ chart reads that chain (MESZ6 reads MESFZ6's),
|
|
5
|
+
* never the physically settled MES and MNQ options, which end on 2026-12-18 and stay in the Options tab as their own
|
|
6
|
+
* roots. The gateway and streamd group and price each MESF/MNQF option under its effective coin, the root's future
|
|
7
|
+
* with the earliest expiry not before the option's (OPTIONS-PORT brief 5a-EFFECTIVE-COIN): a chain is an expiry window.
|
|
8
|
+
*
|
|
9
|
+
* LOCKSTEP: the inverse of the gateway's priced-on roots (tsdb-gateway internal/cmeoption/cmeoption.go, `rules`
|
|
10
|
+
* `pricedOn`), which price these options on the future of the same month of the chart's root.
|
|
11
|
+
* tests/utility/options/cme-options-root.util.spec.ts pins the pairs: a pair changed there changes this table.
|
|
12
|
+
*/
|
|
13
|
+
export const CME_OPTIONS_ROOT_OF = Object.freeze({ MES: 'MESF', MNQ: 'MNQF' });
|
|
14
|
+
const OPTIONS_ROOT = new Map(Object.entries(CME_OPTIONS_ROOT_OF));
|
|
15
|
+
const CHART_ROOT = new Map([...OPTIONS_ROOT].map(([root, optionsRoot]) => [optionsRoot, root]));
|
|
16
|
+
/** A CME contract code's root and its month code with one or two year digits, read as the gateway's `cmeoption.Root`. */
|
|
17
|
+
const CONTRACT_CODE = /^(.+?)([FGHJKMNQUVXZ]\d{1,2})$/;
|
|
18
|
+
/** The root a chart of `root`'s futures reads its options on: MESF for MES, the root itself for every other. */
|
|
19
|
+
export function cmeOptionsRootOf(root) {
|
|
20
|
+
return OPTIONS_ROOT.get(root) ?? root;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The root whose charts read `optionsRoot`'s options: MES for MESF (a reference future, which never trades and so
|
|
24
|
+
* charts nothing), the root itself for every other.
|
|
25
|
+
*/
|
|
26
|
+
export function cmeChartRootOf(optionsRoot) {
|
|
27
|
+
return CHART_ROOT.get(optionsRoot) ?? optionsRoot;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The contract a chart of `contract` reads its options on: its options root's contract of the same month (MESFZ6 for
|
|
31
|
+
* MESZ6), or `contract` itself for every other root and for a code that is no dated contract (a continuous alias).
|
|
32
|
+
*/
|
|
33
|
+
export function cmeOptionsContract(contract) {
|
|
34
|
+
const code = CONTRACT_CODE.exec(contract);
|
|
35
|
+
if (!code)
|
|
36
|
+
return contract;
|
|
37
|
+
const [, root, monthYear] = code;
|
|
38
|
+
const optionsRoot = cmeOptionsRootOf(root);
|
|
39
|
+
return optionsRoot === root ? contract : `${optionsRoot}${monthYear}`;
|
|
40
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OptionVenue } from '../../constants/option-venues.constants.js';
|
|
2
|
+
/**
|
|
3
|
+
* A symbol's product book and its base coin. Without a venue it reads Deribit's
|
|
4
|
+
* prefix (`BTC` inverse, `BTC_USDC` linear); on a venue it is the parsed root
|
|
5
|
+
* and settlement family, which also separates OKX `BTC-USD` from `BTC-USD_UM`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function optionBook(symbol: string, venueId?: OptionVenue['id']): {
|
|
8
|
+
base: string;
|
|
9
|
+
book: string;
|
|
10
|
+
};
|
|
11
|
+
/** What the book rule reads of a chain row: its symbol, its mark IV, and the options venue it was read from. */
|
|
12
|
+
export interface OptionBookRow {
|
|
13
|
+
symbol: string;
|
|
14
|
+
markIv?: number;
|
|
15
|
+
/** The `OptionVenue` id the row was read from (`OptionInstrumentSnapshot.venue`); absent rows read `venueId`. */
|
|
16
|
+
venue?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The options numbers' C0, the scope before every other number: an aggregate over a coin's chain reads ONE product
|
|
20
|
+
* book per base coin, the dominant one. `BTC-...` (inverse) and `BTC_USDC-...` (linear) share base `BTC` but are two
|
|
21
|
+
* vol surfaces with their own open interest, so a sum or a median over both is neither book's number. The book with
|
|
22
|
+
* the most contracts quoting a mark IV above 0 wins, ties to the lexicographically smaller book name (never input
|
|
23
|
+
* order); book and base come from `optionBook` at the row's own venue (`venueId` for rows without one). Each venue of
|
|
24
|
+
* a merged board keeps its own dominant book. A base with one book keeps every row (single-book coins, CME and OPRA
|
|
25
|
+
* chains, synthetic fixtures). Listings (the chain table, the picker's rows) never read this: they show every book.
|
|
26
|
+
*/
|
|
27
|
+
export declare function filterDominantBooks<T extends OptionBookRow>(rows: Iterable<T>, venueId?: OptionVenue['id']): T[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { parseOptionSymbol } from './option-symbol.util.js';
|
|
2
|
+
/**
|
|
3
|
+
* A symbol's product book and its base coin. Without a venue it reads Deribit's
|
|
4
|
+
* prefix (`BTC` inverse, `BTC_USDC` linear); on a venue it is the parsed root
|
|
5
|
+
* and settlement family, which also separates OKX `BTC-USD` from `BTC-USD_UM`.
|
|
6
|
+
*/
|
|
7
|
+
export function optionBook(symbol, venueId) {
|
|
8
|
+
const parsed = venueId ? parseOptionSymbol(venueId, symbol) : null;
|
|
9
|
+
if (parsed)
|
|
10
|
+
return { base: parsed.root, book: `${parsed.root}:${parsed.family ?? ''}` };
|
|
11
|
+
const book = symbol.split('-', 1)[0];
|
|
12
|
+
return { base: book.split('_', 1)[0], book };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `optionBook` per venue and symbol, read many times over: a chain's symbols repeat on every read, and every bar of a
|
|
16
|
+
* heatmap day reads the whole day (a venue's parser is a regular expression per symbol). Cleared whole at its cap.
|
|
17
|
+
*/
|
|
18
|
+
const booksByVenue = new Map();
|
|
19
|
+
let cachedBooks = 0;
|
|
20
|
+
const BOOK_CACHE_MAX = 50_000;
|
|
21
|
+
function cachedOptionBook(symbol, venueId) {
|
|
22
|
+
if (cachedBooks >= BOOK_CACHE_MAX) {
|
|
23
|
+
booksByVenue.clear();
|
|
24
|
+
cachedBooks = 0;
|
|
25
|
+
}
|
|
26
|
+
let books = booksByVenue.get(venueId ?? '');
|
|
27
|
+
if (!books) {
|
|
28
|
+
books = new Map();
|
|
29
|
+
booksByVenue.set(venueId ?? '', books);
|
|
30
|
+
}
|
|
31
|
+
let entry = books.get(symbol);
|
|
32
|
+
if (!entry) {
|
|
33
|
+
entry = optionBook(symbol, venueId);
|
|
34
|
+
books.set(symbol, entry);
|
|
35
|
+
cachedBooks += 1;
|
|
36
|
+
}
|
|
37
|
+
return entry;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The options numbers' C0, the scope before every other number: an aggregate over a coin's chain reads ONE product
|
|
41
|
+
* book per base coin, the dominant one. `BTC-...` (inverse) and `BTC_USDC-...` (linear) share base `BTC` but are two
|
|
42
|
+
* vol surfaces with their own open interest, so a sum or a median over both is neither book's number. The book with
|
|
43
|
+
* the most contracts quoting a mark IV above 0 wins, ties to the lexicographically smaller book name (never input
|
|
44
|
+
* order); book and base come from `optionBook` at the row's own venue (`venueId` for rows without one). Each venue of
|
|
45
|
+
* a merged board keeps its own dominant book. A base with one book keeps every row (single-book coins, CME and OPRA
|
|
46
|
+
* chains, synthetic fixtures). Listings (the chain table, the picker's rows) never read this: they show every book.
|
|
47
|
+
*/
|
|
48
|
+
export function filterDominantBooks(rows, venueId) {
|
|
49
|
+
const list = [...rows];
|
|
50
|
+
const keys = list.map((row) => {
|
|
51
|
+
const { base, book } = cachedOptionBook(row.symbol, row.venue ?? venueId);
|
|
52
|
+
return { group: `${row.venue ?? ''}|${base}`, book };
|
|
53
|
+
});
|
|
54
|
+
const countsByGroup = new Map();
|
|
55
|
+
list.forEach((row, at) => {
|
|
56
|
+
const { group, book } = keys[at];
|
|
57
|
+
let books = countsByGroup.get(group);
|
|
58
|
+
if (!books) {
|
|
59
|
+
books = new Map();
|
|
60
|
+
countsByGroup.set(group, books);
|
|
61
|
+
}
|
|
62
|
+
books.set(book, (books.get(book) ?? 0) + ((row.markIv ?? 0) > 0 ? 1 : 0));
|
|
63
|
+
});
|
|
64
|
+
const dominantByGroup = new Map();
|
|
65
|
+
for (const [group, books] of countsByGroup) {
|
|
66
|
+
let best = null;
|
|
67
|
+
for (const [book, count] of books) {
|
|
68
|
+
const bestCount = best === null ? -1 : (books.get(best) ?? 0);
|
|
69
|
+
if (best === null || count > bestCount || (count === bestCount && book < best))
|
|
70
|
+
best = book;
|
|
71
|
+
}
|
|
72
|
+
if (best !== null)
|
|
73
|
+
dominantByGroup.set(group, best);
|
|
74
|
+
}
|
|
75
|
+
return list.filter((_, at) => dominantByGroup.get(keys[at].group) === keys[at].book);
|
|
76
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The trade date an option row is dated on, on its venue family's clock: the ONE place the app dates an option print,
|
|
3
|
+
* bucket or expiry into a trade date. The clocks are the data plane's `option_venue_clocks` table, carried on the venue
|
|
4
|
+
* config (option-venues.constants `OptionVenue.tradeDateClock`), so no code here names a venue; a venue with no clock
|
|
5
|
+
* dates by the UTC date. Pure and worker-safe. docs/features/kscript/wrun/wrun-browser-runtime.md, "The venue-family
|
|
6
|
+
* trade-date clock".
|
|
7
|
+
*/
|
|
8
|
+
import { type OptionTradeDateRule } from '../../constants/option-venues.constants.js';
|
|
9
|
+
/** The chain an option row belongs to: the exchange its venue lists it on and, for a root family's rule, the coin its
|
|
10
|
+
* plane files it under (a CME futures contract, `BTCZ6`). */
|
|
11
|
+
export interface OptionTradeDateChain {
|
|
12
|
+
exchange: string;
|
|
13
|
+
coin?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The rule one row dates by: its zone and its dating rule. */
|
|
16
|
+
export interface OptionTradeDateClockRule {
|
|
17
|
+
zone: string;
|
|
18
|
+
rule: OptionTradeDateRule;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The clock a chain's rows date by: a root family's rule when the coin is one of its roots' futures on its exchanges,
|
|
22
|
+
* else the venue's clock, else the UTC date.
|
|
23
|
+
*/
|
|
24
|
+
export declare function optionTradeDateClockOf(chain: OptionTradeDateChain): OptionTradeDateClockRule;
|
|
25
|
+
/** The trade date an instant falls on under one clock rule, in days since the epoch (NaN for an instant it cannot
|
|
26
|
+
* read). */
|
|
27
|
+
export declare function optionTradeDayByClock(clock: OptionTradeDateClockRule, instantMs: number): number;
|
|
28
|
+
/** The trade date an instant falls on for a chain's rows, in days since the epoch (`optionTradeDateClockOf`). */
|
|
29
|
+
export declare function optionTradeDay(chain: OptionTradeDateChain, instantMs: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* The first instant of a trade date under one clock rule (the instant the date starts: 00:00 New York on OPRA, 17:00
|
|
32
|
+
* Chicago the evening before on a CME Group exchange, 16:00 Chicago on the Friday before a CME crypto Monday), or NaN
|
|
33
|
+
* for a date no instant falls on (a Saturday or a Sunday under `weekendsToMonday`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function optionTradeDayStartMsByClock(clock: OptionTradeDateClockRule, day: number): number;
|
|
36
|
+
/** A bar as `history` "today" dates it: its open and its end (one bar span on). */
|
|
37
|
+
export interface OptionTradeDayBar {
|
|
38
|
+
openMs: number;
|
|
39
|
+
endMs: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The first instant of `history` "today" under one clock rule: the trade date of the NEWEST BAR the chart holds (the
|
|
43
|
+
* newest bar a lane plans for), read at the bar's middle as a bucket is (a calendar bar stamped 00:00Z reads its own
|
|
44
|
+
* date). Never a clock's date: on a weekend, a holiday (the table models none, the chart's bars do) or a morning before
|
|
45
|
+
* the session's first print, the chart's newest bar is the last session's, so "today" is that session. It takes a
|
|
46
|
+
* bar, never an instant, so a clock cannot be handed to it. NaN for a bar it cannot date.
|
|
47
|
+
*/
|
|
48
|
+
export declare function optionTodayStartMsByClock(clock: OptionTradeDateClockRule, newestBar: OptionTradeDayBar): number;
|
|
49
|
+
/** Whether an expiry trades on the trade date of an instant (a bucket's) for a chain's rows: the 0DTE class. */
|
|
50
|
+
export declare function optionExpiresOnTradeDay(chain: OptionTradeDateChain, expiryMs: number, instantMs: number): boolean;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The trade date an option row is dated on, on its venue family's clock: the ONE place the app dates an option print,
|
|
3
|
+
* bucket or expiry into a trade date. The clocks are the data plane's `option_venue_clocks` table, carried on the venue
|
|
4
|
+
* config (option-venues.constants `OptionVenue.tradeDateClock`), so no code here names a venue; a venue with no clock
|
|
5
|
+
* dates by the UTC date. Pure and worker-safe. docs/features/kscript/wrun/wrun-browser-runtime.md, "The venue-family
|
|
6
|
+
* trade-date clock".
|
|
7
|
+
*/
|
|
8
|
+
import { OPTION_VENUES, } from '../../constants/option-venues.constants.js';
|
|
9
|
+
import { zoneWallMsAt, zoneWallToUtcMs } from '../chart/ny-calendar.util.js';
|
|
10
|
+
const HOUR_MS = 3_600_000;
|
|
11
|
+
const DAY_MS = 86_400_000;
|
|
12
|
+
const UTC_ZONE = 'UTC';
|
|
13
|
+
/** The UTC date, the clock of a venue the table does not list. */
|
|
14
|
+
const UTC_CLOCK = Object.freeze({ zone: UTC_ZONE, rule: { offsetHours: 0 } });
|
|
15
|
+
/** Each venue clock by exchange name (upper case), read off the venue config once. */
|
|
16
|
+
const CLOCKS_BY_EXCHANGE = new Map(OPTION_VENUES.flatMap((venue) => venue.tradeDateClock === undefined
|
|
17
|
+
? []
|
|
18
|
+
: venue.exchanges.map((exchange) => [exchange.toUpperCase(), venue.tradeDateClock])));
|
|
19
|
+
/** A root family's coin pattern: the root, a month code, one or two year digits (the data plane's own). */
|
|
20
|
+
const rootPatterns = new Map();
|
|
21
|
+
function rootPatternOf(roots) {
|
|
22
|
+
const key = roots.join('|');
|
|
23
|
+
let pattern = rootPatterns.get(key);
|
|
24
|
+
if (pattern === undefined) {
|
|
25
|
+
pattern = new RegExp(`^(${key})[FGHJKMNQUVXZ][0-9]{1,2}$`);
|
|
26
|
+
rootPatterns.set(key, pattern);
|
|
27
|
+
}
|
|
28
|
+
return pattern;
|
|
29
|
+
}
|
|
30
|
+
/** The rules decided per chain (a fold dates every row of one chain by the same rule). */
|
|
31
|
+
const rulesByChain = new Map();
|
|
32
|
+
const RULES_KEPT = 256;
|
|
33
|
+
/**
|
|
34
|
+
* The clock a chain's rows date by: a root family's rule when the coin is one of its roots' futures on its exchanges,
|
|
35
|
+
* else the venue's clock, else the UTC date.
|
|
36
|
+
*/
|
|
37
|
+
export function optionTradeDateClockOf(chain) {
|
|
38
|
+
const exchange = (chain.exchange ?? '').toUpperCase();
|
|
39
|
+
const coin = (chain.coin ?? '').toUpperCase();
|
|
40
|
+
const key = `${exchange}|${coin}`;
|
|
41
|
+
const held = rulesByChain.get(key);
|
|
42
|
+
if (held !== undefined)
|
|
43
|
+
return held;
|
|
44
|
+
const clock = CLOCKS_BY_EXCHANGE.get(exchange);
|
|
45
|
+
let decided = UTC_CLOCK;
|
|
46
|
+
if (clock !== undefined) {
|
|
47
|
+
const family = clock.rootFamilies?.find((candidate) => candidate.exchanges.some((name) => name.toUpperCase() === exchange) &&
|
|
48
|
+
rootPatternOf(candidate.roots).test(coin));
|
|
49
|
+
decided = { zone: clock.zone, rule: family?.rule ?? clock.rule };
|
|
50
|
+
}
|
|
51
|
+
if (rulesByChain.size >= RULES_KEPT)
|
|
52
|
+
rulesByChain.clear();
|
|
53
|
+
rulesByChain.set(key, decided);
|
|
54
|
+
return decided;
|
|
55
|
+
}
|
|
56
|
+
/** Days since the epoch, Monday-based weekday: 0 Monday .. 6 Sunday (1970-01-01, day 0, was a Thursday). */
|
|
57
|
+
function isoWeekday(day) {
|
|
58
|
+
return (((day + 3) % 7) + 7) % 7;
|
|
59
|
+
}
|
|
60
|
+
/** The wall clock of `zone` at an instant, a UTC-shaped epoch; NaN outside the instants the zone clock serves. */
|
|
61
|
+
function wallMsOf(zone, instantMs) {
|
|
62
|
+
return zone === UTC_ZONE ? instantMs : zoneWallMsAt(zone, instantMs);
|
|
63
|
+
}
|
|
64
|
+
/** The trade date an instant falls on under one clock rule, in days since the epoch (NaN for an instant it cannot
|
|
65
|
+
* read). */
|
|
66
|
+
export function optionTradeDayByClock(clock, instantMs) {
|
|
67
|
+
if (!Number.isFinite(instantMs))
|
|
68
|
+
return Number.NaN;
|
|
69
|
+
const wall = wallMsOf(clock.zone, instantMs);
|
|
70
|
+
if (!Number.isFinite(wall))
|
|
71
|
+
return Number.NaN;
|
|
72
|
+
const day = Math.floor((wall + clock.rule.offsetHours * HOUR_MS) / DAY_MS);
|
|
73
|
+
if (clock.rule.weekendsToMonday !== true)
|
|
74
|
+
return day;
|
|
75
|
+
const weekday = isoWeekday(day);
|
|
76
|
+
return weekday === 5 ? day + 2 : weekday === 6 ? day + 1 : day;
|
|
77
|
+
}
|
|
78
|
+
/** The trade date an instant falls on for a chain's rows, in days since the epoch (`optionTradeDateClockOf`). */
|
|
79
|
+
export function optionTradeDay(chain, instantMs) {
|
|
80
|
+
return optionTradeDayByClock(optionTradeDateClockOf(chain), instantMs);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The first instant of a trade date under one clock rule (the instant the date starts: 00:00 New York on OPRA, 17:00
|
|
84
|
+
* Chicago the evening before on a CME Group exchange, 16:00 Chicago on the Friday before a CME crypto Monday), or NaN
|
|
85
|
+
* for a date no instant falls on (a Saturday or a Sunday under `weekendsToMonday`).
|
|
86
|
+
*/
|
|
87
|
+
export function optionTradeDayStartMsByClock(clock, day) {
|
|
88
|
+
if (!Number.isFinite(day))
|
|
89
|
+
return Number.NaN;
|
|
90
|
+
let firstLocalDay = day;
|
|
91
|
+
if (clock.rule.weekendsToMonday === true) {
|
|
92
|
+
const weekday = isoWeekday(day);
|
|
93
|
+
if (weekday === 5 || weekday === 6)
|
|
94
|
+
return Number.NaN;
|
|
95
|
+
if (weekday === 0)
|
|
96
|
+
firstLocalDay = day - 2;
|
|
97
|
+
}
|
|
98
|
+
const wall = firstLocalDay * DAY_MS - clock.rule.offsetHours * HOUR_MS;
|
|
99
|
+
return clock.zone === UTC_ZONE ? wall : zoneWallToUtcMs(clock.zone, wall);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The first instant of `history` "today" under one clock rule: the trade date of the NEWEST BAR the chart holds (the
|
|
103
|
+
* newest bar a lane plans for), read at the bar's middle as a bucket is (a calendar bar stamped 00:00Z reads its own
|
|
104
|
+
* date). Never a clock's date: on a weekend, a holiday (the table models none, the chart's bars do) or a morning before
|
|
105
|
+
* the session's first print, the chart's newest bar is the last session's, so "today" is that session. It takes a
|
|
106
|
+
* bar, never an instant, so a clock cannot be handed to it. NaN for a bar it cannot date.
|
|
107
|
+
*/
|
|
108
|
+
export function optionTodayStartMsByClock(clock, newestBar) {
|
|
109
|
+
const { openMs, endMs } = newestBar;
|
|
110
|
+
if (!Number.isFinite(openMs))
|
|
111
|
+
return Number.NaN;
|
|
112
|
+
const span = Number.isFinite(endMs) && endMs > openMs ? endMs - openMs : 0;
|
|
113
|
+
return optionTradeDayStartMsByClock(clock, optionTradeDayByClock(clock, openMs + Math.floor(span / 2)));
|
|
114
|
+
}
|
|
115
|
+
/** Whether an expiry trades on the trade date of an instant (a bucket's) for a chain's rows: the 0DTE class. */
|
|
116
|
+
export function optionExpiresOnTradeDay(chain, expiryMs, instantMs) {
|
|
117
|
+
const clock = optionTradeDateClockOf(chain);
|
|
118
|
+
const expiryDay = optionTradeDayByClock(clock, expiryMs);
|
|
119
|
+
return Number.isFinite(expiryDay) && expiryDay === optionTradeDayByClock(clock, instantMs);
|
|
120
|
+
}
|
|
@@ -2,9 +2,9 @@ import { Category, Exchange } from '@orangecharts/orange-v2-pb-common';
|
|
|
2
2
|
import { type OptionVenue } from '../../constants/option-venues.constants.js';
|
|
3
3
|
import type { GateProvider } from '../../workers/constants/socket-slots.js';
|
|
4
4
|
/**
|
|
5
|
-
* Whether a gate plane's chain stamps true expiry instants (OptionVenue.expiryInstants: OPRA
|
|
6
|
-
*
|
|
7
|
-
* needs before it is offered on that plane.
|
|
5
|
+
* Whether a gate plane's chain stamps true expiry instants (OptionVenue.expiryInstants: OPRA and CME both,
|
|
6
|
+
* their registries stamp each expiry's instant, never a bare UTC-midnight date): what an option metric that
|
|
7
|
+
* reads time to expiry needs before it is offered on that plane.
|
|
8
8
|
*/
|
|
9
9
|
export declare function planeServesExpiryInstants(plane: GateProvider): boolean;
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Category, Exchange } from '@orangecharts/orange-v2-pb-common';
|
|
2
2
|
import { OPTION_VENUES } from '../../constants/option-venues.constants.js';
|
|
3
3
|
/**
|
|
4
|
-
* Whether a gate plane's chain stamps true expiry instants (OptionVenue.expiryInstants: OPRA
|
|
5
|
-
*
|
|
6
|
-
* needs before it is offered on that plane.
|
|
4
|
+
* Whether a gate plane's chain stamps true expiry instants (OptionVenue.expiryInstants: OPRA and CME both,
|
|
5
|
+
* their registries stamp each expiry's instant, never a bare UTC-midnight date): what an option metric that
|
|
6
|
+
* reads time to expiry needs before it is offered on that plane.
|
|
7
7
|
*/
|
|
8
8
|
export function planeServesExpiryInstants(plane) {
|
|
9
9
|
return OPTION_VENUES.some((venue) => venue.plane === plane && venue.expiryInstants === true);
|
|
@@ -71,7 +71,7 @@ export declare function forgetWrunLateReads(indicatorId: string): void;
|
|
|
71
71
|
* A run's lane thunks with every lane joining or adopting its late read first (`take`, the run's own lookup by its
|
|
72
72
|
* ask identity): a lane with one never runs its thunk, so no second ask leaves. The run's shape: the builtin lanes by
|
|
73
73
|
* name (a function or undefined) and the lists of `[lane id, thunk]` pairs (trades legs, poll lanes, row lanes);
|
|
74
|
-
* everything else is returned as it is.
|
|
74
|
+
* everything else is returned as it is. A thunk that runs gets every argument the lane runner hands it.
|
|
75
75
|
*/
|
|
76
76
|
export declare function wrunJoinLateReads<T extends object>(thunks: T, take: (lane: string) => Promise<WrunLateReadRows> | undefined): T;
|
|
77
77
|
export declare function __resetWrunLateReadsForTests(): void;
|
|
@@ -171,10 +171,10 @@ export function forgetWrunLateReads(indicatorId) {
|
|
|
171
171
|
* A run's lane thunks with every lane joining or adopting its late read first (`take`, the run's own lookup by its
|
|
172
172
|
* ask identity): a lane with one never runs its thunk, so no second ask leaves. The run's shape: the builtin lanes by
|
|
173
173
|
* name (a function or undefined) and the lists of `[lane id, thunk]` pairs (trades legs, poll lanes, row lanes);
|
|
174
|
-
* everything else is returned as it is.
|
|
174
|
+
* everything else is returned as it is. A thunk that runs gets every argument the lane runner hands it.
|
|
175
175
|
*/
|
|
176
176
|
export function wrunJoinLateReads(thunks, take) {
|
|
177
|
-
const joined = (lane, run) => (abandoned) => take(lane) ?? run(abandoned);
|
|
177
|
+
const joined = (lane, run) => (abandoned, ...rest) => take(lane) ?? run(abandoned, ...rest);
|
|
178
178
|
const out = { ...thunks };
|
|
179
179
|
for (const [key, value] of Object.entries(out)) {
|
|
180
180
|
if (typeof value === 'function') {
|
|
@@ -3,8 +3,8 @@ import type { WrunChartSourceRows } from '../wrun-source-rows.util.js';
|
|
|
3
3
|
import type { WrunPollLaneInstance } from '../sources/wrun-poll-lane.types.js';
|
|
4
4
|
import type { WrunRowLaneInstance } from '../sources/wrun-row-lane.types.js';
|
|
5
5
|
import { type WrunPrefixLaneClause, type WrunPrefixLaneEvidence, type WrunPrefixLanePages, type WrunPrefixLanePlan, type WrunPrefixLaneSplice } from '../wrun-prefix-lanes.util.js';
|
|
6
|
-
/** The clause that refuses a session (`lanes:<clause>`): the base rule's,
|
|
7
|
-
export type WrunPrefixFeedClause = WrunPrefixLaneClause | 'row-budget';
|
|
6
|
+
/** The clause that refuses a session (`lanes:<clause>`): the base rule's, `row-budget` or `filling` (the module note). */
|
|
7
|
+
export type WrunPrefixFeedClause = WrunPrefixLaneClause | 'row-budget' | 'filling';
|
|
8
8
|
/** What a page asks again: the base rule's lanes, the daily poll lanes, the row lanes asked by host bar, and the row
|
|
9
9
|
* lanes read empty on the page (a `latest` landing). */
|
|
10
10
|
export interface WrunPrefixFeedPlan extends WrunPrefixLanePlan {
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
* refused (`live-row`), as the options chain's is.
|
|
23
23
|
*
|
|
24
24
|
* Still refused, each by a named clause (`lanes:<clause>`): a row lane under a row budget (`row-budget`: a whole run
|
|
25
|
-
* keeps the NEWEST bars of its whole window that fit, a page would keep the page's own), a row lane
|
|
25
|
+
* keeps the NEWEST bars of its whole window that fit, a page would keep the page's own), a row lane whose rows hold its
|
|
26
|
+
* first-paint slice alone (`filling`: its older bars read partial until the source ladder adopts the whole answer, and
|
|
27
|
+
* a page spliced before them would keep them partial), a row lane this build does
|
|
26
28
|
* not know or holds no buffer of (`input-source`), a daily lane under a host-grid landing, or with no recorded ask or
|
|
27
29
|
* no buffer to stand on (`daily`), a primary under carry reading a daily lane (`primary-carry`), and any of these
|
|
28
30
|
* lanes on an index-mode chart unless it
|
|
@@ -118,6 +120,8 @@ export function planWrunPrefixFeeds(context) {
|
|
|
118
120
|
}
|
|
119
121
|
if (lane.rowBudget !== undefined)
|
|
120
122
|
return refused('row-budget');
|
|
123
|
+
if (context.rowLaneFilling?.[instance.key] !== undefined)
|
|
124
|
+
return refused('filling');
|
|
121
125
|
if (context.acquisition[instance.key] === undefined)
|
|
122
126
|
return refused('input-source');
|
|
123
127
|
if (indexMode && lane.fetch === undefined && wrunRowLaneFetchOptions(lane)?.nativeRows !== true) {
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
* The registry check of a host-grid landing (UW-PARITY rule 9), shared by the poll-lane registry (`barGrid` on a
|
|
3
3
|
* `nativeRows` lane) and the row-lane registry (a flow or snapshot row lane's `landing`): a flow or a snapshot, and
|
|
4
4
|
* its backend tiers, each a key of its own, a positive whole width in ms, a positive retention or none and a positive
|
|
5
|
-
* served lag or none
|
|
5
|
+
* served lag or none; a tier choice, when the grid names one, the finest or the coarsest, the coarsest on a flow with
|
|
6
|
+
* tiers only (a snapshot's newest sealed row is its tier's own, and with no tiers there is nothing to choose).
|
|
6
7
|
*
|
|
7
8
|
* A LEAF on purpose (type imports only): both registries read it at module load, and the row-lane registry stays off
|
|
8
9
|
* the poll-lane registry's import graph (a module reading row lanes never loads the poll lanes' files).
|
|
9
10
|
*/
|
|
10
|
-
import type { WrunBackendTier, WrunTierLanding } from '../wrun-tier-grid.util.js';
|
|
11
|
+
import type { WrunBackendTier, WrunTierChoice, WrunTierLanding } from '../wrun-tier-grid.util.js';
|
|
11
12
|
/** Refuse a malformed host-grid landing by name (a programming error, never a user's). */
|
|
12
13
|
export declare function assertWrunHostGridLanding(who: string, grid: {
|
|
13
14
|
landing: WrunTierLanding;
|
|
14
15
|
tiers?: readonly WrunBackendTier[];
|
|
16
|
+
tierChoice?: WrunTierChoice;
|
|
15
17
|
}): void;
|
|
@@ -3,6 +3,14 @@ export function assertWrunHostGridLanding(who, grid) {
|
|
|
3
3
|
if (grid.landing !== 'flow' && grid.landing !== 'snapshot') {
|
|
4
4
|
throw new Error(`${who}: barGrid landing is 'flow' or 'snapshot'`);
|
|
5
5
|
}
|
|
6
|
+
if (grid.tierChoice !== undefined) {
|
|
7
|
+
if (grid.tierChoice !== 'finest' && grid.tierChoice !== 'coarsest') {
|
|
8
|
+
throw new Error(`${who}: barGrid tierChoice is 'finest', 'coarsest' or absent`);
|
|
9
|
+
}
|
|
10
|
+
if (grid.tierChoice === 'coarsest' && (grid.landing !== 'flow' || grid.tiers === undefined)) {
|
|
11
|
+
throw new Error(`${who}: the coarsest tier choice needs a flow with tiers (a bar summed alike from any tier)`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
6
14
|
if (grid.tiers === undefined)
|
|
7
15
|
return;
|
|
8
16
|
if (!Array.isArray(grid.tiers) || grid.tiers.length === 0) {
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* It reads OPTION_PRINT_AGG flow scope rows (wrun-opra-flow.leaf: which rows each ask names) through the
|
|
8
8
|
* `K_OPTION_PRINT_AGG_SCOPE` control and its worker twin, which sums a bucket's matching rows into the 32 fields
|
|
9
9
|
* (`foldWrunOptionsFlowRows`); this lane lands the buckets on the chart's bars under the tier rule (rule 9: 1m kept 7
|
|
10
|
-
* days, 5m kept 30, 1d kept
|
|
10
|
+
* days, 5m kept 30, 1d kept; OPTLOAD-READ-CONTRACT 5.4: the COARSEST that fits the bar, still holds it and already
|
|
11
|
+
* serves it, `tierChoice`, so a closed hourly bar reads 5m buckets and the forming one 1m; a stock chart's 09:30 New
|
|
12
|
+
* York bars, an
|
|
11
13
|
* OPRA contract chart's and a crypto chart's UTC ones, a CME chart's intraday ones on their stamps; a CME bar of a day
|
|
12
14
|
* or longer over its Globex session, from the 17:00 Chicago open before its 00:00Z stamp, which no UTC day bucket fits:
|
|
13
15
|
* such a bar older than the 5m tier reads its fill, never a misdated day), summed per bar. A bar no tier holds any more
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
* alone for a guest, as every other chain class reads the gate), `equity`, `etf`, `index` (MARKET rows of that US
|
|
31
33
|
* issue type: OPRA only), `venue` (OPRA: VENUE rows of the `venue` knob's exchange; crypto: COIN rows of the chart's
|
|
32
34
|
* coin on that venue, every book, a venue the gate keeps dark refused `flag-off` as the chain decision refuses it;
|
|
33
|
-
* CME, one venue: none);
|
|
35
|
+
* CME, one venue: none), `prints` (PRINTS rows of the chain's underlying on every plane, every book);
|
|
34
36
|
* - `dte`: `all` (the default), `0dte`, `week` (1 to 7 days), `month` (8 to 35), `later`;
|
|
35
37
|
* - `moneyness`: `all` (the default), `otm`, `itm`;
|
|
36
38
|
* - `venue`: scope `venue` only, required there: on OPRA an exchange's ISO MIC (`XCBO`), read by its Databento
|
|
@@ -38,11 +40,22 @@
|
|
|
38
40
|
* (`OKEX_OPTIONS`, the venue table's). That scope serves `call_prem_total`, `put_prem_total`,
|
|
39
41
|
* `call_contracts_total`, `put_contracts_total` and `prints` alone, with no `dte` or `moneyness` split;
|
|
40
42
|
* - `book`: scope `ticker` only: `auto` (the default, the chain's default book) or one series of the chain, decided
|
|
41
|
-
* when the run plans; a crypto chain's ask names it, an OPRA or CME chain's one book is its underlying
|
|
43
|
+
* when the run plans; a crypto chain's ask names it, an OPRA or CME chain's one book is its underlying;
|
|
44
|
+
* - `min_premium` and `max_dte`: scope `prints` only (OPTLOAD G4, kit 0.89.0): the premium floor in USD (required, above
|
|
45
|
+
* 0) and the most days to expiry (whole, 0 to 3,650; 0 keeps every expiry) of the chart underlying's prints the scope
|
|
46
|
+
* sums per bar, on every plane (the chain's exchange and underlying, every book). A knob may name a setting (an
|
|
47
|
+
* author's `"@floor"`, the sheet's `"floor"`): the planner reads its current value before this plan (wrun-poll-lanes
|
|
48
|
+
* `resolveWrunOptionSettingKnobs`), so a settings change re-plans and re-asks; a name no value reached is refused
|
|
49
|
+
* by name. Its history is the print tables' reach (`horizon`: 3 days raw, the large table past 25,000 USD up to the
|
|
50
|
+
* gateway's bar limit); older bars read the fill.
|
|
42
51
|
* A scope the chart's plane does not serve (a US issue type off OPRA, `venue` on CME, a venue word of another plane) is
|
|
43
52
|
* refused with `wrunLaneUnservedScopeSeed`'s seed, so the planner drops an input that declared a fill with the market's
|
|
44
53
|
* note, as on a chart with no option chain (the options chain's `no-chain`, a LINK perp).
|
|
45
54
|
*
|
|
55
|
+
* OPTLOAD (OPTLOAD-READ-CONTRACT section 5): the worker twin asks the gateway for one row per chart bar per option type
|
|
56
|
+
* of the asked split (`optionRead`: the bar, its anchor, the split) and packs the frames, and falls back to today's ask
|
|
57
|
+
* for the session when the gateway refuses `optionRead` by name; the fold, the landing and every answer stay the same.
|
|
58
|
+
*
|
|
46
59
|
* Before the protocol package names OPTION_PRINT_AGG, every input refuses by name before any fetch
|
|
47
60
|
* (`protocol-pending:OPTION_PRINT_AGG`). The gateway's scope reads stay behind its `read.option_print_scopes`
|
|
48
61
|
* switch: while it is off, the worker twin answers the refusal by name (`option-scope-reads-off`) and the run
|
|
@@ -50,12 +63,35 @@
|
|
|
50
63
|
*/
|
|
51
64
|
import { type WrunPollLane } from '../wrun-poll-lane.types.js';
|
|
52
65
|
import type { WrunBackendTier } from '../../wrun-tier-grid.util.js';
|
|
66
|
+
import type { WrunRowLaneHorizon } from '../wrun-row-lane.types.js';
|
|
53
67
|
/** The lane key (the refusal record's feed words, `wrun.refusal.feed.optionsFlow`). */
|
|
54
68
|
export declare const WRUN_OPTIONS_FLOW_LANE_KEY = "options_flow";
|
|
55
69
|
/** The tiers a bar is read from (rule 9, ADDENDUM-2 B3, the cme plane's scope families and ore's alike: C7-1; the VENUE
|
|
56
70
|
* family keeps no 5m tier, so a 5m ask of it the gateway rolls up from its 1m rows, which a bar older than 7 days no
|
|
57
|
-
* longer has: that bar reads its fill).
|
|
71
|
+
* longer has: that bar reads its fill).
|
|
72
|
+
* `servedLagMs` (OPTLOAD-READ-CONTRACT 5.4, read by the lane's coarsest tier choice): how long after a bar ends a
|
|
73
|
+
* coarser tier serves it. The 5m tier waits out the delayed window's lag, as the contract tiers do (the 15-minute
|
|
74
|
+
* OPRA delay plus the governed route's 120 s: a delayed read's end never falls inside a 5m bucket the reader serves
|
|
75
|
+
* whole); the day tier is refreshed only by `option-print-flow-slow` (hourly at :45, 4 hours back, once the day has
|
|
76
|
+
* ended), so it serves a day 6 hours after it ends. */
|
|
58
77
|
export declare const WRUN_OPTIONS_FLOW_TIERS: readonly WrunBackendTier[];
|
|
78
|
+
/**
|
|
79
|
+
* The print tables scope `prints` sums (OPTLOAD-READ-CONTRACT 7.2 and 7.4, the same pick as `option_prints`):
|
|
80
|
+
* `option_print_large` (90 days) once the floor reaches the large premium, else the raw `option_print` (3 days), never
|
|
81
|
+
* past the gateway's bar limit on a minute read (15,000 minutes); the clock margin keeps a bar at the edge out. The
|
|
82
|
+
* values are wrun-option-prints.util's (its module loads the venue table, which this lane reads lazily), pinned equal by
|
|
83
|
+
* the lane's spec.
|
|
84
|
+
*/
|
|
85
|
+
export declare const WRUN_OPTIONS_FLOW_PRINT_TABLES: Readonly<{
|
|
86
|
+
largeMinPremium: 25000;
|
|
87
|
+
rawRetentionMs: number;
|
|
88
|
+
largeRetentionMs: number;
|
|
89
|
+
barLimitMs: number;
|
|
90
|
+
clockMarginMs: number;
|
|
91
|
+
}>;
|
|
92
|
+
/** The span scope `prints` is served over at the clock (the lane's `horizon`): from the table its floor reads, within
|
|
93
|
+
* the bar limit; every other scope's history is its tiers' (none). */
|
|
94
|
+
export declare function wrunOptionsFlowHorizon(extras: Readonly<Record<string, unknown>>, nowMs: number): WrunRowLaneHorizon | undefined;
|
|
59
95
|
/**
|
|
60
96
|
* The Databento publisher id the data plane names each `venue` word by (the VENUE rows' `venue`, the request's
|
|
61
97
|
* `VENUE:<id>`). The words are ISO MIC codes, Databento's OPRA.PILLAR publisher suffixes (`OPRA.PILLAR.XCBO`): the
|