@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.
Files changed (170) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +6 -1
  3. package/dist/constants/feature-flags.constants.js +67 -24
  4. package/dist/constants/opra-compliance.constants.d.ts +3 -2
  5. package/dist/constants/opra-compliance.constants.js +3 -2
  6. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  7. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  8. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  9. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  10. package/dist/constants/venue-presets.constants.d.ts +20 -20
  11. package/dist/constants/venue-presets.constants.js +24 -26
  12. package/dist/host-env.d.ts +29 -5
  13. package/dist/host-env.js +6 -0
  14. package/dist/host-ports.types.d.ts +69 -15
  15. package/dist/index.d.ts +13 -0
  16. package/dist/index.js +13 -0
  17. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  18. package/dist/interfaces/replay.interface.d.ts +8 -0
  19. package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
  20. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +41 -4
  21. package/dist/kscript-data/controls/live-trades-merge.util.js +52 -7
  22. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
  23. package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
  24. package/dist/market-data/billing.interface.d.ts +95 -31
  25. package/dist/market-data/billing.interface.js +36 -5
  26. package/dist/market-data/venue.d.ts +88 -6
  27. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  28. package/dist/market-data/venues/cme.d.ts +126 -0
  29. package/dist/market-data/venues/cme.js +133 -0
  30. package/dist/market-data/venues/index.d.ts +162 -5
  31. package/dist/market-data/venues/index.js +48 -6
  32. package/dist/settings-templates/index.js +7 -3
  33. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  34. package/dist/settings-templates/indicator-fields.js +45 -6
  35. package/dist/settings-templates/tool-rules.d.ts +27 -17
  36. package/dist/settings-templates/tool-rules.js +27 -11
  37. package/dist/settings-templates/tool-tables.generated.js +91 -31
  38. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  39. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  40. package/dist/utility/chart/index-mode-admission.util.js +15 -2
  41. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  42. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  43. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
  44. package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
  45. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  46. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  47. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  48. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  49. package/dist/utility/chart/kscript-venue-policy.util.d.ts +54 -35
  50. package/dist/utility/chart/kscript-venue-policy.util.js +78 -42
  51. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  52. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  53. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  54. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  55. package/dist/utility/chart/rth-session.util.d.ts +3 -2
  56. package/dist/utility/chart/rth-session.util.js +2 -1
  57. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  58. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  59. package/dist/utility/chart/wrun-run-result.util.d.ts +12 -0
  60. package/dist/utility/chart/wrun-run-result.util.js +141 -6
  61. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  62. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  63. package/dist/utility/options/option-venue.util.d.ts +18 -0
  64. package/dist/utility/options/option-venue.util.js +27 -0
  65. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  66. package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
  67. package/dist/utility/wrun/derived-roots.util.js +471 -0
  68. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
  69. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  70. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  71. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  72. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -2
  73. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
  74. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  75. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  76. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  77. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  78. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  79. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
  80. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
  81. package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
  82. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  83. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
  84. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
  85. package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
  86. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  87. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
  88. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +39 -10
  89. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
  90. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
  91. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +15 -3
  92. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
  93. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
  94. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +174 -13
  95. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +685 -27
  96. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  97. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  98. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +53 -12
  99. package/dist/utility/wrun/wrun-chart-market-facts.util.js +101 -53
  100. package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
  101. package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
  102. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  103. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  104. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  105. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  106. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  107. package/dist/utility/wrun/wrun-frames.js +73 -10
  108. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  109. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  110. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +18 -4
  111. package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
  112. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  113. package/dist/utility/wrun/wrun-live-intake.util.d.ts +13 -7
  114. package/dist/utility/wrun/wrun-live-intake.util.js +82 -29
  115. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
  116. package/dist/utility/wrun/wrun-live-tick.util.js +158 -14
  117. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +49 -10
  118. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +65 -5
  119. package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
  120. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  121. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  122. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  123. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  124. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +23 -6
  125. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
  126. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
  127. package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
  128. package/dist/utility/wrun/wrun-option-views.util.d.ts +47 -13
  129. package/dist/utility/wrun/wrun-option-views.util.js +98 -26
  130. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  131. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  132. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +17 -0
  133. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  134. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  135. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +100 -31
  136. package/dist/utility/wrun/wrun-overlay-run.util.js +733 -114
  137. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  138. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  139. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  140. package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
  141. package/dist/utility/wrun/wrun-panel-style.util.d.ts +10 -9
  142. package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
  143. package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
  144. package/dist/utility/wrun/wrun-param-map.util.js +10 -5
  145. package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
  146. package/dist/utility/wrun/wrun-param-values.util.js +4 -0
  147. package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
  148. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  149. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  150. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  151. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  152. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  153. package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
  154. package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
  155. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +45 -1
  156. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  157. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  158. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  159. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  160. package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
  161. package/dist/utility/wrun/wrun-source-rows.util.d.ts +5 -1
  162. package/dist/utility/wrun/wrun-source-rows.util.js +16 -3
  163. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  164. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  165. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  166. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  167. package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
  168. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  169. package/dist/utils/replay/replay-buffer-math.js +227 -20
  170. package/package.json +11 -11
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The order gate of a per-order tape's live prints (BT-ORDER-FLOOR): the ONE rule the wrun intake's tape enqueue and the
3
+ * kScript fan-out of a `trades` source both apply, before their capped queues.
4
+ *
5
+ * Where the per-order switch holds (wrun-tape-per-order.util `wrunTapePerOrder`) a CME Group tape keeps its raw TRADE
6
+ * live channel and its floor judges ORDERS, as the gateway's per-order history read does. Consecutive same-side prints
7
+ * whose millisecond stamps sit within TRADES_ORDER_JOIN_MS of the print before form one order (Big Trades' "Combine
8
+ * fills: One order" rule, the kScript template's `joins`). The order is judged when a print of the other side or a
9
+ * later stamp arrives, or after TRADES_ORDER_HOLD_MS of quiet, so the last order of a quiet stretch is never held. It is
10
+ * judged by its total in the floor's unit (contracts under `minSize`, dollars under `minValue`, each print valued by
11
+ * `tradesTapeCellSize`): at or above the floor EVERY fill is admitted, so the package's combine sees them all; below it
12
+ * the order is dropped whole. A per-fill floor there drew a 147-contract NQZ6 buy of 45 fills as its two 17-lot fills.
13
+ *
14
+ * The gateway keys an order by its exact exchange stamp and side, the gate by the package's combine group: the group
15
+ * holds every such order, so an admitted fill belongs to an order the per-order history at the same floor answers,
16
+ * except when two same-side orders within 1 ms each fall short of the floor and only their sum reaches it (the package
17
+ * draws them as one trade; the reconcile, which only adds prints to a bar, keeps them).
18
+ *
19
+ * Pure but for its hold timer: no store, no chart, worker-safe.
20
+ */
21
+ import { type LiveTradePrint, type TradesTapeFloor } from './live-trades-merge.util.js';
22
+ /** The widest gap between two consecutive fills of one order, ms (the package's "One order" combine). */
23
+ export declare const TRADES_ORDER_JOIN_MS = 1;
24
+ /** How long the forming order waits for another fill before it is judged, ms. */
25
+ export declare const TRADES_ORDER_HOLD_MS = 50;
26
+ /** Where the gate's verdicts go: every fill of an order at or above the floor, or of one below it, in arrival order. */
27
+ export interface TradesOrderGateHooks<T> {
28
+ admit(items: readonly T[]): void;
29
+ drop(items: readonly T[]): void;
30
+ }
31
+ /** The floor a tape floor sets on an order's total, in the unit `tradesTapeCellSize` values a print in; 0 for none. */
32
+ export declare function tradesOrderGateThreshold(floor: TradesTapeFloor): number;
33
+ /** One tape's order gate (above): `push` each live print with the item the caller admits; `flush` judges the forming
34
+ * order now; `dispose` forgets it (a teardown, a new generation). */
35
+ export declare class TradesOrderGate<T> {
36
+ private readonly hooks;
37
+ private items;
38
+ private side;
39
+ private lastTsMs;
40
+ private total;
41
+ private threshold;
42
+ private timer;
43
+ constructor(hooks: TradesOrderGateHooks<T>);
44
+ /** The fills of the forming order, not judged yet. */
45
+ get held(): number;
46
+ /** Take one live print (`print`, read by `readLiveTradePrint`) under the tape's floor. A print the floor cannot value
47
+ * (a dollar floor without a unit, an option print its units cannot price) is dropped alone; with no floor the print
48
+ * is admitted at once, after the forming order. */
49
+ push(item: T, print: Pick<LiveTradePrint, 'tsMs' | 'price' | 'size' | 'side'>, floor: TradesTapeFloor): void;
50
+ /** Judge the forming order now: every fill admitted when its total reaches the floor, else every fill dropped. */
51
+ flush(): void;
52
+ /** Forget the forming order without a verdict. */
53
+ dispose(): void;
54
+ private arm;
55
+ private clearTimer;
56
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The order gate of a per-order tape's live prints (BT-ORDER-FLOOR): the ONE rule the wrun intake's tape enqueue and the
3
+ * kScript fan-out of a `trades` source both apply, before their capped queues.
4
+ *
5
+ * Where the per-order switch holds (wrun-tape-per-order.util `wrunTapePerOrder`) a CME Group tape keeps its raw TRADE
6
+ * live channel and its floor judges ORDERS, as the gateway's per-order history read does. Consecutive same-side prints
7
+ * whose millisecond stamps sit within TRADES_ORDER_JOIN_MS of the print before form one order (Big Trades' "Combine
8
+ * fills: One order" rule, the kScript template's `joins`). The order is judged when a print of the other side or a
9
+ * later stamp arrives, or after TRADES_ORDER_HOLD_MS of quiet, so the last order of a quiet stretch is never held. It is
10
+ * judged by its total in the floor's unit (contracts under `minSize`, dollars under `minValue`, each print valued by
11
+ * `tradesTapeCellSize`): at or above the floor EVERY fill is admitted, so the package's combine sees them all; below it
12
+ * the order is dropped whole. A per-fill floor there drew a 147-contract NQZ6 buy of 45 fills as its two 17-lot fills.
13
+ *
14
+ * The gateway keys an order by its exact exchange stamp and side, the gate by the package's combine group: the group
15
+ * holds every such order, so an admitted fill belongs to an order the per-order history at the same floor answers,
16
+ * except when two same-side orders within 1 ms each fall short of the floor and only their sum reaches it (the package
17
+ * draws them as one trade; the reconcile, which only adds prints to a bar, keeps them).
18
+ *
19
+ * Pure but for its hold timer: no store, no chart, worker-safe.
20
+ */
21
+ import { tradesTapeCellSize, tradesTapeFloorIsDollars, } from './live-trades-merge.util.js';
22
+ /** The widest gap between two consecutive fills of one order, ms (the package's "One order" combine). */
23
+ export const TRADES_ORDER_JOIN_MS = 1;
24
+ /** How long the forming order waits for another fill before it is judged, ms. */
25
+ export const TRADES_ORDER_HOLD_MS = 50;
26
+ /** The floor a tape floor sets on an order's total, in the unit `tradesTapeCellSize` values a print in; 0 for none. */
27
+ export function tradesOrderGateThreshold(floor) {
28
+ const threshold = Number(tradesTapeFloorIsDollars(floor) ? floor.minValue : floor.minSize);
29
+ return Number.isFinite(threshold) && threshold > 0 ? threshold : 0;
30
+ }
31
+ /** One tape's order gate (above): `push` each live print with the item the caller admits; `flush` judges the forming
32
+ * order now; `dispose` forgets it (a teardown, a new generation). */
33
+ export class TradesOrderGate {
34
+ hooks;
35
+ items = [];
36
+ side = 0;
37
+ lastTsMs = Number.NaN;
38
+ total = 0;
39
+ threshold = 0;
40
+ timer;
41
+ constructor(hooks) {
42
+ this.hooks = hooks;
43
+ }
44
+ /** The fills of the forming order, not judged yet. */
45
+ get held() {
46
+ return this.items.length;
47
+ }
48
+ /** Take one live print (`print`, read by `readLiveTradePrint`) under the tape's floor. A print the floor cannot value
49
+ * (a dollar floor without a unit, an option print its units cannot price) is dropped alone; with no floor the print
50
+ * is admitted at once, after the forming order. */
51
+ push(item, print, floor) {
52
+ const value = tradesTapeCellSize(print, { ...floor, perOrder: true });
53
+ if (value === null) {
54
+ this.hooks.drop([item]);
55
+ return;
56
+ }
57
+ const threshold = tradesOrderGateThreshold(floor);
58
+ if (threshold === 0) {
59
+ this.flush();
60
+ this.hooks.admit([item]);
61
+ return;
62
+ }
63
+ const joins = this.items.length > 0 && print.side === this.side && Math.abs(print.tsMs - this.lastTsMs) <= TRADES_ORDER_JOIN_MS;
64
+ if (!joins) {
65
+ this.flush();
66
+ this.side = print.side;
67
+ this.total = 0;
68
+ }
69
+ this.items.push(item);
70
+ this.total += value;
71
+ this.lastTsMs = print.tsMs;
72
+ this.threshold = threshold;
73
+ this.arm();
74
+ }
75
+ /** Judge the forming order now: every fill admitted when its total reaches the floor, else every fill dropped. */
76
+ flush() {
77
+ this.clearTimer();
78
+ if (this.items.length === 0)
79
+ return;
80
+ const items = this.items;
81
+ const admitted = this.total >= this.threshold;
82
+ this.items = [];
83
+ this.total = 0;
84
+ if (admitted)
85
+ this.hooks.admit(items);
86
+ else
87
+ this.hooks.drop(items);
88
+ }
89
+ /** Forget the forming order without a verdict. */
90
+ dispose() {
91
+ this.clearTimer();
92
+ this.items = [];
93
+ this.total = 0;
94
+ }
95
+ arm() {
96
+ this.clearTimer();
97
+ this.timer = setTimeout(() => {
98
+ this.timer = undefined;
99
+ this.flush();
100
+ }, TRADES_ORDER_HOLD_MS);
101
+ }
102
+ clearTimer() {
103
+ if (this.timer !== undefined)
104
+ clearTimeout(this.timer);
105
+ this.timer = undefined;
106
+ }
107
+ }
@@ -6,17 +6,21 @@
6
6
  * place (src/services/market-data.service.ts). Nothing here names a venue. Worker-safe: types, one error class and pure
7
7
  * helpers.
8
8
  *
9
- * Differences from CME are deliberate: one product per venue, no depth, a professional declaration refused (recorded,
10
- * never re-priced), an EXPLICIT agreement acceptance (never inferred from a grant or a subscription), and pay first:
11
- * the declaration and the agreement bind real-time ACCESS, not the payment, so checkout needs neither and the server
12
- * serves real-time only once the account is both paid and qualified (delayed otherwise).
9
+ * OPRA's card is the base shape: one product per venue, no depth, a professional declaration refused (recorded, never
10
+ * re-priced), an EXPLICIT agreement acceptance (never inferred from a grant or a subscription), and pay first: the
11
+ * declaration and the agreement bind real-time ACCESS, not the payment, so checkout needs neither and the server
12
+ * serves real-time only once the account is both paid and qualified (delayed otherwise). A card may ask for CME's
13
+ * policies instead (docs/features/market-data/plane.md, "CME on the plane"): several products in level order, a
14
+ * checkout and an in-place plan change that name the product (`level`), professionals sold, the declaration first,
15
+ * and the data terms recorded as the registration the venue's wall makes; the wire additions below are optional, and a
16
+ * server that sends none of them reads exactly as before.
13
17
  *
14
18
  * The agreement itself is the server's (contracts K1 and K2 of the OPRA compliance round): `GET <basePath>/agreement`
15
19
  * serves the complete populated text with its version and hash, the acceptance names that version and both hashes,
16
20
  * and an acceptance counts only for the version the server presents now, never for a version a build carries.
17
21
  */
18
22
  import type { CancelFeedback } from '../interfaces/cancel-reason.interface.js';
19
- import type { MarketDataBillingInterval, MarketDataClassification, MarketDataVenue } from './venue.js';
23
+ import type { MarketDataBillingInterval, MarketDataClassification, MarketDataProduct, MarketDataVenue } from './venue.js';
20
24
  /**
21
25
  * POST <basePath>/attestation request body (201 for both classifications). The server derives the classification from
22
26
  * `answers` and refuses a body whose `classification` disagrees, so the client sends the one
@@ -52,11 +56,25 @@ export interface MarketDataAttestationRecordDto {
52
56
  export interface GetMarketDataAttestationResponseDto {
53
57
  attestation: MarketDataAttestationRecordDto | null;
54
58
  }
55
- /** POST <basePath>/checkout request body. */
59
+ /** POST <basePath>/checkout request body of a one-product venue (OPRA): the interval of its one plan. */
56
60
  export interface MarketDataCheckoutDto {
57
61
  interval: MarketDataBillingInterval;
58
62
  locale?: string;
59
63
  }
64
+ /**
65
+ * POST <basePath>/checkout request body of a venue that sells several products (CME, contract KB2): the product
66
+ * picked, by its key (`level`), and the Stripe page's language. The service adds the desktop app's `client` marker on
67
+ * the wire (the checkout then returns to the desktop return page).
68
+ */
69
+ export interface MarketDataProductCheckoutDto {
70
+ level: string;
71
+ /** The Stripe page's language; the service sends the app's when absent. */
72
+ locale?: string;
73
+ }
74
+ /** POST <basePath>/subscription/change-plan request body (contract KB2): the product the subscription moves to. */
75
+ export interface MarketDataChangePlanDto {
76
+ level: string;
77
+ }
60
78
  /**
61
79
  * POST <basePath>/checkout -> 200: a Stripe redirect, or a refusal. 'professional_unavailable' is terminal (the UI
62
80
  * shows "not available"). 'review_held' and 'review_withdrawn': a review of the account's answers only an operator
@@ -97,6 +115,12 @@ export interface MarketDataReviewConfirmDto {
97
115
  * not completed the subscriber questions and the agreement.
98
116
  */
99
117
  export type MarketDataSubscriptionHold = 'unqualified';
118
+ /** A downgrade the subscription carries to its period end (contract KB2): the product it moves to, and when. */
119
+ export interface MarketDataPendingDowngrade {
120
+ level: string;
121
+ /** ISO timestamp the downgrade takes effect (the current period end). */
122
+ at: string;
123
+ }
100
124
  /** Subscription as served by GET <basePath>/subscription. */
101
125
  export interface MarketDataSubscriptionDto {
102
126
  interval: MarketDataBillingInterval;
@@ -111,6 +135,12 @@ export interface MarketDataSubscriptionDto {
111
135
  * subscriber's own cancel or none: completing the status never reverses that cancel.
112
136
  */
113
137
  hold: MarketDataSubscriptionHold | null;
138
+ /** The product held now (its key; still the higher one while a downgrade is pending). A multi-product venue only. */
139
+ level?: string;
140
+ /** A downgrade scheduled for the period end, or null. A multi-product venue only. */
141
+ pendingDowngrade?: MarketDataPendingDowngrade | null;
142
+ /** The Stripe payment method the subscription charges, or null. Additive (a multi-product venue's DTO names it). */
143
+ paymentMethodId?: string | null;
114
144
  }
115
145
  export interface GetMarketDataSubscriptionResponseDto {
116
146
  subscription: MarketDataSubscriptionDto | null;
@@ -131,15 +161,37 @@ export interface MarketDataAttestationWithdrawal {
131
161
  subscriptionCancelled: boolean;
132
162
  refunded: boolean;
133
163
  }
134
- /** POST <basePath>/attestation -> 201 body; `withdrawal` only for a professional declaration. */
164
+ /**
165
+ * POST <basePath>/attestation -> 201 body; `withdrawal` only for a professional declaration a refusing venue recorded.
166
+ * `offer` (a venue that sells professionals, plan 12.6 A11): the declaration changed a live subscriber from
167
+ * non-professional to professional, so the server cancelled the subscription at once (no refund of the period) and
168
+ * offers the product the new classification may hold, by its key (CME: `depth_pro`).
169
+ */
135
170
  export interface SubmitMarketDataAttestationResponseDto {
136
171
  attestationId: number;
137
172
  withdrawal?: MarketDataAttestationWithdrawal;
173
+ offer?: string;
138
174
  }
139
- /** The submit's answer in the domain: the record id, and what a professional declaration withdrew (else null). */
175
+ /**
176
+ * The submit's answer in the domain: the record id, what a professional declaration withdrew (else null), and the
177
+ * product a classification change offers (present only when the server named one).
178
+ */
140
179
  export interface MarketDataAttestationSubmitResult {
141
180
  attestationId: number;
142
181
  withdrawal: MarketDataAttestationWithdrawal | null;
182
+ offer?: string;
183
+ }
184
+ /**
185
+ * A postal address as a declaration records it inside its answers (`questionnaire.postalAddress.answerId`; CME's
186
+ * `postal_address`): the optional lines left out, never sent empty, and the ISO 3166-1 alpha-2 country.
187
+ */
188
+ export interface MarketDataPostalAddress {
189
+ line1: string;
190
+ line2?: string;
191
+ city: string;
192
+ region?: string;
193
+ postalCode: string;
194
+ country: string;
143
195
  }
144
196
  /**
145
197
  * GET <basePath>/agreement -> 200 (signed in, any tier), contract K1: the subscriber agreement the server presents now.
@@ -205,17 +257,6 @@ export interface AcceptMarketDataDataTermsDto {
205
257
  export interface MarketDataCancelResponseDto {
206
258
  message?: string;
207
259
  }
208
- /**
209
- * POST <basePath>/register (no body) -> 201 body, sent only once the gate confirmed the free registration (delayed
210
- * data); 403 for a suspended account. Idempotent on the server.
211
- */
212
- export interface MarketDataRegisterResponseDto {
213
- registered: boolean;
214
- }
215
- /** The register's answer in the domain: it resolves only on the confirmed registration (anything else throws). */
216
- export interface MarketDataRegistration {
217
- registered: true;
218
- }
219
260
  export type MarketDataAttestation = MarketDataAttestationRecordDto;
220
261
  export type MarketDataSubscription = MarketDataSubscriptionDto;
221
262
  /** The review of the account's answers, as served (`MarketDataReviewDto`). */
@@ -239,6 +280,16 @@ export type MarketDataAcceptedAgreement = MarketDataAcceptedAgreementDto;
239
280
  export type MarketDataQualificationAnswers = Partial<Record<string, boolean>>;
240
281
  /** Every question of the venue's questionnaire answered with its qualifying answer. */
241
282
  export declare function isMarketDataNonProfessional(venue: MarketDataVenue, answers: MarketDataQualificationAnswers): boolean;
283
+ /** Whether a record's form version reads as the venue's current form (`acceptedFormVersions`, else the one version). */
284
+ export declare function isMarketDataFormVersionAccepted(venue: MarketDataVenue, formVersion: string): boolean;
285
+ /** The venue's products, in level order (a product without a level keeps its place in the card's list). */
286
+ export declare function marketDataProductsByLevel(venue: MarketDataVenue): readonly MarketDataProduct[];
287
+ /** The products a classification may hold, in level order (the plan picker's offer). */
288
+ export declare function marketDataProductsFor(venue: MarketDataVenue, classification: MarketDataClassification): readonly MarketDataProduct[];
289
+ /** The venue's product with this key (`level` on the wire), or null. */
290
+ export declare function marketDataProductByKey(venue: MarketDataVenue, key: string | null | undefined): MarketDataProduct | null;
291
+ /** The venue records its agreement as the registration its own wall makes (never a purchase step). */
292
+ export declare function isMarketDataRegistrationAgreement(venue: Pick<MarketDataVenue, 'agreement'>): boolean;
242
293
  /**
243
294
  * A declaration on the venue's current form (a new question set means a new declaration) whose validity has not ended
244
295
  * at `now`, either classification. The client owns expiry: `now` is the caller's clock (the store's last evaluation),
@@ -256,8 +307,10 @@ export declare function isMarketDataAttestationCurrent(venue: MarketDataVenue, a
256
307
  */
257
308
  export declare function isMarketDataProfessionalDeclaration(venue: MarketDataVenue, attestation: MarketDataAttestation | null | undefined, now: number): boolean;
258
309
  /**
259
- * The expiry (ISO, as served) a still-current non-professional declaration must be renewed by, once `now` is inside
260
- * the venue's renewal window before it; null otherwise (no expiry named, further off, or already lapsed).
310
+ * The expiry (ISO, as served) a declaration the venue sells to must be renewed by, once `now` is inside the venue's
311
+ * renewal window before it; null otherwise (no expiry named, further off, or already lapsed). A venue that refuses
312
+ * professionals sells to a non-professional declaration only; one that sells them (CME) to either classification, so
313
+ * a professional subscriber is told before its declaration lapses too.
261
314
  */
262
315
  export declare function marketDataAttestationRenewBy(venue: MarketDataVenue, attestation: MarketDataAttestation | null | undefined, now: number): string | null;
263
316
  /**
@@ -283,12 +336,12 @@ export type MarketDataCheckoutResult = {
283
336
  };
284
337
  /**
285
338
  * Transport-free failure surface for the billing calls. Unlike CME, a bare 403 is NOT an attestation gate (refusals ride
286
- * the 200 checkout body), so it never routes back into the declaration: it is a route the account may not use (the
287
- * register's suspended account included). 'invoice_owed' is the tagged 409 while Stripe still collects an invoice. The
288
- * agreement's typed refusals (K2), read from the body's tag: 'agreement_stale' (409 `<VENUE>_AGREEMENT_STALE`: the text
289
- * changed, read it again), 'attestation_required' (409 `<VENUE>_ATTESTATION_REQUIRED`: declare first) and
290
- * 'email_unverified' (403 `<VENUE>_EMAIL_UNVERIFIED`: verify the email first); the review's 'review_not_open' (409
291
- * `<VENUE>_REVIEW_NOT_OPEN`: no pending review to confirm, read the records again).
339
+ * the 200 checkout body), so it never routes back into the declaration: it is a route the account may not use.
340
+ * 'invoice_owed' is the tagged 409 while Stripe still collects an invoice. The agreement's typed refusals (K2), read
341
+ * from the body's tag: 'agreement_stale' (409 `<VENUE>_AGREEMENT_STALE`: the text changed, read it again),
342
+ * 'attestation_required' (409 `<VENUE>_ATTESTATION_REQUIRED`: declare first) and 'email_unverified' (403
343
+ * `<VENUE>_EMAIL_UNVERIFIED`: verify the email first); the review's 'review_not_open' (409 `<VENUE>_REVIEW_NOT_OPEN`:
344
+ * no pending review to confirm, read the records again).
292
345
  */
293
346
  export type MarketDataBillingErrorKind = 'conflict' | 'invoice_owed' | 'agreement_stale' | 'attestation_required' | 'email_unverified' | 'review_not_open' | 'unauthorized' | 'forbidden' | 'network' | 'aborted' | 'server';
294
347
  export declare class MarketDataBillingError extends Error {
@@ -315,12 +368,26 @@ export interface MarketDataBillingRepository {
315
368
  confirmedAt: string;
316
369
  }>;
317
370
  /** Never resolves 'busy' (that is the store's own answer); a refusal resolves, a failure throws. */
318
- checkout(body: MarketDataCheckoutDto, options: {
371
+ checkout(body: MarketDataCheckoutDto | MarketDataProductCheckoutDto, options: {
319
372
  idempotencyId: string;
320
373
  signal?: AbortSignal;
321
374
  }): Promise<Exclude<MarketDataCheckoutResult, {
322
375
  kind: 'busy';
323
376
  }>>;
377
+ /**
378
+ * POST <basePath>/subscription/change-plan (a venue with `planChanges`): the subscription moved to the product, as
379
+ * the server answers it (an upgrade now, a downgrade pending to the period end); a typed refusal throws. A venue with
380
+ * one plan has no such route, so its repository may leave this out.
381
+ */
382
+ changePlan?(body: MarketDataChangePlanDto, options: {
383
+ idempotencyId: string;
384
+ signal?: AbortSignal;
385
+ }): Promise<MarketDataSubscription | null>;
386
+ /** POST <basePath>/subscription/restore (a venue with `planChanges`): a pending downgrade or period-end cancel cleared. */
387
+ restorePlan?(options: {
388
+ idempotencyId: string;
389
+ signal?: AbortSignal;
390
+ }): Promise<MarketDataSubscription | null>;
324
391
  /** Cancels at period end (one classification is sold, so there is no immediate switch-cancel), with the reason. */
325
392
  cancelSubscription(signal?: AbortSignal, feedback?: CancelFeedback): Promise<{
326
393
  message: string | null;
@@ -335,7 +402,4 @@ export interface MarketDataBillingRepository {
335
402
  getAcceptedAgreement(signal?: AbortSignal): Promise<MarketDataAcceptedAgreement | null>;
336
403
  /** POST <basePath>/data-terms (K2): the assent; a typed refusal throws its kind. */
337
404
  acceptDataTerms(body: AcceptMarketDataDataTermsDto, signal?: AbortSignal): Promise<MarketDataAgreement>;
338
- /** The free registration: resolves only on the confirmed 201 `{ registered: true }`; a failure throws (a 403 is
339
- * 'forbidden'). */
340
- register(signal?: AbortSignal): Promise<MarketDataRegistration>;
341
405
  }
@@ -5,6 +5,32 @@ const DAY_MS = 86_400_000;
5
5
  export function isMarketDataNonProfessional(venue, answers) {
6
6
  return venue.questionnaire.questions.every((question) => answers[question.id] === question.qualifying);
7
7
  }
8
+ /** Whether a record's form version reads as the venue's current form (`acceptedFormVersions`, else the one version). */
9
+ export function isMarketDataFormVersionAccepted(venue, formVersion) {
10
+ const accepted = venue.questionnaire.acceptedFormVersions ?? [venue.questionnaire.formVersion];
11
+ return accepted.includes(formVersion);
12
+ }
13
+ /** The venue's products, in level order (a product without a level keeps its place in the card's list). */
14
+ export function marketDataProductsByLevel(venue) {
15
+ return venue.products
16
+ .map((product, index) => ({ product, index }))
17
+ .sort((a, b) => (a.product.level ?? a.index) - (b.product.level ?? b.index) || a.index - b.index)
18
+ .map(({ product }) => product);
19
+ }
20
+ /** The products a classification may hold, in level order (the plan picker's offer). */
21
+ export function marketDataProductsFor(venue, classification) {
22
+ return marketDataProductsByLevel(venue).filter((product) => product.classifications.includes(classification));
23
+ }
24
+ /** The venue's product with this key (`level` on the wire), or null. */
25
+ export function marketDataProductByKey(venue, key) {
26
+ if (!key)
27
+ return null;
28
+ return venue.products.find((product) => product.key === key) ?? null;
29
+ }
30
+ /** The venue records its agreement as the registration its own wall makes (never a purchase step). */
31
+ export function isMarketDataRegistrationAgreement(venue) {
32
+ return venue.agreement.recordedAs === 'registration';
33
+ }
8
34
  /**
9
35
  * A declaration on the venue's current form (a new question set means a new declaration) whose validity has not ended
10
36
  * at `now`, either classification. The client owns expiry: `now` is the caller's clock (the store's last evaluation),
@@ -13,7 +39,7 @@ export function isMarketDataNonProfessional(venue, answers) {
13
39
  * no end can never be shown to be inside its year.
14
40
  */
15
41
  export function isMarketDataAttestationLive(venue, attestation, now) {
16
- if (!attestation || attestation.formVersion !== venue.questionnaire.formVersion)
42
+ if (!attestation || !isMarketDataFormVersionAccepted(venue, attestation.formVersion))
17
43
  return false;
18
44
  if (attestation.expiresAt === undefined)
19
45
  return false;
@@ -33,15 +59,20 @@ export function isMarketDataProfessionalDeclaration(venue, attestation, now) {
33
59
  if (attestation?.classification !== 'professional')
34
60
  return false;
35
61
  if (attestation.expiresAt === undefined)
36
- return attestation.formVersion === venue.questionnaire.formVersion;
62
+ return isMarketDataFormVersionAccepted(venue, attestation.formVersion);
37
63
  return isMarketDataAttestationLive(venue, attestation, now);
38
64
  }
39
65
  /**
40
- * The expiry (ISO, as served) a still-current non-professional declaration must be renewed by, once `now` is inside
41
- * the venue's renewal window before it; null otherwise (no expiry named, further off, or already lapsed).
66
+ * The expiry (ISO, as served) a declaration the venue sells to must be renewed by, once `now` is inside the venue's
67
+ * renewal window before it; null otherwise (no expiry named, further off, or already lapsed). A venue that refuses
68
+ * professionals sells to a non-professional declaration only; one that sells them (CME) to either classification, so
69
+ * a professional subscriber is told before its declaration lapses too.
42
70
  */
43
71
  export function marketDataAttestationRenewBy(venue, attestation, now) {
44
- if (!isMarketDataAttestationCurrent(venue, attestation, now) || attestation?.expiresAt === undefined)
72
+ const sold = venue.professionalPolicy === 'sell'
73
+ ? isMarketDataAttestationLive(venue, attestation, now)
74
+ : isMarketDataAttestationCurrent(venue, attestation, now);
75
+ if (!sold || attestation?.expiresAt === undefined)
45
76
  return null;
46
77
  return Date.parse(attestation.expiresAt) - now <= venue.questionnaire.renewalWindowDays * DAY_MS
47
78
  ? attestation.expiresAt
@@ -15,6 +15,10 @@
15
15
  * What stays per-venue CODE, never a field here: the questionnaire's wording (a content module keyed by venue,
16
16
  * src/components/dialogs/market-data/questionnaires/), the agreement text and the legal disclosure strings (OPRA's
17
17
  * delay notice lives once, in src/constants/opra-compliance.constants.ts). Worker-safe: types and data only.
18
+ *
19
+ * Every field a second policy needed (CME: several products, professionals sold, attest first, plan changes, the data
20
+ * terms as a registration, the two-way declaration, the addendum and the postal address) is optional, and absent means
21
+ * the behaviour the OPRA card always had: a card that names none of them is served exactly as before.
18
22
  */
19
23
  import type { FeatureFlagKey } from '../constants/feature-flags.constants.js';
20
24
  /** The two declarations a subscriber can make; each product names which of them may hold it. */
@@ -27,13 +31,23 @@ export type MarketDataIdentityField = 'legalName' | 'employer' | 'occupation' |
27
31
  export interface MarketDataProduct {
28
32
  /** The catalog name: the Stripe line item a checkout sells and a payment return names (`opra_rt_1m`). */
29
33
  readonly name: string;
34
+ /**
35
+ * The product's wire key on a venue that sells several (CME: `l1`, `depth`, `depth_pro`): what a checkout and a plan
36
+ * change name and what a subscription answers it holds (`level` on the wire). Absent on a one-product venue (OPRA),
37
+ * whose checkout names no product.
38
+ */
39
+ readonly key?: string;
30
40
  /** The gate plan the product grants (`p1`). */
31
41
  readonly plan: string;
42
+ /** Orders the venue's products: a change to a higher level is an upgrade, to a lower one a downgrade. */
43
+ readonly level?: number;
32
44
  /** The declarations that may hold it. */
33
45
  readonly classifications: readonly MarketDataClassification[];
34
46
  readonly interval: MarketDataBillingInterval;
35
47
  /** The catalog price, display only: once a subscription exists, the server's price is authoritative. */
36
48
  readonly priceUsd: number;
49
+ /** The product's own plan card on a venue that sells several (absent: the venue's `planCard`). */
50
+ readonly planCard?: MarketDataPlanCard;
37
51
  }
38
52
  /** One qualification question: a stable machine id (the record's key, never translated text), its qualifying answer. */
39
53
  export interface MarketDataQuestion {
@@ -60,6 +74,33 @@ export interface MarketDataQuestionnaire {
60
74
  readonly validityDays: number;
61
75
  /** How long before the expiry the management page asks for the renewal. */
62
76
  readonly renewalWindowDays: number;
77
+ /**
78
+ * The form versions a record may carry and still read as this form (absent: `formVersion` only). CME accepts its
79
+ * live records: `v1`, and '' for a release that stored no version.
80
+ */
81
+ readonly acceptedFormVersions?: readonly string[];
82
+ /**
83
+ * How the form asks the questions (absent: 'rows'). 'rows': each question, or group, with its own Yes/No (OPRA).
84
+ * 'two-way': one explicit choice between non-professional and professional, recorded as every question answered
85
+ * with its qualifying answer or every one against it; the conditions are reference text (CME's live form).
86
+ */
87
+ readonly presentation?: 'rows' | 'two-way';
88
+ /**
89
+ * A subscriber addendum the declaration accepts, for either classification: the answer id it is recorded under
90
+ * (always true: the form cannot submit without it) and its version (the server records the version).
91
+ */
92
+ readonly addendum?: {
93
+ readonly id: string;
94
+ readonly version: string;
95
+ };
96
+ /**
97
+ * The address asked as postal fields (street, optional second line, city, optional region, postal code) and recorded
98
+ * under `answerId` inside the answers, beside the one-line `address` and the ISO `country` the identity carries
99
+ * (absent: the one-line address only, OPRA).
100
+ */
101
+ readonly postalAddress?: {
102
+ readonly answerId: string;
103
+ };
63
104
  }
64
105
  /** The venue's subscriber agreement: an explicit, versioned acceptance, never inferred from a grant or a payment. */
65
106
  export interface MarketDataAgreementPolicy {
@@ -69,6 +110,13 @@ export interface MarketDataAgreementPolicy {
69
110
  readonly url: string;
70
111
  /** Whether delayed display needs the acceptance too (false: the agreement binds real time only). */
71
112
  readonly delayedRequiresAcceptance: boolean;
113
+ /**
114
+ * How an acceptance is recorded (absent: 'assent'). 'assent': the agreement step's explicit, hashed assent (K2), a
115
+ * purchase step (OPRA). 'registration': the venue's data terms, served by `GET <basePath>/agreement` and recorded as
116
+ * the account's registration (`POST <basePath>/data-terms` naming the version); the venue's own delayed-data wall
117
+ * accepts them, so they are never a purchase step (CME: the data-terms wall, `delayedRequiresAcceptance`).
118
+ */
119
+ readonly recordedAs?: 'assent' | 'registration';
72
120
  }
73
121
  /** The product terms the plan card shows as written (never translated, like the CME bundle names). */
74
122
  export interface MarketDataPlanCard {
@@ -76,6 +124,10 @@ export interface MarketDataPlanCard {
76
124
  readonly level: string;
77
125
  readonly market: string;
78
126
  readonly region: string;
127
+ /** Every market a bundle covers, one chip each (absent: the one `market`). */
128
+ readonly markets?: readonly string[];
129
+ /** The copy path of the card's one-line description under the venue's namespace (absent: the venue's plan line). */
130
+ readonly descPath?: string;
79
131
  }
80
132
  /**
81
133
  * The surfaces that carry a venue's delay disclosure wherever its delayed data shows (docs/features/search/
@@ -90,17 +142,44 @@ export interface MarketDataVenue {
90
142
  readonly productGroups: readonly string[];
91
143
  /** The venue's API base path (`/opra`; a new venue mounts at `/market-data/<venue>`). */
92
144
  readonly basePath: string;
93
- /** What the venue sells; the purchase flow sells the first (one plan). */
145
+ /**
146
+ * What the venue sells. One product: the purchase flow sells it (OPRA). Several: the plan picker offers the ones the
147
+ * account's classification may hold, in level order, and a checkout names the one picked (`key`).
148
+ */
94
149
  readonly products: readonly MarketDataProduct[];
95
150
  readonly planCard: MarketDataPlanCard;
96
151
  /** The prefix of every Stripe line item of the venue: a return carrying it is the venue's, valid or malformed. */
97
152
  readonly paymentItemPrefix: string;
98
- /** 'refuse': a professional declaration is recorded and ends the purchase in "not available", never a re-price. */
153
+ /**
154
+ * 'refuse': a professional declaration is recorded and ends the purchase in "not available", never a re-price.
155
+ * 'sell': a professional buys the products its classification may hold, at their price (CME: depth_pro).
156
+ */
99
157
  readonly professionalPolicy: 'refuse' | 'sell';
100
- /** 'refuse': no role is consulted, an internal account buys like any other and the server's refusal stands. */
101
- readonly internalRolePolicy: 'refuse' | 'dev';
102
- /** The checkout needs neither the declaration nor the agreement: they bind real-time access, not the payment. */
158
+ /**
159
+ * No role is consulted either way, an internal account buys like any other. 'refuse': the server's refusal stands.
160
+ * 'report': the server records an internal account's grant as staff (`dev: true`) and the gate reports it (CME).
161
+ */
162
+ readonly internalRolePolicy: 'refuse' | 'report';
163
+ /**
164
+ * true: the checkout needs neither the declaration nor the agreement, they bind real-time access, not the payment
165
+ * (OPRA). false: the declaration comes first and the price follows the classification it makes (attest first, CME).
166
+ */
103
167
  readonly payFirst: boolean;
168
+ /**
169
+ * A subscriber changes plan in place (absent: one plan, no change): `POST <basePath>/subscription/change-plan` and
170
+ * `POST <basePath>/subscription/restore` (a pending downgrade or a period-end cancel cleared). The two rules the
171
+ * page's change notes state: a downgrade waits for the period end (`downgradeAtPeriodEnd`), an upgrade applies now
172
+ * and is prorated (`prorateUpgrades`).
173
+ */
174
+ readonly planChanges?: {
175
+ readonly downgradeAtPeriodEnd: boolean;
176
+ readonly prorateUpgrades: boolean;
177
+ };
178
+ /**
179
+ * true: a declaration that changes the classification of a subscriber is answered with the product the new
180
+ * classification may hold (`offer`, plan 12.6 A11), which the plan page preselects. Absent: the venue offers none.
181
+ */
182
+ readonly offers?: boolean;
104
183
  readonly questionnaire: MarketDataQuestionnaire;
105
184
  readonly agreement: MarketDataAgreementPolicy;
106
185
  /** The delayed tier's nominal delay (the gate's delayed window). */
@@ -109,7 +188,10 @@ export interface MarketDataVenue {
109
188
  readonly disclosure: {
110
189
  readonly kind: 'translated' | 'verbatim';
111
190
  };
112
- /** The frontend flag the venue's doors ride (a no-op while it is dark); null for none. */
191
+ /**
192
+ * The frontend flag the venue's doors ride (a no-op while it is dark); null for none. A card the registry carries dark
193
+ * (`FLAG_GATED_MARKET_DATA_VENUES`) is listed by the registry only while this flag reads on.
194
+ */
113
195
  readonly flagKey: FeatureFlagKey | null;
114
196
  /** The locale namespace every string of the venue lives under (OPRA keeps `opraRealtimeData`). */
115
197
  readonly i18nNamespace: string;