wickchart 0.4.0 → 1.2.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 +274 -48
- package/package.json +29 -12
- package/src/core.js +452 -12
- package/src/feeds.js +1 -1
- package/src/react-core.js +191 -0
- package/src/react.js +21 -0
- package/src/{hab-chart.js → wick-chart.js} +525 -111
- package/src/{hab-feed.js → wick-feed.js} +34 -19
- package/types/core.d.ts +209 -3
- package/types/react-core.d.ts +64 -0
- package/types/react.d.ts +3 -0
- package/types/{hab-chart.d.ts → wick-chart.d.ts} +215 -13
- package/types/{hab-feed.d.ts → wick-feed.d.ts} +8 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const HTMLElementBase: {
|
|
2
2
|
new (): {};
|
|
3
3
|
};
|
|
4
|
-
declare class
|
|
4
|
+
declare class WickChart extends HTMLElementBase {
|
|
5
5
|
_canvas: any;
|
|
6
6
|
_ctx: any;
|
|
7
7
|
_legend: any;
|
|
@@ -142,6 +142,18 @@ declare class HabChart extends HTMLElementBase {
|
|
|
142
142
|
_positions: any[];
|
|
143
143
|
_alerts: any[];
|
|
144
144
|
_seq: number;
|
|
145
|
+
_overlays: any[];
|
|
146
|
+
_scenario: {
|
|
147
|
+
path: {
|
|
148
|
+
h: number;
|
|
149
|
+
price: number;
|
|
150
|
+
}[];
|
|
151
|
+
horizon: number;
|
|
152
|
+
cone: boolean;
|
|
153
|
+
levels: number[];
|
|
154
|
+
color: string | null;
|
|
155
|
+
label: string;
|
|
156
|
+
};
|
|
145
157
|
_onResize: () => void;
|
|
146
158
|
_onPointerDown: (e: any) => void;
|
|
147
159
|
_onPointerMove: (e: any) => void;
|
|
@@ -172,13 +184,93 @@ declare class HabChart extends HTMLElementBase {
|
|
|
172
184
|
connectedCallback(): void;
|
|
173
185
|
disconnectedCallback(): void;
|
|
174
186
|
attributeChangedCallback(name: any, _old: any, val: any): void;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
187
|
+
/** Indicator registry (module scope — shared with the legacy alias tag). */
|
|
188
|
+
static _registry(): Map<string, {
|
|
189
|
+
kind: string;
|
|
190
|
+
params: {
|
|
191
|
+
period: number;
|
|
192
|
+
mult?: undefined;
|
|
193
|
+
fast?: undefined;
|
|
194
|
+
slow?: undefined;
|
|
195
|
+
signal?: undefined;
|
|
196
|
+
};
|
|
197
|
+
compute: (bars: any, p: any) => number[];
|
|
198
|
+
range?: undefined;
|
|
199
|
+
color?: undefined;
|
|
200
|
+
guides?: undefined;
|
|
201
|
+
fmt?: undefined;
|
|
202
|
+
} | {
|
|
203
|
+
kind: string;
|
|
204
|
+
params: {
|
|
205
|
+
period: number;
|
|
206
|
+
mult?: undefined;
|
|
207
|
+
fast?: undefined;
|
|
208
|
+
slow?: undefined;
|
|
209
|
+
signal?: undefined;
|
|
210
|
+
};
|
|
211
|
+
compute: (bars: any, p: any) => number[];
|
|
212
|
+
range?: undefined;
|
|
213
|
+
color?: undefined;
|
|
214
|
+
guides?: undefined;
|
|
215
|
+
fmt?: undefined;
|
|
216
|
+
} | {
|
|
217
|
+
kind: string;
|
|
218
|
+
params: {
|
|
219
|
+
period: number;
|
|
220
|
+
mult: number;
|
|
221
|
+
fast?: undefined;
|
|
222
|
+
slow?: undefined;
|
|
223
|
+
signal?: undefined;
|
|
224
|
+
};
|
|
225
|
+
compute: (bars: any, p: any) => {
|
|
226
|
+
lines: {
|
|
227
|
+
name: string;
|
|
228
|
+
values: number[];
|
|
229
|
+
}[];
|
|
230
|
+
};
|
|
231
|
+
range?: undefined;
|
|
232
|
+
color?: undefined;
|
|
233
|
+
guides?: undefined;
|
|
234
|
+
fmt?: undefined;
|
|
235
|
+
} | {
|
|
236
|
+
kind: string;
|
|
237
|
+
params: {
|
|
238
|
+
mult?: undefined;
|
|
239
|
+
period: number;
|
|
240
|
+
fast?: undefined;
|
|
241
|
+
slow?: undefined;
|
|
242
|
+
signal?: undefined;
|
|
243
|
+
};
|
|
244
|
+
guides: number[];
|
|
245
|
+
range: number[];
|
|
246
|
+
fmt: string;
|
|
247
|
+
color: string;
|
|
248
|
+
compute: (bars: any, p: any) => number[];
|
|
249
|
+
} | {
|
|
250
|
+
range?: undefined;
|
|
251
|
+
color?: undefined;
|
|
252
|
+
kind: string;
|
|
253
|
+
params: {
|
|
254
|
+
mult?: undefined;
|
|
255
|
+
period?: undefined;
|
|
256
|
+
fast: number;
|
|
257
|
+
slow: number;
|
|
258
|
+
signal: number;
|
|
259
|
+
};
|
|
260
|
+
guides: number[];
|
|
261
|
+
fmt: string;
|
|
262
|
+
compute: (bars: any, p: any) => {
|
|
263
|
+
lines: {
|
|
264
|
+
name: string;
|
|
265
|
+
values: number[];
|
|
266
|
+
}[];
|
|
267
|
+
histogram: number[];
|
|
268
|
+
};
|
|
269
|
+
}>;
|
|
178
270
|
/**
|
|
179
271
|
* Register a custom indicator.
|
|
180
272
|
*
|
|
181
|
-
*
|
|
273
|
+
* WickChart.registerIndicator('vwap', {
|
|
182
274
|
* kind: 'overlay', // or 'pane'
|
|
183
275
|
* params: { period: 20 }, // defaults; settable via name:period
|
|
184
276
|
* compute(bars, params) { // bars: normalized {time,o,h,l,c,v}
|
|
@@ -269,22 +361,128 @@ declare class HabChart extends HTMLElementBase {
|
|
|
269
361
|
removePosition(id: any): void;
|
|
270
362
|
clearPositions(): void;
|
|
271
363
|
/**
|
|
272
|
-
* Price alert.
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
364
|
+
* Price or scripted alert. Price alerts fire `wick:alert`
|
|
365
|
+
* ({id, price, bar}) on an edge crossing; scripted alerts evaluate a
|
|
366
|
+
* WickScript predicate (`when`) on every streamed bar and fire on its
|
|
367
|
+
* false→true edge — e.g. `when: 'crossup(rsi(close,14), 30)'` or
|
|
368
|
+
* `when: 'volume > sma(volume,20) * 3'`. Scripted events carry the
|
|
369
|
+
* triggering close as `price` plus the `when` source (deprecated
|
|
370
|
+
* `hab:alert` alias still dispatched).
|
|
371
|
+
* @param {{id?: string, price?: number, direction?: 'above'|'below'|'cross',
|
|
372
|
+
* when?: string, once?: boolean}} alert
|
|
373
|
+
* @returns {string|null} the alert id (null when no valid price/when,
|
|
374
|
+
* or the predicate fails to compile)
|
|
277
375
|
*/
|
|
278
376
|
addAlert(alert: {
|
|
279
377
|
id?: string;
|
|
280
|
-
price
|
|
378
|
+
price?: number;
|
|
281
379
|
direction?: 'above' | 'below' | 'cross';
|
|
380
|
+
when?: string;
|
|
282
381
|
once?: boolean;
|
|
283
382
|
}): string | null;
|
|
284
383
|
removeAlert(id: any): void;
|
|
285
384
|
clearAlerts(): void;
|
|
286
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* Server-side overlays: zones & levels anchored in time × price — e.g.
|
|
387
|
+
* supply/demand zones from an analysis API. Zones with no `to` extend
|
|
388
|
+
* into future space past the last bar, like TradingView drawings.
|
|
389
|
+
*
|
|
390
|
+
* zone: { type:'zone', from?:ms, to?:ms|null, priceFrom, priceTo,
|
|
391
|
+
* color?, alpha?, border?, label?, id? }
|
|
392
|
+
* level: { type:'level', price, from?, to?, color?, width?, dash?,
|
|
393
|
+
* label?, id? }
|
|
394
|
+
*
|
|
395
|
+
* Invalid entries are dropped, never thrown. Colors accept hex/rgb()/CSS
|
|
396
|
+
* names plus the palette keys 'up' | 'down' | 'accent'.
|
|
397
|
+
* @param {object[]} list
|
|
398
|
+
* @returns {string[]} applied overlay ids
|
|
399
|
+
*/
|
|
400
|
+
setOverlays(list: object[]): string[];
|
|
401
|
+
/** @returns {object[]} a copy of the current overlays */
|
|
402
|
+
get overlays(): object[];
|
|
403
|
+
/**
|
|
404
|
+
* Add or replace (upsert, by id) a single overlay.
|
|
405
|
+
* @returns {string|null} the overlay id, or null if invalid
|
|
406
|
+
*/
|
|
407
|
+
addOverlay(ov: any): string | null;
|
|
408
|
+
removeOverlay(id: any): void;
|
|
409
|
+
clearOverlays(): void;
|
|
410
|
+
/**
|
|
411
|
+
* Scenario projection into future space: a ghost path of future prices
|
|
412
|
+
* plus optional σ-bands (vol cone) from realized volatility.
|
|
413
|
+
*
|
|
414
|
+
* chart.setScenario({ path: [64000, 65500, 68000], label: 'bull case' });
|
|
415
|
+
* chart.setScenario({ horizon: 48, cone: true }); // cone-only
|
|
416
|
+
*
|
|
417
|
+
* The path is an array of prices (or {price} objects) for future bars
|
|
418
|
+
* 1..N; horizon defaults to the path length (1–500). `cone` (default
|
|
419
|
+
* true) draws ±levels·σ bands widening with √h from the current realized
|
|
420
|
+
* vol; `color` accepts up|down|accent or safe CSS colors. Setting a
|
|
421
|
+
* scenario reserves future space on the right; analysis data — excluded
|
|
422
|
+
* from getState/setState.
|
|
423
|
+
* @param {object} spec
|
|
424
|
+
* @returns {object|null} the normalized scenario, or null when invalid
|
|
425
|
+
*/
|
|
426
|
+
setScenario(spec: object): object | null;
|
|
427
|
+
clearScenario(): void;
|
|
428
|
+
/** @returns {object|null} a copy of the active scenario */
|
|
429
|
+
get scenario(): object | null;
|
|
430
|
+
/** σ-cone for the active scenario, cached per data version. */
|
|
431
|
+
_scenarioConeCache(): any;
|
|
432
|
+
/** Tool manifest for LLM control — JSON-safe copy of AI_TOOLS. */
|
|
433
|
+
aiTools(): any;
|
|
434
|
+
/** System prompt for agent control — paste into any LLM alongside aiTools(). */
|
|
435
|
+
aiPrompt(): string;
|
|
436
|
+
/** Grounding context for a model: current state + visible-window summary. */
|
|
437
|
+
aiContext(): {
|
|
438
|
+
state: import("./core.js").ChartState;
|
|
439
|
+
window: object;
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Apply a list of {tool, args} ops (typically LLM output) through the
|
|
443
|
+
* validated dispatcher in core. Never throws — each op resolves
|
|
444
|
+
* {ok, tool, result} or {ok: false, tool, error} so an agent can
|
|
445
|
+
* self-correct.
|
|
446
|
+
* @param {any} ops
|
|
447
|
+
* @returns {Array<object>}
|
|
448
|
+
*/
|
|
449
|
+
applyAI(ops: any): Array<object>;
|
|
450
|
+
/**
|
|
451
|
+
* Ask an AI to operate the chart. Builds the payload {system,
|
|
452
|
+
* instruction, chart, tools}; with a `run` async function (your model
|
|
453
|
+
* call — the chart itself never touches the network), applies the
|
|
454
|
+
* returned ops and resolves {payload, ops, results}. Without `run`,
|
|
455
|
+
* returns the payload for manual wiring — send it anywhere, then call
|
|
456
|
+
* chart.applyAI(ops) with the model's answer.
|
|
457
|
+
*
|
|
458
|
+
* const { results } = await chart.ask('add RSI and mark the demand zone', {
|
|
459
|
+
* run: async (payload) => (await callMyLLM(payload)).ops,
|
|
460
|
+
* });
|
|
461
|
+
*
|
|
462
|
+
* @param {string} instruction natural-language request
|
|
463
|
+
* @param {{run?: (payload: object) => Promise<any>}} [opts]
|
|
464
|
+
*/
|
|
465
|
+
ask(instruction: string, opts?: {
|
|
466
|
+
run?: (payload: object) => Promise<any>;
|
|
467
|
+
}): Promise<{
|
|
468
|
+
payload: {
|
|
469
|
+
system: string;
|
|
470
|
+
instruction: string;
|
|
471
|
+
chart: {
|
|
472
|
+
state: import("./core.js").ChartState;
|
|
473
|
+
window: object;
|
|
474
|
+
};
|
|
475
|
+
tools: any;
|
|
476
|
+
};
|
|
477
|
+
ops: any;
|
|
478
|
+
results: object[];
|
|
479
|
+
}>;
|
|
480
|
+
/** Check alerts against an incoming bar (prev close → new close).
|
|
481
|
+
* Scripted (`when`) alerts evaluate their predicate series, cached per
|
|
482
|
+
* data version, and fire on the false→true edge. */
|
|
287
483
|
_checkAlerts(prevClose: any, bar: any): void;
|
|
484
|
+
/** Cached boolean series for a scripted alert's predicate (per data version). */
|
|
485
|
+
_predicateCache(alert: any): any;
|
|
288
486
|
get theme(): string;
|
|
289
487
|
set theme(v: string);
|
|
290
488
|
get type(): string;
|
|
@@ -386,6 +584,10 @@ declare class HabChart extends HTMLElementBase {
|
|
|
386
584
|
_setupCoView(): void;
|
|
387
585
|
_coviewSend(msg: any): void;
|
|
388
586
|
_onCoMessage(m: any): void;
|
|
587
|
+
/** Dispatch `wick:name` (canonical) plus the deprecated `hab:name` alias,
|
|
588
|
+
* so 0.x listeners keep working until 2.0. */
|
|
589
|
+
_fire(name: any, detail: any): void;
|
|
389
590
|
_emitRange(): void;
|
|
390
591
|
}
|
|
391
|
-
export default
|
|
592
|
+
export default WickChart;
|
|
593
|
+
export { WickChart };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './wick-chart.js';
|
|
2
2
|
declare const HTMLElementBase: {
|
|
3
3
|
new (): {};
|
|
4
4
|
};
|
|
5
|
-
declare class
|
|
5
|
+
declare class WickFeed extends HTMLElementBase {
|
|
6
6
|
_gen: number;
|
|
7
7
|
_closers: any[];
|
|
8
8
|
_timer: number;
|
|
@@ -15,7 +15,10 @@ declare class HabFeed extends HTMLElementBase {
|
|
|
15
15
|
_scheduleRestart(): void;
|
|
16
16
|
_teardown(): void;
|
|
17
17
|
_setStatus(status: any, detail: any): void;
|
|
18
|
-
/**
|
|
18
|
+
/** Dispatch `wick-feed:name` plus the deprecated `hab-feed:name` alias. */
|
|
19
|
+
_fire(name: any, detail: any): void;
|
|
20
|
+
/** Resolve the target chart (by `for` id, else the first chart element —
|
|
21
|
+
* <wick-chart> or the deprecated <hab-chart>). */
|
|
19
22
|
_resolveChart(): Element;
|
|
20
23
|
_restart(): void;
|
|
21
24
|
_synthetic(gen: any, chart: any, key: any, tfId: any, limit: any, live: any, status?: string): void;
|
|
@@ -24,4 +27,5 @@ declare class HabFeed extends HTMLElementBase {
|
|
|
24
27
|
_degrade(gen: any, chart: any, sym: any, tfId: any, limit: any, live: any, err: any): void;
|
|
25
28
|
_rest(gen: any, chart: any, url: any, limit: any, live: any): Promise<void>;
|
|
26
29
|
}
|
|
27
|
-
export default
|
|
30
|
+
export default WickFeed;
|
|
31
|
+
export { WickFeed };
|