@orangecharts/wrun-chart-host 0.1.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 +72 -0
- package/dist/constants/governed-exchanges.constants.d.ts +11 -0
- package/dist/constants/governed-exchanges.constants.js +11 -0
- package/dist/constants/indicator-sets.constants.d.ts +8 -0
- package/dist/constants/indicator-sets.constants.js +8 -0
- package/dist/constants/interval.constants.d.ts +34 -0
- package/dist/constants/interval.constants.js +121 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +28 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +65 -0
- package/dist/constants/tpo-color-schemes.constants.d.ts +30 -0
- package/dist/constants/tpo-color-schemes.constants.js +32 -0
- package/dist/host-env.d.ts +102 -0
- package/dist/host-env.js +26 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +96 -0
- package/dist/indicators/controls/tpo-letter.util.d.ts +2 -0
- package/dist/indicators/controls/tpo-letter.util.js +13 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +99 -0
- package/dist/indicators/controls/tpo-session.util.js +389 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +64 -0
- package/dist/interfaces/kscript-diagnostics.interface.js +1 -0
- package/dist/interfaces/om-panel-data.interface.d.ts +103 -0
- package/dist/interfaces/om-panel-data.interface.js +7 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +2659 -0
- package/dist/interfaces/wrun-runtime.interface.js +55 -0
- package/dist/utility/chart/calendar-interval.util.d.ts +24 -0
- package/dist/utility/chart/calendar-interval.util.js +81 -0
- package/dist/utility/chart/candle-bar-end.util.d.ts +15 -0
- package/dist/utility/chart/candle-bar-end.util.js +23 -0
- package/dist/utility/chart/cme-realtime.util.d.ts +24 -0
- package/dist/utility/chart/cme-realtime.util.js +53 -0
- package/dist/utility/chart/interval-ladder.util.d.ts +27 -0
- package/dist/utility/chart/interval-ladder.util.js +92 -0
- package/dist/utility/chart/kscript-drawing-prep.util.d.ts +40 -0
- package/dist/utility/chart/kscript-drawing-prep.util.js +184 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +95 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +805 -0
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +166 -0
- package/dist/utility/chart/kscript-legend-entries.util.js +538 -0
- package/dist/utility/chart/kscript-output-role.util.d.ts +32 -0
- package/dist/utility/chart/kscript-output-role.util.js +215 -0
- package/dist/utility/chart/kscript-provenance-keys.util.d.ts +22 -0
- package/dist/utility/chart/kscript-provenance-keys.util.js +56 -0
- package/dist/utility/chart/kscript-run-result-normalize.util.d.ts +53 -0
- package/dist/utility/chart/kscript-run-result-normalize.util.js +476 -0
- package/dist/utility/chart/kscript-run-result-shape.util.d.ts +14 -0
- package/dist/utility/chart/kscript-run-result-shape.util.js +66 -0
- package/dist/utility/chart/kscript-titancharts-container.util.d.ts +29 -0
- package/dist/utility/chart/kscript-titancharts-container.util.js +151 -0
- package/dist/utility/chart/kscript-viewport-overlays.util.d.ts +83 -0
- package/dist/utility/chart/kscript-viewport-overlays.util.js +443 -0
- package/dist/utility/chart/om-panel-push-style.util.d.ts +78 -0
- package/dist/utility/chart/om-panel-push-style.util.js +301 -0
- package/dist/utility/chart/om-panel.util.d.ts +166 -0
- package/dist/utility/chart/om-panel.util.js +815 -0
- package/dist/utility/chart/om-series.util.d.ts +42 -0
- package/dist/utility/chart/om-series.util.js +330 -0
- package/dist/utility/chart/om-target.util.d.ts +11 -0
- package/dist/utility/chart/om-target.util.js +24 -0
- package/dist/utility/chart/om-widget.util.d.ts +148 -0
- package/dist/utility/chart/om-widget.util.js +413 -0
- package/dist/utility/chart/overlay-output-budget.util.d.ts +16 -0
- package/dist/utility/chart/overlay-output-budget.util.js +109 -0
- package/dist/utility/chart/overlay-paint-flags.util.d.ts +24 -0
- package/dist/utility/chart/overlay-paint-flags.util.js +55 -0
- package/dist/utility/chart/profile-row-height.util.d.ts +21 -0
- package/dist/utility/chart/profile-row-height.util.js +110 -0
- package/dist/utility/chart/session-interval.util.d.ts +1 -0
- package/dist/utility/chart/session-interval.util.js +35 -0
- package/dist/utility/chart/technical-script-legend-value.util.d.ts +18 -0
- package/dist/utility/chart/technical-script-legend-value.util.js +53 -0
- package/dist/utility/chart/trading-day.util.d.ts +70 -0
- package/dist/utility/chart/trading-day.util.js +238 -0
- package/dist/utility/chart/wrun-legend-name.util.d.ts +25 -0
- package/dist/utility/chart/wrun-legend-name.util.js +87 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +977 -0
- package/dist/utility/chart/wrun-run-result.util.js +5179 -0
- package/dist/utility/chart/wrun-visibility-chart.util.d.ts +25 -0
- package/dist/utility/chart/wrun-visibility-chart.util.js +22 -0
- package/dist/utility/indicators/heatmap-sensitivity.util.d.ts +62 -0
- package/dist/utility/indicators/heatmap-sensitivity.util.js +82 -0
- package/dist/utility/number-format.util.d.ts +68 -0
- package/dist/utility/number-format.util.js +188 -0
- package/dist/utility/v2/opra-governed.util.d.ts +1 -0
- package/dist/utility/v2/opra-governed.util.js +13 -0
- package/dist/utility/wrun/wrun-auto-row.util.d.ts +54 -0
- package/dist/utility/wrun/wrun-auto-row.util.js +96 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +341 -0
- package/dist/utility/wrun/wrun-batched-marks.util.js +938 -0
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +75 -0
- package/dist/utility/wrun/wrun-batched-readout.util.js +171 -0
- package/dist/utility/wrun/wrun-box-segment.util.d.ts +185 -0
- package/dist/utility/wrun/wrun-box-segment.util.js +570 -0
- package/dist/utility/wrun/wrun-build-memo.util.d.ts +133 -0
- package/dist/utility/wrun/wrun-build-memo.util.js +301 -0
- package/dist/utility/wrun/wrun-builtin-twin-ports.util.d.ts +25 -0
- package/dist/utility/wrun/wrun-builtin-twin-ports.util.js +75 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.js +40 -0
- package/dist/utility/wrun/wrun-canvas-cache.util.d.ts +28 -0
- package/dist/utility/wrun/wrun-canvas-cache.util.js +56 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +69 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.js +53 -0
- package/dist/utility/wrun/wrun-canvases.util.d.ts +295 -0
- package/dist/utility/wrun/wrun-canvases.util.js +1432 -0
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +77 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +296 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +154 -0
- package/dist/utility/wrun/wrun-card-style.util.js +539 -0
- package/dist/utility/wrun/wrun-chart-context.util.d.ts +89 -0
- package/dist/utility/wrun/wrun-chart-context.util.js +213 -0
- package/dist/utility/wrun/wrun-chart-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-chart-names.util.js +33 -0
- package/dist/utility/wrun/wrun-chart-time.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-chart-time.util.js +23 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +44 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +40 -0
- package/dist/utility/wrun/wrun-color-facts.util.js +88 -0
- package/dist/utility/wrun/wrun-color-settings.lazy.d.ts +26 -0
- package/dist/utility/wrun/wrun-color-settings.lazy.js +9 -0
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +351 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +1363 -0
- package/dist/utility/wrun/wrun-footprint-modes.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-footprint-modes.util.js +24 -0
- package/dist/utility/wrun/wrun-frames.d.ts +217 -0
- package/dist/utility/wrun/wrun-frames.js +1021 -0
- package/dist/utility/wrun/wrun-handles.util.d.ts +792 -0
- package/dist/utility/wrun/wrun-handles.util.js +2050 -0
- package/dist/utility/wrun/wrun-heatmap-cell-budget.util.d.ts +156 -0
- package/dist/utility/wrun/wrun-heatmap-cell-budget.util.js +342 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +218 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +667 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +40 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +27 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +182 -0
- package/dist/utility/wrun/wrun-hover.util.js +534 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +246 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +587 -0
- package/dist/utility/wrun/wrun-integration-budget.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-integration-budget.util.js +122 -0
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +19 -0
- package/dist/utility/wrun/wrun-latest-snapshot.js +7 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +131 -0
- package/dist/utility/wrun/wrun-levels-child.util.js +514 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +75 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.js +9 -0
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-market-facts.util.js +238 -0
- package/dist/utility/wrun/wrun-output-style.util.d.ts +344 -0
- package/dist/utility/wrun/wrun-output-style.util.js +1239 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.js +142 -0
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +120 -0
- package/dist/utility/wrun/wrun-overlay-result.util.js +219 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +70 -0
- package/dist/utility/wrun/wrun-pack.util.js +301 -0
- package/dist/utility/wrun/wrun-pane-format.util.d.ts +180 -0
- package/dist/utility/wrun/wrun-pane-format.util.js +299 -0
- package/dist/utility/wrun/wrun-panel-style.lazy.d.ts +25 -0
- package/dist/utility/wrun/wrun-panel-style.lazy.js +15 -0
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +174 -0
- package/dist/utility/wrun/wrun-panel-style.util.js +726 -0
- package/dist/utility/wrun/wrun-param-values.util.d.ts +69 -0
- package/dist/utility/wrun/wrun-param-values.util.js +230 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +263 -0
- package/dist/utility/wrun/wrun-refusal.util.js +1259 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +199 -0
- package/dist/utility/wrun/wrun-registry-errors.util.js +257 -0
- package/dist/utility/wrun/wrun-render-select.util.d.ts +336 -0
- package/dist/utility/wrun/wrun-render-select.util.js +1157 -0
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +434 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +1971 -0
- package/dist/utility/wrun/wrun-setting-words.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-setting-words.lazy.js +9 -0
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +79 -0
- package/dist/utility/wrun/wrun-setting-words.util.js +176 -0
- package/dist/utility/wrun/wrun-socket-row-store.d.ts +98 -0
- package/dist/utility/wrun/wrun-socket-row-store.js +417 -0
- package/dist/utility/wrun/wrun-style-flags.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-style-flags.util.js +21 -0
- package/dist/utility/wrun/wrun-style-words.util.d.ts +148 -0
- package/dist/utility/wrun/wrun-style-words.util.js +439 -0
- package/dist/utility/wrun/wrun-table-look.util.d.ts +125 -0
- package/dist/utility/wrun/wrun-table-look.util.js +225 -0
- package/dist/utility/wrun/wrun-text-look.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-text-look.util.js +227 -0
- package/dist/utility/wrun/wrun-text-params.util.d.ts +106 -0
- package/dist/utility/wrun/wrun-text-params.util.js +171 -0
- package/dist/utility/wrun/wrun-tpo-rows.util.d.ts +71 -0
- package/dist/utility/wrun/wrun-tpo-rows.util.js +438 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +58 -0
- package/dist/utility/wrun/wrun-visibility-table.d.ts +437 -0
- package/dist/utility/wrun/wrun-visibility-table.js +237 -0
- package/dist/utility/wrun/wrun-volume-profile.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +278 -0
- package/package.json +38 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The market facts' codes and the candle blends, as every wrun host reads
|
|
3
|
+
* them (WRUN-GAPS-1005 CONTRACT.md, om `packages/sdk/src/wrun-market-facts.ts`,
|
|
4
|
+
* which the indicator kit exports since 0.52.0): the numbers `market.kind()`,
|
|
5
|
+
* `market.point_value()`, `market.zone()`, `market.quote_is_usd()` and
|
|
6
|
+
* `market.session_open()` (WRUN-SESSION, kit 0.65.0) declare as hidden
|
|
7
|
+
* settings, and the price-source words a `param.source` menu holds, the four
|
|
8
|
+
* blends among them (hl2, hlc3, ohlc4, hlcc4).
|
|
9
|
+
*
|
|
10
|
+
* A verbatim copy, import-free on purpose: the row builder runs on the main
|
|
11
|
+
* thread and in the Node specs, and the worker reads the hosted param maps,
|
|
12
|
+
* none of which load the kit bundle (wrun-kit.ts is its one importer). The
|
|
13
|
+
* values never drift from the kit's: wrun-market-facts.kit-mirror.spec.ts
|
|
14
|
+
* pins every word, code and zone, and the blend arithmetic over a grid of
|
|
15
|
+
* candles, to the kit's own exports. What the chart fills for a market lives
|
|
16
|
+
* in wrun-chart-market-facts.util.
|
|
17
|
+
*
|
|
18
|
+
* The one rule every fact keeps: a host that does not know a fact writes 0.
|
|
19
|
+
* For the kind, the point value and the quote that 0 reads "unknown"; for the
|
|
20
|
+
* zone it is index 0, UTC, the clock every 24/7 market keeps; for the session
|
|
21
|
+
* open it is midnight, the trade day of every market off the CME family.
|
|
22
|
+
*/
|
|
23
|
+
import type { WrunMarketFactFill, WrunMarketKind, WrunMarketQuoteIsUsd, WrunSourceBlendField, WrunSourceFieldWord } from '@orangecharts/indicator-kit';
|
|
24
|
+
export type { WrunSourceBlendField, WrunSourceFieldWord } from '@orangecharts/indicator-kit';
|
|
25
|
+
/** A market fact's host_fill word: the kit's, and `session_open`, which the kit
|
|
26
|
+
* exports from 0.65.0 (om scaffold 65). Once the chart pins 0.65.0 the kit's
|
|
27
|
+
* own word list holds it and the union adds nothing. */
|
|
28
|
+
export type WrunMarketFactWord = WrunMarketFactFill | 'session_open';
|
|
29
|
+
/** The host_fill words of the five market facts, in declaration order
|
|
30
|
+
* (append-only): `market.<word>()` declares the hidden param `market_<word>`. */
|
|
31
|
+
export declare const WRUN_MARKET_FACT_FILLS: readonly WrunMarketFactWord[];
|
|
32
|
+
/** `market.session_open()` on the CME family: its trade day opens at minute
|
|
33
|
+
* 1020 (17:00) on the Chicago clock, the evening before the date it is stamped
|
|
34
|
+
* with (the lattice of wrun-run-interval-session.util). Every other market
|
|
35
|
+
* reads 0, midnight. The kit's WRUN_MARKET_SESSION_OPEN_CME from 0.65.0. */
|
|
36
|
+
export declare const WRUN_MARKET_SESSION_OPEN_CME = 1020;
|
|
37
|
+
/** `market.kind()` codes: the code is the index (append-only). 0 is a market
|
|
38
|
+
* the host does not know, or none of these kinds (a prediction market, an
|
|
39
|
+
* energy or grain contract). A futures contract reports what it trades. */
|
|
40
|
+
export declare const WRUN_MARKET_KINDS: readonly WrunMarketKind[];
|
|
41
|
+
/** `market.quote_is_usd()` codes, the index again: 1 priced in US dollars,
|
|
42
|
+
* 2 in another currency or coin (a dollar stablecoin included), 0 unknown. */
|
|
43
|
+
export declare const WRUN_MARKET_QUOTE_IS_USD: readonly WrunMarketQuoteIsUsd[];
|
|
44
|
+
/** The zones `market.zone()` indexes: param.session's zone list in order
|
|
45
|
+
* (append-only), each with its own daylight-saving rule. 0 is UTC. */
|
|
46
|
+
export declare const WRUN_MARKET_ZONES: readonly string[];
|
|
47
|
+
/** The `market.zone()` code of an IANA zone id: its index in
|
|
48
|
+
* WRUN_MARKET_ZONES, or 0 (UTC, the code of an unknown zone) for an id off
|
|
49
|
+
* the list. Exact match: `Etc/UTC` is off the list and reads 0, UTC anyway. */
|
|
50
|
+
export declare function wrunMarketZoneCode(zone: string): number;
|
|
51
|
+
/** `market.size_unit()` codes (kit 0.68.0): the code is the index (append-only). 0 is a market none
|
|
52
|
+
* of the rules place (forex, a metal, an index, a market the host does not know). */
|
|
53
|
+
export declare const WRUN_MARKET_SIZE_UNITS: readonly string[];
|
|
54
|
+
/** A market's size unit from its `market.kind()`, `market.point_value()` and `market.zone()`
|
|
55
|
+
* codes, the kit's `wrunMarketSizeUnit` (sizeUnit in the kit's declare module), the first rule
|
|
56
|
+
* that holds: contracts (3) when the point value is a contract multiplier (a positive number
|
|
57
|
+
* other than 1) or the zone is Chicago; coins (1) on kind crypto; shares (2) on kind stock; else 0.
|
|
58
|
+
* The point value and the zone decide contracts, so contracts never wait on the directory row. */
|
|
59
|
+
export declare function wrunMarketSizeUnit(kind: number, pointValue: number, zone: number): number;
|
|
60
|
+
/** The `currency` word of a `trades` or `volume_profile` lane whose unit follows the market the
|
|
61
|
+
* indicator runs on (kit 0.69.0, scaffold 69), beside "USD" and "Coin". */
|
|
62
|
+
export declare const WRUN_LANE_CURRENCY_AUTO = "Auto";
|
|
63
|
+
/** The unit a lane's `currency` word reads on a market of size unit `sizeUnit`, the kit's
|
|
64
|
+
* `wrunLaneCurrency`: "Auto" reads "Coin" (the lane's native size, the contracts traded) on
|
|
65
|
+
* contracts and "USD" on every other market, one the host knows no facts for included; "USD",
|
|
66
|
+
* "Coin" and an absent word read as written. */
|
|
67
|
+
export declare function wrunLaneCurrency(currency: string | undefined, sizeUnit: number): string | undefined;
|
|
68
|
+
/** Whether a row declaring `visibleBy` (a setting's or an output's `visible_by`, kit 0.69.0) shows
|
|
69
|
+
* on a market of size unit `sizeUnit`, the kit's `wrunVisibleOnMarket`: always without the word,
|
|
70
|
+
* else only when its `size_unit` list names the code. A word holding no list (a malformed
|
|
71
|
+
* persisted row) reads as absent. The one predicate the settings dialog (its rows) and the run
|
|
72
|
+
* result (an output's plot and the stats rows drawn from it) ask. */
|
|
73
|
+
export declare function wrunRowVisibleHere(visibleBy: {
|
|
74
|
+
size_unit?: unknown;
|
|
75
|
+
} | null | undefined, sizeUnit: number): boolean;
|
|
76
|
+
/** Whether a `visible_by` list needs the market's kind to decide (the directory row on a crypto
|
|
77
|
+
* venue): it names some but not all of 0, 1 and 2, the units the kind tells apart. A list deciding
|
|
78
|
+
* on contracts alone (`[3]`, `[0, 1, 2]`) needs only the point value and the zone. */
|
|
79
|
+
export declare function wrunVisibleByNeedsKind(visibleBy: {
|
|
80
|
+
size_unit?: unknown;
|
|
81
|
+
} | null | undefined): boolean;
|
|
82
|
+
/** The coin-leg and setting-gate words of kit 0.77.0, the kit's own (`WRUN_FOLLOW_COIN`,
|
|
83
|
+
* `wrunFollowsCoin`, `wrunCoinLegSource`, `wrunInputGateOn`): a coin leg's source with `follow`
|
|
84
|
+
* resolved (a pin; null for an unlisted venue; undefined for no answer), and whether a `when`
|
|
85
|
+
* setting's run value turns its lane on. */
|
|
86
|
+
export declare const WRUN_FOLLOW_COIN = "coin";
|
|
87
|
+
export declare function wrunFollowsCoin(source: {
|
|
88
|
+
readonly follow?: unknown;
|
|
89
|
+
}): boolean;
|
|
90
|
+
export declare function wrunCoinLegSource<T extends {
|
|
91
|
+
readonly follow?: unknown;
|
|
92
|
+
readonly exchange?: unknown;
|
|
93
|
+
}>(source: T, coinLegs: Readonly<Record<string, string | null>> | undefined): (Omit<T, 'follow'> & {
|
|
94
|
+
symbol: string;
|
|
95
|
+
}) | T | null | undefined;
|
|
96
|
+
export declare function wrunInputGateOn(gate: {
|
|
97
|
+
readonly when?: unknown;
|
|
98
|
+
readonly when_bit?: unknown;
|
|
99
|
+
}, value: unknown): boolean;
|
|
100
|
+
/** param.source's menu words in their frozen order: the `<name>_field`
|
|
101
|
+
* select stores the index, so a word is appended, never moved (hlcc4 joined
|
|
102
|
+
* at 8). A source default may be any of them. */
|
|
103
|
+
export declare const WRUN_SOURCE_FIELD_WORDS: readonly WrunSourceFieldWord[];
|
|
104
|
+
/** The source words no candle stores: every host derives them from the
|
|
105
|
+
* candle it serves the input (wrunSourceBlend). */
|
|
106
|
+
export declare const WRUN_SOURCE_BLEND_FIELDS: readonly WrunSourceBlendField[];
|
|
107
|
+
/** True for hl2, hlc3, ohlc4 and hlcc4. */
|
|
108
|
+
export declare function isWrunSourceBlendField(field: unknown): field is WrunSourceBlendField;
|
|
109
|
+
/** One candle's blend for `field`, or undefined when `field` is not a blend
|
|
110
|
+
* word (the caller reads the stored field). The f64 arithmetic, left to
|
|
111
|
+
* right, is the contract every host computes so they agree to the bit:
|
|
112
|
+
* hl2 = (high + low) / 2, hlc3 = (high + low + close) / 3,
|
|
113
|
+
* ohlc4 = (open + high + low + close) / 4, hlcc4 = (high + low + close +
|
|
114
|
+
* close) / 4. NaN when a field the blend reads is not a finite number (a
|
|
115
|
+
* field it does not read, the open of an hl2, never matters). */
|
|
116
|
+
export declare function wrunSourceBlend(field: string, open: number, high: number, low: number, close: number): number | undefined;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The market facts' codes and the candle blends, as every wrun host reads
|
|
3
|
+
* them (WRUN-GAPS-1005 CONTRACT.md, om `packages/sdk/src/wrun-market-facts.ts`,
|
|
4
|
+
* which the indicator kit exports since 0.52.0): the numbers `market.kind()`,
|
|
5
|
+
* `market.point_value()`, `market.zone()`, `market.quote_is_usd()` and
|
|
6
|
+
* `market.session_open()` (WRUN-SESSION, kit 0.65.0) declare as hidden
|
|
7
|
+
* settings, and the price-source words a `param.source` menu holds, the four
|
|
8
|
+
* blends among them (hl2, hlc3, ohlc4, hlcc4).
|
|
9
|
+
*
|
|
10
|
+
* A verbatim copy, import-free on purpose: the row builder runs on the main
|
|
11
|
+
* thread and in the Node specs, and the worker reads the hosted param maps,
|
|
12
|
+
* none of which load the kit bundle (wrun-kit.ts is its one importer). The
|
|
13
|
+
* values never drift from the kit's: wrun-market-facts.kit-mirror.spec.ts
|
|
14
|
+
* pins every word, code and zone, and the blend arithmetic over a grid of
|
|
15
|
+
* candles, to the kit's own exports. What the chart fills for a market lives
|
|
16
|
+
* in wrun-chart-market-facts.util.
|
|
17
|
+
*
|
|
18
|
+
* The one rule every fact keeps: a host that does not know a fact writes 0.
|
|
19
|
+
* For the kind, the point value and the quote that 0 reads "unknown"; for the
|
|
20
|
+
* zone it is index 0, UTC, the clock every 24/7 market keeps; for the session
|
|
21
|
+
* open it is midnight, the trade day of every market off the CME family.
|
|
22
|
+
*/
|
|
23
|
+
/** The host_fill words of the five market facts, in declaration order
|
|
24
|
+
* (append-only): `market.<word>()` declares the hidden param `market_<word>`. */
|
|
25
|
+
export const WRUN_MARKET_FACT_FILLS = Object.freeze([
|
|
26
|
+
'kind',
|
|
27
|
+
'point_value',
|
|
28
|
+
'zone',
|
|
29
|
+
'quote_is_usd',
|
|
30
|
+
'session_open',
|
|
31
|
+
]);
|
|
32
|
+
/** `market.session_open()` on the CME family: its trade day opens at minute
|
|
33
|
+
* 1020 (17:00) on the Chicago clock, the evening before the date it is stamped
|
|
34
|
+
* with (the lattice of wrun-run-interval-session.util). Every other market
|
|
35
|
+
* reads 0, midnight. The kit's WRUN_MARKET_SESSION_OPEN_CME from 0.65.0. */
|
|
36
|
+
export const WRUN_MARKET_SESSION_OPEN_CME = 1020;
|
|
37
|
+
/** `market.kind()` codes: the code is the index (append-only). 0 is a market
|
|
38
|
+
* the host does not know, or none of these kinds (a prediction market, an
|
|
39
|
+
* energy or grain contract). A futures contract reports what it trades. */
|
|
40
|
+
export const WRUN_MARKET_KINDS = Object.freeze([
|
|
41
|
+
'unknown',
|
|
42
|
+
'crypto',
|
|
43
|
+
'stock',
|
|
44
|
+
'forex',
|
|
45
|
+
'metal',
|
|
46
|
+
'index',
|
|
47
|
+
'economic',
|
|
48
|
+
]);
|
|
49
|
+
/** `market.quote_is_usd()` codes, the index again: 1 priced in US dollars,
|
|
50
|
+
* 2 in another currency or coin (a dollar stablecoin included), 0 unknown. */
|
|
51
|
+
export const WRUN_MARKET_QUOTE_IS_USD = Object.freeze(['unknown', 'usd', 'other']);
|
|
52
|
+
/** The zones `market.zone()` indexes: param.session's zone list in order
|
|
53
|
+
* (append-only), each with its own daylight-saving rule. 0 is UTC. */
|
|
54
|
+
export const WRUN_MARKET_ZONES = Object.freeze([
|
|
55
|
+
'UTC',
|
|
56
|
+
'America/New_York',
|
|
57
|
+
'America/Chicago',
|
|
58
|
+
'Europe/London',
|
|
59
|
+
'Europe/Berlin',
|
|
60
|
+
'Asia/Tokyo',
|
|
61
|
+
'Asia/Hong_Kong',
|
|
62
|
+
'Asia/Singapore',
|
|
63
|
+
'Australia/Sydney',
|
|
64
|
+
'Asia/Kolkata',
|
|
65
|
+
'America/Los_Angeles',
|
|
66
|
+
'America/Toronto',
|
|
67
|
+
'America/Mexico_City',
|
|
68
|
+
'America/Sao_Paulo',
|
|
69
|
+
'America/Argentina/Buenos_Aires',
|
|
70
|
+
'Europe/Paris',
|
|
71
|
+
'Europe/Amsterdam',
|
|
72
|
+
'Europe/Zurich',
|
|
73
|
+
'Europe/Madrid',
|
|
74
|
+
'Europe/Rome',
|
|
75
|
+
'Europe/Stockholm',
|
|
76
|
+
'Europe/Oslo',
|
|
77
|
+
'Europe/Copenhagen',
|
|
78
|
+
'Europe/Warsaw',
|
|
79
|
+
'Europe/Helsinki',
|
|
80
|
+
'Europe/Athens',
|
|
81
|
+
'Europe/Istanbul',
|
|
82
|
+
'Europe/Moscow',
|
|
83
|
+
'Asia/Jerusalem',
|
|
84
|
+
'Asia/Riyadh',
|
|
85
|
+
'Asia/Dubai',
|
|
86
|
+
'Africa/Johannesburg',
|
|
87
|
+
'Asia/Karachi',
|
|
88
|
+
'Asia/Bangkok',
|
|
89
|
+
'Asia/Jakarta',
|
|
90
|
+
'Asia/Ho_Chi_Minh',
|
|
91
|
+
'Asia/Kuala_Lumpur',
|
|
92
|
+
'Asia/Shanghai',
|
|
93
|
+
'Asia/Taipei',
|
|
94
|
+
'Asia/Manila',
|
|
95
|
+
'Asia/Seoul',
|
|
96
|
+
'Pacific/Auckland',
|
|
97
|
+
]);
|
|
98
|
+
/** The `market.zone()` code of an IANA zone id: its index in
|
|
99
|
+
* WRUN_MARKET_ZONES, or 0 (UTC, the code of an unknown zone) for an id off
|
|
100
|
+
* the list. Exact match: `Etc/UTC` is off the list and reads 0, UTC anyway. */
|
|
101
|
+
export function wrunMarketZoneCode(zone) {
|
|
102
|
+
const index = WRUN_MARKET_ZONES.indexOf(zone);
|
|
103
|
+
return index < 0 ? 0 : index;
|
|
104
|
+
}
|
|
105
|
+
/** `market.size_unit()` codes (kit 0.68.0): the code is the index (append-only). 0 is a market none
|
|
106
|
+
* of the rules place (forex, a metal, an index, a market the host does not know). */
|
|
107
|
+
export const WRUN_MARKET_SIZE_UNITS = Object.freeze(['unknown', 'coins', 'shares', 'contracts']);
|
|
108
|
+
/** The contracts code, the one a lane's `currency: "Auto"` reads "Coin" on. */
|
|
109
|
+
const CONTRACTS_SIZE_UNIT = 3;
|
|
110
|
+
/** America/Chicago's zone code: the CME family's clock, which names a contract even where the
|
|
111
|
+
* host holds no multiplier for it. */
|
|
112
|
+
const CME_FAMILY_ZONE = 2;
|
|
113
|
+
/** A market's size unit from its `market.kind()`, `market.point_value()` and `market.zone()`
|
|
114
|
+
* codes, the kit's `wrunMarketSizeUnit` (sizeUnit in the kit's declare module), the first rule
|
|
115
|
+
* that holds: contracts (3) when the point value is a contract multiplier (a positive number
|
|
116
|
+
* other than 1) or the zone is Chicago; coins (1) on kind crypto; shares (2) on kind stock; else 0.
|
|
117
|
+
* The point value and the zone decide contracts, so contracts never wait on the directory row. */
|
|
118
|
+
export function wrunMarketSizeUnit(kind, pointValue, zone) {
|
|
119
|
+
const multiplier = Number.isFinite(pointValue) && pointValue > 0 && pointValue !== 1;
|
|
120
|
+
if (multiplier || zone === CME_FAMILY_ZONE)
|
|
121
|
+
return CONTRACTS_SIZE_UNIT;
|
|
122
|
+
if (kind === 1)
|
|
123
|
+
return 1;
|
|
124
|
+
if (kind === 2)
|
|
125
|
+
return 2;
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
/** The `currency` word of a `trades` or `volume_profile` lane whose unit follows the market the
|
|
129
|
+
* indicator runs on (kit 0.69.0, scaffold 69), beside "USD" and "Coin". */
|
|
130
|
+
export const WRUN_LANE_CURRENCY_AUTO = 'Auto';
|
|
131
|
+
/** The unit a lane's `currency` word reads on a market of size unit `sizeUnit`, the kit's
|
|
132
|
+
* `wrunLaneCurrency`: "Auto" reads "Coin" (the lane's native size, the contracts traded) on
|
|
133
|
+
* contracts and "USD" on every other market, one the host knows no facts for included; "USD",
|
|
134
|
+
* "Coin" and an absent word read as written. */
|
|
135
|
+
export function wrunLaneCurrency(currency, sizeUnit) {
|
|
136
|
+
if (currency !== WRUN_LANE_CURRENCY_AUTO)
|
|
137
|
+
return currency;
|
|
138
|
+
return sizeUnit === CONTRACTS_SIZE_UNIT ? 'Coin' : 'USD';
|
|
139
|
+
}
|
|
140
|
+
/** Whether a row declaring `visibleBy` (a setting's or an output's `visible_by`, kit 0.69.0) shows
|
|
141
|
+
* on a market of size unit `sizeUnit`, the kit's `wrunVisibleOnMarket`: always without the word,
|
|
142
|
+
* else only when its `size_unit` list names the code. A word holding no list (a malformed
|
|
143
|
+
* persisted row) reads as absent. The one predicate the settings dialog (its rows) and the run
|
|
144
|
+
* result (an output's plot and the stats rows drawn from it) ask. */
|
|
145
|
+
export function wrunRowVisibleHere(visibleBy, sizeUnit) {
|
|
146
|
+
const codes = visibleBy?.size_unit;
|
|
147
|
+
return !Array.isArray(codes) || codes.includes(sizeUnit);
|
|
148
|
+
}
|
|
149
|
+
/** Whether a `visible_by` list needs the market's kind to decide (the directory row on a crypto
|
|
150
|
+
* venue): it names some but not all of 0, 1 and 2, the units the kind tells apart. A list deciding
|
|
151
|
+
* on contracts alone (`[3]`, `[0, 1, 2]`) needs only the point value and the zone. */
|
|
152
|
+
export function wrunVisibleByNeedsKind(visibleBy) {
|
|
153
|
+
const codes = visibleBy?.size_unit;
|
|
154
|
+
if (!Array.isArray(codes))
|
|
155
|
+
return false;
|
|
156
|
+
const named = [0, 1, 2].filter((code) => codes.includes(code)).length;
|
|
157
|
+
return named > 0 && named < 3;
|
|
158
|
+
}
|
|
159
|
+
/** The coin-leg and setting-gate words of kit 0.77.0, the kit's own (`WRUN_FOLLOW_COIN`,
|
|
160
|
+
* `wrunFollowsCoin`, `wrunCoinLegSource`, `wrunInputGateOn`): a coin leg's source with `follow`
|
|
161
|
+
* resolved (a pin; null for an unlisted venue; undefined for no answer), and whether a `when`
|
|
162
|
+
* setting's run value turns its lane on. */
|
|
163
|
+
export const WRUN_FOLLOW_COIN = 'coin';
|
|
164
|
+
export function wrunFollowsCoin(source) {
|
|
165
|
+
return source.follow === WRUN_FOLLOW_COIN;
|
|
166
|
+
}
|
|
167
|
+
export function wrunCoinLegSource(source, coinLegs) {
|
|
168
|
+
if (!wrunFollowsCoin(source))
|
|
169
|
+
return source;
|
|
170
|
+
const venue = typeof source.exchange === 'string' ? source.exchange : '';
|
|
171
|
+
if (coinLegs === undefined || !Object.hasOwn(coinLegs, venue))
|
|
172
|
+
return undefined;
|
|
173
|
+
const symbol = coinLegs[venue];
|
|
174
|
+
if (symbol === null || symbol === undefined)
|
|
175
|
+
return null;
|
|
176
|
+
const { follow: _resolved, ...pinned } = source;
|
|
177
|
+
return { ...pinned, symbol };
|
|
178
|
+
}
|
|
179
|
+
export function wrunInputGateOn(gate, value) {
|
|
180
|
+
if (typeof gate.when !== 'string')
|
|
181
|
+
return true;
|
|
182
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
183
|
+
return true;
|
|
184
|
+
const bit = gate.when_bit;
|
|
185
|
+
if (typeof bit !== 'number' || !Number.isInteger(bit) || bit < 0)
|
|
186
|
+
return value !== 0;
|
|
187
|
+
return Math.floor(Math.abs(value) / 2 ** bit) % 2 === 1;
|
|
188
|
+
}
|
|
189
|
+
/** param.source's menu words in their frozen order: the `<name>_field`
|
|
190
|
+
* select stores the index, so a word is appended, never moved (hlcc4 joined
|
|
191
|
+
* at 8). A source default may be any of them. */
|
|
192
|
+
export const WRUN_SOURCE_FIELD_WORDS = Object.freeze([
|
|
193
|
+
'open',
|
|
194
|
+
'high',
|
|
195
|
+
'low',
|
|
196
|
+
'close',
|
|
197
|
+
'hl2',
|
|
198
|
+
'hlc3',
|
|
199
|
+
'ohlc4',
|
|
200
|
+
'volume',
|
|
201
|
+
'hlcc4',
|
|
202
|
+
]);
|
|
203
|
+
/** The source words no candle stores: every host derives them from the
|
|
204
|
+
* candle it serves the input (wrunSourceBlend). */
|
|
205
|
+
export const WRUN_SOURCE_BLEND_FIELDS = Object.freeze([
|
|
206
|
+
'hl2',
|
|
207
|
+
'hlc3',
|
|
208
|
+
'ohlc4',
|
|
209
|
+
'hlcc4',
|
|
210
|
+
]);
|
|
211
|
+
/** True for hl2, hlc3, ohlc4 and hlcc4. */
|
|
212
|
+
export function isWrunSourceBlendField(field) {
|
|
213
|
+
return typeof field === 'string' && WRUN_SOURCE_BLEND_FIELDS.includes(field);
|
|
214
|
+
}
|
|
215
|
+
/** One candle's blend for `field`, or undefined when `field` is not a blend
|
|
216
|
+
* word (the caller reads the stored field). The f64 arithmetic, left to
|
|
217
|
+
* right, is the contract every host computes so they agree to the bit:
|
|
218
|
+
* hl2 = (high + low) / 2, hlc3 = (high + low + close) / 3,
|
|
219
|
+
* ohlc4 = (open + high + low + close) / 4, hlcc4 = (high + low + close +
|
|
220
|
+
* close) / 4. NaN when a field the blend reads is not a finite number (a
|
|
221
|
+
* field it does not read, the open of an hl2, never matters). */
|
|
222
|
+
export function wrunSourceBlend(field, open, high, low, close) {
|
|
223
|
+
switch (field) {
|
|
224
|
+
case 'hl2':
|
|
225
|
+
return finite(high, low) ? (high + low) / 2 : Number.NaN;
|
|
226
|
+
case 'hlc3':
|
|
227
|
+
return finite(high, low, close) ? (high + low + close) / 3 : Number.NaN;
|
|
228
|
+
case 'ohlc4':
|
|
229
|
+
return finite(open, high, low, close) ? (open + high + low + close) / 4 : Number.NaN;
|
|
230
|
+
case 'hlcc4':
|
|
231
|
+
return finite(high, low, close) ? (high + low + close + close) / 4 : Number.NaN;
|
|
232
|
+
default:
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function finite(...values) {
|
|
237
|
+
return values.every((value) => typeof value === 'number' && Number.isFinite(value));
|
|
238
|
+
}
|