@orangecharts/wrun-chart-host 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +2 -1
  2. package/dist/constants/feature-flags.constants.d.ts +4 -0
  3. package/dist/constants/feature-flags.constants.js +27 -0
  4. package/dist/constants/marketCapabilities.constants.d.ts +14 -9
  5. package/dist/constants/marketCapabilities.constants.js +36 -13
  6. package/dist/constants/opra-compliance.constants.d.ts +14 -0
  7. package/dist/constants/opra-compliance.constants.js +14 -0
  8. package/dist/constants/option-venues.constants.d.ts +11 -6
  9. package/dist/constants/option-venues.constants.js +5 -2
  10. package/dist/host-env.d.ts +10 -4
  11. package/dist/host-ports.types.d.ts +39 -3
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +1 -0
  14. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  15. package/dist/interfaces/opra-realtime.interface.js +10 -10
  16. package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
  17. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +53 -10
  18. package/dist/kscript-data/controls/live-trades-merge.util.js +81 -16
  19. package/dist/market-data/billing.interface.d.ts +138 -17
  20. package/dist/market-data/billing.interface.js +25 -8
  21. package/dist/market-data/venues/index.d.ts +3 -3
  22. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  23. package/dist/market-data/venues/opra.d.ts +3 -3
  24. package/dist/market-data/venues/opra.js +5 -4
  25. package/dist/replay/replayLadder.js +3 -1
  26. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  27. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  28. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  29. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  30. package/dist/utility/chart/index-mode.util.js +23 -13
  31. package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
  32. package/dist/utility/chart/kscript-venue-policy.util.js +30 -24
  33. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  34. package/dist/utility/chart/marketKind.util.js +17 -7
  35. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  36. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  37. package/dist/utility/chart/om-panel.util.js +6 -6
  38. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  39. package/dist/utility/chart/profile-block-size.util.js +7 -0
  40. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  41. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  42. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
  43. package/dist/utility/chart/wrun-run-result.util.js +4 -1
  44. package/dist/utility/common/transformations.util.d.ts +7 -0
  45. package/dist/utility/common/transformations.util.js +11 -0
  46. package/dist/utility/options/option-venue.util.d.ts +3 -3
  47. package/dist/utility/options/option-venue.util.js +3 -3
  48. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
  49. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
  50. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  51. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  52. package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
  53. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  54. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
  55. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +11 -0
  56. package/dist/utility/wrun/sources/row-lanes/option_prints.js +63 -9
  57. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +8 -0
  58. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +12 -0
  59. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
  60. package/dist/utility/wrun/sources/row-lanes/option_surface.js +5 -2
  61. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +11 -5
  62. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +31 -10
  63. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +33 -1
  64. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +95 -6
  65. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
  66. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +55 -18
  67. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +146 -40
  68. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  69. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  70. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  71. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  72. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  73. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  74. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  75. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
  76. package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
  77. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  78. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  79. package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
  80. package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
  81. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  82. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  83. package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
  84. package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
  85. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
  86. package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
  87. package/dist/utility/wrun/wrun-frames.js +5 -5
  88. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  89. package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
  90. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
  91. package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
  92. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  93. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  94. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  95. package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
  96. package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
  97. package/dist/utility/wrun/wrun-live-tick.util.js +91 -38
  98. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  99. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  100. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +166 -48
  101. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +216 -33
  102. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
  103. package/dist/utility/wrun/wrun-market-size-defaults.util.js +314 -56
  104. package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
  105. package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
  106. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +3 -0
  107. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +3 -0
  108. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +23 -0
  109. package/dist/utility/wrun/wrun-option-strike-flow.util.js +55 -0
  110. package/dist/utility/wrun/wrun-option-views.util.d.ts +51 -7
  111. package/dist/utility/wrun/wrun-option-views.util.js +151 -28
  112. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  113. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  114. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  115. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  116. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  117. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
  118. package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
  119. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  120. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  121. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
  122. package/dist/utility/wrun/wrun-overlay-run.util.js +416 -171
  123. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
  124. package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
  125. package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
  126. package/dist/utility/wrun/wrun-pack.util.js +20 -9
  127. package/dist/utility/wrun/wrun-panel-style.util.d.ts +27 -15
  128. package/dist/utility/wrun/wrun-panel-style.util.js +42 -20
  129. package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
  130. package/dist/utility/wrun/wrun-param-map.util.js +8 -5
  131. package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
  132. package/dist/utility/wrun/wrun-param-values.util.js +2 -0
  133. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  134. package/dist/utility/wrun/wrun-refusal.util.js +10 -1
  135. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +7 -0
  136. package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
  137. package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
  138. package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
  139. package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
  140. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  141. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  142. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  143. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  144. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  145. package/package.json +11 -11
@@ -1,37 +1,59 @@
1
1
  /**
2
- * The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1): how a package's
3
- * `inputSources.<name> = { source: "tape", min_size, history }` becomes the ONE acquisition the
4
- * K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the
5
- * run pass calls it at its head, before any lane fetch, so every refusal here lands by name and
6
- * at zero fetches.
2
+ * The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1, and C-DOLLAR for the dollar floor): how a
3
+ * package's `inputSources.<name> = { source: "tape", min_size | min_value, history }` becomes the ONE acquisition the
4
+ * K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the run pass calls it at
5
+ * its head, before any lane fetch, so every refusal here lands by name and at zero fetches.
7
6
  *
8
- * - `min_size: number | string`. A number literal is the smallest print size served (base units:
9
- * contracts on futures, coins on crypto). A string names a declared numeric `param`, resolved
10
- * from the run's CURRENT param values (`wrunParamValuesFromSettings`, the values `init()`
11
- * receives, so a settings edit moves the threshold with the module). The resolved value must be
12
- * finite and above zero, else the run refuses `wrun_tape_min_size_invalid` naming the input and
13
- * the param. `min_size` rides the wire as the gateway's `minAmount` (the K_TRADES worker), so an
14
- * unfiltered tape is never requested. The table's own floor ($10k quote on USD-quoted markets)
15
- * is a fact a package cannot lower: a `min_size` below it is served at the floor (documented,
16
- * never enforced here).
17
- * - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration
18
- * `^\d+(s|m|h|d)$` seeds that much history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC`
19
- * (30 days); a zero-length spelling ("0m") is the live edge too. Anything else refuses
20
- * `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded window)`, and no
21
- * more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
22
- * one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it),
23
- * so the acquisition's `historySeconds` is the history served, capped there; `history` stays the
24
- * declared spelling the K_TRADES payload carries.
25
- * - Every tape input of a package must be celled (`cellType: "array"`) and resolve to the SAME
26
- * `min_size` and `history`: the browser lane serves one tape acquisition per package (one
27
- * K_TRADES fetch, one live fold), and silently serving a second input at the first input's
28
- * threshold would be a wrong-but-plausible block. Two inputs that differ refuse by name.
29
- * The om daemon shares the vocabulary (`wrun_tape_min_size_invalid`, `wrun_tape_history_invalid`).
7
+ * - A tape declares exactly ONE floor, `min_size` or `min_value`; both or neither refuses `wrun_tape_floor_invalid`
8
+ * naming the input. Each is a number literal or a string naming a declared numeric `param`, resolved from the run's
9
+ * CURRENT param values (`wrunParamValuesFromSettings`, the values `init()` receives, so a settings edit moves the
10
+ * floor with the module). The resolved value must be finite and above zero, else the run refuses by the floor's own
11
+ * code (`wrun_tape_min_size_invalid`, `wrun_tape_min_value_invalid`) naming the input and the param.
12
+ * - `min_size` is the smallest print size served in the venue's RAW STORED unit (coins on Binance, contracts on
13
+ * gate.io futures and OKX swaps, USD contracts on inverse venues, lots on CME). It rides the wire as the gateway's
14
+ * `minAmount` (the K_TRADES worker), and a cell's `size` is the raw amount. It keeps @om-core/big-trades 0.5.0
15
+ * running byte for byte; a raw floor means a different thing on every venue whose unit differs, which is why the
16
+ * dollar floor exists.
17
+ * - `min_value` is the smallest print served by its value in US dollars. It rides the wire as the gateway's
18
+ * `minQuoteAmount` (never beside a `minAmount`), and a cell's `size` is then the print's dollar value (the gateway's
19
+ * `quoteAmount` for a history row, the market's dollar unit times price times size for a live print,
20
+ * live-trades-merge.util `tradesTapeCellSize`), so a package compares and draws in the same unit as its floor. The
21
+ * cell layout is unchanged (`[tsOffsetMs, price, size, side]`).
22
+ * - The table's own floor ($10k quote on USD-quoted markets, a contracts floor per CME Group root) is a fact a package
23
+ * cannot lower: a floor below it is served at the table's floor (documented, never enforced here).
24
+ * - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration `^\d+(s|m|h|d)$` seeds that much
25
+ * history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC` (30 days); a zero-length spelling ("0m") is the live
26
+ * edge too. Anything else refuses `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded
27
+ * window)`, and no more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
28
+ * one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it), so the
29
+ * acquisition's `historySeconds` is the history served, capped there; `history` stays the declared spelling the
30
+ * K_TRADES payload carries.
31
+ * - Every tape input the run ASKS must be celled (`cellType: "array"`) and resolve to the SAME floor (facet and
32
+ * value) and `history`: the browser lane serves one tape acquisition per package (one K_TRADES fetch, one live
33
+ * fold), and silently serving a second input at the first input's floor would be a wrong-but-plausible block. Two
34
+ * asked inputs that differ refuse by name.
35
+ * - A tape the chart's market does not ask (kit 0.95.0: its `needed_by` leaves the market's size unit out, so the run's
36
+ * sheet on the market marks it `undemanded`, wrunSheetWithLaneDemand) is no part of the acquisition: no floor, no
37
+ * history, no refusal and no setting words read it (`isWrunAskedTapeSource`), and every row reads zero cells for it
38
+ * (the row builder's empty block). Big Trades 0.8.0 floors CME in contracts (`min_size` on `tape_contracts`, asked
39
+ * on size unit 3) and every other market in dollars (`min_value` on `tape`, asked on 0, 1 and 2): one acquisition
40
+ * on every market, two floors in the sheet.
41
+ * The om daemon shares the vocabulary (`wrun_tape_floor_invalid`, `wrun_tape_min_size_invalid`,
42
+ * `wrun_tape_min_value_invalid`, `wrun_tape_history_invalid`).
30
43
  */
31
44
  import { TRADES_LARGE_BAR_LIMIT_SEC } from '../../kscript-data/controls/live-trades-merge.util.js';
32
- /** A tape `min_size` that resolves to nothing servable (absent, a param the package does not
33
- * declare, non-finite or not above zero). */
45
+ /** A tape `min_size` that resolves to nothing servable (a param the package does not declare, non-finite or not
46
+ * above zero). */
34
47
  export const WRUN_TAPE_MIN_SIZE_INVALID_CODE = 'wrun_tape_min_size_invalid';
48
+ /** A tape `min_value` that resolves to nothing servable (a param the package does not declare, non-finite or not
49
+ * above zero): C-DOLLAR's refusal, naming the input and the param. */
50
+ export const WRUN_TAPE_MIN_VALUE_INVALID_CODE = 'wrun_tape_min_value_invalid';
51
+ /** A tape input declaring both floors or neither (C-DOLLAR): a tape serves exactly one floor. */
52
+ export const WRUN_TAPE_FLOOR_INVALID_CODE = 'wrun_tape_floor_invalid';
53
+ /** A dollar tape (C-DOLLAR's `min_value`) on a market whose dollar unit no read can ever prove (a quote that is no
54
+ * dollar, a venue or a contract with no point value): none of its prints could be valued, so the run refuses it by
55
+ * name before any fetch. The om daemon's code for the same refusal (packages/sdk wrun-host refusals). */
56
+ export const WRUN_TAPE_VALUE_UNPROVEN_CODE = 'wrun_tape_value_unproven';
35
57
  /** A tape `history` outside the contract ("0" or `^\d+(s|m|h|d)$` at most 30 days). */
36
58
  export const WRUN_TAPE_HISTORY_INVALID_CODE = 'wrun_tape_history_invalid';
37
59
  /** A tape input on a chart interval the lane does not serve (a one-second or any sub-minute chart, a
@@ -52,6 +74,19 @@ export const WRUN_TAPE_HISTORY_MAX_SEC = 2_592_000;
52
74
  export const WRUN_TAPE_HISTORY_SERVED_MAX_SEC = TRADES_LARGE_BAR_LIMIT_SEC;
53
75
  const WRUN_TAPE_HISTORY_PATTERN = /^(\d+)(s|m|h|d)$/;
54
76
  const WRUN_TAPE_HISTORY_UNIT_SEC = { s: 1, m: 60, h: 3600, d: 86_400 };
77
+ const WRUN_TAPE_FLOOR_FACETS = ['min_size', 'min_value'];
78
+ /** Each floor facet's refusal code and the words a refusal uses for what it floors. */
79
+ const WRUN_TAPE_FLOOR_RULES = {
80
+ min_size: { code: WRUN_TAPE_MIN_SIZE_INVALID_CODE, what: 'size' },
81
+ min_value: { code: WRUN_TAPE_MIN_VALUE_INVALID_CODE, what: 'value' },
82
+ };
83
+ /** Whether an input source is a tape the run asks: a `tape` source the run's sheet on the chart's market did not mark
84
+ * `undemanded` (wrunSheetWithLaneDemand, kit 0.95.0's `needed_by` on a secondary tape). THE predicate every reader
85
+ * of the package's tapes takes (the acquisition, its floor settings and words, the plan's floor params, the live
86
+ * refusals): an unasked tape has no lane, and its rows read zero cells. */
87
+ export function isWrunAskedTapeSource(source) {
88
+ return source?.source === 'tape' && source.undemanded !== true;
89
+ }
55
90
  /** The declared `history` as the lane reads it: "0" when absent. */
56
91
  export function wrunTapeHistoryOf(source) {
57
92
  return source.history === undefined ? '0' : String(source.history);
@@ -72,47 +107,95 @@ export function parseWrunTapeHistory(metadata, inputName, history) {
72
107
  }
73
108
  return seconds;
74
109
  }
75
- /** The smallest print size a tape input serves: the literal, or the named param's current value;
76
- * refused by name when it is not finite and above zero (an unfiltered tape is the one request the
77
- * lane never makes). */
78
- export function resolveWrunTapeMinSize(metadata, inputName, source, paramValues) {
79
- const declared = source.min_size;
110
+ /** The floor facet a tape source declares when it declares exactly one, else undefined (both, or neither). */
111
+ export function wrunTapeFloorFacetOf(source) {
112
+ const declared = WRUN_TAPE_FLOOR_FACETS.filter((facet) => source[facet] !== undefined);
113
+ return declared.length === 1 ? declared[0] : undefined;
114
+ }
115
+ /** The name of the param a tape source's floor reads (its one floor facet's string), else undefined (a literal floor,
116
+ * or a source declaring both floors or neither). */
117
+ export function wrunTapeFloorParamOf(source) {
118
+ const facet = wrunTapeFloorFacetOf(source);
119
+ const declared = facet === undefined ? undefined : source[facet];
120
+ return typeof declared === 'string' ? declared : undefined;
121
+ }
122
+ /** The value of one floor facet: the literal, or the named param's current value; refused by the facet's own code
123
+ * when it is not finite and above zero (an unfiltered tape is the one request the lane never makes). */
124
+ function resolveWrunTapeFloorFacet(metadata, inputName, facet, declared, paramValues) {
125
+ const { code, what } = WRUN_TAPE_FLOOR_RULES[facet];
80
126
  const refuse = (detail) => {
81
- throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) ${detail} (${WRUN_TAPE_MIN_SIZE_INVALID_CODE})`);
127
+ throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) ${detail} (${code})`);
82
128
  };
83
129
  if (typeof declared === 'string') {
84
130
  if (!metadata.params.some((param) => param.name === declared)) {
85
- return refuse(`binds min_size to param '${declared}', which the package does not declare: min_size is a positive ` +
131
+ return refuse(`binds ${facet} to param '${declared}', which the package does not declare: ${facet} is a positive ` +
86
132
  'number or the name of a numeric param');
87
133
  }
88
134
  const value = Number(paramValues[declared]);
89
135
  if (!Number.isFinite(value) || value <= 0) {
90
- return refuse(`binds min_size to param '${declared}', which is ${String(paramValues[declared])}: the smallest print ` +
91
- 'size must be finite and above zero');
136
+ return refuse(`binds ${facet} to param '${declared}', which is ${String(paramValues[declared])}: the smallest print ` +
137
+ `${what} must be finite and above zero`);
92
138
  }
93
139
  return value;
94
140
  }
95
141
  if (declared === undefined) {
96
- return refuse('declares no min_size: the smallest print size to serve is required (a positive number or the name of a ' +
142
+ return refuse(`declares no ${facet}: the smallest print ${what} to serve is required (a positive number or the name of a ` +
97
143
  'numeric param)');
98
144
  }
99
145
  const value = Number(declared);
100
146
  if (typeof declared !== 'number' || !Number.isFinite(value) || value <= 0) {
101
- return refuse(`declares min_size ${JSON.stringify(declared)}: the smallest print size must be finite and above zero`);
147
+ return refuse(`declares ${facet} ${JSON.stringify(declared)}: the smallest print ${what} must be finite and above zero`);
102
148
  }
103
149
  return value;
104
150
  }
151
+ /** The smallest print size a tape input serves (raw stored units): the literal, or the named param's current value;
152
+ * refused by name (`wrun_tape_min_size_invalid`) when it is not finite and above zero. */
153
+ export function resolveWrunTapeMinSize(metadata, inputName, source, paramValues) {
154
+ return resolveWrunTapeFloorFacet(metadata, inputName, 'min_size', source.min_size, paramValues);
155
+ }
156
+ /** The smallest print value a tape input serves (US dollars): the literal, or the named param's current value;
157
+ * refused by name (`wrun_tape_min_value_invalid`, naming the input and the param) when it is not finite and above
158
+ * zero. */
159
+ export function resolveWrunTapeMinValue(metadata, inputName, source, paramValues) {
160
+ return resolveWrunTapeFloorFacet(metadata, inputName, 'min_value', source.min_value, paramValues);
161
+ }
162
+ /** A tape input's one floor, by its facet: refused `wrun_tape_floor_invalid` naming the input when it declares both
163
+ * floors or neither, else by the facet's own code when the value is not servable. */
164
+ export function resolveWrunTapeFloor(metadata, inputName, source, paramValues) {
165
+ const facet = wrunTapeFloorFacetOf(source);
166
+ if (facet === undefined) {
167
+ const both = source.min_size !== undefined && source.min_value !== undefined;
168
+ throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) declares ${both ? 'both min_size and min_value' : 'no floor'} ` +
169
+ `(${WRUN_TAPE_FLOOR_INVALID_CODE}): a tape takes exactly one floor, min_size (the raw stored unit) or ` +
170
+ 'min_value (US dollars)');
171
+ }
172
+ return { facet, value: resolveWrunTapeFloorFacet(metadata, inputName, facet, source[facet], paramValues) };
173
+ }
174
+ /** The floor an acquisition asks at, in its own unit (raw stored units under `min_size`, dollars under `min_value`). */
175
+ export function wrunTapeFloorOf(tape) {
176
+ return (tape.minValue ?? tape.minSize);
177
+ }
178
+ /** The words a refusal states an acquisition's floor in: the raw number under `min_size`, a US dollar amount under
179
+ * `min_value` (`$500,000`). */
180
+ export function wrunTapeFloorWords(tape) {
181
+ if (tape === undefined)
182
+ return '0';
183
+ if (tape.minValue === undefined)
184
+ return String(tape.minSize ?? 0);
185
+ return `$${tape.minValue.toLocaleString('en-US', { maximumFractionDigits: 2 })}`;
186
+ }
105
187
  /**
106
- * Resolve every declared tape input against the run's param values into the package's one tape
107
- * acquisition, refusing by name before any fetch; undefined when the package declares no tape
108
- * input.
188
+ * Resolve every tape input the run asks (`isWrunAskedTapeSource`: the run's sheet on the chart's market, its
189
+ * unasked tapes marked) against the run's param values into the package's one tape acquisition, refusing by name
190
+ * before any fetch; undefined when the package asks no tape input here.
109
191
  */
110
192
  export function resolveWrunTapeAcquisition(metadata, paramValues) {
111
193
  let acquisition;
194
+ let first;
112
195
  const inputs = [...metadata.inputs].sort((a, b) => a.index - b.index);
113
196
  for (const input of inputs) {
114
197
  const source = metadata.inputSources[input.name];
115
- if (!source || source.source !== 'tape')
198
+ if (!isWrunAskedTapeSource(source))
116
199
  continue;
117
200
  const name = input.name;
118
201
  if (input.cellType !== 'array') {
@@ -120,50 +203,92 @@ export function resolveWrunTapeAcquisition(metadata, paramValues) {
120
203
  }
121
204
  const history = wrunTapeHistoryOf(source);
122
205
  const historySeconds = Math.min(parseWrunTapeHistory(metadata, name, history), WRUN_TAPE_HISTORY_SERVED_MAX_SEC);
123
- const minSize = resolveWrunTapeMinSize(metadata, name, source, paramValues);
124
- if (acquisition === undefined) {
125
- acquisition = { minSize, history, historySeconds, inputNames: [name] };
206
+ const floor = resolveWrunTapeFloor(metadata, name, source, paramValues);
207
+ if (acquisition === undefined || first === undefined) {
208
+ first = floor;
209
+ acquisition =
210
+ floor.facet === 'min_size'
211
+ ? { minSize: floor.value, history, historySeconds, inputNames: [name] }
212
+ : { minValue: floor.value, history, historySeconds, inputNames: [name] };
126
213
  continue;
127
214
  }
128
- if (acquisition.minSize !== minSize || acquisition.historySeconds !== historySeconds) {
129
- throw new Error(`WRUN ${metadata.id}: input '${name}' (tape) resolves to min_size ${minSize} and history '${history}', but ` +
130
- `input '${acquisition.inputNames[0]}' resolves to min_size ${acquisition.minSize} and history ` +
215
+ if (first.facet !== floor.facet || first.value !== floor.value || acquisition.historySeconds !== historySeconds) {
216
+ throw new Error(`WRUN ${metadata.id}: input '${name}' (tape) resolves to ${floor.facet} ${floor.value} and history '${history}', ` +
217
+ `but input '${acquisition.inputNames[0]}' resolves to ${first.facet} ${first.value} and history ` +
131
218
  `'${acquisition.history}': the browser lane serves one tape acquisition per package`);
132
219
  }
133
220
  acquisition.inputNames.push(name);
134
221
  }
135
222
  return acquisition;
136
223
  }
137
- /** The words of the setting a tape's floor reads: the label (else the name) of the param its first tape input's
138
- * `min_size` names, or `min_size` itself for a literal floor (a source edit raises it). */
224
+ /** The words of the setting a tape's floor reads: the label (else the name) of the param its first asked tape input's
225
+ * floor (`min_size` or `min_value`) names, or the floor facet itself for a literal floor (a source edit raises it).
226
+ * An unasked tape's floor is no setting the chart's tape reads (Big Trades 0.8.0 on CME names Min size, the contracts
227
+ * floor, never Min value). */
139
228
  export function wrunTapeFloorSettingWords(metadata) {
229
+ let literal;
140
230
  for (const source of Object.values(metadata.inputSources)) {
141
- if (source?.source !== 'tape' || typeof source.min_size !== 'string')
231
+ if (!isWrunAskedTapeSource(source))
232
+ continue;
233
+ const paramName = wrunTapeFloorParamOf(source);
234
+ if (paramName === undefined) {
235
+ literal ??= wrunTapeFloorFacetOf(source);
142
236
  continue;
143
- const param = metadata.params.find((candidate) => candidate.name === source.min_size);
237
+ }
238
+ const param = metadata.params.find((candidate) => candidate.name === paramName);
144
239
  const label = typeof param?.label === 'string' ? param.label.trim() : '';
145
- return label !== '' ? label : source.min_size;
240
+ return label !== '' ? label : paramName;
146
241
  }
147
- return 'min_size';
242
+ return literal ?? 'min_size';
148
243
  }
149
244
  /**
150
245
  * The settings a row build hands the shared host's plan for a param-bound floor
151
- * (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at, under the name
152
- * of every param a tape input's `min_size` names. The host resolves that floor itself from the
153
- * settings it is handed (its planTapeFloors), so the plan's tape ask carries the floor the run
154
- * resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its
155
- * acquisition's floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry
156
- * advance or a reseed plans the ask its full run planned whatever the settings say meanwhile (a
157
- * refused settings run keeps the session). Undefined without a finite floor or a bound param.
246
+ * (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at (`wrunTapeFloorOf`, in its own
247
+ * unit), under the name of every param a tape input's floor (`min_size` or `min_value`) names. The host resolves that
248
+ * floor itself from the settings it is handed (its planTapeFloors; a `min_value` tape is planned as the kit's floor
249
+ * facet over the dollar cells, wrun-source-rows.util `wrunPlannedSheet`), so the plan's tape ask carries the floor the
250
+ * run resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its acquisition's
251
+ * floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry advance or a reseed plans the ask
252
+ * its full run planned whatever the settings say meanwhile (a refused settings run keeps the session). An unasked
253
+ * tape's param is left out: its floor is in another unit, and the plan reads no cells for it. Undefined without a
254
+ * finite floor or a bound param.
158
255
  */
159
- export function wrunTapeFloorSettings(metadata, minSize) {
160
- const floor = Number(minSize);
161
- if (minSize === undefined || minSize === null || !Number.isFinite(floor))
256
+ export function wrunTapeFloorSettings(metadata, floorValue) {
257
+ const floor = Number(floorValue);
258
+ if (floorValue === undefined || floorValue === null || !Number.isFinite(floor))
162
259
  return undefined;
163
260
  let settings;
164
261
  for (const source of Object.values(metadata.inputSources)) {
165
- if (source?.source === 'tape' && typeof source.min_size === 'string')
166
- (settings ??= {})[source.min_size] = floor;
262
+ if (!isWrunAskedTapeSource(source))
263
+ continue;
264
+ const paramName = wrunTapeFloorParamOf(source);
265
+ if (paramName !== undefined)
266
+ (settings ??= {})[paramName] = floor;
167
267
  }
168
268
  return settings;
169
269
  }
270
+ /** The floor a recorded tape acquisition (a K_TRADES payload: the full run's `fetchLane` extras, the live context's
271
+ * `acquisition.tape`) asks at, in its own unit: `minValue` when it floors by dollars, else `minSize`. */
272
+ export function wrunTapeAcquisitionFloor(acquisition) {
273
+ if (acquisition === undefined)
274
+ return undefined;
275
+ return acquisition.minValue !== undefined ? acquisition.minValue : acquisition.minSize;
276
+ }
277
+ /**
278
+ * The K_TRADES payload extras of a tape acquisition (the run pass's `fetchLane('trades', 'tp', ...)`, which the run
279
+ * records as the lane's acquisition: the history fetch, the reconcile's re-ask and the live fold read the SAME
280
+ * payload): the large lane, the declared history and the one floor. A dollar floor also carries `valuePerUnit`, the US
281
+ * dollars one price unit times one size unit of a live print is worth on the chart's market (the run head's
282
+ * `wrunMarketDollarUnit`); without it no live print can be priced and none folds (the history rows carry the gateway's
283
+ * own dollar value). A raw floor carries exactly what it always did, so 0.5.0's payload is unchanged.
284
+ */
285
+ export function wrunTapeLaneExtras(tape, valuePerUnit) {
286
+ if (tape.minValue === undefined)
287
+ return { minSize: tape.minSize, history: tape.history, large: true };
288
+ return {
289
+ minValue: tape.minValue,
290
+ ...(valuePerUnit !== undefined && Number.isFinite(valuePerUnit) && valuePerUnit > 0 ? { valuePerUnit } : {}),
291
+ history: tape.history,
292
+ large: true,
293
+ };
294
+ }
@@ -33,9 +33,11 @@ export interface WrunVolumeProfileLaneExtras {
33
33
  ticksPerBar: number;
34
34
  currency: 'USD' | 'Coin';
35
35
  }
36
- /** The lane payload extras the sheet's volume_profile inputs declare;
37
- * undefined when none declares `ticks_per_bar` or `currency`. Throws, naming
38
- * the inputs, when two inputs declare different lanes, and naming the input
39
- * when its bucket size is a `"@<param>"` reference the paint seam could not
40
- * resolve (no declared param of that name). */
36
+ /** The lane payload extras the sheet's demanded volume_profile inputs declare
37
+ * (an input the run's sheet on the market leaves undemanded asks no lane, as
38
+ * wrunOiLaneExtras reads it); undefined when none declares `ticks_per_bar` or
39
+ * `currency`. Throws, naming the inputs, when two inputs declare different
40
+ * lanes, and naming the input when its bucket size is a `"@<param>"`
41
+ * reference the paint seam could not resolve (no declared param of that
42
+ * name). */
41
43
  export declare function wrunVolumeProfileLaneExtras(metadata: Pick<WrunIndicatorMetadata, 'inputs' | 'inputSources'>): WrunVolumeProfileLaneExtras | undefined;
@@ -30,16 +30,18 @@ export const WRUN_VOLUME_PROFILE_TICKS_PARAM_CODE = 'wrun_volume_profile_ticks_p
30
30
  function describeLane(lane) {
31
31
  return `ticksPerBar ${lane.ticksPerBar} in ${lane.currency === 'USD' ? 'USD' : 'coins'}`;
32
32
  }
33
- /** The lane payload extras the sheet's volume_profile inputs declare;
34
- * undefined when none declares `ticks_per_bar` or `currency`. Throws, naming
35
- * the inputs, when two inputs declare different lanes, and naming the input
36
- * when its bucket size is a `"@<param>"` reference the paint seam could not
37
- * resolve (no declared param of that name). */
33
+ /** The lane payload extras the sheet's demanded volume_profile inputs declare
34
+ * (an input the run's sheet on the market leaves undemanded asks no lane, as
35
+ * wrunOiLaneExtras reads it); undefined when none declares `ticks_per_bar` or
36
+ * `currency`. Throws, naming the inputs, when two inputs declare different
37
+ * lanes, and naming the input when its bucket size is a `"@<param>"`
38
+ * reference the paint seam could not resolve (no declared param of that
39
+ * name). */
38
40
  export function wrunVolumeProfileLaneExtras(metadata) {
39
41
  let declared;
40
42
  for (const input of metadata.inputs) {
41
43
  const source = metadata.inputSources[input.name];
42
- if (source?.source !== 'volume_profile')
44
+ if (source?.source !== 'volume_profile' || source.undemanded === true)
43
45
  continue;
44
46
  if (source.ticks_per_bar === undefined && source.currency === undefined)
45
47
  continue;
@@ -132,7 +132,10 @@ export declare function maxProfileBucketHeight(rows: (number | number[])[][]): n
132
132
  * a wide served bucket outside a non-multiple cell's span — e.g. 2.0-wide
133
133
  * rows into 2.25 cells); with no coarse rows present the user height applies
134
134
  * exactly, and uniform fine-grid windows (crypto, recent-only CME) keep the
135
- * legacy branches byte-identically.
135
+ * legacy branches byte-identically. At one block per row, rows served FINER
136
+ * than the block (an answer the gateway served below the overlay's held base,
137
+ * resolveHeldProfileBlockSize) are regridded onto it first: gap-filled as-is,
138
+ * each finer level became its own cell on another grid.
136
139
  */
137
140
  export declare function finalizeVolumeProfileGrid(rows: any[], barHeight: number | undefined, minimumBarHeight: number): any[];
138
141
  /**
@@ -485,7 +485,10 @@ export function maxProfileBucketHeight(rows) {
485
485
  * a wide served bucket outside a non-multiple cell's span — e.g. 2.0-wide
486
486
  * rows into 2.25 cells); with no coarse rows present the user height applies
487
487
  * exactly, and uniform fine-grid windows (crypto, recent-only CME) keep the
488
- * legacy branches byte-identically.
488
+ * legacy branches byte-identically. At one block per row, rows served FINER
489
+ * than the block (an answer the gateway served below the overlay's held base,
490
+ * resolveHeldProfileBlockSize) are regridded onto it first: gap-filled as-is,
491
+ * each finer level became its own cell on another grid.
489
492
  */
490
493
  export function finalizeVolumeProfileGrid(rows, barHeight, minimumBarHeight) {
491
494
  const { servedCoarse, userCoarse, target } = resolveFinalizedProfileGridBranches(rows, barHeight, minimumBarHeight);
@@ -493,7 +496,7 @@ export function finalizeVolumeProfileGrid(rows, barHeight, minimumBarHeight) {
493
496
  return rebucketVolumeProfile(rows, target, minimumBarHeight);
494
497
  if (userCoarse > 0)
495
498
  return rebucketVolumeProfile(rows, userCoarse, minimumBarHeight);
496
- return fillVolumeProfilePriceGaps(rows, minimumBarHeight);
499
+ return fillVolumeProfilePriceGaps(regridRowsServedFinerThan(rows, minimumBarHeight), minimumBarHeight);
497
500
  }
498
501
  function resolveFinalizedProfileGridBranches(rows, barHeight, minimumBarHeight) {
499
502
  const maxServed = maxProfileBucketHeight(rows);
@@ -387,8 +387,9 @@ export async function createWrunAbiSession(config) {
387
387
  const byteLength = len * BYTES_PER_CELL;
388
388
  if (!Number.isInteger(ptr) || ptr < 0 || ptr + byteLength > memory.buffer.byteLength) {
389
389
  throw new Error(`WRUN wrun_arg_bytes(${index}, ${ptr}): ${byteLength} bytes do not fit the module's ` +
390
- `exported memory of ${memory.buffer.byteLength} bytes; reserve max_cells * ${BYTES_PER_CELL} ` +
391
- `bytes per celled input and pass a pointer inside that buffer`);
390
+ `exported memory of ${memory.buffer.byteLength} bytes; reserve the input's capacity ` +
391
+ `(in_<name>_capacity: max_cells tuples, max_cells + newest for a print class's union) * ` +
392
+ `${BYTES_PER_CELL} bytes per celled input and pass a pointer inside that buffer`);
392
393
  }
393
394
  new Uint8Array(memory.buffer, ptr, byteLength).set(new Uint8Array(block.cells.buffer, block.cells.byteOffset + block.cellOffsets[at] * BYTES_PER_CELL, byteLength));
394
395
  return byteLength;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecharts/wrun-chart-host",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "The wrun chart-host layer shared by the kiyotaka web app and the mobile app: the wrun result reader and painter model, cut from the web app (its reference implementation).",
5
5
  "type": "module",
6
6
  "files": [
@@ -22,23 +22,23 @@
22
22
  "default": "./dist/*.js"
23
23
  }
24
24
  },
25
- "scripts": {
26
- "build": "node scripts/generate-tool-tables.mjs && rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
27
- "consumer-check": "node scripts/consumer-check.mjs",
28
- "typecheck": "tsc -p tsconfig.json --noEmit"
29
- },
30
25
  "peerDependencies": {
31
- "@orangecharts/indicator-kit": "0.91.1",
32
- "@orangecharts/orange-v2-pb-common": "12.72.0",
26
+ "@orangecharts/indicator-kit": "0.97.0",
27
+ "@orangecharts/orange-v2-pb-common": "12.73.0",
33
28
  "dayjs": "1.11.23",
34
29
  "lodash-es": "4.18.1"
35
30
  },
36
31
  "devDependencies": {
37
- "@orangecharts/indicator-kit": "0.91.1",
38
- "@orangecharts/orange-v2-pb-common": "12.72.0",
32
+ "@orangecharts/indicator-kit": "0.97.0",
33
+ "@orangecharts/orange-v2-pb-common": "12.73.0",
39
34
  "@types/lodash-es": "4.17.12",
40
35
  "dayjs": "1.11.23",
41
36
  "lodash-es": "4.18.1",
42
37
  "typescript": "5.9.3"
38
+ },
39
+ "scripts": {
40
+ "build": "node scripts/generate-tool-tables.mjs && rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
41
+ "consumer-check": "node scripts/consumer-check.mjs",
42
+ "typecheck": "tsc -p tsconfig.json --noEmit"
43
43
  }
44
- }
44
+ }