@orangecharts/wrun-chart-host 0.8.0 → 0.10.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 +3 -1
- package/dist/constants/feature-flags.constants.d.ts +9 -0
- package/dist/constants/feature-flags.constants.js +86 -16
- 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 +15 -0
- package/dist/constants/opra-compliance.constants.js +15 -0
- package/dist/constants/option-venues.constants.d.ts +11 -6
- package/dist/constants/option-venues.constants.js +5 -2
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
- package/dist/constants/venue-presets.constants.d.ts +20 -20
- package/dist/constants/venue-presets.constants.js +24 -26
- package/dist/host-env.d.ts +39 -9
- package/dist/host-env.js +6 -0
- package/dist/host-ports.types.d.ts +108 -18
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
- package/dist/interfaces/opra-realtime.interface.js +10 -10
- package/dist/interfaces/replay.interface.d.ts +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +52 -15
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +94 -14
- package/dist/kscript-data/controls/live-trades-merge.util.js +132 -22
- package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
- package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
- package/dist/market-data/billing.interface.d.ts +227 -42
- package/dist/market-data/billing.interface.js +60 -12
- package/dist/market-data/venue.d.ts +88 -6
- package/dist/market-data/venues/cme.contract.copy.json +66 -0
- package/dist/market-data/venues/cme.d.ts +126 -0
- package/dist/market-data/venues/cme.js +133 -0
- package/dist/market-data/venues/index.d.ts +165 -8
- package/dist/market-data/venues/index.js +48 -6
- 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/index.js +7 -3
- package/dist/settings-templates/indicator-fields.d.ts +5 -4
- package/dist/settings-templates/indicator-fields.js +45 -6
- package/dist/settings-templates/tool-rules.d.ts +27 -17
- package/dist/settings-templates/tool-rules.js +27 -11
- package/dist/settings-templates/tool-tables.generated.js +91 -31
- package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
- package/dist/utility/chart/book-live-bucket.util.js +47 -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/index-mode-admission.util.js +24 -3
- 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-drawing-safe-area.util.d.ts +35 -11
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
- package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
- package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -27
- package/dist/utility/chart/kscript-venue-policy.util.js +74 -32
- package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
- package/dist/utility/chart/market-session-schedule.util.js +16 -0
- 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.js +6 -6
- package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
- package/dist/utility/chart/opra-read-access.leaf.js +5 -3
- 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/rth-session.util.d.ts +3 -2
- package/dist/utility/chart/rth-session.util.js +2 -1
- package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
- package/dist/utility/chart/window-geometry.leaf.js +22 -6
- package/dist/utility/chart/wrun-run-result.util.d.ts +17 -0
- package/dist/utility/chart/wrun-run-result.util.js +145 -7
- package/dist/utility/common/transformations.util.d.ts +7 -0
- package/dist/utility/common/transformations.util.js +11 -0
- package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
- package/dist/utility/options/option-bar-anchor.util.js +340 -0
- package/dist/utility/options/option-venue.util.d.ts +21 -3
- package/dist/utility/options/option-venue.util.js +30 -3
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
- package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
- package/dist/utility/wrun/derived-roots.util.js +471 -0
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +5 -3
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +6 -4
- 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/lanes/option_daily.js +5 -2
- package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
- package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
- 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 +15 -6
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +82 -13
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -8
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +95 -14
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +7 -3
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +35 -14
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +70 -20
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +45 -1
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +114 -6
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +56 -5
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +224 -26
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +822 -58
- 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-builtin-twin.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
- 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 +192 -13
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +437 -55
- 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 +15 -4
- package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
- 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 +107 -0
- package/dist/utility/wrun/wrun-download-meter.util.js +134 -0
- package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
- package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
- package/dist/utility/wrun/wrun-frames.d.ts +27 -6
- package/dist/utility/wrun/wrun-frames.js +78 -15
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
- package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +51 -21
- package/dist/utility/wrun/wrun-hud-looks.util.js +74 -28
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
- 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 +19 -9
- package/dist/utility/wrun/wrun-live-intake.util.js +213 -45
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +246 -49
- 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 +205 -48
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +277 -34
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +340 -56
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
- package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
- package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +26 -6
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +50 -11
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +109 -19
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +222 -61
- package/dist/utility/wrun/wrun-option-views.util.d.ts +96 -18
- package/dist/utility/wrun/wrun-option-views.util.js +246 -51
- 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-output-style.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-output-style.util.js +20 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +20 -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-lifecycle.util.d.ts +10 -1
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
- 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 +134 -37
- package/dist/utility/wrun/wrun-overlay-run.util.js +1118 -254
- package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
- package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
- package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-pack.util.js +20 -9
- package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +37 -24
- package/dist/utility/wrun/wrun-panel-style.util.js +100 -29
- package/dist/utility/wrun/wrun-param-map.util.d.ts +15 -11
- package/dist/utility/wrun/wrun-param-map.util.js +13 -5
- package/dist/utility/wrun/wrun-param-values.util.d.ts +21 -3
- package/dist/utility/wrun/wrun-param-values.util.js +6 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
- package/dist/utility/wrun/wrun-refusal.util.js +10 -1
- package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
- package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +52 -1
- package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
- package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +9 -1
- package/dist/utility/wrun/wrun-source-rows.util.js +108 -43
- package/dist/utility/wrun/wrun-style-words.util.js +6 -4
- package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
- package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
- package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
- 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/utils/replay/replay-buffer-math.d.ts +53 -2
- package/dist/utils/replay/replay-buffer-math.js +227 -20
- 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 +5 -5
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bars a grouped option read lays (OPTLOAD-READ-CONTRACT 3.2 to 3.4): the app's ONE mirror of tsdb-gateway's anchor
|
|
3
|
+
* rules, read at origin/main d83cbbf20 (pkg/tsdb/selects/option_read_shape.go `barAnchorRules`, `optionReadAnchorReads`,
|
|
4
|
+
* `OptionReadGridOf` and each rule's `fitTier`, `bar`, `session`, `boundary`, `barEnd` and `lays`;
|
|
5
|
+
* option_print_agg_group.go `optionPrintAggCMESessionScopes`; trade_agg.go `cmeRegularSessionAnchor` and
|
|
6
|
+
* `cmeEnergySessionAnchor`; cme.go `cmeSessionDay`, `cmeSessionOpen`, `cmeCurrentSessionLabel` and `isCMEGroupExchange`).
|
|
7
|
+
* Every option read that names a `barAnchor` takes the anchors, their bars, the venues they lay and the reads that take
|
|
8
|
+
* them from here: the strike and contract flow groupings (wrun-option-strike-flow.util), the flow scopes' bars
|
|
9
|
+
* (option-print-agg-scope.worker.util), the prints' per-bar cut (k-option-print.worker), the surface pick
|
|
10
|
+
* (k-option-surface.worker) and the delayed bound's grid (option-read-grid.util). The rules are keyed by pb-common's
|
|
11
|
+
* `BarAnchor`, so an anchor the protocol adds fails the type check until it has a rule here, and the class guard
|
|
12
|
+
* (tests/utility/options/option-bar-anchor.class.spec.ts) fails by name on any other module that names an anchor.
|
|
13
|
+
*
|
|
14
|
+
* - UTC: bars on the Unix epoch, every row counted; its session is the UTC date.
|
|
15
|
+
* - US_EQUITY_RTH, CME_RTH and CME_ENERGY_RTH: a regular session on the New York wall clock (09:30 to 16:00; 09:30 to
|
|
16
|
+
* 16:15, the CME platform session the CME candles keep; 09:00 to 14:30, the energy pit session), weekdays only, bars
|
|
17
|
+
* open + k * width, only rows of [open, close) counted, the last bar of a day short; no holiday is modelled, as the
|
|
18
|
+
* charts model none. The two CME anchors lay bars over the CME group's rows alone, built from tiers dividing 15 and 30
|
|
19
|
+
* minutes; daylight saving comes from the tz database on both sides.
|
|
20
|
+
* - CME_SESSION: the Globex trade date (17:00 Chicago opens the next; a weekday holiday's session belongs to the next
|
|
21
|
+
* trade date on the CME calendar, a weekend day keeps its own date), each bar stamped at the 17:00 open of its first
|
|
22
|
+
* session day; a 604,800 s bar is the ISO week of a trade date. The CME group's alone, taken by OPTION_PRINT_AGG's
|
|
23
|
+
* COIN, MARKET, STRIKE, EXPIRY, EXPIRY_STRIKE and CONTRACT scopes alone, from a tier dividing an hour. It drops no
|
|
24
|
+
* row: an always-on root's weekend rows land on their own dates, as the chart's lattice books them.
|
|
25
|
+
*
|
|
26
|
+
* A decider proves an anchor's bars against the chart's own: a bucket the anchor lays no bar for may fall on a chart bar
|
|
27
|
+
* only where the chart's product holds no trading (`optionChartClosedAt`, its schedule), never because the anchor's own
|
|
28
|
+
* hours leave it out (a CME regular session's weekend on an always-on root).
|
|
29
|
+
*
|
|
30
|
+
* Pure and worker-safe: the zone clock (ny-calendar.util), the CME lattice's trade calendar (cme-session-bucket.util) and
|
|
31
|
+
* the CME products' schedules (market-session-schedule.util).
|
|
32
|
+
*/
|
|
33
|
+
import { BarAnchor, BarSpan } from '@orangecharts/orange-v2-pb-common';
|
|
34
|
+
import { cmeSessionBucketMs, isCmeSessionLatticeExchange } from '../chart/cme-session-bucket.util.js';
|
|
35
|
+
import { isGovernedFuturesSymbolOpenAt } from '../chart/market-session-schedule.util.js';
|
|
36
|
+
import { zoneWallMsAt, zoneWallToUtcMs } from '../chart/ny-calendar.util.js';
|
|
37
|
+
const MINUTE_MS = 60_000;
|
|
38
|
+
const HOUR_MS = 3_600_000;
|
|
39
|
+
const DAY_MS = 86_400_000;
|
|
40
|
+
const WEEK_MS = 7 * DAY_MS;
|
|
41
|
+
/** pb-common `BarAnchor` by name: the values a request names (the gateway decodes JSON enums as numbers). */
|
|
42
|
+
export const OPTION_BAR_ANCHOR = Object.freeze({
|
|
43
|
+
UTC: BarAnchor.UTC,
|
|
44
|
+
US_EQUITY_RTH: BarAnchor.US_EQUITY_RTH,
|
|
45
|
+
CME_SESSION: BarAnchor.CME_SESSION,
|
|
46
|
+
CME_RTH: BarAnchor.CME_RTH,
|
|
47
|
+
CME_ENERGY_RTH: BarAnchor.CME_ENERGY_RTH,
|
|
48
|
+
});
|
|
49
|
+
const floorMod = (value, width) => ((value % width) + width) % width;
|
|
50
|
+
/** `fitDayBars`: no bar wider than a day, a day bar from the DAY tier alone, and a whole number of the tier's buckets;
|
|
51
|
+
* a session is the anchor's own to fit. */
|
|
52
|
+
function fitDayBars(tierMs, barMs, session) {
|
|
53
|
+
if (session)
|
|
54
|
+
return true;
|
|
55
|
+
if (barMs > DAY_MS || (barMs === DAY_MS && tierMs !== DAY_MS))
|
|
56
|
+
return false;
|
|
57
|
+
return barMs % tierMs === 0;
|
|
58
|
+
}
|
|
59
|
+
/** `opensBar`: `tMs` opens the bar (or session) it lands in, or lands in none. */
|
|
60
|
+
function opensBar(rule, tMs, barMs, session) {
|
|
61
|
+
const open = session ? rule.sessionOpenMs(tMs) : rule.barOpenMs(tMs, barMs);
|
|
62
|
+
return open === null || open === tMs;
|
|
63
|
+
}
|
|
64
|
+
/** The latest boundary at or before `tMs` on a rule whose bars run unbroken from their open: the open of the bar (or
|
|
65
|
+
* session) holding it, else `tMs` itself (it lands in none). */
|
|
66
|
+
function floorOpensBar(rule, tMs, barMs, session) {
|
|
67
|
+
return (session ? rule.sessionOpenMs(tMs) : rule.barOpenMs(tMs, barMs)) ?? tMs;
|
|
68
|
+
}
|
|
69
|
+
const UTC_RULE = {
|
|
70
|
+
anchor: BarAnchor.UTC,
|
|
71
|
+
name: BarAnchor[BarAnchor.UTC],
|
|
72
|
+
tradeDate: { zone: 'UTC', offsetHours: 0 },
|
|
73
|
+
venues: 'every',
|
|
74
|
+
lays: () => true,
|
|
75
|
+
takes: () => true,
|
|
76
|
+
fitsTier: (tierMs, barMs, session) => tierMs > 0 && fitDayBars(tierMs, barMs, session) && (!session || DAY_MS % tierMs === 0),
|
|
77
|
+
barOpenMs: (tMs, barMs) => {
|
|
78
|
+
if (!Number.isFinite(tMs))
|
|
79
|
+
return null;
|
|
80
|
+
return barMs > 0 ? tMs - floorMod(tMs, barMs) : tMs;
|
|
81
|
+
},
|
|
82
|
+
sessionOpenMs: (tMs) => (Number.isFinite(tMs) ? tMs - floorMod(tMs, DAY_MS) : null),
|
|
83
|
+
isBoundary: (tMs, barMs, session) => opensBar(UTC_RULE, tMs, barMs, session),
|
|
84
|
+
floorBoundaryMs: (tMs, barMs, session) => floorOpensBar(UTC_RULE, tMs, barMs, session),
|
|
85
|
+
barEndMs: (openMs, barMs, session) => openMs + (session ? DAY_MS : barMs),
|
|
86
|
+
};
|
|
87
|
+
/** 1970-01-01, day 0, was a Thursday: a weekend day is a Saturday or a Sunday. */
|
|
88
|
+
const isWeekendDay = (day) => {
|
|
89
|
+
const weekday = floorMod(day + 4, 7);
|
|
90
|
+
return weekday === 0 || weekday === 6;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* `regularSessionAnchor`: each weekday's open in the session's zone, bars open + k * width, only rows of [open, close)
|
|
94
|
+
* of that weekday counted, the last bar of a day ending at the close; its session is one trade date of the zone. Built
|
|
95
|
+
* from tiers dividing `tierMs` (the coarsest bucket the open and the close both sit on).
|
|
96
|
+
*/
|
|
97
|
+
function regularSessionRule(anchor, session, tierMs, venues) {
|
|
98
|
+
const dayOf = (tMs) => Math.floor(zoneWallMsAt(session.zone, tMs) / DAY_MS);
|
|
99
|
+
const wallAt = (day, minutes) => zoneWallToUtcMs(session.zone, day * DAY_MS + minutes * MINUTE_MS);
|
|
100
|
+
/** `openOf`: the open of the session `tMs` trades in, null on a weekend or outside [open, close) of its day. */
|
|
101
|
+
const openOf = (tMs) => {
|
|
102
|
+
if (!Number.isFinite(tMs))
|
|
103
|
+
return null;
|
|
104
|
+
const day = dayOf(tMs);
|
|
105
|
+
if (!Number.isFinite(day) || isWeekendDay(day))
|
|
106
|
+
return null;
|
|
107
|
+
const open = wallAt(day, session.openMinutes);
|
|
108
|
+
return tMs >= open && tMs < wallAt(day, session.closeMinutes) ? open : null;
|
|
109
|
+
};
|
|
110
|
+
const rule = {
|
|
111
|
+
anchor,
|
|
112
|
+
name: BarAnchor[anchor],
|
|
113
|
+
tradeDate: { zone: session.zone, offsetHours: 0 },
|
|
114
|
+
session: Object.freeze({ ...session }),
|
|
115
|
+
venues,
|
|
116
|
+
lays: (exchange) => venues === 'every' || isCmeSessionLatticeExchange(exchange),
|
|
117
|
+
takes: () => true,
|
|
118
|
+
fitsTier: (tier, barMs, isSession) => tier > 0 && fitDayBars(tier, barMs, isSession) && tierMs % tier === 0,
|
|
119
|
+
barOpenMs: (tMs, barMs) => {
|
|
120
|
+
const open = openOf(tMs);
|
|
121
|
+
if (open === null)
|
|
122
|
+
return null;
|
|
123
|
+
return barMs > 0 ? open + Math.floor((tMs - open) / barMs) * barMs : tMs;
|
|
124
|
+
},
|
|
125
|
+
sessionOpenMs: openOf,
|
|
126
|
+
isBoundary: (tMs, barMs, isSession) => opensBar(rule, tMs, barMs, isSession),
|
|
127
|
+
floorBoundaryMs: (tMs, barMs, isSession) => floorOpensBar(rule, tMs, barMs, isSession),
|
|
128
|
+
barEndMs: (openMs, barMs, isSession) => {
|
|
129
|
+
const closing = wallAt(dayOf(openMs), session.closeMinutes);
|
|
130
|
+
const end = openMs + barMs;
|
|
131
|
+
return !isSession && end < closing ? end : closing;
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
return rule;
|
|
135
|
+
}
|
|
136
|
+
/** The CME Group's session clock (cme.go `cmeSessionTimezone`, `cmeSessionOpenHour`). */
|
|
137
|
+
const CME_SESSION_ZONE = 'America/Chicago';
|
|
138
|
+
const CME_SESSION_OPEN_HOUR = 17;
|
|
139
|
+
/** How far apart two session days of one bar lie (`cmeSessionReachDays`): a week bar from a Friday holiday booked
|
|
140
|
+
* into it to its Sunday, a day bar from a holiday to its trade date. */
|
|
141
|
+
const CME_SESSION_REACH_DAYS = 14;
|
|
142
|
+
/** `cmeSessionDay`: the calendar date (days since the epoch) of the session close `tMs` trades toward: the Chicago
|
|
143
|
+
* wall clock's date, moved on at the 17:00 open. */
|
|
144
|
+
const cmeSessionDayOf = (tMs) => Math.floor((zoneWallMsAt(CME_SESSION_ZONE, tMs) + (24 - CME_SESSION_OPEN_HOUR) * HOUR_MS) / DAY_MS);
|
|
145
|
+
/** `cmeSessionOpen`: the 17:00 Chicago open that starts session day `day`, on the calendar day before it. */
|
|
146
|
+
const cmeSessionOpenOf = (day) => zoneWallToUtcMs(CME_SESSION_ZONE, (day - 1) * DAY_MS + CME_SESSION_OPEN_HOUR * HOUR_MS);
|
|
147
|
+
/** `cmeSessionBarLabel`: the candle label (days since the epoch) of the bar holding session day `day`: its trade date
|
|
148
|
+
* (a weekend day its own), or the Monday of that date's week for a week bar. */
|
|
149
|
+
function cmeSessionLabelOf(day, barMs) {
|
|
150
|
+
const label = cmeSessionBucketMs(cmeSessionOpenOf(day), barMs === WEEK_MS ? WEEK_MS : DAY_MS);
|
|
151
|
+
return label === null ? Number.NaN : Math.round(label / DAY_MS);
|
|
152
|
+
}
|
|
153
|
+
/** `cmeSessionBarOpen`: the stamp of the bar holding session day `day`: the open of the first day of the run of
|
|
154
|
+
* session days booked to its label that ends on the label's own day. */
|
|
155
|
+
function cmeSessionBarOpenOf(day, barMs) {
|
|
156
|
+
const label = cmeSessionLabelOf(day, barMs);
|
|
157
|
+
let first = label;
|
|
158
|
+
for (let back = 0; back < CME_SESSION_REACH_DAYS && cmeSessionLabelOf(first - 1, barMs) === label; back += 1) {
|
|
159
|
+
first -= 1;
|
|
160
|
+
}
|
|
161
|
+
return cmeSessionOpenOf(first);
|
|
162
|
+
}
|
|
163
|
+
const CME_SESSION_READS = new Set([
|
|
164
|
+
'OPTION_PRINT_AGG/COIN',
|
|
165
|
+
'OPTION_PRINT_AGG/MARKET',
|
|
166
|
+
'OPTION_PRINT_AGG/STRIKE',
|
|
167
|
+
'OPTION_PRINT_AGG/EXPIRY',
|
|
168
|
+
'OPTION_PRINT_AGG/EXPIRY_STRIKE',
|
|
169
|
+
'OPTION_PRINT_AGG/CONTRACT',
|
|
170
|
+
]);
|
|
171
|
+
const CME_SESSION_RULE = {
|
|
172
|
+
anchor: BarAnchor.CME_SESSION,
|
|
173
|
+
name: BarAnchor[BarAnchor.CME_SESSION],
|
|
174
|
+
tradeDate: { zone: CME_SESSION_ZONE, offsetHours: 24 - CME_SESSION_OPEN_HOUR },
|
|
175
|
+
venues: 'cme',
|
|
176
|
+
lays: isCmeSessionLatticeExchange,
|
|
177
|
+
takes: (read) => CME_SESSION_READS.has(read),
|
|
178
|
+
// A trade date, a session span or a week, from a tier dividing an hour: the 17:00 open sits on the hour in both of
|
|
179
|
+
// Chicago's offsets.
|
|
180
|
+
fitsTier: (tierMs, barMs, session) => tierMs > 0 && (session || barMs === DAY_MS || barMs === WEEK_MS) && HOUR_MS % tierMs === 0,
|
|
181
|
+
barOpenMs: (tMs, barMs) => {
|
|
182
|
+
if (!Number.isFinite(tMs))
|
|
183
|
+
return null;
|
|
184
|
+
return barMs > 0 ? cmeSessionBarOpenOf(cmeSessionDayOf(tMs), barMs) : tMs;
|
|
185
|
+
},
|
|
186
|
+
sessionOpenMs: (tMs) => (Number.isFinite(tMs) ? cmeSessionBarOpenOf(cmeSessionDayOf(tMs), DAY_MS) : null),
|
|
187
|
+
// A session open no bar straddles: every bar of the session days before it differs from every bar of the days from
|
|
188
|
+
// it on (Christmas's session is Monday 12/28's, so no window starts or ends on the weekend opens between them).
|
|
189
|
+
isBoundary: (tMs, barMs, session) => {
|
|
190
|
+
const width = session ? DAY_MS : barMs;
|
|
191
|
+
if (!(width > 0))
|
|
192
|
+
return true;
|
|
193
|
+
if (!Number.isFinite(tMs))
|
|
194
|
+
return false;
|
|
195
|
+
const day = cmeSessionDayOf(tMs);
|
|
196
|
+
if (cmeSessionOpenOf(day) !== tMs)
|
|
197
|
+
return false;
|
|
198
|
+
const before = new Set();
|
|
199
|
+
for (let back = 1; back <= CME_SESSION_REACH_DAYS; back += 1)
|
|
200
|
+
before.add(cmeSessionLabelOf(day - back, width));
|
|
201
|
+
for (let ahead = 0; ahead < CME_SESSION_REACH_DAYS; ahead += 1) {
|
|
202
|
+
if (before.has(cmeSessionLabelOf(day + ahead, width)))
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return true;
|
|
206
|
+
},
|
|
207
|
+
// Boundaries are session opens: the newest one at or before `tMs`, a session day at a time.
|
|
208
|
+
floorBoundaryMs: (tMs, barMs, session) => {
|
|
209
|
+
if (CME_SESSION_RULE.isBoundary(tMs, barMs, session) || !Number.isFinite(tMs))
|
|
210
|
+
return tMs;
|
|
211
|
+
let day = cmeSessionDayOf(tMs);
|
|
212
|
+
for (let back = 0; back <= 2 * CME_SESSION_REACH_DAYS; back += 1, day -= 1) {
|
|
213
|
+
const open = cmeSessionOpenOf(day);
|
|
214
|
+
if (open <= tMs && CME_SESSION_RULE.isBoundary(open, barMs, session))
|
|
215
|
+
return open;
|
|
216
|
+
}
|
|
217
|
+
return tMs;
|
|
218
|
+
},
|
|
219
|
+
// The open of the session day after the bar's last: its label's own day (a day bar), or its week's Sunday.
|
|
220
|
+
barEndMs: (openMs, barMs, session) => {
|
|
221
|
+
const width = session ? DAY_MS : barMs;
|
|
222
|
+
if (!(width > 0))
|
|
223
|
+
return openMs;
|
|
224
|
+
const label = cmeSessionLabelOf(cmeSessionDayOf(openMs), width);
|
|
225
|
+
return cmeSessionOpenOf(label + Math.round(width / DAY_MS));
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
const NEW_YORK = 'America/New_York';
|
|
229
|
+
/** Every anchor's rule, by pb-common's value (`barAnchorRules`): a value without a rule fails the type check. */
|
|
230
|
+
export const OPTION_BAR_ANCHOR_RULES = Object.freeze({
|
|
231
|
+
[BarAnchor.UTC]: UTC_RULE,
|
|
232
|
+
[BarAnchor.US_EQUITY_RTH]: regularSessionRule(BarAnchor.US_EQUITY_RTH, { zone: NEW_YORK, openMinutes: 9 * 60 + 30, closeMinutes: 16 * 60 }, 30 * MINUTE_MS, 'every'),
|
|
233
|
+
[BarAnchor.CME_SESSION]: CME_SESSION_RULE,
|
|
234
|
+
[BarAnchor.CME_RTH]: regularSessionRule(BarAnchor.CME_RTH, { zone: NEW_YORK, openMinutes: 9 * 60 + 30, closeMinutes: 16 * 60 + 15 }, 15 * MINUTE_MS, 'cme'),
|
|
235
|
+
[BarAnchor.CME_ENERGY_RTH]: regularSessionRule(BarAnchor.CME_ENERGY_RTH, { zone: NEW_YORK, openMinutes: 9 * 60, closeMinutes: 14 * 60 + 30 }, 30 * MINUTE_MS, 'cme'),
|
|
236
|
+
});
|
|
237
|
+
/** The rules in pb-common's order (UTC, US_EQUITY_RTH, CME_SESSION, CME_RTH, CME_ENERGY_RTH): the order deciders try. */
|
|
238
|
+
const RULES_IN_ORDER = Object.freeze(Object.values(OPTION_BAR_ANCHOR_RULES).sort((a, b) => a.anchor - b.anchor));
|
|
239
|
+
/** The rule of an anchor value, or undefined for a value no rule lays (the gateway refuses it by name). */
|
|
240
|
+
export function optionBarAnchorRuleOf(anchor) {
|
|
241
|
+
return typeof anchor === 'number' && Object.prototype.hasOwnProperty.call(OPTION_BAR_ANCHOR_RULES, anchor)
|
|
242
|
+
? OPTION_BAR_ANCHOR_RULES[anchor]
|
|
243
|
+
: undefined;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The anchors a read takes on a venue, in pb-common's order: every anchor the read takes that lays every venue's rows,
|
|
247
|
+
* and one laid over a venue group's alone only when the read names a venue of that group (`exchange`, the chain's): the
|
|
248
|
+
* gateway refuses a CME anchor by name on any other venue (OPRA, Deribit) and on a read that names none.
|
|
249
|
+
*/
|
|
250
|
+
export function optionBarAnchorsTaken(read, exchange) {
|
|
251
|
+
return RULES_IN_ORDER.filter((rule) => rule.takes(read) && (rule.venues === 'every' || (exchange !== undefined && rule.lays(exchange))));
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Where a bar proof may drop a bucket the chart lays a bar for: only at an instant the chart's own product holds no
|
|
255
|
+
* trading at, by its schedule (market-session-schedule.util `isGovernedFuturesSymbolOpenAt`). This is the one drop
|
|
256
|
+
* exemption every decider proves an anchor's bars with (the strike and contract flow groupings, the flow scopes' bars,
|
|
257
|
+
* the prints' per-bar cut). An anchor's own hours are not it: a CME regular session lays no bar on a weekend day, which a
|
|
258
|
+
* weekday product's regular-hours chart lays empty bars for, while an always-on root (crypto since 2026-05-29, 1OZ since
|
|
259
|
+
* 2026-07-24) trades through it. So on an always-on root's chart the session lands on no bars that hold weekend rows,
|
|
260
|
+
* and the decider falls back (UTC bars where they land, else today's fold). A chart off the CME group has no schedule
|
|
261
|
+
* here, so nothing it lays may be dropped.
|
|
262
|
+
*/
|
|
263
|
+
export function optionChartClosedAt(grid) {
|
|
264
|
+
if (grid === null || grid === undefined || !isCmeSessionLatticeExchange(grid.exchange))
|
|
265
|
+
return () => false;
|
|
266
|
+
const symbol = grid.symbol;
|
|
267
|
+
return (tMs) => !isGovernedFuturesSymbolOpenAt(symbol, tMs);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The anchor whose sessions are a chain's trade dates (contract 3.4), or undefined where none is: the first anchor the
|
|
271
|
+
* read takes on the venue whose session key (`tradeDate`) is the clock's own rule, a clock that moves its weekends to
|
|
272
|
+
* Monday matching none. New York's clock reads US_EQUITY_RTH's sessions, the UTC date UTC's, the Globex trade date
|
|
273
|
+
* (Chicago's wall clock plus 7 hours) CME_SESSION's on a CME group venue; a CME crypto root's clock (16:00 Chicago,
|
|
274
|
+
* weekends on Monday) is no anchor's.
|
|
275
|
+
*/
|
|
276
|
+
export function optionSessionAnchorOf(clock, read, exchange) {
|
|
277
|
+
if (clock.rule.weekendsToMonday === true)
|
|
278
|
+
return undefined;
|
|
279
|
+
return optionBarAnchorsTaken(read, exchange).find((rule) => rule.tradeDate.zone === clock.zone && rule.tradeDate.offsetHours === clock.rule.offsetHours);
|
|
280
|
+
}
|
|
281
|
+
const DAY_SECONDS = DAY_MS / 1000;
|
|
282
|
+
/**
|
|
283
|
+
* The grid an `optionRead` groups on (`OptionReadGridOf`), or null when it groups nothing (no `barSeconds`, span BAR). A
|
|
284
|
+
* day bar is a UTC day's row on UTC and US_EQUITY_RTH, and keeps its anchor on every other (a trade date on
|
|
285
|
+
* CME_SESSION).
|
|
286
|
+
*/
|
|
287
|
+
export function optionBarAnchorGridOf(shape) {
|
|
288
|
+
if (typeof shape !== 'object' || shape === null)
|
|
289
|
+
return null;
|
|
290
|
+
const fields = shape;
|
|
291
|
+
const barSeconds = Number(fields.barSeconds ?? 0);
|
|
292
|
+
const seconds = Number.isFinite(barSeconds) && barSeconds > 0 ? barSeconds : 0;
|
|
293
|
+
const session = Number(fields.span ?? BarSpan.BAR) === BarSpan.SESSION;
|
|
294
|
+
if (!session && seconds === 0)
|
|
295
|
+
return null;
|
|
296
|
+
let anchor = Number(fields.barAnchor ?? BarAnchor.UTC);
|
|
297
|
+
if (seconds === DAY_SECONDS && (anchor === BarAnchor.UTC || anchor === BarAnchor.US_EQUITY_RTH)) {
|
|
298
|
+
anchor = BarAnchor.UTC;
|
|
299
|
+
}
|
|
300
|
+
return { anchor, seconds, session };
|
|
301
|
+
}
|
|
302
|
+
/** The open of the bar (or session) holding `tMs` on a grid (`OptionReadGrid.Bar`), null where it lands in none or
|
|
303
|
+
* where no rule lays the grid's anchor. */
|
|
304
|
+
export function optionGridBarOpenMs(grid, tMs) {
|
|
305
|
+
const rule = optionBarAnchorRuleOf(grid.anchor);
|
|
306
|
+
if (rule === undefined)
|
|
307
|
+
return null;
|
|
308
|
+
return grid.session ? rule.sessionOpenMs(tMs) : rule.barOpenMs(tMs, grid.seconds * 1000);
|
|
309
|
+
}
|
|
310
|
+
/** Whether a window may start or end at `tMs` on a grid (`OptionReadGrid.Boundary`); an anchor no rule lays splits
|
|
311
|
+
* nothing. */
|
|
312
|
+
export function optionGridIsBoundary(grid, tMs) {
|
|
313
|
+
const rule = optionBarAnchorRuleOf(grid.anchor);
|
|
314
|
+
return rule === undefined || rule.isBoundary(tMs, grid.seconds * 1000, grid.session);
|
|
315
|
+
}
|
|
316
|
+
/** The latest instant at or before `tMs` a window may end at on a grid, so a window cut there ends with its last whole
|
|
317
|
+
* bar. */
|
|
318
|
+
export function optionGridFloorBoundaryMs(grid, tMs) {
|
|
319
|
+
const rule = optionBarAnchorRuleOf(grid.anchor);
|
|
320
|
+
return rule === undefined ? tMs : rule.floorBoundaryMs(tMs, grid.seconds * 1000, grid.session);
|
|
321
|
+
}
|
|
322
|
+
/** The first instant at or after `tMs` a window may start or end at on a grid (`OptionReadGrid.Ceil`): `tMs` on a
|
|
323
|
+
* boundary, else the end of the bar (or session) holding it, or of the bar after it, until one ends on a boundary. */
|
|
324
|
+
export function optionGridCeilBoundaryMs(grid, tMs) {
|
|
325
|
+
const rule = optionBarAnchorRuleOf(grid.anchor);
|
|
326
|
+
if (rule === undefined)
|
|
327
|
+
return tMs;
|
|
328
|
+
const barMs = grid.seconds * 1000;
|
|
329
|
+
let at = tMs;
|
|
330
|
+
for (let step = 0; step < 4 * CME_SESSION_REACH_DAYS && !rule.isBoundary(at, barMs, grid.session); step += 1) {
|
|
331
|
+
const open = optionGridBarOpenMs(grid, at);
|
|
332
|
+
if (open === null)
|
|
333
|
+
break;
|
|
334
|
+
const end = rule.barEndMs(open, barMs, grid.session);
|
|
335
|
+
if (!(end > at))
|
|
336
|
+
break;
|
|
337
|
+
at = end;
|
|
338
|
+
}
|
|
339
|
+
return at;
|
|
340
|
+
}
|
|
@@ -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
|
/**
|
|
@@ -42,6 +42,15 @@ export declare function isOptionVenueVisible(venue: OptionVenue, gates?: OptionV
|
|
|
42
42
|
* futures and their options share exchange codes.
|
|
43
43
|
*/
|
|
44
44
|
export declare function optionVenueForUnderlyingExchange(exchange: Exchange | string): OptionVenue | null;
|
|
45
|
+
/**
|
|
46
|
+
* The provider whose options attach to the market the options seam answers as an underlying (POLYGON `NVDA/USD`
|
|
47
|
+
* resolves to OPRA): `optionVenueForUnderlyingExchange` over that market's exchange. Hand it the seam's market (web:
|
|
48
|
+
* opra-options-gate.util `chartOptionsMarket`), never a chart's own: a stock twin's own code is its crypto venue's, so
|
|
49
|
+
* only the seam knows that its options are its US stock's. Null for no market and for a market no provider lists.
|
|
50
|
+
*/
|
|
51
|
+
export declare function optionsMarketUnderlyingVenue(market: {
|
|
52
|
+
exchange?: Exchange | string | null;
|
|
53
|
+
} | null | undefined): OptionVenue | null;
|
|
45
54
|
/**
|
|
46
55
|
* The underlying key a venue's chain RPC expects for a parsed contract: the base asset for most
|
|
47
56
|
* venues, the catalog ticker (base plus quote, `BTCUSDT`) where the venue keys by it.
|
|
@@ -50,6 +59,15 @@ export declare function venueUnderlying(venue: OptionVenue, parsed: {
|
|
|
50
59
|
root: string;
|
|
51
60
|
quoteAsset?: string;
|
|
52
61
|
}): string;
|
|
62
|
+
/**
|
|
63
|
+
* The root coin a venue files a chain's prints and summaries under, read off the key its chain RPCs take: the inverse
|
|
64
|
+
* of `venueUnderlying`, and the one copy of the rule (tests/structure/venue-root-coin-one-rule.spec.ts). A venue that
|
|
65
|
+
* keys by the catalog ticker (`underlyingKey` 'assetTicker') drops the quote asset of the settlement family the key
|
|
66
|
+
* ends in (Binance Options: `BTCUSDT` reads `BTC`). Any other key already is the root (a Deribit coin, a CME futures
|
|
67
|
+
* contract, an OPRA ticker), and so is a key that ends in none of the venue's quote assets. The match ignores case; the
|
|
68
|
+
* root keeps the key's own.
|
|
69
|
+
*/
|
|
70
|
+
export declare function venueRootCoin(venue: OptionVenue, underlying: string): string;
|
|
53
71
|
/**
|
|
54
72
|
* Where a crypto options indicator reads. `exchange` is the pb-common `Exchange` member name.
|
|
55
73
|
* Summaries are filed under the root `coin`; trades under `tradeCoin`, which differs on venues
|
|
@@ -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);
|
|
@@ -54,6 +54,18 @@ export function optionVenueForUnderlyingExchange(exchange) {
|
|
|
54
54
|
return null;
|
|
55
55
|
return OPTION_VENUES.find((venue) => venue.underlyingExchanges?.includes(name)) ?? null;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The provider whose options attach to the market the options seam answers as an underlying (POLYGON `NVDA/USD`
|
|
59
|
+
* resolves to OPRA): `optionVenueForUnderlyingExchange` over that market's exchange. Hand it the seam's market (web:
|
|
60
|
+
* opra-options-gate.util `chartOptionsMarket`), never a chart's own: a stock twin's own code is its crypto venue's, so
|
|
61
|
+
* only the seam knows that its options are its US stock's. Null for no market and for a market no provider lists.
|
|
62
|
+
*/
|
|
63
|
+
export function optionsMarketUnderlyingVenue(market) {
|
|
64
|
+
const exchange = market?.exchange;
|
|
65
|
+
return exchange === undefined || exchange === null || exchange === ''
|
|
66
|
+
? null
|
|
67
|
+
: optionVenueForUnderlyingExchange(exchange);
|
|
68
|
+
}
|
|
57
69
|
/**
|
|
58
70
|
* The underlying key a venue's chain RPC expects for a parsed contract: the base asset for most
|
|
59
71
|
* venues, the catalog ticker (base plus quote, `BTCUSDT`) where the venue keys by it.
|
|
@@ -61,6 +73,21 @@ export function optionVenueForUnderlyingExchange(exchange) {
|
|
|
61
73
|
export function venueUnderlying(venue, parsed) {
|
|
62
74
|
return venue.underlyingKey === 'assetTicker' ? `${parsed.root}${parsed.quoteAsset ?? ''}` : parsed.root;
|
|
63
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The root coin a venue files a chain's prints and summaries under, read off the key its chain RPCs take: the inverse
|
|
78
|
+
* of `venueUnderlying`, and the one copy of the rule (tests/structure/venue-root-coin-one-rule.spec.ts). A venue that
|
|
79
|
+
* keys by the catalog ticker (`underlyingKey` 'assetTicker') drops the quote asset of the settlement family the key
|
|
80
|
+
* ends in (Binance Options: `BTCUSDT` reads `BTC`). Any other key already is the root (a Deribit coin, a CME futures
|
|
81
|
+
* contract, an OPRA ticker), and so is a key that ends in none of the venue's quote assets. The match ignores case; the
|
|
82
|
+
* root keeps the key's own.
|
|
83
|
+
*/
|
|
84
|
+
export function venueRootCoin(venue, underlying) {
|
|
85
|
+
if (venue.underlyingKey !== 'assetTicker')
|
|
86
|
+
return underlying;
|
|
87
|
+
const key = underlying.toUpperCase();
|
|
88
|
+
const quote = venue.families?.find(({ quoteAsset }) => quoteAsset && key.length > quoteAsset.length && key.endsWith(quoteAsset.toUpperCase()))?.quoteAsset;
|
|
89
|
+
return quote ? underlying.slice(0, -quote.length) : underlying;
|
|
90
|
+
}
|
|
64
91
|
/**
|
|
65
92
|
* Where an ordinary chart's coin reads its chain on a plain crypto venue (one the metadata listing
|
|
66
93
|
* names for the coin): the venue's exchange, the root coin, and the trade key the venue files trades
|
|
@@ -270,6 +270,8 @@ export function normalizeRuntimeDiagnostics(value, options = {}) {
|
|
|
270
270
|
generation: positiveInteger(raw.generation),
|
|
271
271
|
type: optionalString(raw.type),
|
|
272
272
|
details: isObject(raw.details) ? { ...raw.details } : undefined,
|
|
273
|
+
// The row's OPRA mark (computed over OPRA data) survives every normalization: the store's choke point included.
|
|
274
|
+
...(raw.opra === true ? { opra: true } : {}),
|
|
273
275
|
},
|
|
274
276
|
];
|
|
275
277
|
});
|