wickchart 1.7.0 → 2.0.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 +38 -16
- package/package.json +5 -4
- package/src/core.js +2590 -3012
- package/src/wick-chart.js +87 -935
- package/src/wick-feed.js +4 -12
- package/types/core.d.ts +4 -234
- package/types/wick-chart.d.ts +14 -263
- package/types/wick-feed.d.ts +2 -2
package/src/wick-feed.js
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
* streaming. Status is reflected in the `status` attribute and via
|
|
20
20
|
* `wick-feed:status` events (loading / live / polling / fallback / loaded /
|
|
21
21
|
* waiting / idle). `wick-feed:fallback` fires when a live source degrades.
|
|
22
|
-
* (The 0.x event names `hab-feed:*` still fire as deprecated aliases.)
|
|
23
22
|
* ========================================================================== */
|
|
24
23
|
|
|
25
24
|
import './wick-chart.js';
|
|
@@ -41,6 +40,7 @@ import {
|
|
|
41
40
|
normalizeTrades,
|
|
42
41
|
} from './feeds.js';
|
|
43
42
|
|
|
43
|
+
|
|
44
44
|
const LIVE_TICK_MS = 650;
|
|
45
45
|
|
|
46
46
|
const HTMLElementBase = typeof HTMLElement !== 'undefined' ? HTMLElement : class {};
|
|
@@ -99,21 +99,19 @@ class WickFeed extends HTMLElementBase {
|
|
|
99
99
|
this._fire('status', { status, ...detail });
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
/** Dispatch `wick-feed:name
|
|
102
|
+
/** Dispatch `wick-feed:name`. */
|
|
103
103
|
_fire(name, detail) {
|
|
104
104
|
this.dispatchEvent(new CustomEvent('wick-feed:' + name, { detail }));
|
|
105
|
-
this.dispatchEvent(new CustomEvent('hab-feed:' + name, { detail }));
|
|
106
105
|
}
|
|
107
|
-
|
|
108
106
|
/** Resolve the target chart (by `for` id, else the first chart element —
|
|
109
|
-
* <wick-chart>
|
|
107
|
+
* <wick-chart>). */
|
|
110
108
|
_resolveChart() {
|
|
111
109
|
const id = this.getAttribute('for');
|
|
112
110
|
if (id) {
|
|
113
111
|
const el = document.getElementById(id);
|
|
114
112
|
return el && (el.tagName === 'WICK-CHART' || el.tagName === 'HAB-CHART') ? el : null;
|
|
115
113
|
}
|
|
116
|
-
return document.querySelector('wick-chart')
|
|
114
|
+
return document.querySelector('wick-chart');
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
_restart() {
|
|
@@ -459,12 +457,6 @@ if (typeof customElements !== 'undefined') {
|
|
|
459
457
|
if (!customElements.get('wick-feed')) {
|
|
460
458
|
customElements.define('wick-feed', WickFeed);
|
|
461
459
|
}
|
|
462
|
-
// 0.x alias: same element under its old tag name (deprecated, removed in 2.0)
|
|
463
|
-
if (!customElements.get('hab-feed')) {
|
|
464
|
-
/** @deprecated use <wick-feed> */
|
|
465
|
-
class HabFeed extends WickFeed {}
|
|
466
|
-
customElements.define('hab-feed', HabFeed);
|
|
467
|
-
}
|
|
468
460
|
}
|
|
469
461
|
|
|
470
462
|
export default WickFeed;
|
package/types/core.d.ts
CHANGED
|
@@ -199,6 +199,9 @@ export declare const DAY: number;
|
|
|
199
199
|
* @returns {number} milliseconds
|
|
200
200
|
*/
|
|
201
201
|
export declare const toMs: (t: number | Date) => number;
|
|
202
|
+
/** Warn once per distinct message (used by the 2.0 moved-method stubs in
|
|
203
|
+
* wick-chart.js — deleted with them in 3.0). */
|
|
204
|
+
export declare function warnDeprecatedAlias(message: any): void;
|
|
202
205
|
/**
|
|
203
206
|
* Milliseconds east of UTC in `zone` at the instant `at`.
|
|
204
207
|
* 'utc' → 0
|
|
@@ -477,20 +480,6 @@ export declare function detectAnnotations(bars: Bar[], i0: number, i1: number, r
|
|
|
477
480
|
i: number;
|
|
478
481
|
note: string;
|
|
479
482
|
}>;
|
|
480
|
-
/**
|
|
481
|
-
* Map a price to a sonification frequency over the visible scale.
|
|
482
|
-
* Logarithmic scales map through log-space; result clamped to [lo, hi] Hz.
|
|
483
|
-
* @param {number} price
|
|
484
|
-
* @param {{min: number, max: number, useLog?: boolean}} scale
|
|
485
|
-
* @param {number} [freqLo=180]
|
|
486
|
-
* @param {number} [freqHi=880]
|
|
487
|
-
* @returns {number} frequency in Hz
|
|
488
|
-
*/
|
|
489
|
-
export declare function priceToFreq(price: number, scale: {
|
|
490
|
-
min: number;
|
|
491
|
-
max: number;
|
|
492
|
-
useLog?: boolean;
|
|
493
|
-
}, freqLo?: number, freqHi?: number): number;
|
|
494
483
|
/**
|
|
495
484
|
* Volume profile over a visible bar range: volume distributed into price
|
|
496
485
|
* rows, with POC and the value area (greedy expansion around the POC).
|
|
@@ -826,7 +815,7 @@ export declare function evalScript(compiled: {
|
|
|
826
815
|
/**
|
|
827
816
|
* Build an indicator definition from a WickScript expression — used inline by
|
|
828
817
|
* `indicators="expr:{…}"` / `pexpr:{…}"`, or register it under a name:
|
|
829
|
-
* `
|
|
818
|
+
* `WickChart.registerIndicator('myspread', scriptIndicator('close - ema(close,21)'))`.
|
|
830
819
|
* @param {string} src
|
|
831
820
|
* @param {{pane?: boolean}} [opts]
|
|
832
821
|
* @returns {IndicatorDef}
|
|
@@ -987,24 +976,6 @@ export declare function normalizeOverlays(list: any): object[];
|
|
|
987
976
|
* @returns {string} a concrete CSS color
|
|
988
977
|
*/
|
|
989
978
|
export declare function resolveOverlayColor(raw: any, pal: object): string;
|
|
990
|
-
/**
|
|
991
|
-
* σ-cone projection from realized per-bar volatility: price bands widening
|
|
992
|
-
* with √h (GBM-style, exp(±z·σ·√h)) over `horizon` future bars.
|
|
993
|
-
* @param {number} lastClose anchor price (bar 0)
|
|
994
|
-
* @param {number} volPerBar per-bar stddev of log returns (from calcRealizedVol)
|
|
995
|
-
* @param {number} horizon future bars (clamped 1–500, default 48)
|
|
996
|
-
* @param {number[]} [levels] σ multipliers, e.g. [1, 2] (each clamped to 0–5)
|
|
997
|
-
* @returns {{horizon: number, levels: number[], bands: Record<string, {up: number[], down: number[]}>}}
|
|
998
|
-
* bands[z].up/.down are arrays indexed by h = 0…horizon ([0] === lastClose)
|
|
999
|
-
*/
|
|
1000
|
-
export declare function calcVolCone(lastClose: number, volPerBar: number, horizon: number, levels?: number[]): {
|
|
1001
|
-
horizon: number;
|
|
1002
|
-
levels: number[];
|
|
1003
|
-
bands: Record<string, {
|
|
1004
|
-
up: number[];
|
|
1005
|
-
down: number[];
|
|
1006
|
-
}>;
|
|
1007
|
-
};
|
|
1008
979
|
/**
|
|
1009
980
|
* Validate a scenario spec: a ghost path of future prices (bars or API data)
|
|
1010
981
|
* plus optional cone settings. Invalid entries are dropped, never thrown.
|
|
@@ -1061,34 +1032,6 @@ export declare function normalizeRiskPlan(spec: any): null | {
|
|
|
1061
1032
|
maxK: number;
|
|
1062
1033
|
label: string;
|
|
1063
1034
|
};
|
|
1064
|
-
/**
|
|
1065
|
-
* Turn a bar window into an ordered story: the annotation events (pivot
|
|
1066
|
-
* highs/lows, volume spikes, gaps, RSI divergences) plus derived **legs** —
|
|
1067
|
-
* the move between consecutive opposite pivots ("+12.4% over 38 bars").
|
|
1068
|
-
* The timeline drives the bar-walk player and any caption UI.
|
|
1069
|
-
*
|
|
1070
|
-
* @param {Bar[]} bars full dataset
|
|
1071
|
-
* @param {number} i0 first index of the window
|
|
1072
|
-
* @param {number} i1 last index of the window
|
|
1073
|
-
* @param {{pivot?: number, volMult?: number, gapMult?: number, rsiPeriod?: number}} [opts]
|
|
1074
|
-
* pivot window defaults to 8 (denser than the annotations overlay's 20)
|
|
1075
|
-
* @returns {{i: number, time: number, type: string, side: string, note: string,
|
|
1076
|
-
* legPct?: number, legBars?: number}[]} sorted by index, capped at 60
|
|
1077
|
-
*/
|
|
1078
|
-
export declare function narrateWindow(bars: Bar[], i0: number, i1: number, opts?: {
|
|
1079
|
-
pivot?: number;
|
|
1080
|
-
volMult?: number;
|
|
1081
|
-
gapMult?: number;
|
|
1082
|
-
rsiPeriod?: number;
|
|
1083
|
-
}): {
|
|
1084
|
-
i: number;
|
|
1085
|
-
time: number;
|
|
1086
|
-
type: string;
|
|
1087
|
-
side: string;
|
|
1088
|
-
note: string;
|
|
1089
|
-
legPct?: number;
|
|
1090
|
-
legBars?: number;
|
|
1091
|
-
}[];
|
|
1092
1035
|
/**
|
|
1093
1036
|
* Stats for a brushed bar range: net move (open of the first bar → close
|
|
1094
1037
|
* of the last), extremes, and summed volume. Powers the brush-selection
|
|
@@ -1120,72 +1063,6 @@ export declare function brushStats(bars: Bar[], i0: number, i1: number): null |
|
|
|
1120
1063
|
low: number;
|
|
1121
1064
|
volume: number;
|
|
1122
1065
|
};
|
|
1123
|
-
/** Smoothest cheap easing for viewport pans: slow in, slow out. */
|
|
1124
|
-
export declare function easeInOutCubic(t: any): number;
|
|
1125
|
-
/**
|
|
1126
|
-
* Validate one story scene. Every field is optional except that a scene
|
|
1127
|
-
* must be an object; omitted fields simply don't change that aspect of
|
|
1128
|
-
* the chart when played. `scenario`/`riskPlan` use a 'clear' sentinel for
|
|
1129
|
-
* explicit "remove it" (null input means clear too when the KEY is present).
|
|
1130
|
-
*
|
|
1131
|
-
* { title: 'The breakout', note: 'What happened…',
|
|
1132
|
-
* range: { from, to }, // times (s or ms) — the camera pans there
|
|
1133
|
-
* indicators: 'sma:20 rsi:14', // optional indicator string
|
|
1134
|
-
* type: 'candles', // optional series type
|
|
1135
|
-
* overlays: [...], // optional zones/levels (normalizeOverlays)
|
|
1136
|
-
* scenario: {...} | null, // set / clear a scenario
|
|
1137
|
-
* riskPlan: {...} | null, // set / clear a risk plan
|
|
1138
|
-
* dwell: 2200 } // ms to hold after the pan (500–30000)
|
|
1139
|
-
*
|
|
1140
|
-
* @returns {object|null} normalized scene, or null for non-objects
|
|
1141
|
-
*/
|
|
1142
|
-
export declare function normalizeScene(scene: any): object | null;
|
|
1143
|
-
/**
|
|
1144
|
-
* Validate a whole story: normalize each scene, drop junk, cap at 20.
|
|
1145
|
-
* @returns {object[]} possibly empty
|
|
1146
|
-
*/
|
|
1147
|
-
export declare function sceneList(story: any): object[];
|
|
1148
|
-
/**
|
|
1149
|
-
* Tracks other charts viewing the same room: last-sighting timestamps per
|
|
1150
|
-
* peer plus the viewport each one is looking at. Pure bookkeeping — the
|
|
1151
|
-
* transport (BroadcastChannel, WebSocket, …) lives in the component/app.
|
|
1152
|
-
*
|
|
1153
|
-
* Peers expire `ttl` ms after their last sighting, so a closed tab fades
|
|
1154
|
-
* out of the room without an explicit goodbye.
|
|
1155
|
-
*/
|
|
1156
|
-
export declare class PresenceTracker {
|
|
1157
|
-
ttl: number;
|
|
1158
|
-
/** @type {Map<string, {id: string, name: string|null, range: {from:number,to:number}|null, at: number}>} */
|
|
1159
|
-
peers: Map<string, {
|
|
1160
|
-
id: string;
|
|
1161
|
-
name: string | null;
|
|
1162
|
-
range: {
|
|
1163
|
-
from: number;
|
|
1164
|
-
to: number;
|
|
1165
|
-
} | null;
|
|
1166
|
-
at: number;
|
|
1167
|
-
}>;
|
|
1168
|
-
/** @param {number} [ttl=12000] ms a peer survives without a sighting */
|
|
1169
|
-
constructor(ttl?: number);
|
|
1170
|
-
/**
|
|
1171
|
-
* Record a sighting. `patch.range` ({from,to} times) is validated and
|
|
1172
|
-
* normalized; a sighting without a range keeps the previous one.
|
|
1173
|
-
* @returns {boolean} true when this sighting is a join (new peer)
|
|
1174
|
-
*/
|
|
1175
|
-
track(id: any, patch?: {}, now?: number): boolean;
|
|
1176
|
-
/** @returns {object|null} the removed peer entry, or null when unknown */
|
|
1177
|
-
drop(id: any): object | null;
|
|
1178
|
-
/** Expire peers not seen within the ttl.
|
|
1179
|
-
* @returns {object[]} the peer entries that left */
|
|
1180
|
-
sweep(now?: number): object[];
|
|
1181
|
-
/** @returns {{id: string, name: string|null, range: object|null, at: number}[]} copies, oldest sighting first */
|
|
1182
|
-
list(): {
|
|
1183
|
-
id: string;
|
|
1184
|
-
name: string | null;
|
|
1185
|
-
range: object | null;
|
|
1186
|
-
at: number;
|
|
1187
|
-
}[];
|
|
1188
|
-
}
|
|
1189
1066
|
export declare const tfLabelOf: (dtMs: any) => string;
|
|
1190
1067
|
/**
|
|
1191
1068
|
* Compact, LLM-friendly summary of a bar window: structured fields plus a
|
|
@@ -1215,110 +1092,3 @@ export declare function encodeStateQuery(state: ChartState | null): string;
|
|
|
1215
1092
|
* @returns {ChartState}
|
|
1216
1093
|
*/
|
|
1217
1094
|
export declare function decodeStateQuery(str: string): ChartState;
|
|
1218
|
-
/**
|
|
1219
|
-
* Tool manifest for LLM/agent control of a chart. Tools map 1:1 onto the
|
|
1220
|
-
* public element API; every op through applyChartOps is validated before it
|
|
1221
|
-
* touches the chart (LLM output is untrusted input).
|
|
1222
|
-
*/
|
|
1223
|
-
export declare const AI_TOOLS: ({
|
|
1224
|
-
tool: string;
|
|
1225
|
-
description: string;
|
|
1226
|
-
args: {
|
|
1227
|
-
indicators?: undefined;
|
|
1228
|
-
overlays?: undefined;
|
|
1229
|
-
from?: undefined;
|
|
1230
|
-
to?: undefined;
|
|
1231
|
-
type?: undefined;
|
|
1232
|
-
enabled?: undefined;
|
|
1233
|
-
low?: undefined;
|
|
1234
|
-
high?: undefined;
|
|
1235
|
-
};
|
|
1236
|
-
} | {
|
|
1237
|
-
tool: string;
|
|
1238
|
-
description: string;
|
|
1239
|
-
args: {
|
|
1240
|
-
indicators: string;
|
|
1241
|
-
overlays?: undefined;
|
|
1242
|
-
from?: undefined;
|
|
1243
|
-
to?: undefined;
|
|
1244
|
-
type?: undefined;
|
|
1245
|
-
enabled?: undefined;
|
|
1246
|
-
low?: undefined;
|
|
1247
|
-
high?: undefined;
|
|
1248
|
-
};
|
|
1249
|
-
} | {
|
|
1250
|
-
tool: string;
|
|
1251
|
-
description: string;
|
|
1252
|
-
args: {
|
|
1253
|
-
indicators?: undefined;
|
|
1254
|
-
overlays: string;
|
|
1255
|
-
from?: undefined;
|
|
1256
|
-
to?: undefined;
|
|
1257
|
-
type?: undefined;
|
|
1258
|
-
enabled?: undefined;
|
|
1259
|
-
low?: undefined;
|
|
1260
|
-
high?: undefined;
|
|
1261
|
-
};
|
|
1262
|
-
} | {
|
|
1263
|
-
tool: string;
|
|
1264
|
-
description: string;
|
|
1265
|
-
args: {
|
|
1266
|
-
indicators?: undefined;
|
|
1267
|
-
overlays?: undefined;
|
|
1268
|
-
from: string;
|
|
1269
|
-
to: string;
|
|
1270
|
-
type?: undefined;
|
|
1271
|
-
enabled?: undefined;
|
|
1272
|
-
low?: undefined;
|
|
1273
|
-
high?: undefined;
|
|
1274
|
-
};
|
|
1275
|
-
} | {
|
|
1276
|
-
tool: string;
|
|
1277
|
-
description: string;
|
|
1278
|
-
args: {
|
|
1279
|
-
indicators?: undefined;
|
|
1280
|
-
overlays?: undefined;
|
|
1281
|
-
from?: undefined;
|
|
1282
|
-
to?: undefined;
|
|
1283
|
-
type: string;
|
|
1284
|
-
enabled?: undefined;
|
|
1285
|
-
low?: undefined;
|
|
1286
|
-
high?: undefined;
|
|
1287
|
-
};
|
|
1288
|
-
} | {
|
|
1289
|
-
tool: string;
|
|
1290
|
-
description: string;
|
|
1291
|
-
args: {
|
|
1292
|
-
indicators?: undefined;
|
|
1293
|
-
overlays?: undefined;
|
|
1294
|
-
from?: undefined;
|
|
1295
|
-
to?: undefined;
|
|
1296
|
-
type?: undefined;
|
|
1297
|
-
enabled: string;
|
|
1298
|
-
low: string;
|
|
1299
|
-
high: string;
|
|
1300
|
-
};
|
|
1301
|
-
})[];
|
|
1302
|
-
/**
|
|
1303
|
-
* Compact system prompt for agent control: paste into any LLM alongside the
|
|
1304
|
-
* tool manifest. The model answers with a JSON array of {tool, args} ops.
|
|
1305
|
-
* @returns {string}
|
|
1306
|
-
*/
|
|
1307
|
-
export declare function aiPromptText(): string;
|
|
1308
|
-
/**
|
|
1309
|
-
* Validate + apply a list of {tool, args} ops (typically LLM output) to a
|
|
1310
|
-
* chart-like target. Ops are whitelisted and their args validated — an op
|
|
1311
|
-
* never throws; it returns {ok: false, error} instead so the agent can
|
|
1312
|
-
* self-correct. Target contract: getDataWindow(), setAttribute(k, v),
|
|
1313
|
-
* setOverlays(list), clearOverlays(), addAlert(a), setVisibleRange(r),
|
|
1314
|
-
* fit(), and (static) _registry() for indicator name checks.
|
|
1315
|
-
* @param {object} target chart element (or test double)
|
|
1316
|
-
* @param {any} ops
|
|
1317
|
-
* @returns {Array<{ok: boolean, tool?: string, result?: any, error?: string}>}
|
|
1318
|
-
*/
|
|
1319
|
-
export declare function applyChartOps(target: object, ops: any): Array<{
|
|
1320
|
-
ok: boolean;
|
|
1321
|
-
tool?: string;
|
|
1322
|
-
result?: any;
|
|
1323
|
-
error?: string;
|
|
1324
|
-
}>;
|
package/types/wick-chart.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PresenceTracker } from './core.js';
|
|
2
1
|
declare const HTMLElementBase: {
|
|
3
2
|
new (): {};
|
|
4
3
|
};
|
|
@@ -22,10 +21,6 @@ declare class WickChart extends HTMLElementBase {
|
|
|
22
21
|
index: any;
|
|
23
22
|
x: number;
|
|
24
23
|
y: any;
|
|
25
|
-
} | {
|
|
26
|
-
index: number;
|
|
27
|
-
x: number;
|
|
28
|
-
y: number;
|
|
29
24
|
};
|
|
30
25
|
_dt: number;
|
|
31
26
|
_ly: {
|
|
@@ -103,24 +98,13 @@ declare class WickChart extends HTMLElementBase {
|
|
|
103
98
|
p2: number;
|
|
104
99
|
period: number;
|
|
105
100
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
_coviewPeer: string;
|
|
109
|
-
_coviewLast: number;
|
|
110
|
-
_ghost: {
|
|
111
|
-
index: number;
|
|
112
|
-
yFrac: any;
|
|
113
|
-
at: number;
|
|
114
|
-
};
|
|
101
|
+
_coviewCh: any;
|
|
102
|
+
_ghost: any;
|
|
115
103
|
_ghostTimer: number;
|
|
116
|
-
|
|
117
|
-
_presence: PresenceTracker;
|
|
104
|
+
_presence: any;
|
|
118
105
|
_coviewBeat: number;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
_actx: any;
|
|
122
|
-
_lastToneIdx: number;
|
|
123
|
-
_playToken: number;
|
|
106
|
+
_scenario: any;
|
|
107
|
+
_riskPlan: any;
|
|
124
108
|
_measure: {
|
|
125
109
|
iA: any;
|
|
126
110
|
pA: number;
|
|
@@ -129,9 +113,6 @@ declare class WickChart extends HTMLElementBase {
|
|
|
129
113
|
done: boolean;
|
|
130
114
|
};
|
|
131
115
|
_measuring: boolean;
|
|
132
|
-
_walkTimer: number;
|
|
133
|
-
_storyToken: number;
|
|
134
|
-
_story: object[];
|
|
135
116
|
_brush: boolean;
|
|
136
117
|
_brushSel: {
|
|
137
118
|
i0: number;
|
|
@@ -212,29 +193,6 @@ declare class WickChart extends HTMLElementBase {
|
|
|
212
193
|
_tz: string;
|
|
213
194
|
_vwapAnchor: string;
|
|
214
195
|
_overlays: any[];
|
|
215
|
-
_scenario: {
|
|
216
|
-
path: {
|
|
217
|
-
h: number;
|
|
218
|
-
price: number;
|
|
219
|
-
}[];
|
|
220
|
-
horizon: number;
|
|
221
|
-
cone: boolean;
|
|
222
|
-
levels: number[];
|
|
223
|
-
color: string | null;
|
|
224
|
-
label: string;
|
|
225
|
-
};
|
|
226
|
-
_riskPlan: {
|
|
227
|
-
entry: number;
|
|
228
|
-
stop: number;
|
|
229
|
-
risk: number;
|
|
230
|
-
direction: 'long' | 'short';
|
|
231
|
-
levels: {
|
|
232
|
-
k: number;
|
|
233
|
-
price: number;
|
|
234
|
-
}[];
|
|
235
|
-
maxK: number;
|
|
236
|
-
label: string;
|
|
237
|
-
};
|
|
238
196
|
_onResize: () => void;
|
|
239
197
|
_onPointerDown: (e: any) => void;
|
|
240
198
|
_onPointerMove: (e: any) => void;
|
|
@@ -533,8 +491,7 @@ declare class WickChart extends HTMLElementBase {
|
|
|
533
491
|
*/
|
|
534
492
|
/** @param {import('./core.js').IndicatorDef} def */
|
|
535
493
|
static registerIndicator(name: any, def: import('./core.js').IndicatorDef): void;
|
|
536
|
-
/** The tag this class registers as.
|
|
537
|
-
* registered from the HabChart subclass, not this name.) */
|
|
494
|
+
/** The tag this class registers as. */
|
|
538
495
|
static get elementName(): string;
|
|
539
496
|
get data(): any[];
|
|
540
497
|
/**
|
|
@@ -615,8 +572,7 @@ declare class WickChart extends HTMLElementBase {
|
|
|
615
572
|
* WickScript predicate (`when`) on every streamed bar and fire on its
|
|
616
573
|
* false→true edge — e.g. `when: 'crossup(rsi(close,14), 30)'` or
|
|
617
574
|
* `when: 'volume > sma(volume,20) * 3'`. Scripted events carry the
|
|
618
|
-
* triggering close as `price` plus the `when` source
|
|
619
|
-
* `hab:alert` alias still dispatched).
|
|
575
|
+
* triggering close as `price` plus the `when` source.
|
|
620
576
|
* @param {{id?: string, price?: number, direction?: 'above'|'below'|'cross',
|
|
621
577
|
* when?: string, once?: boolean}} alert
|
|
622
578
|
* @returns {string|null} the alert id (null when no valid price/when,
|
|
@@ -656,96 +612,13 @@ declare class WickChart extends HTMLElementBase {
|
|
|
656
612
|
addOverlay(ov: any): string | null;
|
|
657
613
|
removeOverlay(id: any): void;
|
|
658
614
|
clearOverlays(): void;
|
|
659
|
-
/**
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
* chart.setScenario({ path: [64000, 65500, 68000], label: 'bull case' });
|
|
664
|
-
* chart.setScenario({ horizon: 48, cone: true }); // cone-only
|
|
665
|
-
*
|
|
666
|
-
* The path is an array of prices (or {price} objects) for future bars
|
|
667
|
-
* 1..N; horizon defaults to the path length (1–500). `cone` (default
|
|
668
|
-
* true) draws ±levels·σ bands widening with √h from the current realized
|
|
669
|
-
* vol; `color` accepts up|down|accent or safe CSS colors. Setting a
|
|
670
|
-
* scenario reserves future space on the right; analysis data — excluded
|
|
671
|
-
* from getState/setState.
|
|
672
|
-
* @param {object} spec
|
|
673
|
-
* @returns {object|null} the normalized scenario, or null when invalid
|
|
674
|
-
*/
|
|
675
|
-
setScenario(spec: object): object | null;
|
|
676
|
-
clearScenario(): void;
|
|
677
|
-
/** @returns {object|null} a copy of the active scenario */
|
|
615
|
+
/** @returns {object|null} a copy of the active scenario (set through the
|
|
616
|
+
* `_scenario` seam by the wickchart-scenario plugin; reserves future
|
|
617
|
+
* space via _rightMargin) */
|
|
678
618
|
get scenario(): object | null;
|
|
679
|
-
/**
|
|
680
|
-
*
|
|
681
|
-
* stop| (the risk unit); reward lines are drawn at kR beyond the entry
|
|
682
|
-
* with the risk/reward zones shaded, so sizing and take-profit choices
|
|
683
|
-
* read directly off the chart.
|
|
684
|
-
*
|
|
685
|
-
* chart.setRiskPlan({ entry: 64500, stop: 63800, multiples: [1, 2, 3] });
|
|
686
|
-
* chart.setRiskPlan({ entry: 64500, stop: 63800, targets: [65900, 67300] });
|
|
687
|
-
*
|
|
688
|
-
* Direction is derived (stop below entry ⇒ long). Targets convert to
|
|
689
|
-
* their R multiple; `multiples` win when both are given. Invalid specs
|
|
690
|
-
* clear the plan (replace semantics, like setScenario); excluded from
|
|
691
|
-
* getState/setState — it is app state, not chart state.
|
|
692
|
-
* @param {object} spec
|
|
693
|
-
* @returns {object|null} the normalized plan, or null when invalid
|
|
694
|
-
*/
|
|
695
|
-
setRiskPlan(spec: object): object | null;
|
|
696
|
-
clearRiskPlan(): void;
|
|
697
|
-
/** @returns {object|null} a copy of the active risk plan */
|
|
619
|
+
/** @returns {object|null} a copy of the active risk plan (set through
|
|
620
|
+
* the `_riskPlan` seam by the wickchart-scenario plugin) */
|
|
698
621
|
get riskPlan(): object | null;
|
|
699
|
-
/** σ-cone for the active scenario, cached per data version. */
|
|
700
|
-
_scenarioConeCache(): any;
|
|
701
|
-
/** Tool manifest for LLM control — JSON-safe copy of AI_TOOLS. */
|
|
702
|
-
aiTools(): any;
|
|
703
|
-
/** System prompt for agent control — paste into any LLM alongside aiTools(). */
|
|
704
|
-
aiPrompt(): string;
|
|
705
|
-
/** Grounding context for a model: current state + visible-window summary. */
|
|
706
|
-
aiContext(): {
|
|
707
|
-
state: import("./core.js").ChartState;
|
|
708
|
-
window: object;
|
|
709
|
-
};
|
|
710
|
-
/**
|
|
711
|
-
* Apply a list of {tool, args} ops (typically LLM output) through the
|
|
712
|
-
* validated dispatcher in core. Never throws — each op resolves
|
|
713
|
-
* {ok, tool, result} or {ok: false, tool, error} so an agent can
|
|
714
|
-
* self-correct.
|
|
715
|
-
* @param {any} ops
|
|
716
|
-
* @returns {Array<object>}
|
|
717
|
-
*/
|
|
718
|
-
applyAI(ops: any): Array<object>;
|
|
719
|
-
/**
|
|
720
|
-
* Ask an AI to operate the chart. Builds the payload {system,
|
|
721
|
-
* instruction, chart, tools}; with a `run` async function (your model
|
|
722
|
-
* call — the chart itself never touches the network), applies the
|
|
723
|
-
* returned ops and resolves {payload, ops, results}. Without `run`,
|
|
724
|
-
* returns the payload for manual wiring — send it anywhere, then call
|
|
725
|
-
* chart.applyAI(ops) with the model's answer.
|
|
726
|
-
*
|
|
727
|
-
* const { results } = await chart.ask('add RSI and mark the demand zone', {
|
|
728
|
-
* run: async (payload) => (await callMyLLM(payload)).ops,
|
|
729
|
-
* });
|
|
730
|
-
*
|
|
731
|
-
* @param {string} instruction natural-language request
|
|
732
|
-
* @param {{run?: (payload: object) => Promise<any>}} [opts]
|
|
733
|
-
*/
|
|
734
|
-
ask(instruction: string, opts?: {
|
|
735
|
-
run?: (payload: object) => Promise<any>;
|
|
736
|
-
}): Promise<{
|
|
737
|
-
payload: {
|
|
738
|
-
system: string;
|
|
739
|
-
instruction: string;
|
|
740
|
-
chart: {
|
|
741
|
-
state: import("./core.js").ChartState;
|
|
742
|
-
window: object;
|
|
743
|
-
};
|
|
744
|
-
tools: any;
|
|
745
|
-
};
|
|
746
|
-
ops: any;
|
|
747
|
-
results: object[];
|
|
748
|
-
}>;
|
|
749
622
|
/** Check alerts against an incoming bar (prev close → new close).
|
|
750
623
|
* Scripted (`when`) alerts evaluate their predicate series, cached per
|
|
751
624
|
* data version, and fire on the false→true edge. */
|
|
@@ -980,84 +853,11 @@ declare class WickChart extends HTMLElementBase {
|
|
|
980
853
|
_pointerMove(e: any): void;
|
|
981
854
|
_pointerUp(e: any): void;
|
|
982
855
|
_yToPrice(y: any): number;
|
|
856
|
+
/** Dispatch a `wick:name` event on the element. */
|
|
857
|
+
_fire(name: any, detail: any): void;
|
|
983
858
|
_wheel(e: any): void;
|
|
984
859
|
_keydown(e: any): void;
|
|
985
|
-
/** Lazily-created shared AudioContext (enable within a user gesture). */
|
|
986
|
-
_audio(): any;
|
|
987
|
-
/** Short sine blip; `when` schedules against AudioContext time. */
|
|
988
|
-
_tone(freq: any, dur?: number, when?: number): void;
|
|
989
|
-
/** One tone for a bar's close, pitched by its position on the y-scale. */
|
|
990
|
-
_sonifyBar(i: any): void;
|
|
991
|
-
/** One tone per crosshair bar change (dedupes y-only moves). */
|
|
992
|
-
_maybeSonify(idx: any): void;
|
|
993
|
-
/**
|
|
994
|
-
* Play the visible range as a pitch sweep (~4s), riding the crosshair —
|
|
995
|
-
* the audible equivalent of running your eye along the price line.
|
|
996
|
-
*/
|
|
997
|
-
playRange(): void;
|
|
998
860
|
_emitCrosshair(hover: any): void;
|
|
999
|
-
/** Join/leave the co-view channel named by the `co-view` attribute. */
|
|
1000
|
-
_setupCoView(): void;
|
|
1001
|
-
/** Broadcast our visible range for presence; throttled unless forced. */
|
|
1002
|
-
_coviewSendView(force: any): void;
|
|
1003
|
-
_coviewSend(msg: any): void;
|
|
1004
|
-
_onCoMessage(m: any): void;
|
|
1005
|
-
/** Dispatch `wick:name` (canonical) plus the deprecated `hab:name` alias,
|
|
1006
|
-
* so 0.x listeners keep working until 2.0. */
|
|
1007
|
-
_fire(name: any, detail: any): void;
|
|
1008
|
-
/**
|
|
1009
|
-
* Live co-view peers: who else is in the room and the time window each
|
|
1010
|
-
* one is looking at — [{ id, name, range: {from, to}, at }], oldest
|
|
1011
|
-
* sighting first. Peers fade out ~12 s after their last sighting.
|
|
1012
|
-
* @returns {object[]}
|
|
1013
|
-
*/
|
|
1014
|
-
getPeers(): object[];
|
|
1015
|
-
/**
|
|
1016
|
-
* Narrated timeline for a window (default: the visible range) — pivot
|
|
1017
|
-
* highs/lows, volume spikes, gaps, RSI divergences plus derived legs
|
|
1018
|
-
* ("+12.4% over 38 bars"), sorted by index. Pure data, perfect for
|
|
1019
|
-
* caption UIs or the walk player.
|
|
1020
|
-
* chart.narrate(); // visible range
|
|
1021
|
-
* chart.narrate({ from, to }); // times in ms (s accepted)
|
|
1022
|
-
* @param {{from?: number, to?: number}} [range]
|
|
1023
|
-
* @returns {{i: number, time: number, type: string, side: string, note: string,
|
|
1024
|
-
* legPct?: number, legBars?: number}[]}
|
|
1025
|
-
*/
|
|
1026
|
-
narrate(range?: {
|
|
1027
|
-
from?: number;
|
|
1028
|
-
to?: number;
|
|
1029
|
-
}): {
|
|
1030
|
-
i: number;
|
|
1031
|
-
time: number;
|
|
1032
|
-
type: string;
|
|
1033
|
-
side: string;
|
|
1034
|
-
note: string;
|
|
1035
|
-
legPct?: number;
|
|
1036
|
-
legBars?: number;
|
|
1037
|
-
}[];
|
|
1038
|
-
/**
|
|
1039
|
-
* Walk the chart through history like a story: the viewport slides
|
|
1040
|
-
* from `from` to `to` while `wick:walk` events announce every step and
|
|
1041
|
-
* the narrator's events (spikes, gaps, pivots, legs) as they're crossed.
|
|
1042
|
-
* Any user interaction — pointer, wheel, keys, double-click — stops it.
|
|
1043
|
-
* chart.walk({ from: 0, to: 500, speed: 120, step: 10 });
|
|
1044
|
-
* chart.addEventListener('wick:walk', (e) => showCaption(e.detail));
|
|
1045
|
-
* // detail: { phase: 'step'|'end'|'stop', index, events: [...], from, to }
|
|
1046
|
-
* @param {{from?: number, to?: number, speed?: number, step?: number}} [opts]
|
|
1047
|
-
* from/to are bar indices (default: last ~500 bars → the end)
|
|
1048
|
-
* @returns {boolean} true when the walk started
|
|
1049
|
-
*/
|
|
1050
|
-
walk(opts?: {
|
|
1051
|
-
from?: number;
|
|
1052
|
-
to?: number;
|
|
1053
|
-
speed?: number;
|
|
1054
|
-
step?: number;
|
|
1055
|
-
}): boolean;
|
|
1056
|
-
/**
|
|
1057
|
-
* Stop the running walk (if any). Fires a final `wick:walk`
|
|
1058
|
-
* { phase: 'stop' } unless called internally.
|
|
1059
|
-
*/
|
|
1060
|
-
stopWalk(silent: any): void;
|
|
1061
861
|
/**
|
|
1062
862
|
* Commit a brush selection over [i0, i1]: stores it (draws the band
|
|
1063
863
|
* and delta chip) and fires `wick:brush` with the range statistics.
|
|
@@ -1069,55 +869,6 @@ declare class WickChart extends HTMLElementBase {
|
|
|
1069
869
|
clearBrush(): void;
|
|
1070
870
|
/** @returns {object|null} the committed selection { i0, i1, stats } */
|
|
1071
871
|
get brushSelection(): object | null;
|
|
1072
|
-
/**
|
|
1073
|
-
* Capture the current chart state as a story scene: view, series type,
|
|
1074
|
-
* indicators, overlays, scenario and risk plan, plus a title/note.
|
|
1075
|
-
* Build guided tours by capturing several and playing them back.
|
|
1076
|
-
* const story = [
|
|
1077
|
-
* chart.captureScene('Overview', 'The full picture'),
|
|
1078
|
-
* { title: 'The breakout', range: { from, to }, indicators: 'sma:20' },
|
|
1079
|
-
* ];
|
|
1080
|
-
* chart.playStory(story);
|
|
1081
|
-
* @param {string} [title]
|
|
1082
|
-
* @param {string} [note]
|
|
1083
|
-
* @returns {object} scene (plain data — snapshot of the moment)
|
|
1084
|
-
*/
|
|
1085
|
-
captureScene(title?: string, note?: string): object;
|
|
1086
|
-
/** @returns {object[]|null} a copy of the last played story */
|
|
1087
|
-
getStory(): object[] | null;
|
|
1088
|
-
/**
|
|
1089
|
-
* Play a story: each scene applies its state (type / indicators /
|
|
1090
|
-
* overlays / scenario / risk plan — set or clear), the camera eases
|
|
1091
|
-
* to its range, then holds for its dwell. `wick:story` events narrate:
|
|
1092
|
-
* { phase: 'scene' | 'end' | 'stop', index, total, scene, title, note }
|
|
1093
|
-
* Any user interaction — pointer, wheel, keys, double-click — stops it.
|
|
1094
|
-
* @param {object[]} story scenes (invalid entries dropped, max 20)
|
|
1095
|
-
* @param {{dwell?: number, panMs?: number, loop?: boolean}} [opts]
|
|
1096
|
-
* panMs clamps 100–5000 (default 900); loop replays forever
|
|
1097
|
-
* @returns {boolean} true when playback started
|
|
1098
|
-
*/
|
|
1099
|
-
playStory(story: object[], opts?: {
|
|
1100
|
-
dwell?: number;
|
|
1101
|
-
panMs?: number;
|
|
1102
|
-
loop?: boolean;
|
|
1103
|
-
}): boolean;
|
|
1104
|
-
/**
|
|
1105
|
-
* Stop story playback (if running). Fires a final `wick:story`
|
|
1106
|
-
* { phase: 'stop' } unless called internally.
|
|
1107
|
-
*/
|
|
1108
|
-
stopStory(silent: any): void;
|
|
1109
|
-
/** Apply a scene's state (only the fields it carries). */
|
|
1110
|
-
_applyScene(sc: any): void;
|
|
1111
|
-
/** Map a scene's time range to bar indices (null when not applicable). */
|
|
1112
|
-
_sceneTarget(sc: any): {
|
|
1113
|
-
i0: number;
|
|
1114
|
-
i1: number;
|
|
1115
|
-
};
|
|
1116
|
-
/** Ease the viewport to { i0, i1 } over `ms`; resolves early if the
|
|
1117
|
-
* token changes (superseded or stopped). rAF when available. */
|
|
1118
|
-
_storyTween(target: any, ms: any, token: any): Promise<any>;
|
|
1119
|
-
/** Interrupt narrated playback (walk / story) on user input. */
|
|
1120
|
-
_stopPlayback(): void;
|
|
1121
872
|
_emitRange(): void;
|
|
1122
873
|
}
|
|
1123
874
|
export default WickChart;
|
package/types/wick-feed.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ declare class WickFeed extends HTMLElementBase {
|
|
|
15
15
|
_scheduleRestart(): void;
|
|
16
16
|
_teardown(): void;
|
|
17
17
|
_setStatus(status: any, detail: any): void;
|
|
18
|
-
/** Dispatch `wick-feed:name
|
|
18
|
+
/** Dispatch `wick-feed:name`. */
|
|
19
19
|
_fire(name: any, detail: any): void;
|
|
20
20
|
/** Resolve the target chart (by `for` id, else the first chart element —
|
|
21
|
-
* <wick-chart>
|
|
21
|
+
* <wick-chart>). */
|
|
22
22
|
_resolveChart(): Element;
|
|
23
23
|
_restart(): void;
|
|
24
24
|
_synthetic(gen: any, chart: any, key: any, tfId: any, limit: any, live: any, status?: string): void;
|