@orangecharts/wrun-chart-host 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +25 -2
  2. package/dist/constants/feature-flags.constants.d.ts +1 -0
  3. package/dist/constants/feature-flags.constants.js +5 -0
  4. package/dist/constants/option-venues.constants.d.ts +18 -0
  5. package/dist/constants/option-venues.constants.js +14 -0
  6. package/dist/constants/venue-presets.constants.d.ts +17 -3
  7. package/dist/constants/venue-presets.constants.js +17 -3
  8. package/dist/host-env.d.ts +24 -0
  9. package/dist/host-env.js +21 -0
  10. package/dist/host-ports.types.d.ts +12 -0
  11. package/dist/index.d.ts +16 -0
  12. package/dist/index.js +16 -0
  13. package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
  14. package/dist/indicators/controls/tpo-session.util.js +138 -14
  15. package/dist/interfaces/option-instrument.interface.d.ts +6 -0
  16. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +4 -0
  17. package/dist/kscript-data/controls/live-trades-merge.util.js +4 -0
  18. package/dist/settings-templates/footprint-rows.d.ts +25 -0
  19. package/dist/settings-templates/footprint-rows.js +127 -0
  20. package/dist/settings-templates/form-rows.d.ts +56 -0
  21. package/dist/settings-templates/form-rows.js +19 -0
  22. package/dist/settings-templates/frvp-fields.js +14 -0
  23. package/dist/settings-templates/index.d.ts +11 -0
  24. package/dist/settings-templates/index.js +29 -6
  25. package/dist/settings-templates/indicator-fields.d.ts +2 -0
  26. package/dist/settings-templates/indicator-fields.js +78 -0
  27. package/dist/settings-templates/tool-rules.d.ts +40 -4
  28. package/dist/settings-templates/tool-rules.js +45 -4
  29. package/dist/settings-templates/tool-tables.generated.js +22 -2
  30. package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
  31. package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
  32. package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
  33. package/dist/utility/chart/footprint-columns.util.js +106 -0
  34. package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
  35. package/dist/utility/chart/footprint-display-mode.util.js +62 -0
  36. package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
  37. package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
  38. package/dist/utility/chart/kscript-venue-policy.util.js +4 -2
  39. package/dist/utility/chart/om-panel.util.d.ts +11 -0
  40. package/dist/utility/chart/om-panel.util.js +59 -0
  41. package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
  42. package/dist/utility/chart/window-geometry.leaf.js +78 -6
  43. package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
  44. package/dist/utility/chart/window-owner.leaf.js +5 -0
  45. package/dist/utility/options/cme-options-root.util.d.ts +25 -0
  46. package/dist/utility/options/cme-options-root.util.js +40 -0
  47. package/dist/utility/options/option-book.util.d.ts +27 -0
  48. package/dist/utility/options/option-book.util.js +76 -0
  49. package/dist/utility/options/option-trade-date.util.d.ts +50 -0
  50. package/dist/utility/options/option-trade-date.util.js +120 -0
  51. package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
  52. package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
  53. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
  54. package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
  55. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
  56. package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
  57. package/dist/utility/wrun/sources/row-lane-registry.js +9 -5
  58. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  59. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
  60. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
  61. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -1
  62. package/dist/utility/wrun/sources/row-lanes/option_prints.js +100 -23
  63. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
  64. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
  65. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +47 -1
  66. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +71 -2
  67. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +14 -1
  68. package/dist/utility/wrun/sources/row-lanes/option_surface.js +30 -2
  69. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
  70. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +45 -5
  71. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +115 -3
  72. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +10 -0
  73. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +57 -0
  74. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +60 -6
  75. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +160 -23
  76. package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
  77. package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
  78. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
  79. package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
  80. package/dist/utility/wrun/wrun-color-settings.util.d.ts +7 -5
  81. package/dist/utility/wrun/wrun-color-settings.util.js +26 -11
  82. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +4 -2
  83. package/dist/utility/wrun/wrun-draft-overlay.util.js +40 -3
  84. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
  85. package/dist/utility/wrun/wrun-hosted-wire-caps.js +4 -0
  86. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
  87. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
  88. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
  89. package/dist/utility/wrun/wrun-live-tick.util.js +39 -6
  90. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +106 -0
  91. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +159 -0
  92. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +44 -0
  93. package/dist/utility/wrun/wrun-market-size-defaults.util.js +213 -0
  94. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
  95. package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
  96. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
  97. package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
  98. package/dist/utility/wrun/wrun-option-prints.util.d.ts +133 -3
  99. package/dist/utility/wrun/wrun-option-prints.util.js +318 -8
  100. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +96 -0
  101. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +215 -0
  102. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +342 -0
  103. package/dist/utility/wrun/wrun-option-strike-flow.util.js +742 -0
  104. package/dist/utility/wrun/wrun-option-views.util.d.ts +183 -3
  105. package/dist/utility/wrun/wrun-option-views.util.js +504 -7
  106. package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
  107. package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
  108. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +2 -1
  109. package/dist/utility/wrun/wrun-overlay-recovery.util.js +7 -2
  110. package/dist/utility/wrun/wrun-overlay-run.util.js +120 -18
  111. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
  112. package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
  113. package/dist/utility/wrun/wrun-pack.util.d.ts +9 -8
  114. package/dist/utility/wrun/wrun-pack.util.js +21 -15
  115. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
  116. package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
  117. package/dist/utility/wrun/wrun-panel-style.util.d.ts +17 -2
  118. package/dist/utility/wrun/wrun-panel-style.util.js +47 -9
  119. package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
  120. package/dist/utility/wrun/wrun-refusal.util.js +7 -1
  121. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -0
  122. package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
  123. package/dist/utility/wrun/wrun-tape-source.util.d.ts +9 -0
  124. package/dist/utility/wrun/wrun-tape-source.util.js +18 -0
  125. package/package.json +3 -3
@@ -0,0 +1,159 @@
1
+ import { WRUN_MARKET_SIZE_UNITS } from './wrun-market-facts.util.js';
2
+ /**
3
+ * The params whose default follows the market, by package name, then param name (the sheet's own names). A built-in
4
+ * twin whose sheet binds a param to a trade size floor lists it here or in the guard's exemptions with a reason
5
+ * (tests/utility/wrun/wrun-market-size-defaults.twins.spec.ts walks every proven twin's frozen sheet).
6
+ */
7
+ export const WRUN_MARKET_SCALED_PARAMS = Object.freeze({
8
+ '@om-core/big-trades': Object.freeze({
9
+ // The tape's floor (its `min_size` facet names it) and the bubbles' size unit: 0.01% of a day's base volume.
10
+ min_size: Object.freeze({ kind: 'daily-volume', share: 0.0001 }),
11
+ // The Whale buy and Whale sell signals' threshold, in Min size's unit: ten times its market default.
12
+ whale_size: Object.freeze({ kind: 'times', param: 'min_size', factor: 10 }),
13
+ }),
14
+ });
15
+ /** The scaled params of a package, or undefined for a package that scales none. */
16
+ export function wrunMarketScaledParamsOf(packageName) {
17
+ if (packageName === undefined || !Object.hasOwn(WRUN_MARKET_SCALED_PARAMS, packageName))
18
+ return undefined;
19
+ return WRUN_MARKET_SCALED_PARAMS[packageName];
20
+ }
21
+ const HOUR_MS = 3_600_000;
22
+ const DAY_MS = 86_400_000;
23
+ /** The candle row's volume column (`[ts, open, high, low, close, volume]`, the chart's main series rows). */
24
+ const VOLUME_COLUMN = 5;
25
+ /** `market.size_unit()`'s codes (the kit's table, wrun-market-facts.util). */
26
+ const UNKNOWN_SIZE_UNIT = WRUN_MARKET_SIZE_UNITS.indexOf('unknown');
27
+ const COINS_SIZE_UNIT = WRUN_MARKET_SIZE_UNITS.indexOf('coins');
28
+ const CONTRACTS_SIZE_UNIT = WRUN_MARKET_SIZE_UNITS.indexOf('contracts');
29
+ /**
30
+ * A market's daily volume in its candles' unit, from the chart's own candles (ascending, the newest the forming
31
+ * one, which is left out: its volume is partial): the closed candles opening in the 24 hours before the newest one's
32
+ * open, summed and scaled to a day by the span they cover (a fine chart loads less than a day: 500 one-minute candles
33
+ * count 499 minutes; a gap where nothing traded counts as covered time with no volume). One closed candle longer than
34
+ * a day (1W, 1M) is prorated by its length, the gap to the next open held to `intervalMs`. Undefined when the closed
35
+ * candles cover under an hour or hold no volume.
36
+ */
37
+ export function wrunDailyCandleVolume(rows, intervalMs) {
38
+ const last = rows.length - 1;
39
+ if (last < 1)
40
+ return undefined;
41
+ const newestOpen = Number(rows[last][0]);
42
+ const lastClosedOpen = Number(rows[last - 1][0]);
43
+ if (!Number.isFinite(newestOpen) || !Number.isFinite(lastClosedOpen))
44
+ return undefined;
45
+ const barMs = intervalMs !== undefined && Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : Infinity;
46
+ const lastSpan = Math.min(newestOpen - lastClosedOpen, barMs);
47
+ if (lastSpan > DAY_MS) {
48
+ const volume = Number(rows[last - 1][VOLUME_COLUMN]);
49
+ return Number.isFinite(volume) && volume > 0 ? (volume * DAY_MS) / lastSpan : undefined;
50
+ }
51
+ const windowStart = newestOpen - DAY_MS;
52
+ let volume = 0;
53
+ for (let at = last - 1; at >= 0; at -= 1) {
54
+ if (!(Number(rows[at][0]) >= windowStart))
55
+ break;
56
+ const bar = Number(rows[at][VOLUME_COLUMN]);
57
+ if (Number.isFinite(bar) && bar > 0)
58
+ volume += bar;
59
+ }
60
+ const covered = newestOpen - Math.max(windowStart, Number(rows[0][0]));
61
+ if (!(covered >= HOUR_MS) || !(volume > 0))
62
+ return undefined;
63
+ return (volume * DAY_MS) / covered;
64
+ }
65
+ /**
66
+ * The largest 1, 2 or 5 times a power of ten at or below `value` (5,000,000, 200, 10, then 0.5, 0.2, 0.1 below 1), as
67
+ * a clean decimal; undefined for a value that is not finite and above zero.
68
+ */
69
+ export function wrunNiceFloor(value) {
70
+ if (!Number.isFinite(value) || value <= 0)
71
+ return undefined;
72
+ const scale = 10 ** Math.floor(Math.log10(value));
73
+ // A hair over the float quotient: 0.6 / 0.1 reads 5.999999999999999, and log10 can land a power of ten one
74
+ // exponent low (the mantissa then reads 10).
75
+ const mantissa = (value / scale) * (1 + 1e-9);
76
+ const step = mantissa >= 10 ? 10 : mantissa >= 5 ? 5 : mantissa >= 2 ? 2 : 1;
77
+ return Number((step * scale).toPrecision(1));
78
+ }
79
+ /**
80
+ * Each scaled param's default on a market trading `dailyVolume` base units a day: the daily-volume rules first, then
81
+ * the multiples of them. Undefined when the volume yields no default (not finite and above zero).
82
+ */
83
+ export function wrunMarketScaledDefaults(rules, dailyVolume) {
84
+ const defaults = {};
85
+ for (const [name, rule] of Object.entries(rules)) {
86
+ if (rule.kind !== 'daily-volume')
87
+ continue;
88
+ const value = wrunNiceFloor(dailyVolume * rule.share);
89
+ if (value === undefined)
90
+ return undefined;
91
+ defaults[name] = value;
92
+ }
93
+ for (const [name, rule] of Object.entries(rules)) {
94
+ if (rule.kind !== 'times')
95
+ continue;
96
+ const base = defaults[rule.param];
97
+ if (base === undefined)
98
+ return undefined;
99
+ defaults[name] = Number((base * rule.factor).toPrecision(12));
100
+ }
101
+ return defaults;
102
+ }
103
+ /** The verdict of a market's facts on a package's scaled params (`rules`). */
104
+ export function wrunMarketSizeVerdict(rules, facts) {
105
+ if (facts.sizeUnit === CONTRACTS_SIZE_UNIT)
106
+ return { kind: 'package', reason: 'contracts' };
107
+ if (facts.sizeUnit === UNKNOWN_SIZE_UNIT)
108
+ return { kind: 'skip', reason: 'size-unit' };
109
+ if (facts.sizeUnit !== COINS_SIZE_UNIT)
110
+ return { kind: 'package', reason: 'size-unit' };
111
+ if (!facts.candleVolumeInCoins)
112
+ return { kind: 'package', reason: 'candle-unit' };
113
+ const daily = wrunDailyCandleVolume(facts.rows, facts.intervalMs);
114
+ const defaults = daily === undefined ? undefined : wrunMarketScaledDefaults(rules, daily);
115
+ return defaults === undefined ? { kind: 'skip', reason: 'cover' } : { kind: 'market', defaults };
116
+ }
117
+ /** A number row's value held to its bounds, or undefined for one that is not finite. */
118
+ export function wrunMarketDefaultWithinRow(row, value) {
119
+ if (typeof value !== 'number' || !Number.isFinite(value))
120
+ return undefined;
121
+ const { min, max } = row.constraints ?? {};
122
+ if (typeof min === 'number' && value < min)
123
+ return min;
124
+ if (typeof max === 'number' && value > max)
125
+ return max;
126
+ return value;
127
+ }
128
+ /**
129
+ * `rows` (the rows a sheet builds, `buildWrunScriptInputs`) with the market defaults a record holds: each scaled
130
+ * param's row takes the default its row in `held` (the record's own `scriptInputs`) carries, the one the run head last
131
+ * moved it to, so a rebuild of the rows from the sheet (a delivered sheet's reconcile, a pin move) never moves a market
132
+ * default back to the sheet's, and a value at it never reads as changed. A held default that is not a number within
133
+ * the row's bounds stays the sheet's. The same array when nothing moves.
134
+ */
135
+ export function wrunRowsKeepingMarketDefaults(rows, held, packageName) {
136
+ const rules = wrunMarketScaledParamsOf(packageName);
137
+ if (rules === undefined || !Array.isArray(held))
138
+ return rows;
139
+ let moved = false;
140
+ const kept = rows.map((row) => {
141
+ if (!Object.hasOwn(rules, row.name) || !isWrunMarketScaledRow(row))
142
+ return row;
143
+ const own = held.find((candidate) => candidate !== null && typeof candidate === 'object' && candidate.name === row.name);
144
+ const value = own?.defaultValue;
145
+ if (typeof value !== 'number' || wrunMarketDefaultWithinRow(row, value) !== value)
146
+ return row;
147
+ if (value === row.defaultValue)
148
+ return row;
149
+ moved = true;
150
+ return { ...row, defaultValue: value };
151
+ });
152
+ return moved ? kept : rows;
153
+ }
154
+ /** The row kinds a scaled param is: a number, int or price row (they store the same finite number). */
155
+ const WRUN_MARKET_SCALED_ROW_TYPES = new Set(['number', 'int', 'price']);
156
+ /** Whether a settings row can hold a market default (a number kind; a sheet that retyped the param keeps its own). */
157
+ export function isWrunMarketScaledRow(row) {
158
+ return WRUN_MARKET_SCALED_ROW_TYPES.has(row.type);
159
+ }
@@ -0,0 +1,44 @@
1
+ import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
2
+ /**
3
+ * The patch that moves a record (`settings`: its `scriptInputs` rows and each value flat under its row's name) to a
4
+ * market's `defaults`: every scaled row whose value reads as its default (never changed) takes the market's default
5
+ * (held to the row's bounds), value and `defaultValue` together. A changed value keeps both: the changed mark is the
6
+ * value against its own row's default, so a default moved under a kept value would read the value as never changed on
7
+ * the first market whose default equals it, and the next market would move it (SOL 200, then ETH whose default is
8
+ * 200, then SOL reset it to 1000). Its reset goes to the default of the market where the user changed it, a save
9
+ * whose run head then moves the unchanged value on. Undefined when the record already reads the defaults. Pure.
10
+ */
11
+ export declare function wrunMarketSizeSettingsPatch(settings: unknown, defaults: Readonly<Record<string, number>>): Record<string, unknown> | undefined;
12
+ /** The chart market the run computes for, as the head reads it. */
13
+ interface WrunMarketSizeChart {
14
+ exchange?: unknown;
15
+ symbol?: unknown;
16
+ interval?: unknown;
17
+ transformations?: unknown;
18
+ }
19
+ /**
20
+ * Move an overlay's record to its chart market's scaled defaults (above), at the head of a full run, before the
21
+ * lanes read the settings. Resolves once the engine copy reads the defaults (the persist is the routing's own); a
22
+ * package that scales nothing returns at once, and nothing here ever throws over the run.
23
+ *
24
+ * Every fact is proven the keyed market's before it is kept or written: `market` is the market the run computes for
25
+ * (C4: the chart's market identity at the run head, `wrunChartMarketIdentity`, and the reader of the chart's metadata
26
+ * now), and `isCurrent` says the run is still the overlay's own (its chart and mount stand). After each await, in the
27
+ * task that keeps and writes, the chart still names that market (a switch during the directory's answer moves it, and
28
+ * neither the mount nor the refusal attempt sees a switch), and the verdict that reads the candles reads them only
29
+ * while they were loaded for it (`loadedMainIdentityOf`: the symbol pipeline stamps the new market's metadata before
30
+ * its rows replace the old market's). A fact it cannot prove reads as a transient skip: no memo, no write.
31
+ */
32
+ export declare function reconcileWrunMarketSizeDefaults(args: {
33
+ chartIndex: number;
34
+ indicatorId: string;
35
+ tc: unknown;
36
+ meta: Record<string, unknown>;
37
+ sheet: WrunIndicatorMetadata;
38
+ market: {
39
+ identity: string;
40
+ read: () => WrunMarketSizeChart | null | undefined;
41
+ };
42
+ isCurrent: () => boolean;
43
+ }): Promise<void>;
44
+ export {};
@@ -0,0 +1,213 @@
1
+ /**
2
+ * The run head's market-scaled size defaults (the rule and the table: wrun-market-size-defaults.leaf). A package that
3
+ * scales a param (Big Trades' Min size and Whale size) has its record moved to the chart market's defaults at the head
4
+ * of every full run, before the tape is resolved, so the run, the settings panel's value, the reset icon and its
5
+ * target, and the alert arm all read the one record:
6
+ *
7
+ * - The market's defaults are resolved once per mount and market (a page session's switch back to a market reads what
8
+ * it read there the first time), so a value never flaps inside a session: the chart's own candles give the daily
9
+ * base volume on a coin market whose candles are in base coins (the directory row places the coin, so a cold page
10
+ * waits for it once); a market whose facts never yield one (contracts, shares, candles in another unit, a formula
11
+ * chart, keyed apart from its market) reads the package's declared defaults, so the record never keeps the last
12
+ * coin market's; a size unit not known yet or too few candles resolves nothing (the record stays, the next run asks
13
+ * again).
14
+ * - A row moves while the user never changed it (the value reads as the row's default, the settings panel's reset
15
+ * test, `wrunRowValuesEqual` over `wrunRowValue`): its value and its `defaultValue` together. A changed value keeps
16
+ * both, so it reads as changed on every market after it; its reset goes to the default of the market where it was
17
+ * changed, and the run head of the save the reset is moves the now unchanged value to this market's.
18
+ * - The engine copy takes the patch (titan merges it at once, so the run reads it) and the workspace row its own, with
19
+ * one reconcile persist (no gesture, no undo entry), the delivered sheet's reconcile's pattern
20
+ * (wrun-overlay-run.util `reconcileWrunSourceRecord`, which keeps the moved defaults when it rebuilds the rows).
21
+ *
22
+ * Advisory: it never fails the run.
23
+ */
24
+ import { wrunChartHostEnv } from '../../host-env.js';
25
+ import { candleVolumeIsBaseCoins } from '../chart/candle-volume-unit.leaf.js';
26
+ import { normalizeTransformations, selfTransformationToken } from '../common/transformations.util.js';
27
+ import { wrunChartIntervalMsOf } from './wrun-chart-context.util.js';
28
+ import { warmWrunMarketFacts, wrunChartSizeUnit } from './wrun-chart-market-facts.util.js';
29
+ import { isWrunMarketScaledRow, wrunMarketDefaultWithinRow, wrunMarketScaledParamsOf, wrunMarketSizeVerdict, } from './wrun-market-size-defaults.leaf.js';
30
+ import { wrunChartMarketIdentity } from './wrun-overlay-drivers.util.js';
31
+ import { wrunRegistryRefOf } from './wrun-overlay-identity.util.js';
32
+ import { wrunRowValue, wrunRowValuesEqual, wrunValuesEqual, } from './wrun-script-inputs.util.js';
33
+ import { wrunChartCandleRows } from './wrun-source-rows.util.js';
34
+ function isRecord(value) {
35
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
36
+ }
37
+ /**
38
+ * The patch that moves a record (`settings`: its `scriptInputs` rows and each value flat under its row's name) to a
39
+ * market's `defaults`: every scaled row whose value reads as its default (never changed) takes the market's default
40
+ * (held to the row's bounds), value and `defaultValue` together. A changed value keeps both: the changed mark is the
41
+ * value against its own row's default, so a default moved under a kept value would read the value as never changed on
42
+ * the first market whose default equals it, and the next market would move it (SOL 200, then ETH whose default is
43
+ * 200, then SOL reset it to 1000). Its reset goes to the default of the market where the user changed it, a save
44
+ * whose run head then moves the unchanged value on. Undefined when the record already reads the defaults. Pure.
45
+ */
46
+ export function wrunMarketSizeSettingsPatch(settings, defaults) {
47
+ const record = isRecord(settings) ? settings : {};
48
+ if (!Array.isArray(record.scriptInputs))
49
+ return undefined;
50
+ const patch = {};
51
+ let rowsMoved = false;
52
+ const scriptInputs = record.scriptInputs.map((held) => {
53
+ if (!isRecord(held) || typeof held.name !== 'string' || !Object.hasOwn(defaults, held.name))
54
+ return held;
55
+ const row = held;
56
+ if (!isWrunMarketScaledRow(row))
57
+ return held;
58
+ const target = wrunMarketDefaultWithinRow(row, defaults[row.name]);
59
+ if (target === undefined)
60
+ return held;
61
+ if (!wrunRowValuesEqual(row, wrunRowValue(record, row), row.defaultValue))
62
+ return held;
63
+ if (!wrunValuesEqual(record[row.name], target))
64
+ patch[row.name] = target;
65
+ if (wrunValuesEqual(row.defaultValue, target))
66
+ return held;
67
+ rowsMoved = true;
68
+ return { ...row, defaultValue: target };
69
+ });
70
+ if (rowsMoved)
71
+ patch.scriptInputs = scriptInputs;
72
+ return Object.keys(patch).length > 0 ? patch : undefined;
73
+ }
74
+ /** Each mount's resolved defaults, by market (`exchange|symbol`, and a formula chart's formula after it: its candles
75
+ * are no market's, so it reads the package's defaults where its market reads its own): the engine meta is the mount. */
76
+ const wrunMarketSizeDefaultsByMount = new WeakMap();
77
+ /** The scaled params' defaults a sheet declares (the package's own: a `package` verdict's). */
78
+ function wrunDeclaredDefaults(sheet, names) {
79
+ const wanted = new Set(names);
80
+ const defaults = {};
81
+ for (const param of sheet.params ?? []) {
82
+ if (wanted.has(param.name) && typeof param.default === 'number' && Number.isFinite(param.default)) {
83
+ defaults[param.name] = param.default;
84
+ }
85
+ }
86
+ return defaults;
87
+ }
88
+ const WRUN_MARKET_SIZE_UNPROVEN = Object.freeze({ kind: 'skip', reason: 'unproven' });
89
+ /**
90
+ * Move an overlay's record to its chart market's scaled defaults (above), at the head of a full run, before the
91
+ * lanes read the settings. Resolves once the engine copy reads the defaults (the persist is the routing's own); a
92
+ * package that scales nothing returns at once, and nothing here ever throws over the run.
93
+ *
94
+ * Every fact is proven the keyed market's before it is kept or written: `market` is the market the run computes for
95
+ * (C4: the chart's market identity at the run head, `wrunChartMarketIdentity`, and the reader of the chart's metadata
96
+ * now), and `isCurrent` says the run is still the overlay's own (its chart and mount stand). After each await, in the
97
+ * task that keeps and writes, the chart still names that market (a switch during the directory's answer moves it, and
98
+ * neither the mount nor the refusal attempt sees a switch), and the verdict that reads the candles reads them only
99
+ * while they were loaded for it (`loadedMainIdentityOf`: the symbol pipeline stamps the new market's metadata before
100
+ * its rows replace the old market's). A fact it cannot prove reads as a transient skip: no memo, no write.
101
+ */
102
+ export async function reconcileWrunMarketSizeDefaults(args) {
103
+ const { chartIndex, indicatorId, tc, meta, sheet, market, isCurrent } = args;
104
+ const rules = wrunMarketScaledParamsOf(wrunRegistryRefOf(meta.settings)?.package);
105
+ if (rules === undefined)
106
+ return;
107
+ const keyed = () => isCurrent() && wrunChartMarketIdentity(market.read()) === market.identity;
108
+ try {
109
+ if (!keyed())
110
+ return;
111
+ const chartMetadata = market.read() ?? undefined;
112
+ const exchange = typeof chartMetadata?.exchange === 'string' ? chartMetadata.exchange : '';
113
+ const symbol = typeof chartMetadata?.symbol === 'string' ? chartMetadata.symbol : '';
114
+ if (exchange === '' || symbol === '')
115
+ return;
116
+ const transformations = typeof chartMetadata?.transformations === 'string' ? chartMetadata.transformations : '';
117
+ const formula = wrunChartFormulaOf(exchange, symbol, transformations);
118
+ const key = formula === undefined ? `${exchange}|${symbol}` : `${exchange}|${symbol}|${formula}`;
119
+ let resolved = wrunMarketSizeDefaultsByMount.get(meta);
120
+ let defaults = resolved?.get(key);
121
+ if (defaults === undefined) {
122
+ // A crypto market's coin unit is the directory row's (its asset class): asked once per market for the session,
123
+ // never rejects; a contracts market answers from its own facts and waits on nothing. The data loading module
124
+ // says whose candles the chart holds; a host that cannot load it proves nothing.
125
+ const [, dataFetching] = await Promise.all([
126
+ warmWrunMarketFacts(chartMetadata),
127
+ Promise.resolve()
128
+ .then(() => wrunChartHostEnv().chart.loadDataFetching())
129
+ .catch(() => undefined),
130
+ ]);
131
+ const verdict = keyed()
132
+ ? wrunMarketSizeVerdictNow(rules, {
133
+ tc,
134
+ chartMetadata: market.read() ?? undefined,
135
+ identity: market.identity,
136
+ loaded: dataFetching?.loadedMainIdentityOf(chartIndex) ?? null,
137
+ ownCandles: formula === undefined,
138
+ exchange,
139
+ symbol,
140
+ })
141
+ : WRUN_MARKET_SIZE_UNPROVEN;
142
+ if (wrunChartHostEnv().diagnostics.debugEnabled()) {
143
+ wrunChartHostEnv().diagnostics.debug('wrun-market-size-defaults', {
144
+ chartIndex,
145
+ indicatorId,
146
+ market: key,
147
+ verdict: verdict.kind,
148
+ ...(verdict.kind !== 'market' ? { reason: verdict.reason } : {}),
149
+ ...(verdict.kind === 'market' ? { defaults: verdict.defaults } : {}),
150
+ });
151
+ }
152
+ // A fact that can still change (a unit not known yet, too few candles) or that could not be proven the keyed
153
+ // market's: nothing kept, nothing moves, the next run asks again.
154
+ if (verdict.kind === 'skip')
155
+ return;
156
+ defaults = verdict.kind === 'market' ? verdict.defaults : wrunDeclaredDefaults(sheet, Object.keys(rules));
157
+ if (resolved === undefined) {
158
+ resolved = new Map();
159
+ wrunMarketSizeDefaultsByMount.set(meta, resolved);
160
+ }
161
+ resolved.set(key, defaults);
162
+ }
163
+ if (!keyed())
164
+ return;
165
+ const enginePatch = wrunMarketSizeSettingsPatch(meta.settings, defaults);
166
+ if (enginePatch === undefined)
167
+ return;
168
+ const chart = tc;
169
+ if (typeof chart?.updateSettings === 'function')
170
+ chart.updateSettings(indicatorId, enginePatch);
171
+ else
172
+ meta.settings = { ...(isRecord(meta.settings) ? meta.settings : {}), ...enginePatch };
173
+ const { persistChart, resolveChart } = await wrunChartHostEnv().chart.loadChartRouting();
174
+ if (!keyed())
175
+ return;
176
+ const document = resolveChart(chartIndex);
177
+ const row = [...(document?.onchart ?? []), ...(document?.offchart ?? [])].find((candidate) => candidate?.id === indicatorId);
178
+ const rowPatch = row === undefined ? undefined : wrunMarketSizeSettingsPatch(row.settings, defaults);
179
+ if (row === undefined || rowPatch === undefined)
180
+ return;
181
+ row.settings = { ...(row.settings ?? {}), ...rowPatch };
182
+ persistChart(chartIndex, 'reconcile');
183
+ }
184
+ catch (error) {
185
+ console.warn(`[wrun] the market size defaults of '${indicatorId}' were not applied:`, error);
186
+ }
187
+ }
188
+ /** The formula a chart's candles are computed from (normalized), or undefined for a chart of the market's own candles
189
+ * (no transformations, or the market's own token). */
190
+ function wrunChartFormulaOf(exchange, symbol, transformations) {
191
+ const formula = normalizeTransformations(transformations);
192
+ return formula === '' || formula === normalizeTransformations(selfTransformationToken(exchange, symbol))
193
+ ? undefined
194
+ : formula;
195
+ }
196
+ /**
197
+ * The verdict of the keyed market's facts, read in the caller's task once the chart is proven on that market: the
198
+ * size unit once the directory placed it, the venue's candle volume unit (`ownCandles`: a formula chart's candles are
199
+ * no market's), and the chart's own candles while they were loaded for the keyed market (`loaded`, the loaded-main
200
+ * identity, names its `identity`). Candles loaded for another market are never read: the verdict that would read them
201
+ * reads `unproven` (the candles not yet the market's own, never its own too few).
202
+ */
203
+ function wrunMarketSizeVerdictNow(rules, facts) {
204
+ const rowsOwn = facts.loaded !== null && wrunChartMarketIdentity(facts.loaded) === facts.identity;
205
+ const verdict = wrunMarketSizeVerdict(rules, {
206
+ sizeUnit: wrunChartSizeUnit(facts.chartMetadata),
207
+ candleVolumeInCoins: facts.ownCandles && candleVolumeIsBaseCoins(facts.exchange, facts.symbol),
208
+ rows: rowsOwn ? wrunChartCandleRows(facts.tc) : [],
209
+ intervalMs: wrunChartIntervalMsOf(facts.chartMetadata?.interval),
210
+ });
211
+ // Only the verdict that reads the candles meets the rows held back, and no rows read as too few candles.
212
+ return !rowsOwn && verdict.kind === 'skip' && verdict.reason === 'cover' ? WRUN_MARKET_SIZE_UNPROVEN : verdict;
213
+ }
@@ -15,19 +15,36 @@
15
15
  * - a COIN or MARKET row is keyed by option type, `dte_bucket` (1 the print's trade date, 2 one to seven days, 3 eight
16
16
  * to thirty-five, 4 later; 0 a print past its expiry) and `moneyness` (+1 out of the money, -1 in the money, unset
17
17
  * without an underlying price); a VENUE row by option type and issue type. Side is never a dimension: every row
18
- * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid).
18
+ * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid);
19
+ * - PRINTS rows of one underlying (`PRINTS`, the coin beside it; OPTLOAD G4): its prints at or above the ask's premium
20
+ * floor and within its `max_dte`, summed per bar and option type in the COIN columns.
21
+ *
22
+ * OPTLOAD (OPTLOAD-READ-CONTRACT sections 5 and 7): the gateway groups the rows to the chart's bar, filters the split
23
+ * and folds the dimensions (`DataRequest.optionRead`), so an answer is one row per (bar, option type) of the asked split;
24
+ * the worker half builds that shape (option-print-agg-scope.worker.util `wrunOptionsFlowReadShape`).
19
25
  *
20
26
  * Import-free: a lane file stays light at module load and the worker twin reads it too.
21
27
  */
22
- /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`); field i is lane row column i + 1. */
23
- export declare const WRUN_OPTIONS_FLOW_FIELDS: readonly ["call_prem_ask", "call_prem_bid", "call_prem_mid", "call_prem_none", "put_prem_ask", "put_prem_bid", "put_prem_mid", "put_prem_none", "call_prem_total", "put_prem_total", "call_contracts_ask", "call_contracts_bid", "call_contracts_mid", "call_contracts_none", "put_contracts_ask", "put_contracts_bid", "put_contracts_mid", "put_contracts_none", "call_contracts_total", "put_contracts_total", "net_call_prem", "net_put_prem", "net_call_prem_capped", "net_put_prem_capped", "share_delta_ask", "share_delta_bid", "vega_ask", "vega_bid", "prints", "vol_above_ask", "vol_below_bid", "n_priced"];
28
+ /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`, kit 0.89.0); field i is lane row column i + 1. The
29
+ * last four split the contracts printed outside the quote by option type (appended, so every earlier field keeps its
30
+ * column; 0 off OPRA, as `vol_above_ask` is). */
31
+ export declare const WRUN_OPTIONS_FLOW_FIELDS: readonly ["call_prem_ask", "call_prem_bid", "call_prem_mid", "call_prem_none", "put_prem_ask", "put_prem_bid", "put_prem_mid", "put_prem_none", "call_prem_total", "put_prem_total", "call_contracts_ask", "call_contracts_bid", "call_contracts_mid", "call_contracts_none", "put_contracts_ask", "put_contracts_bid", "put_contracts_mid", "put_contracts_none", "call_contracts_total", "put_contracts_total", "net_call_prem", "net_put_prem", "net_call_prem_capped", "net_put_prem_capped", "share_delta_ask", "share_delta_bid", "vega_ask", "vega_bid", "prints", "vol_above_ask", "vol_below_bid", "n_priced", "call_contracts_above_ask", "call_contracts_below_bid", "put_contracts_above_ask", "put_contracts_below_bid"];
24
32
  export type WrunOptionsFlowField = (typeof WRUN_OPTIONS_FLOW_FIELDS)[number];
25
33
  /** The fields scope `venue` serves (om `WRUN_OPTIONS_FLOW_VENUE_FIELDS`): the venue rows carry premium by side,
26
34
  * prints and the contracts' sum, no side, DTE or moneyness split. */
27
35
  export declare const WRUN_OPTIONS_FLOW_VENUE_FIELDS: readonly WrunOptionsFlowField[];
28
- /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`); an absent knob reads `ticker`. */
29
- export declare const WRUN_OPTIONS_FLOW_SCOPES: readonly ["ticker", "market", "equity", "etf", "index", "venue"];
36
+ /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`, kit 0.89.0); an absent knob reads `ticker`. `prints` (OPTLOAD G4) sums the
37
+ * chart underlying's prints at or above `min_premium` (required there) and within `max_dte`. */
38
+ export declare const WRUN_OPTIONS_FLOW_SCOPES: readonly ["ticker", "market", "equity", "etf", "index", "venue", "prints"];
30
39
  export type WrunOptionsFlowScope = (typeof WRUN_OPTIONS_FLOW_SCOPES)[number];
40
+ /** The raw-symbol word of scope `prints` (the gateway's PRINTS scope, the coin beside it). */
41
+ export declare const WRUN_OPTIONS_FLOW_PRINTS_WORD = "PRINTS";
42
+ /** Scope `prints`' `max_dte`: whole days to expiry, 0 to 3,650 (0, like an absent knob, keeps every expiry; om
43
+ * `WRUN_OPTION_MAX_DTE_DAYS`). */
44
+ export declare const WRUN_OPTIONS_FLOW_MAX_DTE_DAYS = 3650;
45
+ /** The named refusal of a scope `prints` read the gateway does not serve yet (it refused the read's `optionRead` by
46
+ * name): a prints read has no ungrouped ask to fall back to. */
47
+ export declare const WRUN_OPTIONS_FLOW_PRINTS_UNSERVED_CODE = "options-flow-prints-unserved";
31
48
  /** The scopes US listed options alone serve (an issue type of the US market, R7c C7-2): unserved off the OPRA plane. */
32
49
  export declare const WRUN_OPTIONS_FLOW_OPRA_SCOPES: readonly WrunOptionsFlowScope[];
33
50
  /** `dte` (om `WRUN_OPTIONS_FLOW_DTE`); an absent knob reads `all`. */
@@ -67,12 +84,22 @@ export declare const WRUN_OPTIONS_FLOW_EXCHANGE_FIELD = "flowExchange";
67
84
  export declare const WRUN_OPTIONS_FLOW_BOOK_FIELD = "flowBook";
68
85
  export declare const WRUN_OPTIONS_FLOW_VENUES_FIELD = "flowVenues";
69
86
  export declare const WRUN_OPTIONS_FLOW_CONTINUOUS_FIELD = "flowContinuous";
87
+ /** The chart's bar grid as an ask carries it (`liveBucketVenueOf` over the chart's metadata, plain strings): where the
88
+ * host bars a grouped read sums to open and close (a regular-session stock chart's 09:30 New York bars, a CME chart's
89
+ * session lattice, the UTC floor elsewhere). */
90
+ export interface WrunOptionsFlowBarGrid {
91
+ exchange?: string;
92
+ symbol?: string;
93
+ sessionType?: string;
94
+ transformations?: string;
95
+ }
70
96
  /** One acquisition: the payload the lane's plan answers and the K control forwards (plus the tier it is asked at). */
71
97
  export interface WrunOptionsFlowAsk {
72
98
  scope: WrunOptionsFlowScope;
73
99
  /** The exchange the chart's chain lists on (pb-common `Exchange` name): the read's venue unless `venues` names them. */
74
100
  exchange: string;
75
- /** A COIN read's underlying, upper case: every ticker read's, a crypto scope across venues' (the chart's coin). */
101
+ /** A COIN read's underlying, upper case: every ticker read's, a prints read's, a crypto scope across venues' (the
102
+ * chart's coin). */
76
103
  coin?: string;
77
104
  /** A crypto ticker read's ONE book (a series name, upper case), read as `COIN:<book>`; absent: every book. */
78
105
  book?: string;
@@ -80,13 +107,21 @@ export interface WrunOptionsFlowAsk {
80
107
  venues?: readonly string[];
81
108
  /** Scope `venue` on OPRA: the venue's Databento publisher id. */
82
109
  venueId?: number;
110
+ /** Scope `prints`: the premium floor in USD, above 0 (the gateway's `minQuoteAmount`). */
111
+ minPremium?: number;
112
+ /** Scope `prints`: the most days to expiry a summed print has, 1 to 3,650 (absent: every expiry). */
113
+ maxDte?: number;
83
114
  dte: WrunOptionsFlowDte;
84
115
  moneyness: WrunOptionsFlowMoneyness;
85
116
  tier: WrunOptionsFlowTier;
117
+ /** The host chart's bar span in ms (the run's interval): the bar a grouped read sums its rows to. */
118
+ barMs?: number;
119
+ /** The host chart's bar grid (absent: unknown, so the read is not grouped to the bar). */
120
+ barGrid?: WrunOptionsFlowBarGrid;
86
121
  }
87
122
  /** Whether an ask reads VENUE rows (scope `venue` on OPRA, by publisher id: no side, DTE or moneyness split); a crypto
88
123
  * scope `venue` reads its venue's COIN rows. */
89
124
  export declare function wrunOptionsFlowReadsVenueRows(ask: Pick<WrunOptionsFlowAsk, 'scope' | 'coin'>): boolean;
90
- /** The raw symbol an ask's read names: `COIN` for a read of one underlying (`COIN:<book>` when it names its ONE book),
91
- * `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
125
+ /** The raw symbol an ask's read names: `PRINTS` for scope `prints`, `COIN` for a read of one underlying (`COIN:<book>`
126
+ * when it names its ONE book), `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
92
127
  export declare function wrunOptionsFlowScopeSymbol(ask: Pick<WrunOptionsFlowAsk, 'scope' | 'coin' | 'book' | 'venueId'>): string;
@@ -15,11 +15,19 @@
15
15
  * - a COIN or MARKET row is keyed by option type, `dte_bucket` (1 the print's trade date, 2 one to seven days, 3 eight
16
16
  * to thirty-five, 4 later; 0 a print past its expiry) and `moneyness` (+1 out of the money, -1 in the money, unset
17
17
  * without an underlying price); a VENUE row by option type and issue type. Side is never a dimension: every row
18
- * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid).
18
+ * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid);
19
+ * - PRINTS rows of one underlying (`PRINTS`, the coin beside it; OPTLOAD G4): its prints at or above the ask's premium
20
+ * floor and within its `max_dte`, summed per bar and option type in the COIN columns.
21
+ *
22
+ * OPTLOAD (OPTLOAD-READ-CONTRACT sections 5 and 7): the gateway groups the rows to the chart's bar, filters the split
23
+ * and folds the dimensions (`DataRequest.optionRead`), so an answer is one row per (bar, option type) of the asked split;
24
+ * the worker half builds that shape (option-print-agg-scope.worker.util `wrunOptionsFlowReadShape`).
19
25
  *
20
26
  * Import-free: a lane file stays light at module load and the worker twin reads it too.
21
27
  */
22
- /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`); field i is lane row column i + 1. */
28
+ /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`, kit 0.89.0); field i is lane row column i + 1. The
29
+ * last four split the contracts printed outside the quote by option type (appended, so every earlier field keeps its
30
+ * column; 0 off OPRA, as `vol_above_ask` is). */
23
31
  export const WRUN_OPTIONS_FLOW_FIELDS = Object.freeze([
24
32
  'call_prem_ask',
25
33
  'call_prem_bid',
@@ -53,6 +61,10 @@ export const WRUN_OPTIONS_FLOW_FIELDS = Object.freeze([
53
61
  'vol_above_ask',
54
62
  'vol_below_bid',
55
63
  'n_priced',
64
+ 'call_contracts_above_ask',
65
+ 'call_contracts_below_bid',
66
+ 'put_contracts_above_ask',
67
+ 'put_contracts_below_bid',
56
68
  ]);
57
69
  /** The fields scope `venue` serves (om `WRUN_OPTIONS_FLOW_VENUE_FIELDS`): the venue rows carry premium by side,
58
70
  * prints and the contracts' sum, no side, DTE or moneyness split. */
@@ -63,8 +75,25 @@ export const WRUN_OPTIONS_FLOW_VENUE_FIELDS = Object.freeze([
63
75
  'put_contracts_total',
64
76
  'prints',
65
77
  ]);
66
- /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`); an absent knob reads `ticker`. */
67
- export const WRUN_OPTIONS_FLOW_SCOPES = Object.freeze(['ticker', 'market', 'equity', 'etf', 'index', 'venue']);
78
+ /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`, kit 0.89.0); an absent knob reads `ticker`. `prints` (OPTLOAD G4) sums the
79
+ * chart underlying's prints at or above `min_premium` (required there) and within `max_dte`. */
80
+ export const WRUN_OPTIONS_FLOW_SCOPES = Object.freeze([
81
+ 'ticker',
82
+ 'market',
83
+ 'equity',
84
+ 'etf',
85
+ 'index',
86
+ 'venue',
87
+ 'prints',
88
+ ]);
89
+ /** The raw-symbol word of scope `prints` (the gateway's PRINTS scope, the coin beside it). */
90
+ export const WRUN_OPTIONS_FLOW_PRINTS_WORD = 'PRINTS';
91
+ /** Scope `prints`' `max_dte`: whole days to expiry, 0 to 3,650 (0, like an absent knob, keeps every expiry; om
92
+ * `WRUN_OPTION_MAX_DTE_DAYS`). */
93
+ export const WRUN_OPTIONS_FLOW_MAX_DTE_DAYS = 3_650;
94
+ /** The named refusal of a scope `prints` read the gateway does not serve yet (it refused the read's `optionRead` by
95
+ * name): a prints read has no ungrouped ask to fall back to. */
96
+ export const WRUN_OPTIONS_FLOW_PRINTS_UNSERVED_CODE = 'options-flow-prints-unserved';
68
97
  /** The scopes US listed options alone serve (an issue type of the US market, R7c C7-2): unserved off the OPRA plane. */
69
98
  export const WRUN_OPTIONS_FLOW_OPRA_SCOPES = Object.freeze(['equity', 'etf', 'index']);
70
99
  /** `dte` (om `WRUN_OPTIONS_FLOW_DTE`); an absent knob reads `all`. */
@@ -110,9 +139,11 @@ export const WRUN_OPTIONS_FLOW_CONTINUOUS_FIELD = 'flowContinuous';
110
139
  export function wrunOptionsFlowReadsVenueRows(ask) {
111
140
  return ask.scope === 'venue' && ask.coin === undefined;
112
141
  }
113
- /** The raw symbol an ask's read names: `COIN` for a read of one underlying (`COIN:<book>` when it names its ONE book),
114
- * `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
142
+ /** The raw symbol an ask's read names: `PRINTS` for scope `prints`, `COIN` for a read of one underlying (`COIN:<book>`
143
+ * when it names its ONE book), `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
115
144
  export function wrunOptionsFlowScopeSymbol(ask) {
145
+ if (ask.scope === 'prints')
146
+ return WRUN_OPTIONS_FLOW_PRINTS_WORD;
116
147
  if (ask.scope === 'ticker' || ask.coin !== undefined)
117
148
  return ask.book !== undefined ? `COIN:${ask.book}` : 'COIN';
118
149
  if (ask.scope === 'venue')