@orangecharts/wrun-chart-host 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/dist/constants/feature-flags.constants.d.ts +1 -0
- package/dist/constants/feature-flags.constants.js +5 -0
- package/dist/constants/option-venues.constants.d.ts +18 -0
- package/dist/constants/option-venues.constants.js +14 -0
- package/dist/constants/venue-presets.constants.d.ts +17 -3
- package/dist/constants/venue-presets.constants.js +17 -3
- package/dist/host-env.d.ts +24 -0
- package/dist/host-env.js +21 -0
- package/dist/host-ports.types.d.ts +12 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
- package/dist/indicators/controls/tpo-session.util.js +138 -14
- package/dist/interfaces/option-instrument.interface.d.ts +6 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +4 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +4 -0
- package/dist/settings-templates/footprint-rows.d.ts +25 -0
- package/dist/settings-templates/footprint-rows.js +127 -0
- package/dist/settings-templates/form-rows.d.ts +56 -0
- package/dist/settings-templates/form-rows.js +19 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/index.d.ts +10 -1
- package/dist/settings-templates/index.js +11 -2
- package/dist/settings-templates/indicator-fields.js +78 -0
- package/dist/settings-templates/tool-rules.d.ts +35 -9
- package/dist/settings-templates/tool-rules.js +42 -8
- package/dist/settings-templates/tool-tables.generated.js +13 -2
- package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
- package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
- package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
- package/dist/utility/chart/footprint-columns.util.js +106 -0
- package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
- package/dist/utility/chart/footprint-display-mode.util.js +62 -0
- package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
- package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
- package/dist/utility/chart/kscript-venue-policy.util.js +4 -2
- package/dist/utility/chart/om-panel.util.d.ts +11 -0
- package/dist/utility/chart/om-panel.util.js +59 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
- package/dist/utility/chart/window-geometry.leaf.js +78 -6
- package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
- package/dist/utility/chart/window-owner.leaf.js +5 -0
- package/dist/utility/options/cme-options-root.util.d.ts +25 -0
- package/dist/utility/options/cme-options-root.util.js +40 -0
- package/dist/utility/options/option-book.util.d.ts +27 -0
- package/dist/utility/options/option-book.util.js +76 -0
- package/dist/utility/options/option-trade-date.util.d.ts +50 -0
- package/dist/utility/options/option-trade-date.util.js +120 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
- package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
- package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
- package/dist/utility/wrun/sources/row-lane-registry.js +9 -5
- package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -1
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +100 -23
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +47 -1
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +71 -2
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +14 -1
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +30 -2
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +45 -5
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +115 -3
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +10 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +57 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +60 -6
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +160 -23
- package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
- package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
- package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +7 -5
- package/dist/utility/wrun/wrun-color-settings.util.js +26 -11
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-draft-overlay.util.js +40 -3
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +4 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
- package/dist/utility/wrun/wrun-live-tick.util.js +39 -6
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +106 -0
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +159 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +44 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +213 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +133 -3
- package/dist/utility/wrun/wrun-option-prints.util.js +318 -8
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +96 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +215 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +342 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +742 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +183 -3
- package/dist/utility/wrun/wrun-option-views.util.js +504 -7
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
- package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +7 -2
- package/dist/utility/wrun/wrun-overlay-run.util.js +120 -18
- package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
- package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +9 -8
- package/dist/utility/wrun/wrun-pack.util.js +21 -15
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +17 -2
- package/dist/utility/wrun/wrun-panel-style.util.js +47 -9
- package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
- package/dist/utility/wrun/wrun-refusal.util.js +7 -1
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +18 -0
- package/package.json +3 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getFootprintDisplayModeBarWidth } from './footprint-display-mode.util.js';
|
|
2
|
+
/**
|
|
3
|
+
* The one-click Sierra look for both footprints: Sierra Chart's Numbers Bars as traders set them up. Cluster cells
|
|
4
|
+
* (bid x ask), each side shaded by its own volume on 4 hard steps, pure green buy steps (0,127,0) to (0,255,0) and
|
|
5
|
+
* pure red sell steps (127,0,0) to (255,0,0), each bar's largest and smallest row boxed by volume, no value-area
|
|
6
|
+
* band, and an outline candle beside the cells.
|
|
7
|
+
*
|
|
8
|
+
* It writes ordinary settings keys and nothing else, so every one stays editable in the dialog, a saved layout
|
|
9
|
+
* keeps it like any edit, and Reset returns to the defaults. The step colours are explicit picks: a theme switch
|
|
10
|
+
* leaves them alone, as it leaves any colour the user picked.
|
|
11
|
+
*
|
|
12
|
+
* The UI calls it Classic Presets (the product never names Sierra Chart); the code name stays. Moved from web
|
|
13
|
+
* (src/utility/chart/footprint-sierra-look.util.ts, now its shim), content unchanged: the bar width rule it reads is
|
|
14
|
+
* this package's copy of web's (./footprint-display-mode.util).
|
|
15
|
+
*/
|
|
16
|
+
const SIERRA_LOOK_BUY_STEP_COLORS = ['#007f00', '#00aa00', '#00d400', '#00ff00'];
|
|
17
|
+
const SIERRA_LOOK_SELL_STEP_COLORS = ['#7f0000', '#aa0000', '#d40000', '#ff0000'];
|
|
18
|
+
/** The model with the Sierra look on top; the display mode change carries what a pick of Cluster carries. */
|
|
19
|
+
export function withFootprintSierraLook(model) {
|
|
20
|
+
const barWidth = typeof model.barWidth === 'number' ? model.barWidth : 0.7;
|
|
21
|
+
return {
|
|
22
|
+
...model,
|
|
23
|
+
displayMode: 'cluster',
|
|
24
|
+
showDelta: false,
|
|
25
|
+
barWidth: getFootprintDisplayModeBarWidth('cluster', barWidth),
|
|
26
|
+
stickToLeft: true,
|
|
27
|
+
clusterCellMetric: 'volume',
|
|
28
|
+
cellShading: 'steps',
|
|
29
|
+
shadingSteps: 4,
|
|
30
|
+
// The even split: steps at 25%, 50% and 75% of the loudest cell.
|
|
31
|
+
shadingThresholds: undefined,
|
|
32
|
+
shadingStepColors: { buy: [...SIERRA_LOOK_BUY_STEP_COLORS], sell: [...SIERRA_LOOK_SELL_STEP_COLORS] },
|
|
33
|
+
highlightExtremes: 'volume',
|
|
34
|
+
showValueAreaBand: false,
|
|
35
|
+
candleMarker: 'outline',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -35,8 +35,10 @@ import { builtinIdentityOf } from './builtin-identity.util.js';
|
|
|
35
35
|
import { isOpraUserScriptsFlagOn } from './opra-user-scripts-gate.util.js';
|
|
36
36
|
// Leaf module (no imports): the row source a record runs on (a Cloud record rides the socket source).
|
|
37
37
|
import { wrunRowSourceKindOf } from '../wrun/wrun-overlay-identity.util.js';
|
|
38
|
-
// Near-leaf (the identity leaf only): the migration on read of a record persisted before lane parity wave 3.
|
|
39
|
-
|
|
38
|
+
// Near-leaf (the identity leaf only): the migration on read of a record persisted before lane parity wave 3. The
|
|
39
|
+
// leaf, never wrun-cloud-record.util: this module rides the boot path (titan-charts' dataFetch guard) and the util
|
|
40
|
+
// does not (tests/utility/wrun/wrun-door.closure.spec.ts).
|
|
41
|
+
import { wrunCloudRecordOf } from '../wrun/wrun-cloud-record.leaf.js';
|
|
40
42
|
// Import-free: the one OPRA read decision every door reads (the wrun lane planners too).
|
|
41
43
|
import { mayReadOpra, payloadReadsOpraPlane } from './opra-read-access.leaf.js';
|
|
42
44
|
// The provenance keys are the pure leaf's (kscript-provenance-keys.util); their importers keep this path.
|
|
@@ -118,6 +118,17 @@ export interface PanelTableCellContext {
|
|
|
118
118
|
* (SC14 SC22 SC35); a cell without an alignment takes its column's. A missing
|
|
119
119
|
* reading (`null`) is an empty cell. */
|
|
120
120
|
export declare function engineTableCell(cell: ParsedPanel['rows'][number][number], column?: PanelTableColumn, ctx?: PanelTableCellContext): unknown;
|
|
121
|
+
/**
|
|
122
|
+
* A wrun table frame without its all-empty columns (C4): a column whose every body cell shows nothing
|
|
123
|
+
* (isEmptyTableCell) leaves the frame whole, its series entry (the header cell, its alignment and number words), its
|
|
124
|
+
* cell in every row and its `column_widths` entry together, so every remaining column keeps its own words. Never a
|
|
125
|
+
* column a colspan or rowspan touches (a span counts columns by place, so a dropped one would move it), never column
|
|
126
|
+
* 0 under `header_column` (the row headers), and never every column (the header of a table with no reading yet
|
|
127
|
+
* stays). A frame with nothing to drop, a frame of another kind and a frame with no rows come back as they are. The
|
|
128
|
+
* wrun child mount runs it ahead of the translation and its formatter, so both read the kept columns by their new
|
|
129
|
+
* index; the om push lane never calls it. `chrome.markets` names rows, so it stays.
|
|
130
|
+
*/
|
|
131
|
+
export declare function withoutEmptyTableColumns(frame: ParsedPanel): ParsedPanel;
|
|
121
132
|
/** Labels for a time-keyed curve or bars panel, as short as the key set
|
|
122
133
|
* allows: clock times inside one day, dates for day-aligned keys, a year
|
|
123
134
|
* only past a year. `offsetMs` is the chart's display-timezone shift
|
|
@@ -485,6 +485,65 @@ export function engineTableCell(cell, column = {}, ctx = {}) {
|
|
|
485
485
|
...(entry.font_weight !== undefined ? { fontWeight: wrunFontWeightCss(entry.font_weight) } : {}),
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
|
+
/** A table cell that shows nothing: a missing reading (`null`), no cell, empty text, or a styled cell with no text,
|
|
489
|
+
* no value, no bar and no spark. A styled cell with only a background (a fill or a gradient) shows its fill, so it
|
|
490
|
+
* is not empty. */
|
|
491
|
+
function isEmptyTableCell(cell) {
|
|
492
|
+
if (cell === null || cell === undefined || cell === '')
|
|
493
|
+
return true;
|
|
494
|
+
if (!isRecord(cell))
|
|
495
|
+
return false;
|
|
496
|
+
const entry = cell;
|
|
497
|
+
return ((entry.text === undefined || entry.text === '') &&
|
|
498
|
+
entry.value === undefined &&
|
|
499
|
+
entry.bar === undefined &&
|
|
500
|
+
(entry.spark === undefined || entry.spark.length === 0) &&
|
|
501
|
+
entry.background_color === undefined &&
|
|
502
|
+
entry.gradient === undefined);
|
|
503
|
+
}
|
|
504
|
+
/** The span a table cell declares past its own column and row (1 when none). */
|
|
505
|
+
function cellSpan(cell, key) {
|
|
506
|
+
const span = isRecord(cell) ? cell[key] : undefined;
|
|
507
|
+
return typeof span === 'number' && span > 1 ? span : 1;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* A wrun table frame without its all-empty columns (C4): a column whose every body cell shows nothing
|
|
511
|
+
* (isEmptyTableCell) leaves the frame whole, its series entry (the header cell, its alignment and number words), its
|
|
512
|
+
* cell in every row and its `column_widths` entry together, so every remaining column keeps its own words. Never a
|
|
513
|
+
* column a colspan or rowspan touches (a span counts columns by place, so a dropped one would move it), never column
|
|
514
|
+
* 0 under `header_column` (the row headers), and never every column (the header of a table with no reading yet
|
|
515
|
+
* stays). A frame with nothing to drop, a frame of another kind and a frame with no rows come back as they are. The
|
|
516
|
+
* wrun child mount runs it ahead of the translation and its formatter, so both read the kept columns by their new
|
|
517
|
+
* index; the om push lane never calls it. `chrome.markets` names rows, so it stays.
|
|
518
|
+
*/
|
|
519
|
+
export function withoutEmptyTableColumns(frame) {
|
|
520
|
+
const { panel, rows } = frame;
|
|
521
|
+
const series = panel.series;
|
|
522
|
+
if (panel.kind !== 'table' || series === undefined || rows.length === 0)
|
|
523
|
+
return frame;
|
|
524
|
+
const kept = new Set();
|
|
525
|
+
if (panel.header_column === true)
|
|
526
|
+
kept.add(0);
|
|
527
|
+
rows.forEach((row) => row.forEach((cell, column) => {
|
|
528
|
+
const colspan = cellSpan(cell, 'colspan');
|
|
529
|
+
const spanned = colspan > 1 || cellSpan(cell, 'rowspan') > 1;
|
|
530
|
+
for (let at = column; at < column + colspan; at += 1)
|
|
531
|
+
if (spanned || !isEmptyTableCell(cell))
|
|
532
|
+
kept.add(at);
|
|
533
|
+
}));
|
|
534
|
+
if (kept.size === 0 || kept.size >= series.length)
|
|
535
|
+
return frame;
|
|
536
|
+
const keep = (entries) => entries.filter((_, column) => kept.has(column));
|
|
537
|
+
return {
|
|
538
|
+
...frame,
|
|
539
|
+
panel: {
|
|
540
|
+
...panel,
|
|
541
|
+
series: keep(series),
|
|
542
|
+
...(panel.column_widths !== undefined ? { column_widths: keep(panel.column_widths) } : {}),
|
|
543
|
+
},
|
|
544
|
+
rows: rows.map((row) => keep(row)),
|
|
545
|
+
};
|
|
546
|
+
}
|
|
488
547
|
const pad2 = (value) => String(value).padStart(2, '0');
|
|
489
548
|
/** Labels for a time-keyed curve or bars panel, as short as the key set
|
|
490
549
|
* allows: clock times inside one day, dates for day-aligned keys, a year
|
|
@@ -46,6 +46,12 @@ export interface WindowGeometryMeta {
|
|
|
46
46
|
settings?: Record<string, unknown>;
|
|
47
47
|
rawData?: unknown;
|
|
48
48
|
data?: unknown;
|
|
49
|
+
/** An owner's own plots (titan nests every output of a kScript container) and the run titan applied last: what
|
|
50
|
+
* its pane draws (ownerPaneDrawsNothing). */
|
|
51
|
+
nestedMeta?: unknown;
|
|
52
|
+
runResult?: unknown;
|
|
53
|
+
/** The window hid this owner's pane (window-owner.leaf WindowHiddenPaneMeta, C5). */
|
|
54
|
+
wrunWindowHidPane?: boolean;
|
|
49
55
|
}
|
|
50
56
|
export interface WindowGeometryChart {
|
|
51
57
|
metadata: ReadonlyArray<WindowGeometryMeta>;
|
|
@@ -58,6 +64,9 @@ export interface WindowGeometryChart {
|
|
|
58
64
|
} | null;
|
|
59
65
|
updateSettings?(id: string, payload: Record<string, unknown>): unknown;
|
|
60
66
|
resizeCanvasOnce?(): void;
|
|
67
|
+
/** titan's pane collapse: `hide` takes the pane out of the stack (its `isPaneHidden`, its height kept for the way
|
|
68
|
+
* back) and leaves the overlay's eye alone, unlike `togglePane`, which hides the plot too. */
|
|
69
|
+
togglePaneWithAnimation?(id: string, hide: boolean): void;
|
|
61
70
|
}
|
|
62
71
|
/** The body rows of a table pane (a mounted meta or an addOverlay config):
|
|
63
72
|
* its one decorator row's grid minus the header; undefined when unreadable. */
|
|
@@ -67,6 +76,16 @@ export declare function tableRowCountOf(pane: {
|
|
|
67
76
|
}): number | undefined;
|
|
68
77
|
/** The owner's mounted window panes, in stack order, classified for the planner. */
|
|
69
78
|
export declare function mountedWindowPanes(metadata: ReadonlyArray<WindowGeometryMeta>, ownerId: string): WindowPane[];
|
|
79
|
+
/**
|
|
80
|
+
* Whether an owner's own pane draws nothing (C5): an offchart owner that holds only its run's empty container (plot
|
|
81
|
+
* `empty`: every wrun run mounts its outputs as the container's nested plots) and whose every nested plot is hidden,
|
|
82
|
+
* or that has none (every output data only, left out on this market, or hidden by its Style row), with no drawing in
|
|
83
|
+
* its last applied run and no message on its legend row (an error or the inert legend show there). The registry homes
|
|
84
|
+
* an owner offchart when its first output's panel is `lower`, even when every output is hidden (the app's
|
|
85
|
+
* wrun-registry-loader `packagePosition`), and that empty pane took a share of a window of tables. False until a run
|
|
86
|
+
* landed on the meta (what the pane draws is not known yet) and for any other meta.
|
|
87
|
+
*/
|
|
88
|
+
export declare function ownerPaneDrawsNothing(meta: Pick<WindowGeometryMeta, 'type' | 'plot' | 'settings' | 'nestedMeta' | 'runResult'>): boolean;
|
|
70
89
|
/** Whether the candle pane is hidden on this engine: the window layout is in force. */
|
|
71
90
|
export declare function isMainPaneHidden(metadata: ReadonlyArray<WindowGeometryMeta>): boolean;
|
|
72
91
|
/**
|
|
@@ -104,7 +123,9 @@ export declare function savedWindowSplit(ownerSettings: Record<string, unknown>
|
|
|
104
123
|
* nothing held, the reader's saved split (savedWindowSplit over the owner's
|
|
105
124
|
* engine copy, patched in step with the row) is the plan while it names
|
|
106
125
|
* exactly the mounted panes; else the planner's. Main itself is never
|
|
107
|
-
* written.
|
|
126
|
+
* written. First the owner's own pane is settled (settleOwnerPane: hidden
|
|
127
|
+
* while it draws nothing beside other panes, C5), so the plan reads the
|
|
128
|
+
* panes that will show. Returns whether anything was written.
|
|
108
129
|
*/
|
|
109
130
|
export declare function reconcileWindowOwnerGeometry(tc: WindowGeometryChart | null | undefined, ownerId: string, canvasHeightPx?: number): boolean;
|
|
110
131
|
/**
|
|
@@ -114,6 +135,7 @@ export declare function reconcileWindowOwnerGeometry(tc: WindowGeometryChart | n
|
|
|
114
135
|
* Writes only once the candle pane is visible again (the host releases main
|
|
115
136
|
* first), so the engine carves the panes out of main the way a fresh mount
|
|
116
137
|
* would. Keyed by the owner id because the flag is already off by then.
|
|
138
|
+
* An owner pane the window hid (C5) comes back first, as a chart shows it.
|
|
117
139
|
* Returns whether anything was written.
|
|
118
140
|
*/
|
|
119
141
|
export declare function restoreNormalOwnerGeometry(tc: WindowGeometryChart | null | undefined, ownerId: string, canvasHeightPx?: number): boolean;
|
|
@@ -35,6 +35,17 @@
|
|
|
35
35
|
* never squeezed by sum-1 weights. A cell without a flagged owner never gets
|
|
36
36
|
* a write (isWindowCell gates the entry).
|
|
37
37
|
*
|
|
38
|
+
* An owner pane that draws nothing (C5, ownerPaneDrawsNothing: an offchart
|
|
39
|
+
* owner whose every output is hidden or data only) beside other window panes
|
|
40
|
+
* takes no share: the reconcile hides it on the engine (titan's pane
|
|
41
|
+
* collapse, which leaves the owner's eye alone), so the plan, which reads the
|
|
42
|
+
* visible panes, leaves it out and a window whose only drawn panes are tables
|
|
43
|
+
* gives them the whole cell. It comes back when it draws again, when it would
|
|
44
|
+
* be the window's only pane (never a blank window) and on the reversal; a
|
|
45
|
+
* pane the reader hid stays theirs. While hidden, the meta carries the
|
|
46
|
+
* window's mark (window-owner.leaf isPaneHiddenByWindow), so the run gates
|
|
47
|
+
* never take it for the reader's collapse: the owner keeps running.
|
|
48
|
+
*
|
|
38
49
|
* The reader's own split outranks the plan. The reconcile runs at the end of
|
|
39
50
|
* EVERY run of the owner (the child mount calls it on each live tick), so a
|
|
40
51
|
* plan that re-asserts itself there undoes a splitter drag within one tick.
|
|
@@ -194,6 +205,63 @@ function windowPaneOf(meta, ownerId) {
|
|
|
194
205
|
export function mountedWindowPanes(metadata, ownerId) {
|
|
195
206
|
return windowPaneMetas(metadata, ownerId).map((meta) => windowPaneOf(meta, ownerId));
|
|
196
207
|
}
|
|
208
|
+
function isObject(value) {
|
|
209
|
+
return value !== null && typeof value === 'object';
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether an owner's own pane draws nothing (C5): an offchart owner that holds only its run's empty container (plot
|
|
213
|
+
* `empty`: every wrun run mounts its outputs as the container's nested plots) and whose every nested plot is hidden,
|
|
214
|
+
* or that has none (every output data only, left out on this market, or hidden by its Style row), with no drawing in
|
|
215
|
+
* its last applied run and no message on its legend row (an error or the inert legend show there). The registry homes
|
|
216
|
+
* an owner offchart when its first output's panel is `lower`, even when every output is hidden (the app's
|
|
217
|
+
* wrun-registry-loader `packagePosition`), and that empty pane took a share of a window of tables. False until a run
|
|
218
|
+
* landed on the meta (what the pane draws is not known yet) and for any other meta.
|
|
219
|
+
*/
|
|
220
|
+
export function ownerPaneDrawsNothing(meta) {
|
|
221
|
+
if (meta.type !== 'offchart' || meta.plot !== 'empty' || !isObject(meta.runResult))
|
|
222
|
+
return false;
|
|
223
|
+
const drawings = meta.runResult.drawings;
|
|
224
|
+
if (Array.isArray(drawings) && drawings.length > 0)
|
|
225
|
+
return false;
|
|
226
|
+
const message = meta.settings?.errorMessage;
|
|
227
|
+
if (isObject(message) && message.show === true)
|
|
228
|
+
return false;
|
|
229
|
+
const plots = meta.nestedMeta;
|
|
230
|
+
return !Array.isArray(plots) || plots.every((plot) => isObject(plot) && plot.isHidden === true);
|
|
231
|
+
}
|
|
232
|
+
/** Show an owner pane the window hid again (its mark, window-owner.leaf; a pane the reader hid carries none and stays
|
|
233
|
+
* hidden), the mark taken off. Returns whether the engine changed. */
|
|
234
|
+
function showOwnerPane(tc, ownerId) {
|
|
235
|
+
const owner = tc.metadata.find((meta) => meta.id === ownerId);
|
|
236
|
+
if (owner?.wrunWindowHidPane !== true)
|
|
237
|
+
return false;
|
|
238
|
+
delete owner.wrunWindowHidPane;
|
|
239
|
+
if (owner.isPaneHidden !== true || typeof tc.togglePaneWithAnimation !== 'function')
|
|
240
|
+
return false;
|
|
241
|
+
tc.togglePaneWithAnimation(ownerId, false);
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The owner's own pane under the window layout (C5): hidden while it draws nothing beside another window pane of the
|
|
246
|
+
* owner, so the plan (the visible panes) leaves it out; shown again once it draws or once it would be the window's
|
|
247
|
+
* only pane. Only the pane collapse is used (the owner's eye, which its children follow, is untouched), the meta
|
|
248
|
+
* carries the window's mark while hidden (so the run gates tell it from the reader's collapse, window-owner.leaf
|
|
249
|
+
* isPaneHiddenByWindow), only a marked pane is shown again, and an engine without the collapse keeps today's pane.
|
|
250
|
+
* Returns whether the engine changed.
|
|
251
|
+
*/
|
|
252
|
+
function settleOwnerPane(tc, ownerId) {
|
|
253
|
+
const owner = tc.metadata.find((meta) => meta.id === ownerId);
|
|
254
|
+
if (!owner || owner.type !== 'offchart' || owner.hostPaneId)
|
|
255
|
+
return false;
|
|
256
|
+
const others = tc.metadata.some((meta) => meta.id !== ownerId && isWindowPaneMeta(meta, ownerId));
|
|
257
|
+
if (!others || !ownerPaneDrawsNothing(owner))
|
|
258
|
+
return showOwnerPane(tc, ownerId);
|
|
259
|
+
if (owner.isPaneHidden === true || typeof tc.togglePaneWithAnimation !== 'function')
|
|
260
|
+
return false;
|
|
261
|
+
owner.wrunWindowHidPane = true;
|
|
262
|
+
tc.togglePaneWithAnimation(ownerId, true);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
197
265
|
/** Whether the candle pane is hidden on this engine: the window layout is in force. */
|
|
198
266
|
export function isMainPaneHidden(metadata) {
|
|
199
267
|
const main = metadata.find((meta) => meta.id === 'main') ?? metadata[0];
|
|
@@ -288,16 +356,19 @@ export function savedWindowSplit(ownerSettings, panes) {
|
|
|
288
356
|
* nothing held, the reader's saved split (savedWindowSplit over the owner's
|
|
289
357
|
* engine copy, patched in step with the row) is the plan while it names
|
|
290
358
|
* exactly the mounted panes; else the planner's. Main itself is never
|
|
291
|
-
* written.
|
|
359
|
+
* written. First the owner's own pane is settled (settleOwnerPane: hidden
|
|
360
|
+
* while it draws nothing beside other panes, C5), so the plan reads the
|
|
361
|
+
* panes that will show. Returns whether anything was written.
|
|
292
362
|
*/
|
|
293
363
|
export function reconcileWindowOwnerGeometry(tc, ownerId, canvasHeightPx) {
|
|
294
364
|
if (!tc || tc.isDestroyed || typeof tc.updateSettings !== 'function')
|
|
295
365
|
return false;
|
|
296
366
|
if (!isMainPaneHidden(tc.metadata)) {
|
|
297
|
-
// The window layout is not in force: no hold outlives it.
|
|
367
|
+
// The window layout is not in force: no hold outlives it, and an owner pane it hid comes back.
|
|
298
368
|
windowHolds.delete(tc);
|
|
299
|
-
return
|
|
369
|
+
return showOwnerPane(tc, ownerId);
|
|
300
370
|
}
|
|
371
|
+
let written = settleOwnerPane(tc, ownerId);
|
|
301
372
|
const metas = windowPaneMetas(tc.metadata, ownerId);
|
|
302
373
|
const height = canvasHeightPx ?? tc.canvasChartController?.canvasElement?.clientHeight;
|
|
303
374
|
let plan = [];
|
|
@@ -306,7 +377,6 @@ export function reconcileWindowOwnerGeometry(tc, ownerId, canvasHeightPx) {
|
|
|
306
377
|
const owner = tc.metadata.find((candidate) => candidate.id === ownerId);
|
|
307
378
|
plan = savedWindowSplit(owner?.settings, panes) ?? planWindowWeights(panes, height);
|
|
308
379
|
}
|
|
309
|
-
let written = false;
|
|
310
380
|
for (const { id, gridHeight } of plan) {
|
|
311
381
|
const meta = tc.metadata.find((candidate) => candidate.id === id);
|
|
312
382
|
if (!meta)
|
|
@@ -340,6 +410,7 @@ export function reconcileWindowOwnerGeometry(tc, ownerId, canvasHeightPx) {
|
|
|
340
410
|
* Writes only once the candle pane is visible again (the host releases main
|
|
341
411
|
* first), so the engine carves the panes out of main the way a fresh mount
|
|
342
412
|
* would. Keyed by the owner id because the flag is already off by then.
|
|
413
|
+
* An owner pane the window hid (C5) comes back first, as a chart shows it.
|
|
343
414
|
* Returns whether anything was written.
|
|
344
415
|
*/
|
|
345
416
|
export function restoreNormalOwnerGeometry(tc, ownerId, canvasHeightPx) {
|
|
@@ -349,11 +420,12 @@ export function restoreNormalOwnerGeometry(tc, ownerId, canvasHeightPx) {
|
|
|
349
420
|
return false;
|
|
350
421
|
// Back to a chart: the reader's window split ends with the window.
|
|
351
422
|
windowHolds.delete(tc);
|
|
423
|
+
const shown = showOwnerPane(tc, ownerId);
|
|
352
424
|
const panes = mountedWindowPanes(tc.metadata, ownerId);
|
|
353
425
|
if (panes.length === 0)
|
|
354
|
-
return
|
|
426
|
+
return shown;
|
|
355
427
|
const height = canvasHeightPx ?? tc.canvasChartController?.canvasElement?.clientHeight;
|
|
356
|
-
let written =
|
|
428
|
+
let written = shown;
|
|
357
429
|
for (const pane of panes) {
|
|
358
430
|
const meta = tc.metadata.find((candidate) => candidate.id === pane.id);
|
|
359
431
|
if (!meta)
|
|
@@ -17,3 +17,16 @@ export type WindowOwnerOverlay = {
|
|
|
17
17
|
} | null | undefined;
|
|
18
18
|
/** A wrun Indicator overlay (registry, draft or hosted lane) that carries the owner flag. */
|
|
19
19
|
export declare function isWrunWindowOwner(overlay: WindowOwnerOverlay): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* An engine meta as the window's pane mark reads it. The window geometry (window-geometry.leaf, C5) hides an owner's
|
|
22
|
+
* own pane that draws nothing beside the owner's other window panes and marks the meta `wrunWindowHidPane`: the
|
|
23
|
+
* window's layout, never the reader's collapse. The mark lives on the engine meta, not in its settings, so no save
|
|
24
|
+
* carries it, and it goes with the meta (a rebuilt engine shows every pane).
|
|
25
|
+
*/
|
|
26
|
+
export interface WindowHiddenPaneMeta {
|
|
27
|
+
isPaneHidden?: boolean;
|
|
28
|
+
wrunWindowHidPane?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Whether a meta's pane is hidden by its window (above) and not by the reader: a gate that holds a collapsed pane's
|
|
31
|
+
* runs lets this owner run, since its runs feed the window's tables (wrun-overlay-recovery.util). */
|
|
32
|
+
export declare function isPaneHiddenByWindow(meta: WindowHiddenPaneMeta | null | undefined): boolean;
|
|
@@ -22,3 +22,8 @@ export function isWrunWindowOwner(overlay) {
|
|
|
22
22
|
const settings = overlay?.settings;
|
|
23
23
|
return !!settings && settings[WRUN_WINDOW_SETTING] === true && isWrunPackageOverlaySettings(settings);
|
|
24
24
|
}
|
|
25
|
+
/** Whether a meta's pane is hidden by its window (above) and not by the reader: a gate that holds a collapsed pane's
|
|
26
|
+
* runs lets this owner run, since its runs feed the window's tables (wrun-overlay-recovery.util). */
|
|
27
|
+
export function isPaneHiddenByWindow(meta) {
|
|
28
|
+
return meta?.isPaneHidden === true && meta.wrunWindowHidPane === true;
|
|
29
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CME futures roots whose charts read their options on another root. Since 2026-06-29 CME lists the financially
|
|
3
|
+
* settled Monday to Friday micro E-mini options (MS*, MN*) on settlement-only reference futures, MESF<q> and MNQF<q>,
|
|
4
|
+
* which never trade and expire with MES<q> and MNQ<q>. An MES or MNQ chart reads that chain (MESZ6 reads MESFZ6's),
|
|
5
|
+
* never the physically settled MES and MNQ options, which end on 2026-12-18 and stay in the Options tab as their own
|
|
6
|
+
* roots. The gateway and streamd group and price each MESF/MNQF option under its effective coin, the root's future
|
|
7
|
+
* with the earliest expiry not before the option's (OPTIONS-PORT brief 5a-EFFECTIVE-COIN): a chain is an expiry window.
|
|
8
|
+
*
|
|
9
|
+
* LOCKSTEP: the inverse of the gateway's priced-on roots (tsdb-gateway internal/cmeoption/cmeoption.go, `rules`
|
|
10
|
+
* `pricedOn`), which price these options on the future of the same month of the chart's root.
|
|
11
|
+
* tests/utility/options/cme-options-root.util.spec.ts pins the pairs: a pair changed there changes this table.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CME_OPTIONS_ROOT_OF: Readonly<Record<string, string>>;
|
|
14
|
+
/** The root a chart of `root`'s futures reads its options on: MESF for MES, the root itself for every other. */
|
|
15
|
+
export declare function cmeOptionsRootOf(root: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The root whose charts read `optionsRoot`'s options: MES for MESF (a reference future, which never trades and so
|
|
18
|
+
* charts nothing), the root itself for every other.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cmeChartRootOf(optionsRoot: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The contract a chart of `contract` reads its options on: its options root's contract of the same month (MESFZ6 for
|
|
23
|
+
* MESZ6), or `contract` itself for every other root and for a code that is no dated contract (a continuous alias).
|
|
24
|
+
*/
|
|
25
|
+
export declare function cmeOptionsContract(contract: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CME futures roots whose charts read their options on another root. Since 2026-06-29 CME lists the financially
|
|
3
|
+
* settled Monday to Friday micro E-mini options (MS*, MN*) on settlement-only reference futures, MESF<q> and MNQF<q>,
|
|
4
|
+
* which never trade and expire with MES<q> and MNQ<q>. An MES or MNQ chart reads that chain (MESZ6 reads MESFZ6's),
|
|
5
|
+
* never the physically settled MES and MNQ options, which end on 2026-12-18 and stay in the Options tab as their own
|
|
6
|
+
* roots. The gateway and streamd group and price each MESF/MNQF option under its effective coin, the root's future
|
|
7
|
+
* with the earliest expiry not before the option's (OPTIONS-PORT brief 5a-EFFECTIVE-COIN): a chain is an expiry window.
|
|
8
|
+
*
|
|
9
|
+
* LOCKSTEP: the inverse of the gateway's priced-on roots (tsdb-gateway internal/cmeoption/cmeoption.go, `rules`
|
|
10
|
+
* `pricedOn`), which price these options on the future of the same month of the chart's root.
|
|
11
|
+
* tests/utility/options/cme-options-root.util.spec.ts pins the pairs: a pair changed there changes this table.
|
|
12
|
+
*/
|
|
13
|
+
export const CME_OPTIONS_ROOT_OF = Object.freeze({ MES: 'MESF', MNQ: 'MNQF' });
|
|
14
|
+
const OPTIONS_ROOT = new Map(Object.entries(CME_OPTIONS_ROOT_OF));
|
|
15
|
+
const CHART_ROOT = new Map([...OPTIONS_ROOT].map(([root, optionsRoot]) => [optionsRoot, root]));
|
|
16
|
+
/** A CME contract code's root and its month code with one or two year digits, read as the gateway's `cmeoption.Root`. */
|
|
17
|
+
const CONTRACT_CODE = /^(.+?)([FGHJKMNQUVXZ]\d{1,2})$/;
|
|
18
|
+
/** The root a chart of `root`'s futures reads its options on: MESF for MES, the root itself for every other. */
|
|
19
|
+
export function cmeOptionsRootOf(root) {
|
|
20
|
+
return OPTIONS_ROOT.get(root) ?? root;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The root whose charts read `optionsRoot`'s options: MES for MESF (a reference future, which never trades and so
|
|
24
|
+
* charts nothing), the root itself for every other.
|
|
25
|
+
*/
|
|
26
|
+
export function cmeChartRootOf(optionsRoot) {
|
|
27
|
+
return CHART_ROOT.get(optionsRoot) ?? optionsRoot;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The contract a chart of `contract` reads its options on: its options root's contract of the same month (MESFZ6 for
|
|
31
|
+
* MESZ6), or `contract` itself for every other root and for a code that is no dated contract (a continuous alias).
|
|
32
|
+
*/
|
|
33
|
+
export function cmeOptionsContract(contract) {
|
|
34
|
+
const code = CONTRACT_CODE.exec(contract);
|
|
35
|
+
if (!code)
|
|
36
|
+
return contract;
|
|
37
|
+
const [, root, monthYear] = code;
|
|
38
|
+
const optionsRoot = cmeOptionsRootOf(root);
|
|
39
|
+
return optionsRoot === root ? contract : `${optionsRoot}${monthYear}`;
|
|
40
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OptionVenue } from '../../constants/option-venues.constants.js';
|
|
2
|
+
/**
|
|
3
|
+
* A symbol's product book and its base coin. Without a venue it reads Deribit's
|
|
4
|
+
* prefix (`BTC` inverse, `BTC_USDC` linear); on a venue it is the parsed root
|
|
5
|
+
* and settlement family, which also separates OKX `BTC-USD` from `BTC-USD_UM`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function optionBook(symbol: string, venueId?: OptionVenue['id']): {
|
|
8
|
+
base: string;
|
|
9
|
+
book: string;
|
|
10
|
+
};
|
|
11
|
+
/** What the book rule reads of a chain row: its symbol, its mark IV, and the options venue it was read from. */
|
|
12
|
+
export interface OptionBookRow {
|
|
13
|
+
symbol: string;
|
|
14
|
+
markIv?: number;
|
|
15
|
+
/** The `OptionVenue` id the row was read from (`OptionInstrumentSnapshot.venue`); absent rows read `venueId`. */
|
|
16
|
+
venue?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The options numbers' C0, the scope before every other number: an aggregate over a coin's chain reads ONE product
|
|
20
|
+
* book per base coin, the dominant one. `BTC-...` (inverse) and `BTC_USDC-...` (linear) share base `BTC` but are two
|
|
21
|
+
* vol surfaces with their own open interest, so a sum or a median over both is neither book's number. The book with
|
|
22
|
+
* the most contracts quoting a mark IV above 0 wins, ties to the lexicographically smaller book name (never input
|
|
23
|
+
* order); book and base come from `optionBook` at the row's own venue (`venueId` for rows without one). Each venue of
|
|
24
|
+
* a merged board keeps its own dominant book. A base with one book keeps every row (single-book coins, CME and OPRA
|
|
25
|
+
* chains, synthetic fixtures). Listings (the chain table, the picker's rows) never read this: they show every book.
|
|
26
|
+
*/
|
|
27
|
+
export declare function filterDominantBooks<T extends OptionBookRow>(rows: Iterable<T>, venueId?: OptionVenue['id']): T[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { parseOptionSymbol } from './option-symbol.util.js';
|
|
2
|
+
/**
|
|
3
|
+
* A symbol's product book and its base coin. Without a venue it reads Deribit's
|
|
4
|
+
* prefix (`BTC` inverse, `BTC_USDC` linear); on a venue it is the parsed root
|
|
5
|
+
* and settlement family, which also separates OKX `BTC-USD` from `BTC-USD_UM`.
|
|
6
|
+
*/
|
|
7
|
+
export function optionBook(symbol, venueId) {
|
|
8
|
+
const parsed = venueId ? parseOptionSymbol(venueId, symbol) : null;
|
|
9
|
+
if (parsed)
|
|
10
|
+
return { base: parsed.root, book: `${parsed.root}:${parsed.family ?? ''}` };
|
|
11
|
+
const book = symbol.split('-', 1)[0];
|
|
12
|
+
return { base: book.split('_', 1)[0], book };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `optionBook` per venue and symbol, read many times over: a chain's symbols repeat on every read, and every bar of a
|
|
16
|
+
* heatmap day reads the whole day (a venue's parser is a regular expression per symbol). Cleared whole at its cap.
|
|
17
|
+
*/
|
|
18
|
+
const booksByVenue = new Map();
|
|
19
|
+
let cachedBooks = 0;
|
|
20
|
+
const BOOK_CACHE_MAX = 50_000;
|
|
21
|
+
function cachedOptionBook(symbol, venueId) {
|
|
22
|
+
if (cachedBooks >= BOOK_CACHE_MAX) {
|
|
23
|
+
booksByVenue.clear();
|
|
24
|
+
cachedBooks = 0;
|
|
25
|
+
}
|
|
26
|
+
let books = booksByVenue.get(venueId ?? '');
|
|
27
|
+
if (!books) {
|
|
28
|
+
books = new Map();
|
|
29
|
+
booksByVenue.set(venueId ?? '', books);
|
|
30
|
+
}
|
|
31
|
+
let entry = books.get(symbol);
|
|
32
|
+
if (!entry) {
|
|
33
|
+
entry = optionBook(symbol, venueId);
|
|
34
|
+
books.set(symbol, entry);
|
|
35
|
+
cachedBooks += 1;
|
|
36
|
+
}
|
|
37
|
+
return entry;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The options numbers' C0, the scope before every other number: an aggregate over a coin's chain reads ONE product
|
|
41
|
+
* book per base coin, the dominant one. `BTC-...` (inverse) and `BTC_USDC-...` (linear) share base `BTC` but are two
|
|
42
|
+
* vol surfaces with their own open interest, so a sum or a median over both is neither book's number. The book with
|
|
43
|
+
* the most contracts quoting a mark IV above 0 wins, ties to the lexicographically smaller book name (never input
|
|
44
|
+
* order); book and base come from `optionBook` at the row's own venue (`venueId` for rows without one). Each venue of
|
|
45
|
+
* a merged board keeps its own dominant book. A base with one book keeps every row (single-book coins, CME and OPRA
|
|
46
|
+
* chains, synthetic fixtures). Listings (the chain table, the picker's rows) never read this: they show every book.
|
|
47
|
+
*/
|
|
48
|
+
export function filterDominantBooks(rows, venueId) {
|
|
49
|
+
const list = [...rows];
|
|
50
|
+
const keys = list.map((row) => {
|
|
51
|
+
const { base, book } = cachedOptionBook(row.symbol, row.venue ?? venueId);
|
|
52
|
+
return { group: `${row.venue ?? ''}|${base}`, book };
|
|
53
|
+
});
|
|
54
|
+
const countsByGroup = new Map();
|
|
55
|
+
list.forEach((row, at) => {
|
|
56
|
+
const { group, book } = keys[at];
|
|
57
|
+
let books = countsByGroup.get(group);
|
|
58
|
+
if (!books) {
|
|
59
|
+
books = new Map();
|
|
60
|
+
countsByGroup.set(group, books);
|
|
61
|
+
}
|
|
62
|
+
books.set(book, (books.get(book) ?? 0) + ((row.markIv ?? 0) > 0 ? 1 : 0));
|
|
63
|
+
});
|
|
64
|
+
const dominantByGroup = new Map();
|
|
65
|
+
for (const [group, books] of countsByGroup) {
|
|
66
|
+
let best = null;
|
|
67
|
+
for (const [book, count] of books) {
|
|
68
|
+
const bestCount = best === null ? -1 : (books.get(best) ?? 0);
|
|
69
|
+
if (best === null || count > bestCount || (count === bestCount && book < best))
|
|
70
|
+
best = book;
|
|
71
|
+
}
|
|
72
|
+
if (best !== null)
|
|
73
|
+
dominantByGroup.set(group, best);
|
|
74
|
+
}
|
|
75
|
+
return list.filter((_, at) => dominantByGroup.get(keys[at].group) === keys[at].book);
|
|
76
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The trade date an option row is dated on, on its venue family's clock: the ONE place the app dates an option print,
|
|
3
|
+
* bucket or expiry into a trade date. The clocks are the data plane's `option_venue_clocks` table, carried on the venue
|
|
4
|
+
* config (option-venues.constants `OptionVenue.tradeDateClock`), so no code here names a venue; a venue with no clock
|
|
5
|
+
* dates by the UTC date. Pure and worker-safe. docs/features/kscript/wrun/wrun-browser-runtime.md, "The venue-family
|
|
6
|
+
* trade-date clock".
|
|
7
|
+
*/
|
|
8
|
+
import { type OptionTradeDateRule } from '../../constants/option-venues.constants.js';
|
|
9
|
+
/** The chain an option row belongs to: the exchange its venue lists it on and, for a root family's rule, the coin its
|
|
10
|
+
* plane files it under (a CME futures contract, `BTCZ6`). */
|
|
11
|
+
export interface OptionTradeDateChain {
|
|
12
|
+
exchange: string;
|
|
13
|
+
coin?: string;
|
|
14
|
+
}
|
|
15
|
+
/** The rule one row dates by: its zone and its dating rule. */
|
|
16
|
+
export interface OptionTradeDateClockRule {
|
|
17
|
+
zone: string;
|
|
18
|
+
rule: OptionTradeDateRule;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The clock a chain's rows date by: a root family's rule when the coin is one of its roots' futures on its exchanges,
|
|
22
|
+
* else the venue's clock, else the UTC date.
|
|
23
|
+
*/
|
|
24
|
+
export declare function optionTradeDateClockOf(chain: OptionTradeDateChain): OptionTradeDateClockRule;
|
|
25
|
+
/** The trade date an instant falls on under one clock rule, in days since the epoch (NaN for an instant it cannot
|
|
26
|
+
* read). */
|
|
27
|
+
export declare function optionTradeDayByClock(clock: OptionTradeDateClockRule, instantMs: number): number;
|
|
28
|
+
/** The trade date an instant falls on for a chain's rows, in days since the epoch (`optionTradeDateClockOf`). */
|
|
29
|
+
export declare function optionTradeDay(chain: OptionTradeDateChain, instantMs: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* The first instant of a trade date under one clock rule (the instant the date starts: 00:00 New York on OPRA, 17:00
|
|
32
|
+
* Chicago the evening before on a CME Group exchange, 16:00 Chicago on the Friday before a CME crypto Monday), or NaN
|
|
33
|
+
* for a date no instant falls on (a Saturday or a Sunday under `weekendsToMonday`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function optionTradeDayStartMsByClock(clock: OptionTradeDateClockRule, day: number): number;
|
|
36
|
+
/** A bar as `history` "today" dates it: its open and its end (one bar span on). */
|
|
37
|
+
export interface OptionTradeDayBar {
|
|
38
|
+
openMs: number;
|
|
39
|
+
endMs: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The first instant of `history` "today" under one clock rule: the trade date of the NEWEST BAR the chart holds (the
|
|
43
|
+
* newest bar a lane plans for), read at the bar's middle as a bucket is (a calendar bar stamped 00:00Z reads its own
|
|
44
|
+
* date). Never a clock's date: on a weekend, a holiday (the table models none, the chart's bars do) or a morning before
|
|
45
|
+
* the session's first print, the chart's newest bar is the last session's, so "today" is that session. It takes a
|
|
46
|
+
* bar, never an instant, so a clock cannot be handed to it. NaN for a bar it cannot date.
|
|
47
|
+
*/
|
|
48
|
+
export declare function optionTodayStartMsByClock(clock: OptionTradeDateClockRule, newestBar: OptionTradeDayBar): number;
|
|
49
|
+
/** Whether an expiry trades on the trade date of an instant (a bucket's) for a chain's rows: the 0DTE class. */
|
|
50
|
+
export declare function optionExpiresOnTradeDay(chain: OptionTradeDateChain, expiryMs: number, instantMs: number): boolean;
|