@orangecharts/wrun-chart-host 0.9.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 +1 -0
- package/dist/constants/feature-flags.constants.d.ts +6 -1
- package/dist/constants/feature-flags.constants.js +67 -24
- package/dist/constants/opra-compliance.constants.d.ts +3 -2
- package/dist/constants/opra-compliance.constants.js +3 -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 +29 -5
- package/dist/host-env.js +6 -0
- package/dist/host-ports.types.d.ts +69 -15
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
- package/dist/interfaces/replay.interface.d.ts +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +41 -4
- package/dist/kscript-data/controls/live-trades-merge.util.js +52 -7
- 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 +95 -31
- package/dist/market-data/billing.interface.js +36 -5
- 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 +162 -5
- package/dist/market-data/venues/index.js +48 -6
- 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/index-mode-admission.util.js +15 -2
- 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 +54 -35
- package/dist/utility/chart/kscript-venue-policy.util.js +78 -42
- 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/opra-read-access.leaf.d.ts +5 -3
- package/dist/utility/chart/opra-read-access.leaf.js +5 -3
- 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 +12 -0
- package/dist/utility/chart/wrun-run-result.util.js +141 -6
- 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 +18 -0
- package/dist/utility/options/option-venue.util.js +27 -0
- 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 +4 -2
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
- 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-lanes/option_contract_flow.js +2 -1
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +39 -10
- 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 +15 -3
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +174 -13
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +685 -27
- 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-chart-market-facts.util.d.ts +53 -12
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +101 -53
- package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
- 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-frames.d.ts +27 -6
- package/dist/utility/wrun/wrun-frames.js +73 -10
- 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 +18 -4
- package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +13 -7
- package/dist/utility/wrun/wrun-live-intake.util.js +82 -29
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +158 -14
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +49 -10
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +65 -5
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
- 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-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 +23 -6
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
- package/dist/utility/wrun/wrun-option-views.util.d.ts +47 -13
- package/dist/utility/wrun/wrun-option-views.util.js +98 -26
- 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 +17 -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-run.util.d.ts +100 -31
- package/dist/utility/wrun/wrun-overlay-run.util.js +733 -114
- 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 +10 -9
- package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
- package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
- package/dist/utility/wrun/wrun-param-map.util.js +10 -5
- package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
- package/dist/utility/wrun/wrun-param-values.util.js +4 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
- 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-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 +45 -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 +5 -1
- package/dist/utility/wrun/wrun-source-rows.util.js +16 -3
- 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/utils/replay/replay-buffer-math.d.ts +53 -2
- package/dist/utils/replay/replay-buffer-math.js +227 -20
- package/package.json +11 -11
|
@@ -7,3 +7,15 @@ export declare const BUILTIN_TWIN_OF_SETTING = "builtinTwinOf";
|
|
|
7
7
|
* a settings value: read alone, any package could claim a built-in's saved
|
|
8
8
|
* values, guide, one-per-chart rule and theme by carrying it. */
|
|
9
9
|
export declare function builtinTwinOf(settings: unknown): string | undefined;
|
|
10
|
+
/** The built-in whose port a registry overlay RUNS, stamp or not: the stamp when
|
|
11
|
+
* it is one (builtinTwinOf), else the built-in the package itself ports
|
|
12
|
+
* (BUILTIN_TWIN_PORTS). The run contract reads this one, the stamp readers
|
|
13
|
+
* above keep the stamp: the Timeframe rule (a selection at or below the chart
|
|
14
|
+
* runs the plain chart path), the lookback the run-interval warm-up sizes from
|
|
15
|
+
* and the alert arm's guards are properties of the package's code, the same
|
|
16
|
+
* through every door (the Indicators list stamps, the store page, a share, a
|
|
17
|
+
* template, the CLI and the agent do not). Read by the stamp alone, the store's
|
|
18
|
+
* copy of an R3 port took a Timeframe finer than the chart as-is, aborted with
|
|
19
|
+
* the engine's words and never drew again after a reload. Undefined for a
|
|
20
|
+
* package that ports no built-in and for anything without a registry identity. */
|
|
21
|
+
export declare function builtinPortOf(settings: unknown): string | undefined;
|
|
@@ -38,3 +38,24 @@ export function builtinTwinOf(settings) {
|
|
|
38
38
|
return undefined;
|
|
39
39
|
return builtinTwinOfPackage(packageName) === stamp ? stamp : undefined;
|
|
40
40
|
}
|
|
41
|
+
/** The built-in whose port a registry overlay RUNS, stamp or not: the stamp when
|
|
42
|
+
* it is one (builtinTwinOf), else the built-in the package itself ports
|
|
43
|
+
* (BUILTIN_TWIN_PORTS). The run contract reads this one, the stamp readers
|
|
44
|
+
* above keep the stamp: the Timeframe rule (a selection at or below the chart
|
|
45
|
+
* runs the plain chart path), the lookback the run-interval warm-up sizes from
|
|
46
|
+
* and the alert arm's guards are properties of the package's code, the same
|
|
47
|
+
* through every door (the Indicators list stamps, the store page, a share, a
|
|
48
|
+
* template, the CLI and the agent do not). Read by the stamp alone, the store's
|
|
49
|
+
* copy of an R3 port took a Timeframe finer than the chart as-is, aborted with
|
|
50
|
+
* the engine's words and never drew again after a reload. Undefined for a
|
|
51
|
+
* package that ports no built-in and for anything without a registry identity. */
|
|
52
|
+
export function builtinPortOf(settings) {
|
|
53
|
+
const stamped = builtinTwinOf(settings);
|
|
54
|
+
if (stamped !== undefined)
|
|
55
|
+
return stamped;
|
|
56
|
+
if (!settings || typeof settings !== 'object')
|
|
57
|
+
return undefined;
|
|
58
|
+
const ref = settings.wrunRegistryRef;
|
|
59
|
+
const packageName = ref && typeof ref === 'object' ? ref.package : undefined;
|
|
60
|
+
return typeof packageName === 'string' && packageName !== '' ? builtinTwinOfPackage(packageName) : undefined;
|
|
61
|
+
}
|
|
@@ -46,11 +46,15 @@
|
|
|
46
46
|
* Beside the five the host fill carries `market.option_multiplier()` (kit 0.87.0,
|
|
47
47
|
* om WRUN_OPTION_FACT_FILLS, which only the chart's browser lane fills): the US
|
|
48
48
|
* dollars one price unit times one size unit of an option on the chart's options
|
|
49
|
-
* chain is worth, 100 on OPRA
|
|
50
|
-
*
|
|
49
|
+
* chain is worth, 100 on OPRA (a stock twin reading its stock's OPRA chain too:
|
|
50
|
+
* the `optionsExchange` fact), the CME root's point value, 1 on a crypto chart,
|
|
51
|
+
* else 0 (wrunChartOptionMultiplier); `market.dollar_multiplier()` (kit 0.95.0):
|
|
51
52
|
* the US dollars one size unit of the market's own trades at one price unit is
|
|
52
53
|
* worth, the market's proven dollar unit (wrunMarketDollarUnit: the CME
|
|
53
|
-
* registry's point value, NQ 20; 1 on a market quoted in dollars), else 0
|
|
54
|
+
* registry's point value, NQ 20; 1 on a market quoted in dollars), else 0; and
|
|
55
|
+
* `market.option_contract()` (C5, a kit word by 0.102.0): 1 when the chart's
|
|
56
|
+
* market is one option contract (an OPRA contract, a CME or crypto option), else
|
|
57
|
+
* 0 (wrunChartOptionContract), so no recipe guesses it from price distance.
|
|
54
58
|
*
|
|
55
59
|
* The 0 rule: a fact the chart does not know is 0, never a guess. Main thread
|
|
56
60
|
* only (the directory read goes through the markets service); the hosted lanes
|
|
@@ -58,6 +62,7 @@
|
|
|
58
62
|
*/
|
|
59
63
|
import type { WrunMarketKind, WrunMarketQuoteIsUsd } from '@orangecharts/indicator-kit';
|
|
60
64
|
import type { WrunVenueLegsResult } from '../../host-ports.types.js';
|
|
65
|
+
import type { CmeExchangeDto } from '../../interfaces/cme-realtime.interface.js';
|
|
61
66
|
import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
|
|
62
67
|
/** The five facts one run reads, as the codes the module sees. */
|
|
63
68
|
export interface WrunMarketFacts {
|
|
@@ -72,10 +77,13 @@ export interface WrunMarketFacts {
|
|
|
72
77
|
/** The minute on the market's clock its trade day opens (0 midnight). */
|
|
73
78
|
sessionOpen: number;
|
|
74
79
|
}
|
|
75
|
-
/** The option
|
|
80
|
+
/** The option facts the host fill carries beside the five: the option multiplier (om WRUN_OPTION_FACT_FILLS, kit
|
|
81
|
+
* 0.87.0) and whether the chart is one option contract (C5, `market.option_contract()`). */
|
|
76
82
|
export interface WrunOptionFacts {
|
|
77
83
|
/** The US dollars one price unit times one size unit of an option on the chart's options chain is worth (0 none). */
|
|
78
84
|
optionMultiplier: number;
|
|
85
|
+
/** 1 when the chart's market is one option contract, else 0 (wrunChartOptionContract). */
|
|
86
|
+
optionContract: number;
|
|
79
87
|
}
|
|
80
88
|
/** The trade value fact the host fill carries beside the five (kit 0.95.0, `market.dollar_multiplier()`). */
|
|
81
89
|
export interface WrunDollarFacts {
|
|
@@ -90,6 +98,10 @@ export interface WrunFactsMarket {
|
|
|
90
98
|
category?: unknown;
|
|
91
99
|
/** A continuous CME chart's lead contract as the chart stamped it (`ESZ6` under `ES1!`), when it did. */
|
|
92
100
|
resolvedContract?: unknown;
|
|
101
|
+
/** The exchange of the market whose options the chart reads, as the options seam names it (web:
|
|
102
|
+
* opra-options-gate.util `chartOptionsMarket`): a stock twin's US stock venue (POLYGON) while the opra flag is lit.
|
|
103
|
+
* Absent: the chart's own exchange (every other market answers itself). Read by `wrunChartOptionMultiplier` alone. */
|
|
104
|
+
optionsExchange?: unknown;
|
|
93
105
|
}
|
|
94
106
|
/** The directory row fields the facts read, duck-typed like om's (the wire
|
|
95
107
|
* carries `assetClass` and `quoteAssetId` beside the declared type). */
|
|
@@ -106,9 +118,13 @@ export interface CmeRootSpec {
|
|
|
106
118
|
pointValue: number;
|
|
107
119
|
/** The quotation currency of the price the chart draws. */
|
|
108
120
|
quote: WrunMarketQuoteIsUsd;
|
|
121
|
+
/** The CME Group exchange the root lists on (its contracts and its options). */
|
|
122
|
+
exchange: CmeExchangeDto;
|
|
109
123
|
}
|
|
110
124
|
/** Read-only outside this module: the paper venue reads each contract's point value from it. */
|
|
111
125
|
export declare const CME_ROOT_SPECS: Readonly<Record<string, Readonly<CmeRootSpec>>>;
|
|
126
|
+
/** The CME Group exchange a futures root lists on (`CME_ROOT_SPECS`), or undefined for a root off the table. */
|
|
127
|
+
export declare function wrunCmeRootExchange(root: string): CmeExchangeDto | undefined;
|
|
112
128
|
/**
|
|
113
129
|
* The five facts the chart fills for `market` (the module doc): om's rules
|
|
114
130
|
* over the directory `row` (undefined when the chart has none: not read, not
|
|
@@ -131,8 +147,9 @@ export declare const WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE = "wrun_dollar_multipl
|
|
|
131
147
|
* CME a CME-governed chart reads the chain of its own root: the root's point value (CME_ROOT_SPECS, ES 50,
|
|
132
148
|
* NQ 20) when the root is quoted in US dollars; a root off the table, or quoted in another unit (a CBOT
|
|
133
149
|
* grain quotes US cents), is 0.
|
|
134
|
-
* OPRA a chart whose options list on OPRA (the venue table
|
|
135
|
-
*
|
|
150
|
+
* OPRA a chart whose options list on OPRA (the venue table over the options seam's market, `optionsExchange`
|
|
151
|
+
* else the chart's own: an OPRA contract chart, a US stock or ETF chart, a stock twin while the opra flag
|
|
152
|
+
* is lit): 100.
|
|
136
153
|
* crypto a chart on a crypto exchange, whichever venue and category (isCryptoChartVenue): its chain, when it has
|
|
137
154
|
* one, is a crypto chain (its own option venue's, the coin's Deribit chain, or another crypto venue's that
|
|
138
155
|
* lists the coin), priced in dollars per coin on every venue: 1. A crypto chart with no chain serves no
|
|
@@ -146,11 +163,33 @@ export declare const WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE = "wrun_dollar_multipl
|
|
|
146
163
|
* multiply). Pure.
|
|
147
164
|
*/
|
|
148
165
|
export declare function wrunChartOptionMultiplier(market: WrunFactsMarket | undefined): number;
|
|
166
|
+
/** The host_fill word of `market.option_contract()` (C5), a WrunParamHostFill word of the kit the chart pins
|
|
167
|
+
* (0.102.0). The host fills the hidden param `market_option_contract` by this word, never by a slot, so a package
|
|
168
|
+
* compiled without the word keeps every init slot and no scaffold bump is needed. */
|
|
169
|
+
export declare const WRUN_OPTION_CONTRACT_FILL = "option_contract";
|
|
170
|
+
/**
|
|
171
|
+
* `market.option_contract()` of the chart market `market` (C5): 1 when the chart is one option contract, else 0. A
|
|
172
|
+
* recipe that marks the underlying's prices (Option Prints) reads it to draw no marks on a contract's own price axis,
|
|
173
|
+
* instead of guessing from price distance. The add door's identity (cme-option-indicator-availability.util
|
|
174
|
+
* isOptionContractChart, which the option-contract indicator refusals read), widened to the crypto option venues:
|
|
175
|
+
*
|
|
176
|
+
* OPRA every chart on the OPRA venue is one contract, a document saved without its category included.
|
|
177
|
+
* CME a chart whose category is OPTION (`ESZ6 C6000`): the category tells the contract from the future on the
|
|
178
|
+
* same venue (ESZ6, ES1!).
|
|
179
|
+
* crypto a chart whose category is OPTION, or one on a plain option venue whose symbol the venue's grammar parses
|
|
180
|
+
* (isPlainOptionContract: Deribit `BTC-25DEC26-100000-C`), so a contract saved without its category still
|
|
181
|
+
* reads 1 and the venue's perpetual (`BTC-PERPETUAL`) reads 0.
|
|
182
|
+
* else 0: a stock or ETF (SPY/USD, an options underlying), a future, a perpetual, spot, forex, an index, an
|
|
183
|
+
* economic series, a prediction market, an unknown venue, no market.
|
|
184
|
+
*
|
|
185
|
+
* The chart metadata alone decides, synchronously and with no read, like the option multiplier. Pure.
|
|
186
|
+
*/
|
|
187
|
+
export declare function wrunChartOptionContract(market: WrunFactsMarket | undefined): number;
|
|
149
188
|
/** True when the sheet declares one of the market's facts (a host-filled
|
|
150
189
|
* param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open`,
|
|
151
|
-
* `option_multiplier` or `
|
|
152
|
-
* carries the market's facts. Only a sheet that declares a
|
|
153
|
-
* waits for the read (wrunMarketFactsNeedDirectory). */
|
|
190
|
+
* `option_multiplier`, `dollar_multiplier` or `option_contract`): the runs
|
|
191
|
+
* whose host fill carries the market's facts. Only a sheet that declares a
|
|
192
|
+
* directory fact waits for the read (wrunMarketFactsNeedDirectory). */
|
|
154
193
|
export declare function wrunReadsMarketFacts(metadata: Pick<WrunIndicatorMetadata, 'params'> | undefined): boolean;
|
|
155
194
|
/** True when the sheet reads the market's dollar multiplier (a host-filled param on `dollar_multiplier`, kit
|
|
156
195
|
* 0.95.0): its run proves the market's dollar unit at its head before any fetch (wrun-overlay-run.util), so its
|
|
@@ -269,9 +308,11 @@ export declare function wrunMarketFactsSettled(market: WrunFactsMarket | undefin
|
|
|
269
308
|
/** The facts the chart fills for `market` now (synchronous): the five over the
|
|
270
309
|
* directory row once warmWrunMarketFacts settled it, else without one, the
|
|
271
310
|
* option multiplier of its options chain (wrunChartOptionMultiplier: the
|
|
272
|
-
* venue tables alone, no read)
|
|
273
|
-
* (
|
|
274
|
-
*
|
|
311
|
+
* venue tables alone, no read), whether it is one option contract
|
|
312
|
+
* (wrunChartOptionContract: its metadata alone, no read) and the dollar
|
|
313
|
+
* multiplier of its own trades (wrunMarketDollarUnit over the reads
|
|
314
|
+
* warmWrunMarketDollarFacts settled; 0 while it is not proven). Every word is
|
|
315
|
+
* written on every market, 0 included, so the block keeps one shape. */
|
|
275
316
|
export declare function wrunMarketFactsFor(market: WrunFactsMarket | undefined): WrunMarketFacts & WrunOptionFacts & WrunDollarFacts;
|
|
276
317
|
/**
|
|
277
318
|
* What the instrument registry (StreamRegistryMetadatas, the metadata service's `getSymbolMetadata`) proves about one
|
|
@@ -46,11 +46,15 @@
|
|
|
46
46
|
* Beside the five the host fill carries `market.option_multiplier()` (kit 0.87.0,
|
|
47
47
|
* om WRUN_OPTION_FACT_FILLS, which only the chart's browser lane fills): the US
|
|
48
48
|
* dollars one price unit times one size unit of an option on the chart's options
|
|
49
|
-
* chain is worth, 100 on OPRA
|
|
50
|
-
*
|
|
49
|
+
* chain is worth, 100 on OPRA (a stock twin reading its stock's OPRA chain too:
|
|
50
|
+
* the `optionsExchange` fact), the CME root's point value, 1 on a crypto chart,
|
|
51
|
+
* else 0 (wrunChartOptionMultiplier); `market.dollar_multiplier()` (kit 0.95.0):
|
|
51
52
|
* the US dollars one size unit of the market's own trades at one price unit is
|
|
52
53
|
* worth, the market's proven dollar unit (wrunMarketDollarUnit: the CME
|
|
53
|
-
* registry's point value, NQ 20; 1 on a market quoted in dollars), else 0
|
|
54
|
+
* registry's point value, NQ 20; 1 on a market quoted in dollars), else 0; and
|
|
55
|
+
* `market.option_contract()` (C5, a kit word by 0.102.0): 1 when the chart's
|
|
56
|
+
* market is one option contract (an OPRA contract, a CME or crypto option), else
|
|
57
|
+
* 0 (wrunChartOptionContract), so no recipe guesses it from price distance.
|
|
54
58
|
*
|
|
55
59
|
* The 0 rule: a fact the chart does not know is 0, never a guess. Main thread
|
|
56
60
|
* only (the directory read goes through the markets service); the hosted lanes
|
|
@@ -62,7 +66,9 @@ import { isCmeGoverned } from '../chart/cme-realtime.util.js';
|
|
|
62
66
|
import { isContinuousSymbol } from '../chart/continuous-contracts.util.js';
|
|
63
67
|
import { governedContractCoin } from '../chart/governed-contract-coin.util.js';
|
|
64
68
|
import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
|
|
65
|
-
import {
|
|
69
|
+
import { optionsMarketUnderlyingVenue, optionVenueForExchange } from '../options/option-venue.util.js';
|
|
70
|
+
import { isPlainOptionContract } from '../options/option-trade-units.util.js';
|
|
71
|
+
import { isOpraGoverned } from '../v2/opra-governed.util.js';
|
|
66
72
|
import { WRUN_LANE_CURRENCY_AUTO, WRUN_MARKET_FACT_FILLS, WRUN_MARKET_KINDS, WRUN_MARKET_QUOTE_IS_USD, WRUN_MARKET_SESSION_OPEN_CME, wrunLaneCurrency, wrunMarketSizeUnit, wrunMarketZoneCode, wrunCoinLegSource, wrunFollowsCoin, wrunRowVisibleHere, wrunVisibleByNeedsKind, } from './wrun-market-facts.util.js';
|
|
67
73
|
import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
|
|
68
74
|
import { isTradesDollarQuoteAsset } from '../../kscript-data/controls/live-trades-merge.util.js';
|
|
@@ -174,54 +180,59 @@ const UNKNOWN_MULTIPLIER_EXCHANGES = new Set(['ICE', 'PLATTS']);
|
|
|
174
180
|
/** Read-only outside this module: the paper venue reads each contract's point value from it. */
|
|
175
181
|
export const CME_ROOT_SPECS = {
|
|
176
182
|
// Equity index futures, quoted in index points: the dollar multiplier.
|
|
177
|
-
ES: { kind: 'index', pointValue: 50, quote: 'usd' }, // $50 x S&P 500: equities/sp/e-mini-sandp500
|
|
178
|
-
MES: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x S&P 500: equities/sp/micro-e-mini-sandp-500
|
|
179
|
-
NQ: { kind: 'index', pointValue: 20, quote: 'usd' }, // $20 x Nasdaq-100: equities/nasdaq/e-mini-nasdaq-100
|
|
180
|
-
MNQ: { kind: 'index', pointValue: 2, quote: 'usd' }, // $2 x Nasdaq-100: equities/nasdaq/micro-e-mini-nasdaq-100
|
|
181
|
-
RTY: { kind: 'index', pointValue: 50, quote: 'usd' }, // $50 x Russell 2000: equities/russell/e-mini-russell-2000
|
|
182
|
-
M2K: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x Russell 2000: equities/russell/micro-e-mini-russell-2000
|
|
183
|
-
YM: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x DJIA: equities/dow-jones/e-mini-dow
|
|
184
|
-
MYM: { kind: 'index', pointValue: 0.5, quote: 'usd' }, // $0.50 x DJIA: equities/dow-jones/micro-e-mini-dow
|
|
183
|
+
ES: { kind: 'index', pointValue: 50, quote: 'usd', exchange: 'CME' }, // $50 x S&P 500: equities/sp/e-mini-sandp500
|
|
184
|
+
MES: { kind: 'index', pointValue: 5, quote: 'usd', exchange: 'CME' }, // $5 x S&P 500: equities/sp/micro-e-mini-sandp-500
|
|
185
|
+
NQ: { kind: 'index', pointValue: 20, quote: 'usd', exchange: 'CME' }, // $20 x Nasdaq-100: equities/nasdaq/e-mini-nasdaq-100
|
|
186
|
+
MNQ: { kind: 'index', pointValue: 2, quote: 'usd', exchange: 'CME' }, // $2 x Nasdaq-100: equities/nasdaq/micro-e-mini-nasdaq-100
|
|
187
|
+
RTY: { kind: 'index', pointValue: 50, quote: 'usd', exchange: 'CME' }, // $50 x Russell 2000: equities/russell/e-mini-russell-2000
|
|
188
|
+
M2K: { kind: 'index', pointValue: 5, quote: 'usd', exchange: 'CME' }, // $5 x Russell 2000: equities/russell/micro-e-mini-russell-2000
|
|
189
|
+
YM: { kind: 'index', pointValue: 5, quote: 'usd', exchange: 'CBOT' }, // $5 x DJIA: equities/dow-jones/e-mini-dow
|
|
190
|
+
MYM: { kind: 'index', pointValue: 0.5, quote: 'usd', exchange: 'CBOT' }, // $0.50 x DJIA: equities/dow-jones/micro-e-mini-dow
|
|
185
191
|
// FX futures, quoted in US dollars per unit of the foreign currency (6J per yen, 0.00xxxx).
|
|
186
|
-
'6E': { kind: 'forex', pointValue: 125_000, quote: 'usd' }, // 125,000 euro: fx/g10/euro-fx
|
|
187
|
-
'6B': { kind: 'forex', pointValue: 62_500, quote: 'usd' }, // 62,500 pounds: fx/g10/british-pound
|
|
188
|
-
'6J': { kind: 'forex', pointValue: 12_500_000, quote: 'usd' }, // 12,500,000 yen: fx/g10/japanese-yen
|
|
189
|
-
'6C': { kind: 'forex', pointValue: 100_000, quote: 'usd' }, // 100,000 CAD: fx/g10/canadian-dollar
|
|
192
|
+
'6E': { kind: 'forex', pointValue: 125_000, quote: 'usd', exchange: 'CME' }, // 125,000 euro: fx/g10/euro-fx
|
|
193
|
+
'6B': { kind: 'forex', pointValue: 62_500, quote: 'usd', exchange: 'CME' }, // 62,500 pounds: fx/g10/british-pound
|
|
194
|
+
'6J': { kind: 'forex', pointValue: 12_500_000, quote: 'usd', exchange: 'CME' }, // 12,500,000 yen: fx/g10/japanese-yen
|
|
195
|
+
'6C': { kind: 'forex', pointValue: 100_000, quote: 'usd', exchange: 'CME' }, // 100,000 CAD: fx/g10/canadian-dollar
|
|
190
196
|
// US Treasury futures, quoted in points of par (100): the face value / 100 per point.
|
|
191
|
-
ZT: { kind: 'unknown', pointValue: 2_000, quote: 'usd' }, // $200,000 face: interest-rates/us-treasury/2-year-us-treasury-note
|
|
192
|
-
ZF: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/5-year-us-treasury-note
|
|
193
|
-
ZN: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/10-year-us-treasury-note
|
|
194
|
-
TN: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/ultra-10-year-us-treasury-note
|
|
195
|
-
ZB: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/30-year-us-treasury-bond
|
|
196
|
-
UB: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/ultra-t-bond
|
|
197
|
+
ZT: { kind: 'unknown', pointValue: 2_000, quote: 'usd', exchange: 'CBOT' }, // $200,000 face: interest-rates/us-treasury/2-year-us-treasury-note
|
|
198
|
+
ZF: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/5-year-us-treasury-note
|
|
199
|
+
ZN: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/10-year-us-treasury-note
|
|
200
|
+
TN: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/ultra-10-year-us-treasury-note
|
|
201
|
+
ZB: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/30-year-us-treasury-bond
|
|
202
|
+
UB: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/ultra-t-bond
|
|
197
203
|
// Energy (NYMEX), quoted in US dollars per unit of the commodity.
|
|
198
|
-
CL: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // 1,000 barrels: energy/crude-oil/light-sweet-crude
|
|
199
|
-
MCL: { kind: 'unknown', pointValue: 100, quote: 'usd' }, // 100 barrels: energy/crude-oil/micro-wti-crude-oil
|
|
200
|
-
NG: { kind: 'unknown', pointValue: 10_000, quote: 'usd' }, // 10,000 MMBtu: energy/natural-gas/natural-gas
|
|
201
|
-
RB: { kind: 'unknown', pointValue: 42_000, quote: 'usd' }, // 42,000 gallons: energy/refined-products/rbob-gasoline
|
|
202
|
-
HO: { kind: 'unknown', pointValue: 42_000, quote: 'usd' }, // 42,000 gallons: energy/refined-products/heating-oil
|
|
203
|
-
BZ: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // 1,000 barrels: energy/crude-oil/brent-crude-oil-last-day
|
|
204
|
+
CL: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'NYMEX' }, // 1,000 barrels: energy/crude-oil/light-sweet-crude
|
|
205
|
+
MCL: { kind: 'unknown', pointValue: 100, quote: 'usd', exchange: 'NYMEX' }, // 100 barrels: energy/crude-oil/micro-wti-crude-oil
|
|
206
|
+
NG: { kind: 'unknown', pointValue: 10_000, quote: 'usd', exchange: 'NYMEX' }, // 10,000 MMBtu: energy/natural-gas/natural-gas
|
|
207
|
+
RB: { kind: 'unknown', pointValue: 42_000, quote: 'usd', exchange: 'NYMEX' }, // 42,000 gallons: energy/refined-products/rbob-gasoline
|
|
208
|
+
HO: { kind: 'unknown', pointValue: 42_000, quote: 'usd', exchange: 'NYMEX' }, // 42,000 gallons: energy/refined-products/heating-oil
|
|
209
|
+
BZ: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'NYMEX' }, // 1,000 barrels: energy/crude-oil/brent-crude-oil-last-day
|
|
204
210
|
// Metals (COMEX), quoted in US dollars per troy ounce (copper per pound).
|
|
205
|
-
GC: { kind: 'metal', pointValue: 100, quote: 'usd' }, // 100 troy ounces: metals/precious/gold
|
|
206
|
-
MGC: { kind: 'metal', pointValue: 10, quote: 'usd' }, // 10 troy ounces: metals/precious/e-micro-gold
|
|
207
|
-
SI: { kind: 'metal', pointValue: 5_000, quote: 'usd' }, // 5,000 troy ounces: metals/precious/silver
|
|
208
|
-
SIL: { kind: 'metal', pointValue: 1_000, quote: 'usd' }, // 1,000 troy ounces: metals/precious/1000-oz-silver
|
|
209
|
-
HG: { kind: 'metal', pointValue: 25_000, quote: 'usd' }, // 25,000 pounds: metals/base/copper
|
|
210
|
-
MHG: { kind: 'metal', pointValue: 2_500, quote: 'usd' }, // 2,500 pounds: metals/base/micro-copper
|
|
211
|
+
GC: { kind: 'metal', pointValue: 100, quote: 'usd', exchange: 'COMEX' }, // 100 troy ounces: metals/precious/gold
|
|
212
|
+
MGC: { kind: 'metal', pointValue: 10, quote: 'usd', exchange: 'COMEX' }, // 10 troy ounces: metals/precious/e-micro-gold
|
|
213
|
+
SI: { kind: 'metal', pointValue: 5_000, quote: 'usd', exchange: 'COMEX' }, // 5,000 troy ounces: metals/precious/silver
|
|
214
|
+
SIL: { kind: 'metal', pointValue: 1_000, quote: 'usd', exchange: 'COMEX' }, // 1,000 troy ounces: metals/precious/1000-oz-silver
|
|
215
|
+
HG: { kind: 'metal', pointValue: 25_000, quote: 'usd', exchange: 'COMEX' }, // 25,000 pounds: metals/base/copper
|
|
216
|
+
MHG: { kind: 'metal', pointValue: 2_500, quote: 'usd', exchange: 'COMEX' }, // 2,500 pounds: metals/base/micro-copper
|
|
211
217
|
// Grains (CBOT), quoted in US cents per bushel (soybean oil per pound), the unit the chart
|
|
212
218
|
// draws (corn near 460): a whole point is one cent, worth the contract size in cents, and
|
|
213
219
|
// the quote is US cents, not dollars (Pine reads `syminfo.currency` "USX" there).
|
|
214
|
-
ZC: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/corn
|
|
215
|
-
ZW: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/wheat
|
|
216
|
-
KE: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/kc-wheat
|
|
217
|
-
ZS: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/oilseeds/soybean
|
|
218
|
-
ZL: { kind: 'unknown', pointValue: 60_000, quote: 'other' }, // 60,000 pounds: agriculture/oilseeds/soybean-oil
|
|
220
|
+
ZC: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/grains/corn
|
|
221
|
+
ZW: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/grains/wheat
|
|
222
|
+
KE: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/grains/kc-wheat
|
|
223
|
+
ZS: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/oilseeds/soybean
|
|
224
|
+
ZL: { kind: 'unknown', pointValue: 60_000, quote: 'other', exchange: 'CBOT' }, // 60,000 pounds: agriculture/oilseeds/soybean-oil
|
|
219
225
|
// Cryptocurrency futures (CME), quoted in US dollars per coin.
|
|
220
|
-
BTC: { kind: 'crypto', pointValue: 5, quote: 'usd' }, // 5 bitcoin: cryptocurrencies/bitcoin/bitcoin
|
|
221
|
-
MBT: { kind: 'crypto', pointValue: 0.1, quote: 'usd' }, // 0.1 bitcoin: cryptocurrencies/bitcoin/micro-bitcoin
|
|
222
|
-
ETH: { kind: 'crypto', pointValue: 50, quote: 'usd' }, // 50 ether: cryptocurrencies/ether/ether
|
|
223
|
-
MET: { kind: 'crypto', pointValue: 0.1, quote: 'usd' }, // 0.1 ether: cryptocurrencies/ether/micro-ether
|
|
226
|
+
BTC: { kind: 'crypto', pointValue: 5, quote: 'usd', exchange: 'CME' }, // 5 bitcoin: cryptocurrencies/bitcoin/bitcoin
|
|
227
|
+
MBT: { kind: 'crypto', pointValue: 0.1, quote: 'usd', exchange: 'CME' }, // 0.1 bitcoin: cryptocurrencies/bitcoin/micro-bitcoin
|
|
228
|
+
ETH: { kind: 'crypto', pointValue: 50, quote: 'usd', exchange: 'CME' }, // 50 ether: cryptocurrencies/ether/ether
|
|
229
|
+
MET: { kind: 'crypto', pointValue: 0.1, quote: 'usd', exchange: 'CME' }, // 0.1 ether: cryptocurrencies/ether/micro-ether
|
|
224
230
|
};
|
|
231
|
+
/** The CME Group exchange a futures root lists on (`CME_ROOT_SPECS`), or undefined for a root off the table. */
|
|
232
|
+
export function wrunCmeRootExchange(root) {
|
|
233
|
+
const key = root.trim().toUpperCase();
|
|
234
|
+
return Object.prototype.hasOwnProperty.call(CME_ROOT_SPECS, key) ? CME_ROOT_SPECS[key].exchange : undefined;
|
|
235
|
+
}
|
|
225
236
|
// ---------------------------------------------------------------------------
|
|
226
237
|
// The facts of one market
|
|
227
238
|
// ---------------------------------------------------------------------------
|
|
@@ -389,8 +400,9 @@ function cmeChainRootSpec(market) {
|
|
|
389
400
|
* CME a CME-governed chart reads the chain of its own root: the root's point value (CME_ROOT_SPECS, ES 50,
|
|
390
401
|
* NQ 20) when the root is quoted in US dollars; a root off the table, or quoted in another unit (a CBOT
|
|
391
402
|
* grain quotes US cents), is 0.
|
|
392
|
-
* OPRA a chart whose options list on OPRA (the venue table
|
|
393
|
-
*
|
|
403
|
+
* OPRA a chart whose options list on OPRA (the venue table over the options seam's market, `optionsExchange`
|
|
404
|
+
* else the chart's own: an OPRA contract chart, a US stock or ETF chart, a stock twin while the opra flag
|
|
405
|
+
* is lit): 100.
|
|
394
406
|
* crypto a chart on a crypto exchange, whichever venue and category (isCryptoChartVenue): its chain, when it has
|
|
395
407
|
* one, is a crypto chain (its own option venue's, the coin's Deribit chain, or another crypto venue's that
|
|
396
408
|
* lists the coin), priced in dollars per coin on every venue: 1. A crypto chart with no chain serves no
|
|
@@ -411,24 +423,57 @@ export function wrunChartOptionMultiplier(market) {
|
|
|
411
423
|
const spec = cmeChainRootSpec(market);
|
|
412
424
|
return spec?.quote === 'usd' ? spec.pointValue : 0;
|
|
413
425
|
}
|
|
414
|
-
|
|
426
|
+
// The family of the chain the chart reads: the options seam's market's (a stock twin's US stock) when the host named
|
|
427
|
+
// it, else the chart's own.
|
|
428
|
+
const optionsVenue = upperText(market.optionsExchange) ?? venue;
|
|
429
|
+
const options = optionVenueForExchange(optionsVenue) ?? optionsMarketUnderlyingVenue({ exchange: optionsVenue });
|
|
415
430
|
if (options?.plane === 'opra')
|
|
416
431
|
return OPRA_OPTION_MULTIPLIER;
|
|
417
432
|
return isCryptoChartVenue(venue) ? CRYPTO_OPTION_MULTIPLIER : 0;
|
|
418
433
|
}
|
|
434
|
+
/** The host_fill word of `market.option_contract()` (C5), a WrunParamHostFill word of the kit the chart pins
|
|
435
|
+
* (0.102.0). The host fills the hidden param `market_option_contract` by this word, never by a slot, so a package
|
|
436
|
+
* compiled without the word keeps every init slot and no scaffold bump is needed. */
|
|
437
|
+
export const WRUN_OPTION_CONTRACT_FILL = 'option_contract';
|
|
438
|
+
/**
|
|
439
|
+
* `market.option_contract()` of the chart market `market` (C5): 1 when the chart is one option contract, else 0. A
|
|
440
|
+
* recipe that marks the underlying's prices (Option Prints) reads it to draw no marks on a contract's own price axis,
|
|
441
|
+
* instead of guessing from price distance. The add door's identity (cme-option-indicator-availability.util
|
|
442
|
+
* isOptionContractChart, which the option-contract indicator refusals read), widened to the crypto option venues:
|
|
443
|
+
*
|
|
444
|
+
* OPRA every chart on the OPRA venue is one contract, a document saved without its category included.
|
|
445
|
+
* CME a chart whose category is OPTION (`ESZ6 C6000`): the category tells the contract from the future on the
|
|
446
|
+
* same venue (ESZ6, ES1!).
|
|
447
|
+
* crypto a chart whose category is OPTION, or one on a plain option venue whose symbol the venue's grammar parses
|
|
448
|
+
* (isPlainOptionContract: Deribit `BTC-25DEC26-100000-C`), so a contract saved without its category still
|
|
449
|
+
* reads 1 and the venue's perpetual (`BTC-PERPETUAL`) reads 0.
|
|
450
|
+
* else 0: a stock or ETF (SPY/USD, an options underlying), a future, a perpetual, spot, forex, an index, an
|
|
451
|
+
* economic series, a prediction market, an unknown venue, no market.
|
|
452
|
+
*
|
|
453
|
+
* The chart metadata alone decides, synchronously and with no read, like the option multiplier. Pure.
|
|
454
|
+
*/
|
|
455
|
+
export function wrunChartOptionContract(market) {
|
|
456
|
+
const venue = upperText(market?.exchange);
|
|
457
|
+
if (market === undefined || venue === undefined)
|
|
458
|
+
return 0;
|
|
459
|
+
const symbol = typeof market.symbol === 'string' ? market.symbol : '';
|
|
460
|
+
return isOpraGoverned(venue) || isOptionContract(market.category) || isPlainOptionContract(venue, symbol) ? 1 : 0;
|
|
461
|
+
}
|
|
419
462
|
/** The host_fill words whose values the host fill carries off the chart's market (wrunMarketFactsFor): the five
|
|
420
463
|
* market facts, the option multiplier (om WRUN_OPTION_FACT_FILLS, a word of the kit's WrunParamHostFill since
|
|
421
|
-
* 0.87.0, which the kit exports no runtime list for)
|
|
464
|
+
* 0.87.0, which the kit exports no runtime list for), the dollar multiplier (kit 0.95.0) and the option contract
|
|
465
|
+
* (C5). They ride beside the five and never join WRUN_MARKET_FACT_FILLS, which mirrors the kit's own five. */
|
|
422
466
|
const WRUN_CHART_MARKET_FILLS = new Set([
|
|
423
467
|
...WRUN_MARKET_FACT_FILLS,
|
|
424
468
|
'option_multiplier',
|
|
425
469
|
WRUN_DOLLAR_MULTIPLIER_FILL,
|
|
470
|
+
WRUN_OPTION_CONTRACT_FILL,
|
|
426
471
|
]);
|
|
427
472
|
/** True when the sheet declares one of the market's facts (a host-filled
|
|
428
473
|
* param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open`,
|
|
429
|
-
* `option_multiplier` or `
|
|
430
|
-
* carries the market's facts. Only a sheet that declares a
|
|
431
|
-
* waits for the read (wrunMarketFactsNeedDirectory). */
|
|
474
|
+
* `option_multiplier`, `dollar_multiplier` or `option_contract`): the runs
|
|
475
|
+
* whose host fill carries the market's facts. Only a sheet that declares a
|
|
476
|
+
* directory fact waits for the read (wrunMarketFactsNeedDirectory). */
|
|
432
477
|
export function wrunReadsMarketFacts(metadata) {
|
|
433
478
|
return (metadata?.params ?? []).some((param) => param.host_fill !== undefined && WRUN_CHART_MARKET_FILLS.has(param.host_fill));
|
|
434
479
|
}
|
|
@@ -746,9 +791,11 @@ export function wrunMarketFactsSettled(market) {
|
|
|
746
791
|
/** The facts the chart fills for `market` now (synchronous): the five over the
|
|
747
792
|
* directory row once warmWrunMarketFacts settled it, else without one, the
|
|
748
793
|
* option multiplier of its options chain (wrunChartOptionMultiplier: the
|
|
749
|
-
* venue tables alone, no read)
|
|
750
|
-
* (
|
|
751
|
-
*
|
|
794
|
+
* venue tables alone, no read), whether it is one option contract
|
|
795
|
+
* (wrunChartOptionContract: its metadata alone, no read) and the dollar
|
|
796
|
+
* multiplier of its own trades (wrunMarketDollarUnit over the reads
|
|
797
|
+
* warmWrunMarketDollarFacts settled; 0 while it is not proven). Every word is
|
|
798
|
+
* written on every market, 0 included, so the block keeps one shape. */
|
|
752
799
|
export function wrunMarketFactsFor(market) {
|
|
753
800
|
const parts = marketKeyParts(market);
|
|
754
801
|
const row = parts === undefined ? undefined : settledRows.get(directoryKey(parts.venue, parts.symbol));
|
|
@@ -756,6 +803,7 @@ export function wrunMarketFactsFor(market) {
|
|
|
756
803
|
return {
|
|
757
804
|
...wrunChartMarketFacts(market, row ?? undefined),
|
|
758
805
|
optionMultiplier: wrunChartOptionMultiplier(market),
|
|
806
|
+
optionContract: wrunChartOptionContract(market),
|
|
759
807
|
dollarMultiplier: dollars.kind === 'dollars' ? dollars.unit : 0,
|
|
760
808
|
};
|
|
761
809
|
}
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
*
|
|
20
20
|
* Telemetry only in R1: nothing reads the meter to change an ask; a full run hands its summary to the add's attempt
|
|
21
21
|
* (`downloadBytes` on `wrun-indicator`), the live session counts its reconciles on its own meter.
|
|
22
|
+
*
|
|
23
|
+
* R2 (the download budget's cut, behind `wrun-download-budget-cut`): a run whose projection passes its budget notes
|
|
24
|
+
* it (`noteBudget`: `budgeted`, the bars its reads left unread, the bytes it planned), and each history read it cuts
|
|
25
|
+
* keeps its own tally beside the run's meter (wrun-download-plan.util `createWrunLaneDownloadMeter`, off the boot
|
|
26
|
+
* path), so the read's newest slice measures its own wire bytes while the other reads download beside it.
|
|
22
27
|
*/
|
|
23
28
|
import type { WrunSourceFetchVerdict } from '../../host-ports.types.js';
|
|
24
29
|
/** One indicator add may download at most this many bytes at the standard window (the kit's
|
|
@@ -66,10 +71,20 @@ export interface WrunDownloadSummary {
|
|
|
66
71
|
/** R2: a first slice's bytes plus the older asks still out, projected. */
|
|
67
72
|
plannedBytes?: number;
|
|
68
73
|
}
|
|
74
|
+
/** What a run notes of its budget (R2): it planned a cut (`budgeted`), the bars a read left unread (summed over the
|
|
75
|
+
* notes), and the bytes the run planned (its slices' bytes and the older asks it sends, projected; the last note
|
|
76
|
+
* wins). */
|
|
77
|
+
export interface WrunDownloadBudgetNote {
|
|
78
|
+
budgeted?: true;
|
|
79
|
+
cutBars?: number;
|
|
80
|
+
plannedBytes?: number;
|
|
81
|
+
}
|
|
69
82
|
export interface WrunDownloadMeter extends WrunDownloadMeterPort {
|
|
70
83
|
readonly budgetBytes: number;
|
|
71
84
|
spentBytes(): number;
|
|
72
85
|
remainingBytes(): number;
|
|
86
|
+
/** R2: the run's budget facts for the summary (`budgeted`, `cutBars`, `plannedBytes`). */
|
|
87
|
+
noteBudget(note: WrunDownloadBudgetNote): void;
|
|
73
88
|
summary(): WrunDownloadSummary;
|
|
74
89
|
}
|
|
75
90
|
export declare function createWrunDownloadMeter(windowBars: number): WrunDownloadMeter;
|
|
@@ -25,9 +25,20 @@ export function createWrunDownloadMeter(windowBars) {
|
|
|
25
25
|
let asks = 0;
|
|
26
26
|
let cachedAsks = 0;
|
|
27
27
|
let measure = 'wire';
|
|
28
|
+
let budgeted = false;
|
|
29
|
+
let cutBars = 0;
|
|
30
|
+
let plannedBytes;
|
|
28
31
|
const bytesByKType = new Map();
|
|
29
32
|
return {
|
|
30
33
|
budgetBytes,
|
|
34
|
+
noteBudget(note) {
|
|
35
|
+
if (note.budgeted === true)
|
|
36
|
+
budgeted = true;
|
|
37
|
+
cutBars += countOf(note.cutBars);
|
|
38
|
+
if (note.plannedBytes !== undefined && Number.isFinite(note.plannedBytes)) {
|
|
39
|
+
plannedBytes = Math.max(0, Math.round(note.plannedBytes));
|
|
40
|
+
}
|
|
41
|
+
},
|
|
31
42
|
charge(charge) {
|
|
32
43
|
asks += 1;
|
|
33
44
|
cellBytes += countOf(charge.cellBytes);
|
|
@@ -71,9 +82,10 @@ export function createWrunDownloadMeter(windowBars) {
|
|
|
71
82
|
windowBars: bars,
|
|
72
83
|
budgetBytes,
|
|
73
84
|
over: bytes > budgetBytes,
|
|
74
|
-
budgeted
|
|
75
|
-
cutBars
|
|
85
|
+
budgeted,
|
|
86
|
+
cutBars,
|
|
76
87
|
...(topSource !== undefined ? { topSource } : {}),
|
|
88
|
+
...(plannedBytes !== undefined ? { plannedBytes } : {}),
|
|
77
89
|
};
|
|
78
90
|
},
|
|
79
91
|
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The download budget's plan (OPTLOAD wave 3, unit R2; UW-PARITY/reports/OPTLOAD-W3/guard-design.md sections 3.3 and
|
|
3
|
+
* 3.7): before any fetch, a run prices its reads with the kit's rule (`wrunDownloadReadCost`, the class table the
|
|
4
|
+
* publish gate charges) on its real window and market, and so decides its mode (`wrunRunDownloadMode`):
|
|
5
|
+
* - at or under the run's budget (1 MB per 252 bars, `wrunRunDownloadBudgetBytes`): WHOLE, today's asks unchanged, the
|
|
6
|
+
* meter only counts;
|
|
7
|
+
* - over it: BUDGETED. Snapshot and scalar reads reserve their projected bytes and are never cut; the history reads (a
|
|
8
|
+
* row lane with a flow or snapshot landing, the chart's own celled classes) share what is left in proportion to their
|
|
9
|
+
* projections. Each asks its newest slice first and alone whatever its share (it draws at least its newest bar), then
|
|
10
|
+
* the newest older bars its share fits by the slice's own wire bytes, and no others (wrun-row-lanes.util
|
|
11
|
+
* `fetchWrunRowLaneRows` `download`).
|
|
12
|
+
*
|
|
13
|
+
* The reads are the sheet's own (`wrunRunDownloadReads`: the kit's declared reads of every input the market demands,
|
|
14
|
+
* its setting-bound knobs at the run's values). A read whose lane downloads more than it declares carries the lane's own
|
|
15
|
+
* projection (`projectedBytes`, FE-FOLD-CAP: a strike flow read the lane will fold from the chain's contract rows),
|
|
16
|
+
* which replaces the kit's. The kit prices a 1h and a 5m window; a run on another interval is priced at the nearer one
|
|
17
|
+
* over its own bars (`wrunDownloadKitInterval`), so the rule holds exactly on the windows it is defined on and
|
|
18
|
+
* approximately elsewhere, where the meter still counts every byte.
|
|
19
|
+
*
|
|
20
|
+
* Behind the flag `wrun-download-budget-cut` (the run reads it): off, every run is whole.
|
|
21
|
+
*/
|
|
22
|
+
import type { WrunDownloadInputCost, WrunDownloadInterval, WrunDownloadMarket, WrunDownloadReadFacts } from '@orangecharts/indicator-kit/host';
|
|
23
|
+
import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
|
|
24
|
+
import { type WrunDownloadMeterPort } from './wrun-download-meter.util.js';
|
|
25
|
+
/** One read's tally beside the run's meter (`createWrunLaneDownloadMeter`): what its own asks downloaded. */
|
|
26
|
+
export interface WrunLaneDownloadMeter extends WrunDownloadMeterPort {
|
|
27
|
+
/** Bytes the read's asks downloaded: the wire a stamp measured, else the answer's cell bytes. */
|
|
28
|
+
spentBytes(): number;
|
|
29
|
+
/** The read's asks, and those a stamp measured at 0 bytes (a cache, a follower of another ask's request). */
|
|
30
|
+
asks(): number;
|
|
31
|
+
cachedAsks(): number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A read's own meter: every charge goes on to the run's meter unchanged (the run's summary counts every read once) and
|
|
35
|
+
* into the read's tally, so a budgeted read learns what its newest slice downloaded while the run's other reads
|
|
36
|
+
* download beside it (wrun-row-lanes.util `fetchWrunRowLaneRows` `download`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function createWrunLaneDownloadMeter(run: WrunDownloadMeterPort): WrunLaneDownloadMeter;
|
|
39
|
+
/** The market shapes the kit prices (`WRUN_DOWNLOAD_MARKETS`). */
|
|
40
|
+
export type WrunDownloadPlanMarket = WrunDownloadMarket;
|
|
41
|
+
/** The kit's window nearest a chart's bar (`wrunDownloadReadCost` prices '1h' and '5m' alone). */
|
|
42
|
+
export declare function wrunDownloadKitInterval(intervalMs: number): WrunDownloadInterval;
|
|
43
|
+
/** A chart's market shape as the kit prices it: a CME Group exchange `cme`, a session market (a stock, an ETF, an index
|
|
44
|
+
* mode chart) `us-stock`, every other (a crypto venue, 24/7) `crypto`. */
|
|
45
|
+
export declare function wrunDownloadMarketOf(chart: {
|
|
46
|
+
cme: boolean;
|
|
47
|
+
indexMode: boolean;
|
|
48
|
+
}): WrunDownloadPlanMarket;
|
|
49
|
+
/** One read of a run as the plan prices it: the kit's facts, and the run's own words for it. */
|
|
50
|
+
export interface WrunDownloadPlanRead extends WrunDownloadReadFacts {
|
|
51
|
+
/** The run's name for the read (a row lane instance's id, a built-in lane's): the shares are keyed by it. Absent: the
|
|
52
|
+
* read's inputs, joined. */
|
|
53
|
+
key?: string;
|
|
54
|
+
/** A read the run can cut by bars (a history read). Absent or false: a snapshot or scalar read, reserved. */
|
|
55
|
+
history?: boolean;
|
|
56
|
+
/** The lane's own projection where the read downloads more than it declares (FE-FOLD-CAP), replacing the kit's. */
|
|
57
|
+
projectedBytes?: number;
|
|
58
|
+
}
|
|
59
|
+
/** The run's window as the plan prices it: its bars (the budget's), its bar and its market shape. */
|
|
60
|
+
export interface WrunDownloadPlanWindow {
|
|
61
|
+
bars: number;
|
|
62
|
+
intervalMs: number;
|
|
63
|
+
market: WrunDownloadPlanMarket;
|
|
64
|
+
}
|
|
65
|
+
export type WrunDownloadMode = {
|
|
66
|
+
mode: 'whole';
|
|
67
|
+
projectedBytes: number;
|
|
68
|
+
} | {
|
|
69
|
+
mode: 'budgeted';
|
|
70
|
+
projectedBytes: number;
|
|
71
|
+
budgetBytes: number;
|
|
72
|
+
shares: ReadonlyMap<string, number>;
|
|
73
|
+
};
|
|
74
|
+
/** One read's worst case on the run's window (the kit's `wrunDownloadReadCost`, by default through the shared host). */
|
|
75
|
+
export type WrunDownloadPrice = (read: WrunDownloadReadFacts, market: WrunDownloadMarket, interval: WrunDownloadInterval) => WrunDownloadInputCost;
|
|
76
|
+
/** The key a read's share is filed under. */
|
|
77
|
+
export declare function wrunDownloadPlanKeyOf(read: Pick<WrunDownloadPlanRead, 'key' | 'inputs'>): string;
|
|
78
|
+
/** A read's projected bytes on the window: the lane's own projection where it carries one, else the kit's. */
|
|
79
|
+
export declare function wrunDownloadPlanReadBytes(read: WrunDownloadPlanRead, window: Pick<WrunDownloadPlanWindow, 'intervalMs' | 'market'>, price?: WrunDownloadPrice): number;
|
|
80
|
+
/**
|
|
81
|
+
* The run's mode, before any fetch: WHOLE when the reads' projection is at or under the run's budget, else BUDGETED
|
|
82
|
+
* with each history read's share of what the reserved reads leave, in proportion to its projection (a read the run
|
|
83
|
+
* cannot cut, a snapshot or a scalar read, keeps its projection and is never cut). A read's share never holds it to
|
|
84
|
+
* nothing: it asks its newest slice whatever the share (the lane's rule), so a share is what its older bars may spend.
|
|
85
|
+
*/
|
|
86
|
+
export declare function wrunRunDownloadMode(reads: readonly WrunDownloadPlanRead[], window: WrunDownloadPlanWindow, price?: WrunDownloadPrice): WrunDownloadMode;
|
|
87
|
+
/**
|
|
88
|
+
* The sheet's reads as the kit charges them (`wrunDownloadPlanReads`, the declared-read half: every input it is handed
|
|
89
|
+
* is a read the plan left unasked, so each is charged from its declaration over the window), one per class and knob set
|
|
90
|
+
* with the inputs it serves: its knobs (a view, a fold, `history`, the strike knobs), its setting-bound knobs at the
|
|
91
|
+
* run's values (`settingOf`), its cap a bar (the input's capacity) and its width. `inputs` names the inputs the run
|
|
92
|
+
* reads (an input the market leaves undemanded is no read); the window is the run's, warm-up included
|
|
93
|
+
* (`[fromMs, toMs)`, at its bar). The chart's own candles are no read of the run (its rows answer them).
|
|
94
|
+
*/
|
|
95
|
+
export declare function wrunRunDownloadReads(sheet: WrunIndicatorMetadata, window: {
|
|
96
|
+
fromMs: number;
|
|
97
|
+
toMs: number;
|
|
98
|
+
intervalMs: number;
|
|
99
|
+
}, inputs: readonly string[], settingOf?: (name: string) => number | undefined): WrunDownloadReadFacts[];
|