@orangecharts/wrun-chart-host 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/constants/feature-flags.constants.js +6 -5
- package/dist/host-ports.types.d.ts +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/settings-templates/frvp-fields.js +28 -19
- package/dist/settings-templates/index.d.ts +25 -0
- package/dist/settings-templates/index.js +62 -2
- package/dist/settings-templates/indicator-fields.d.ts +35 -0
- package/dist/settings-templates/indicator-fields.js +261 -114
- package/dist/settings-templates/market-bound.d.ts +214 -0
- package/dist/settings-templates/market-bound.js +369 -0
- package/dist/utility/v2/gate-plane.util.d.ts +7 -0
- package/dist/utility/v2/gate-plane.util.js +6 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.js +32 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +5 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +1 -1
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +3 -1
- package/dist/utility/wrun/wrun-overlay-run.util.js +122 -15
- package/dist/utility/wrun/wrun-replay-lane.util.js +3 -1
- package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.js +17 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -128,6 +128,7 @@ What each published version holds. A host installs a version with the peers of i
|
|
|
128
128
|
|
|
129
129
|
| Version | Peers | What changed |
|
|
130
130
|
| --- | --- | --- |
|
|
131
|
+
| 0.19.0 | `@orangecharts/indicator-kit` 0.121.0, `@orangecharts/orange-v2-pb-common` 12.86.0, `dayjs` 1.11.23, `lodash-es` 4.18.1 | Same peers. Market-bound values in `settings-templates`: a value measured or typed on one market carries the market it belongs to. The heatmap scale leaf: `heatmapMarketKey`, `stampBoundKey`, `parseBoundKey`, `boundSignature`, `heatmapScaleSignature`, `stashBound`, `takeBound`, `BOUND_STASH_CAP` (row fields `settings.boundKey` and `settings.boundByMarket`). The typed threshold contract: each numeric field declares `quantity` (`relative`, `bound` or `amount`) and a kept bound one `keep`; `marketBoundKey(parts)` spells the key (exchange, unit, symbol, interval; a month is `1MO`); `reconcileMarketBound(type, settings, liveKey, options)` is the one decision at every door a row meets a market (its own key: unchanged; another key: the typed values are kept under their market and this market's remembered values or the caller's `defaults` come back; no stamp: trusted and stamped, or judged by `unkeyedAs`); `stampMarketBound` signs a user's edit; `unclassifiedNumericFields` feeds a host's classification guard. A host calls the reconcile at its mount, market switch, settings write and document doors, and the stamp on a user's edit; a script row is never settled. `templatePatch` writes a typed threshold only on the market it was saved on (`TemplateContext.boundKey`, kept in the bag as `boundMarketKey`); the schema version does not move, so a client before 0.19.0 lists that key as dropped and writes the threshold as before. The phone app's Big Trades (`BIG_TRADES`) gets a field table. |
|
|
131
132
|
| 0.18.0 | `@orangecharts/indicator-kit` 0.121.0, `@orangecharts/orange-v2-pb-common` 12.86.0, `dayjs` 1.11.23, `lodash-es` 4.18.1 | Same peers. Four things a host acts on. The index and yield venue's official bars: the index leaf gains `INDEX_OTC_SERVER_BUILT_BARS_FROM_MS` and `barsAreServerBuilt(exchange, intervalMs)`, the root exports `chartBarsAreServerBuilt(market, intervalMs)` (`utility/chart/server-built-bars.util`, a formula leg counts), and the live intake refuses a live fold on such a chart; a host stops folding live prints and gap rows into a bar of one day or wider there and reads the newest bar again from the server. `FeatureFlag` loses `UsEquitiesFull`, `WrunConvergingPrefix`, `DrawingAlertOneClick`, `DrawingsUnderCandles`, `ChartDraftOrder` and `TypedServerFutures` (graduated on web) and gains `FuturesNinjaTraderDepth`. `MARKET_DATA_VENUES` now lists the US stocks venue beside OPRA (it left `FLAG_GATED_MARKET_DATA_VENUES`), so a host that holds stocks behind a switch of its own keeps that switch at its own door. The env gains the optional `isSignedIn()`: the licence and broker flags read as kill switches that default on for a signed-in session, and a host without the port reads every session as a guest. The package commits landed since 0.17.0 ride along (`git log 3ad609a1a4.. -- packages/wrun-chart-host` in the web repo). |
|
|
132
133
|
| 0.17.0 | `@orangecharts/indicator-kit` 0.121.0, `@orangecharts/orange-v2-pb-common` 12.86.0, `dayjs` 1.11.23, `lodash-es` 4.18.1 | Three things a host acts on. The marks section's `text.place` gains `fit` (2: the size inside the mark where the full number fits, else beside it), `fit_short` (3: as `fit`, rounded inside when only the rounded number fits) and `fit_only` (4: as `fit_short`, never beside), and the mount refuses them by name on an engine whose marks pack is below level 3 (`fit`) or 4 (the other two); 0.16.0 refuses a section that names one ("Needs a newer chart"). The data-fetching loader view supplies `mainRowsLoadedFor(chartIndex, metadata)` in place of `loadedMainIdentityOf` (`WrunLoadedMainIdentity` leaves): the host answers whether the mounted main rows are that metadata's market, so a chart whose rows come from another market (a US stock on Trades) proves its candles. The market size defaults count the last trading day on the market's own clock (whole days it stood closed are no part of it), so the first candles after a weekend or a holiday no longer read as a whole day. The peers move with web: the kit from 0.119.0 to 0.121.0 and the protocol enums from 12.84.0 to 12.86.0 (the index and yield venue, `utility/chart/index-otc.leaf`, joins the public modules). The other package commits landed since 0.16.0 ride along (`git log f9aeda13fd.. -- packages/wrun-chart-host` in the web repo). |
|
|
133
134
|
| 0.16.0 | `@orangecharts/indicator-kit` 0.119.0, `@orangecharts/orange-v2-pb-common` 12.84.0, `dayjs` 1.11.23, `lodash-es` 4.18.1 | The peers web's /v3 step 3 moved to: the protocol enums peer from 12.82.0 to 12.84.0 and the kit peer from 0.116.1 (what npm's 0.15.0 declares) to 0.119.0. The package commits landed since 0.15.0 ride along (`git log 3bfefce876.. -- packages/wrun-chart-host` in the web repo). |
|
|
@@ -229,11 +229,12 @@ export const FeatureFlag = {
|
|
|
229
229
|
CmeEngine: 'cme-engine',
|
|
230
230
|
// The index and yield venue (index-otc.leaf: stock indices, the dollar and volatility indices, US Treasury
|
|
231
231
|
// yields) in pickers, search, recents, popular rows and watchlist import: a flag-gated venue
|
|
232
|
-
// (exchange-visibility.util FLAG_GATED_EXCHANGES), read through `isOn`, so unminted
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
232
|
+
// (exchange-visibility.util FLAG_GATED_EXCHANGES), read through `isOn`, so unminted and absent read off. On for
|
|
233
|
+
// every signed-in account since 2026-11-17; a guest reads it from the web build's guest table
|
|
234
|
+
// (guest-default-flags.constants), since a server flip never reaches a guest. The dev/internal override lights it
|
|
235
|
+
// locally (`kiyo.flag-overrides` -> `{"indices-otc": true}`). It is also the venue's release door: the pinned
|
|
236
|
+
// enum names the exchange, and while this reads off the data worker keeps every read of the venue home
|
|
237
|
+
// (workers/series/unreleased-venues).
|
|
237
238
|
IndicesOtc: 'indices-otc',
|
|
238
239
|
// User-authored scripts on OPRA. The OPRA licence covers user-authored scripting over OPRA data, in the
|
|
239
240
|
// browser and on OpenMarket's servers (Kyle 2026-10-27, the signed set); this flag is the one product switch
|
|
@@ -247,9 +247,19 @@ export interface WrunTwinOriginalLookback {
|
|
|
247
247
|
/** The first twin version whose run holds the original's depth, null when every version does. */
|
|
248
248
|
fromTwinVersion: string | null;
|
|
249
249
|
}
|
|
250
|
+
/** A twin whose totals restart each trade date while select `param` holds `value` and one of the `rows` switches is on. */
|
|
251
|
+
export interface WrunTwinTradeDateAnchor {
|
|
252
|
+
param: string;
|
|
253
|
+
value: number;
|
|
254
|
+
rows: readonly string[];
|
|
255
|
+
/** The first twin version that restarts on `time.trade_date`, null when every version does. */
|
|
256
|
+
fromTwinVersion: string | null;
|
|
257
|
+
}
|
|
250
258
|
/** Loader view of the twins roster (web: wrun-twins.util.ts). */
|
|
251
259
|
export interface WrunTwinsRosterModule {
|
|
252
260
|
wrunTwinOriginalLookbackInfo(packageName: string, version: string): WrunTwinOriginalLookback | null;
|
|
261
|
+
/** Optional: a host without it keeps the planner's warm-up start on every run. */
|
|
262
|
+
wrunTwinTradeDateAnchorInfo?(packageName: string, version: string): WrunTwinTradeDateAnchor | null;
|
|
253
263
|
}
|
|
254
264
|
/** Loader view of the pane budget ranking (web: utility/chart/pane-budget-ranking.util.ts). */
|
|
255
265
|
export interface WrunPaneBudgetRankingModule {
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export * from './settings-templates/form-rows.js';
|
|
|
62
62
|
export * from './settings-templates/frvp-fields.js';
|
|
63
63
|
export * from './settings-templates/index.js';
|
|
64
64
|
export * from './settings-templates/indicator-fields.js';
|
|
65
|
+
export * from './settings-templates/market-bound.js';
|
|
65
66
|
export * from './settings-templates/tool-rules.js';
|
|
66
67
|
export * from './settings-templates/tool-tables.generated.js';
|
|
67
68
|
export * from './utility/auth/server-clock.util.js';
|
package/dist/index.js
CHANGED
|
@@ -65,6 +65,7 @@ export * from './settings-templates/form-rows.js';
|
|
|
65
65
|
export * from './settings-templates/frvp-fields.js';
|
|
66
66
|
export * from './settings-templates/index.js';
|
|
67
67
|
export * from './settings-templates/indicator-fields.js';
|
|
68
|
+
export * from './settings-templates/market-bound.js';
|
|
68
69
|
export * from './settings-templates/tool-rules.js';
|
|
69
70
|
export * from './settings-templates/tool-tables.generated.js';
|
|
70
71
|
export * from './utility/auth/server-clock.util.js';
|
|
@@ -34,12 +34,21 @@ const PER_BOX = { owner: 'profile', lanes: ['row', 'mirror'], instance: true };
|
|
|
34
34
|
const CONSTANT = { owner: 'profile', lanes: ['row'] };
|
|
35
35
|
/** Stamped by the control on every mount (engine flags, the block-size status): nothing to save. */
|
|
36
36
|
const STAMPED = { owner: 'profile', lanes: [] };
|
|
37
|
+
// The quantity of each numeric key (indicator-fields' header): what its number measures. The FRVP's threshold is a
|
|
38
|
+
// volume in the profile's unit, classified bound and never reconciled (left carried on purpose); its block size and
|
|
39
|
+
// row height are price units, carried as they are.
|
|
40
|
+
const BOX_STYLE_RELATIVE = { ...BOX_STYLE, quantity: 'relative' };
|
|
41
|
+
const PREFERENCE_RELATIVE = { ...PREFERENCE, quantity: 'relative' };
|
|
42
|
+
const PREFERENCE_BOUND = { ...PREFERENCE, quantity: 'bound' };
|
|
43
|
+
const PER_BOX_RELATIVE = { ...PER_BOX, quantity: 'relative' };
|
|
44
|
+
const PER_BOX_AMOUNT = { ...PER_BOX, quantity: 'amount' };
|
|
45
|
+
const CONSTANT_RELATIVE = { ...CONSTANT, quantity: 'relative' };
|
|
37
46
|
export const FRVP_FIELD_ROWS = [
|
|
38
47
|
// The box's style: the Style tab's boundary line rows.
|
|
39
48
|
['showBoundaryLines', BOX_STYLE],
|
|
40
49
|
['color', BOX_STYLE],
|
|
41
50
|
['lineStyle', BOX_STYLE],
|
|
42
|
-
['lineWidth',
|
|
51
|
+
['lineWidth', BOX_STYLE_RELATIVE],
|
|
43
52
|
// "Show on": the intervals the box shows on, All intervals as [] (TEMPLATES-PLAN decision 3). A template keeps it as
|
|
44
53
|
// every drawing's template does, and so does the default: a new FRVP shows where the last one did (TradingView).
|
|
45
54
|
['visibleIntervalsMs', { owner: 'box', lanes: ['template', 'default'], unset: Object.freeze([]) }],
|
|
@@ -54,8 +63,8 @@ export const FRVP_FIELD_ROWS = [
|
|
|
54
63
|
['hideLegendValues', STAMPED],
|
|
55
64
|
['errorMessage', STAMPED],
|
|
56
65
|
// The window. On a rebuild the box's anchors win (attachFRVPCompanion).
|
|
57
|
-
['fromTimestamp',
|
|
58
|
-
['toTimestamp',
|
|
66
|
+
['fromTimestamp', PER_BOX_RELATIVE],
|
|
67
|
+
['toTimestamp', PER_BOX_RELATIVE],
|
|
59
68
|
// Follow Chart: per box, never a template or a default (every future FRVP would self-advance).
|
|
60
69
|
['followChart', PER_BOX],
|
|
61
70
|
// RTH or ETH: a template applies the choice the user named; a default would detach the next profile from its
|
|
@@ -64,16 +73,16 @@ export const FRVP_FIELD_ROWS = [
|
|
|
64
73
|
['exchange', PER_BOX],
|
|
65
74
|
['symbol', PER_BOX],
|
|
66
75
|
// The instrument's block size; a restore mounts on it and the block-size reconcile heals it.
|
|
67
|
-
['minimumBarHeight',
|
|
76
|
+
['minimumBarHeight', PER_BOX_AMOUNT],
|
|
68
77
|
// Derived: block size x ticks per bar, re-derived by every mount.
|
|
69
|
-
['barHeight',
|
|
78
|
+
['barHeight', PER_BOX_AMOUNT],
|
|
70
79
|
['showLabel', PER_BOX],
|
|
71
80
|
// The theme ownership stamp (the panel's colour edit sets true, a theme pass false); addIndicator re-stamps it from
|
|
72
81
|
// what a rebuild hands over, so a theme-owned palette keeps following the theme.
|
|
73
82
|
['colorsCustomized', PER_BOX],
|
|
74
|
-
['digits',
|
|
75
|
-
['width',
|
|
76
|
-
['verticalPadding',
|
|
83
|
+
['digits', CONSTANT_RELATIVE],
|
|
84
|
+
['width', CONSTANT_RELATIVE],
|
|
85
|
+
['verticalPadding', CONSTANT_RELATIVE],
|
|
77
86
|
['hideWeekends', CONSTANT],
|
|
78
87
|
['currency', PREFERENCE],
|
|
79
88
|
['displayMode', PREFERENCE],
|
|
@@ -81,13 +90,13 @@ export const FRVP_FIELD_ROWS = [
|
|
|
81
90
|
['stickToLeft', PREFERENCE],
|
|
82
91
|
['showValue', PREFERENCE],
|
|
83
92
|
['showValueArea', PREFERENCE],
|
|
84
|
-
['valueArea',
|
|
85
|
-
['barWidth',
|
|
93
|
+
['valueArea', PREFERENCE_RELATIVE],
|
|
94
|
+
['barWidth', PREFERENCE_RELATIVE],
|
|
86
95
|
['rowsLayout', PREFERENCE],
|
|
87
|
-
['barHeightMultiplier',
|
|
88
|
-
['rowsCount',
|
|
89
|
-
['threshold',
|
|
90
|
-
['volumeDecimals',
|
|
96
|
+
['barHeightMultiplier', PREFERENCE_RELATIVE],
|
|
97
|
+
['rowsCount', PREFERENCE_RELATIVE],
|
|
98
|
+
['threshold', PREFERENCE_BOUND],
|
|
99
|
+
['volumeDecimals', PREFERENCE_RELATIVE],
|
|
91
100
|
// Legacy: the mount folds it into volumeDecimals, so a mounted profile never holds it and its copy needs none.
|
|
92
101
|
['showDecimals', { owner: 'profile', lanes: ['row', 'template', 'default'] }],
|
|
93
102
|
['colors', PREFERENCE],
|
|
@@ -110,23 +119,23 @@ export const FRVP_FIELD_ROWS = [
|
|
|
110
119
|
['showVAHNaked', PREFERENCE],
|
|
111
120
|
['showVALNaked', PREFERENCE],
|
|
112
121
|
['cellShading', PREFERENCE],
|
|
113
|
-
['shadingSteps',
|
|
114
|
-
['shadingThresholds',
|
|
122
|
+
['shadingSteps', PREFERENCE_RELATIVE],
|
|
123
|
+
['shadingThresholds', PREFERENCE_RELATIVE],
|
|
115
124
|
['shadingStepColors', PREFERENCE],
|
|
116
125
|
['profileStats', PREFERENCE],
|
|
117
126
|
['profileStatsPosition', PREFERENCE],
|
|
118
|
-
['levelLineWidth',
|
|
127
|
+
['levelLineWidth', PREFERENCE_RELATIVE],
|
|
119
128
|
['levelLineStyle', PREFERENCE],
|
|
120
129
|
// Stamped on every mount in the reader's language: mirrored so the box prints it, never saved.
|
|
121
130
|
['profileStatsLabels', { owner: 'profile', lanes: ['mirror'] }],
|
|
122
131
|
// Not a setting: the stamp the saved defaults' profile half carries in the account's style memory, written with it
|
|
123
132
|
// (FRVP_PROFILE_DEFAULTS_STAMP below). In the default lane so the memory keeps it; no panel, row or copy holds it.
|
|
124
|
-
['profileDefaultsVersion', { owner: 'profile', lanes: ['default'] }],
|
|
133
|
+
['profileDefaultsVersion', { owner: 'profile', lanes: ['default'], quantity: 'relative' }],
|
|
125
134
|
// Dynamic Profile parity (Exocharts, 2026-11-13). The profile's row text and imbalance marks, read with the session
|
|
126
135
|
// volume profile's keys and words, and the candle the box draws for its range ('none' by default).
|
|
127
136
|
['rowText', PREFERENCE],
|
|
128
137
|
['imbalance', PREFERENCE],
|
|
129
|
-
['imbalanceRatio',
|
|
138
|
+
['imbalanceRatio', PREFERENCE_RELATIVE],
|
|
130
139
|
['imbalanceBuyColor', PREFERENCE],
|
|
131
140
|
['imbalanceSellColor', PREFERENCE],
|
|
132
141
|
['rangeCandle', PREFERENCE],
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type BoundCondition, type BoundKeep, type FieldQuantity } from './indicator-fields.js';
|
|
1
2
|
import { type ToolTextRole } from './tool-rules.js';
|
|
2
3
|
import { TOOL_DEFAULT_STYLE, TOOL_TEMPLATE_KEYS } from './tool-tables.generated.js';
|
|
3
4
|
export { TOOL_DEFAULT_STYLE, TOOL_TEMPLATE_KEYS };
|
|
4
5
|
export type { ToolTextRole };
|
|
6
|
+
export type { BoundCondition, BoundKeep, FieldQuantity };
|
|
7
|
+
export * from './market-bound.js';
|
|
5
8
|
export type TemplateKind = 'indicator' | 'tool';
|
|
6
9
|
export type FieldLane = 'row' | 'template' | 'default' | 'mirror';
|
|
7
10
|
export type FieldOwner = 'settings' | 'meta' | 'box' | 'profile';
|
|
@@ -18,7 +21,20 @@ export interface FieldSpec {
|
|
|
18
21
|
label?: boolean;
|
|
19
22
|
/** The serialisable value a capture writes where the engine holds none ("all"), when the field declares one. */
|
|
20
23
|
unset?: unknown;
|
|
24
|
+
/** What its number measures (indicator-fields' header); absent on a field that holds no number. */
|
|
25
|
+
quantity?: FieldQuantity;
|
|
26
|
+
/** On a bound field: reconciled per market (`typed` kept for its market, `measured` dropped). */
|
|
27
|
+
keep?: BoundKeep;
|
|
28
|
+
/** On a bound field: the native unit it is bound in, read off a sibling key; in another unit it is an amount. */
|
|
29
|
+
boundWhen?: BoundCondition;
|
|
30
|
+
/** On a kept bound field: the companion keys that travel with it as one unit. */
|
|
31
|
+
with?: readonly string[];
|
|
21
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Where a stored template keeps the market key it was captured on (inside the settings bag: the user service strips
|
|
35
|
+
* any other top-level field). migrateTemplate lifts it out into the document's `boundKey`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const TEMPLATE_BOUND_KEY_FIELD = "boundMarketKey";
|
|
22
38
|
/** The schema version a capture stamps on the template envelope (never inside the settings bag). */
|
|
23
39
|
export declare const TEMPLATE_SCHEMA_VERSION = 2;
|
|
24
40
|
/**
|
|
@@ -29,6 +45,12 @@ export declare const TEMPLATE_SCHEMA_VERSION = 2;
|
|
|
29
45
|
*/
|
|
30
46
|
export interface TemplateContext {
|
|
31
47
|
market?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The fuller market key of a type with typed thresholds (marketBoundKey: exchange, unit, symbol, interval): the saved
|
|
50
|
+
* market's on a capture, the destination's on a patch. A capture keeps it on the document only for a type with a
|
|
51
|
+
* kept bound field.
|
|
52
|
+
*/
|
|
53
|
+
boundKey?: string;
|
|
32
54
|
/** Reserved for host rules that depend on the chart interval; no rule here reads it. */
|
|
33
55
|
intervalMs?: number;
|
|
34
56
|
declaredInputs?: readonly string[];
|
|
@@ -44,6 +66,8 @@ export interface TemplateDocument {
|
|
|
44
66
|
kind: TemplateKind;
|
|
45
67
|
type: string;
|
|
46
68
|
market?: string;
|
|
69
|
+
/** The market key a capture of a type with typed thresholds was taken on (TemplateContext.boundKey). */
|
|
70
|
+
boundKey?: string;
|
|
47
71
|
settings: Record<string, unknown>;
|
|
48
72
|
meta?: Record<string, unknown>;
|
|
49
73
|
profile?: Record<string, unknown>;
|
|
@@ -115,6 +139,7 @@ export declare function migrateTemplate(entry: {
|
|
|
115
139
|
settings?: unknown;
|
|
116
140
|
meta?: unknown;
|
|
117
141
|
market?: string;
|
|
142
|
+
boundKey?: string;
|
|
118
143
|
schemaVersion?: number;
|
|
119
144
|
}, kind: TemplateKind, type: string, _ctx?: TemplateContext): TemplateDocument;
|
|
120
145
|
/**
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
* - Instance state (`instance`) is never written by a patch: which instance this is stays the destination's.
|
|
19
19
|
* - A market-bound field is written only when the template's market and the destination's (`ctx.market`) are both
|
|
20
20
|
* named and equal; on another market it is skipped, not dropped.
|
|
21
|
+
* - A kept bound field (a typed threshold: `quantity: 'bound'` with `keep`, ./market-bound) that is bound right now in
|
|
22
|
+
* the unit the template writes is written only when the template's market key (`boundKey`, captured from
|
|
23
|
+
* `ctx.boundKey`) equals the destination's (`ctx.boundKey`); when either key is missing, the template's `market` and
|
|
24
|
+
* `ctx.market` decide, as for a market-bound field. Its group companions follow it. Skipped, not dropped. A dollar
|
|
25
|
+
* amount (the field in a notional unit) is written onto any market.
|
|
21
26
|
* - "Show on" (`visibleIntervalsMs`): absent keeps the destination, `[]` is All intervals, a list is that list; a
|
|
22
27
|
* legacy clear (`null`, or a key held as undefined) is written as `[]`. A capture writes `[]` where the engine holds
|
|
23
28
|
* none, so a saved template always states it (an interval-bound drawing keeps its own, as instance state). A
|
|
@@ -32,8 +37,10 @@
|
|
|
32
37
|
* writes it), are no loss and are not named.
|
|
33
38
|
*
|
|
34
39
|
* Stored shape: the user service keeps a template entry's `settings` bag, `market` and `schemaVersion` and strips any
|
|
35
|
-
* other top-level field, so toStoredEntry folds the meta group into `settings.meta
|
|
36
|
-
* the flat bag
|
|
40
|
+
* other top-level field, so toStoredEntry folds the meta group into `settings.meta`, the FRVP profile group into
|
|
41
|
+
* the flat bag and the market key into `settings.boundMarketKey` (TEMPLATE_BOUND_KEY_FIELD), the shape every client
|
|
42
|
+
* reads; migrateTemplate splits them out again. A client before 0.19.0 reads that key as one it cannot set (`dropped`)
|
|
43
|
+
* and writes the threshold ungated, as it always has. An entry without a schemaVersion
|
|
37
44
|
* is version 1 (a save from before this contract, read with the same rules); one above TEMPLATE_SCHEMA_VERSION throws
|
|
38
45
|
* TemplateSchemaVersionError, so a door refuses to apply or overwrite what a newer client wrote.
|
|
39
46
|
*
|
|
@@ -46,9 +53,18 @@ import cloneDeep from 'lodash-es/cloneDeep.js';
|
|
|
46
53
|
import { isWrunViewerRowKey } from '../utility/wrun/wrun-color-facts.util.js';
|
|
47
54
|
import { FRVP_FIELD_ROWS, FRVP_TOOL_TYPE } from './frvp-fields.js';
|
|
48
55
|
import { INDICATOR_COMMON_FIELDS, INDICATOR_TYPE_FIELDS, RESERVED_SCRIPT_INPUT_NAMES, SCRIPT_INDICATOR_TYPE, SCRIPT_INPUT_FIELD, VIEWER_ROW_FIELD, } from './indicator-fields.js';
|
|
56
|
+
import { isBoundNow } from './market-bound.js';
|
|
49
57
|
import { textRoleOf, TOOL_TEMPLATE_RULES } from './tool-rules.js';
|
|
50
58
|
import { TOOL_DEFAULT_STYLE, TOOL_TEMPLATE_KEYS } from './tool-tables.generated.js';
|
|
51
59
|
export { TOOL_DEFAULT_STYLE, TOOL_TEMPLATE_KEYS };
|
|
60
|
+
// The market key and stamp of market-bound values (a heatmap row's scale, a typed threshold) and the one reconcile:
|
|
61
|
+
// served by this entry so a host reads the row rules and the stamp rules from one import.
|
|
62
|
+
export * from './market-bound.js';
|
|
63
|
+
/**
|
|
64
|
+
* Where a stored template keeps the market key it was captured on (inside the settings bag: the user service strips
|
|
65
|
+
* any other top-level field). migrateTemplate lifts it out into the document's `boundKey`.
|
|
66
|
+
*/
|
|
67
|
+
export const TEMPLATE_BOUND_KEY_FIELD = 'boundMarketKey';
|
|
52
68
|
/** The schema version a capture stamps on the template envelope (never inside the settings bag). */
|
|
53
69
|
export const TEMPLATE_SCHEMA_VERSION = 2;
|
|
54
70
|
/**
|
|
@@ -110,6 +126,14 @@ function specOf(key, field) {
|
|
|
110
126
|
spec.label = true;
|
|
111
127
|
if (field.unset !== undefined)
|
|
112
128
|
spec.unset = field.unset;
|
|
129
|
+
if (field.quantity)
|
|
130
|
+
spec.quantity = field.quantity;
|
|
131
|
+
if (field.keep)
|
|
132
|
+
spec.keep = field.keep;
|
|
133
|
+
if (field.boundWhen)
|
|
134
|
+
spec.boundWhen = field.boundWhen;
|
|
135
|
+
if (field.with)
|
|
136
|
+
spec.with = Object.freeze([...field.with]);
|
|
113
137
|
return Object.freeze(spec);
|
|
114
138
|
}
|
|
115
139
|
/** An indicator type's fields: the shared rows, then its own (a row of the same owner and key replaces in place). */
|
|
@@ -307,6 +331,9 @@ export function captureTemplate(kind, type, engineSettings, ctx) {
|
|
|
307
331
|
const market = kind === 'indicator' ? nonEmpty(ctx?.market) : undefined;
|
|
308
332
|
if (market)
|
|
309
333
|
doc.market = market;
|
|
334
|
+
const boundKey = kind === 'indicator' ? nonEmpty(ctx?.boundKey) : undefined;
|
|
335
|
+
if (boundKey && specs.some((spec) => spec.keep))
|
|
336
|
+
doc.boundKey = boundKey;
|
|
310
337
|
if (Object.keys(groups.meta).length)
|
|
311
338
|
doc.meta = groups.meta;
|
|
312
339
|
if (isFrvp(kind, type))
|
|
@@ -355,6 +382,22 @@ export function templatePatch(kind, type, live, template, ctx) {
|
|
|
355
382
|
const metaSpecs = new Map(specs.filter((spec) => spec.owner === 'meta').map((spec) => [spec.key, spec]));
|
|
356
383
|
const templateMarket = nonEmpty(template?.market);
|
|
357
384
|
const sameMarket = !!templateMarket && templateMarket === nonEmpty(ctx?.market);
|
|
385
|
+
// A kept bound field is written on the market key it was typed on; a template or a context with no key falls back to
|
|
386
|
+
// the market (an in-memory older shape may still hold the key in its bag).
|
|
387
|
+
const savedBoundKey = kind === 'indicator' && !bagSpecs.has(TEMPLATE_BOUND_KEY_FIELD) ? saved[TEMPLATE_BOUND_KEY_FIELD] : undefined;
|
|
388
|
+
const templateBoundKey = nonEmpty(template?.boundKey) ?? nonEmpty(savedBoundKey);
|
|
389
|
+
const liveBoundKey = nonEmpty(ctx?.boundKey);
|
|
390
|
+
const sameBoundMarket = templateBoundKey && liveBoundKey ? templateBoundKey === liveBoundKey : sameMarket;
|
|
391
|
+
// The unit a template writes: its own value of the unit key, else the destination's.
|
|
392
|
+
const writtenBag = { ...liveBag, ...saved };
|
|
393
|
+
const gated = new Set();
|
|
394
|
+
if (!sameBoundMarket) {
|
|
395
|
+
for (const spec of bagSpecs.values()) {
|
|
396
|
+
if (spec.keep && isBoundNow(spec.boundWhen, writtenBag))
|
|
397
|
+
for (const key of [spec.key, ...(spec.with ?? [])])
|
|
398
|
+
gated.add(key);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
358
401
|
const groups = { settings: {}, meta: {}, profile: {} };
|
|
359
402
|
const dropped = new Set();
|
|
360
403
|
const take = (spec, value, name) => {
|
|
@@ -366,6 +409,9 @@ export function templatePatch(kind, type, live, template, ctx) {
|
|
|
366
409
|
// and no loss either.
|
|
367
410
|
if (spec.instance || (spec.marketBound && !sameMarket))
|
|
368
411
|
return;
|
|
412
|
+
// A typed threshold of another market (or its companion): no loss, the destination keeps its own.
|
|
413
|
+
if (spec.owner !== 'meta' && gated.has(spec.key))
|
|
414
|
+
return;
|
|
369
415
|
const written = patchedValue(spec, value);
|
|
370
416
|
if (written === INVALID)
|
|
371
417
|
dropped.add(name);
|
|
@@ -373,6 +419,8 @@ export function templatePatch(kind, type, live, template, ctx) {
|
|
|
373
419
|
groupOf(groups, spec.owner)[spec.key] = written;
|
|
374
420
|
};
|
|
375
421
|
for (const [key, value] of Object.entries(saved)) {
|
|
422
|
+
if (savedBoundKey !== undefined && key === TEMPLATE_BOUND_KEY_FIELD)
|
|
423
|
+
continue;
|
|
376
424
|
if (key !== 'meta' || value !== nestedMeta)
|
|
377
425
|
take(bagSpecs.get(key), value, key);
|
|
378
426
|
}
|
|
@@ -450,6 +498,15 @@ _ctx) {
|
|
|
450
498
|
const market = nonEmpty(source.market);
|
|
451
499
|
if (market)
|
|
452
500
|
doc.market = market;
|
|
501
|
+
if (kind === 'indicator' && Object.hasOwn(settings, TEMPLATE_BOUND_KEY_FIELD)) {
|
|
502
|
+
const boundKey = nonEmpty(settings[TEMPLATE_BOUND_KEY_FIELD]);
|
|
503
|
+
delete settings[TEMPLATE_BOUND_KEY_FIELD];
|
|
504
|
+
if (boundKey)
|
|
505
|
+
doc.boundKey = boundKey;
|
|
506
|
+
}
|
|
507
|
+
const entryBoundKey = kind === 'indicator' ? nonEmpty(source.boundKey) : undefined;
|
|
508
|
+
if (entryBoundKey)
|
|
509
|
+
doc.boundKey = entryBoundKey;
|
|
453
510
|
return doc;
|
|
454
511
|
}
|
|
455
512
|
/**
|
|
@@ -472,5 +529,8 @@ export function toStoredEntry(doc) {
|
|
|
472
529
|
const market = nonEmpty(doc.market);
|
|
473
530
|
if (market)
|
|
474
531
|
entry.market = market;
|
|
532
|
+
const boundKey = doc.kind === 'indicator' ? nonEmpty(doc.boundKey) : undefined;
|
|
533
|
+
if (boundKey)
|
|
534
|
+
settings[TEMPLATE_BOUND_KEY_FIELD] = boundKey;
|
|
475
535
|
return entry;
|
|
476
536
|
}
|
|
@@ -18,7 +18,32 @@
|
|
|
18
18
|
* object), its lanes, whether it is instance state (which instance this is: never written by a template or a saved
|
|
19
19
|
* default, kept by a reset) and whether it is bound to the market it was saved on. Imports nothing, so the tool
|
|
20
20
|
* tables' generator can read the FRVP table beside it without the package graph.
|
|
21
|
+
*
|
|
22
|
+
* Quantities (market-bound values, ./market-bound): every field that holds a number, or a container of numbers, says
|
|
23
|
+
* what the number measures, so a reader knows whether it means the same on another market:
|
|
24
|
+
* - `relative`: the same on any market (a percent, ratio, count, period, length, opacity, width, a time);
|
|
25
|
+
* - `bound`: an absolute in the market's native unit (coins, contracts, shares, price units). With `keep` it is
|
|
26
|
+
* reconciled per market (reconcileMarketBound): `typed` values are kept per market and given back on a return,
|
|
27
|
+
* `measured` ones are dropped. Without `keep` it is classified only: a heatmap's meta scale (its own path,
|
|
28
|
+
* settleHeatmapScale) and the FRVP's threshold (left as it is on purpose);
|
|
29
|
+
* - `amount`: an absolute that is carried onto any market as it is: a dollar amount, and an absolute whose unit no
|
|
30
|
+
* reader settles (the shared rows of a field a bound type overrides, price-unit sizes outside the typed thresholds).
|
|
31
|
+
* A field that is bound only in a native unit names that unit (`boundWhen`): in another unit (USD) it is an amount.
|
|
32
|
+
* A field's group companions (`with`) are kept, given back and removed with it as one unit.
|
|
33
|
+
*/
|
|
34
|
+
/** What a number in a field measures (see the file header). */
|
|
35
|
+
export type FieldQuantity = 'relative' | 'bound' | 'amount';
|
|
36
|
+
/** What a market change does with a bound value: `typed` is kept for its market, `measured` is dropped. */
|
|
37
|
+
export type BoundKeep = 'typed' | 'measured';
|
|
38
|
+
/**
|
|
39
|
+
* When a bound field is bound right now, read off a sibling key of the same settings bag: bound when the sibling's
|
|
40
|
+
* value is one of `oneOf` (when named) and none of `noneOf` (when named). A missing sibling is undefined.
|
|
21
41
|
*/
|
|
42
|
+
export interface BoundCondition {
|
|
43
|
+
readonly key: string;
|
|
44
|
+
readonly oneOf?: readonly unknown[];
|
|
45
|
+
readonly noneOf?: readonly unknown[];
|
|
46
|
+
}
|
|
22
47
|
/** A field as a table declares it: its owner (the settings bag when none is named), lanes, flags and unset value. */
|
|
23
48
|
export interface DeclaredField {
|
|
24
49
|
readonly owner?: 'settings' | 'meta' | 'box' | 'profile';
|
|
@@ -29,6 +54,14 @@ export interface DeclaredField {
|
|
|
29
54
|
readonly label?: true;
|
|
30
55
|
/** The value a capture writes where the engine holds none (a serialisable value: "all", never "absent"). */
|
|
31
56
|
readonly unset?: unknown;
|
|
57
|
+
/** What its number measures; every numeric field declares one, a non-numeric field none. */
|
|
58
|
+
readonly quantity?: FieldQuantity;
|
|
59
|
+
/** On a bound field: reconciled per market, and how. */
|
|
60
|
+
readonly keep?: BoundKeep;
|
|
61
|
+
/** On a bound field: the native unit it is bound in; in any other unit it is an amount. */
|
|
62
|
+
readonly boundWhen?: BoundCondition;
|
|
63
|
+
/** On a kept bound field: the keys that travel with it as one unit (a value and its market default). */
|
|
64
|
+
readonly with?: readonly string[];
|
|
32
65
|
}
|
|
33
66
|
/** One table row: a key and its declared field. */
|
|
34
67
|
export type DeclaredFieldRow = readonly [key: string, field: DeclaredField];
|
|
@@ -52,6 +85,8 @@ export declare const RESERVED_SCRIPT_INPUT_NAMES: readonly string[];
|
|
|
52
85
|
* then the instance and runtime keys the row never keeps, then the meta fields.
|
|
53
86
|
*/
|
|
54
87
|
export declare const INDICATOR_COMMON_FIELDS: readonly DeclaredFieldRow[];
|
|
88
|
+
/** The four heatmap types whose meta scale is settled by the heatmap's own path (wave 1: settleHeatmapScale). */
|
|
89
|
+
export declare const HEATMAP_SCALE_TYPES: readonly string[];
|
|
55
90
|
/**
|
|
56
91
|
* The fields one indicator type declares beyond INDICATOR_COMMON_FIELDS: a row here adds a key, or replaces the shared
|
|
57
92
|
* row of the same owner and key.
|