wickchart 1.6.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 +236 -21
- package/package.json +19 -5
- package/src/core.js +165 -457
- package/src/feeds.js +333 -1
- package/src/react-core.js +7 -1
- package/src/report.js +309 -0
- package/src/wick-chart.js +627 -974
- package/src/wick-feed.js +217 -14
- package/src/worker-core.js +89 -0
- package/src/worker.js +128 -0
- package/types/core.d.ts +64 -251
- package/types/feeds.d.ts +165 -0
- package/types/report.d.ts +114 -0
- package/types/wick-chart.d.ts +119 -265
- package/types/wick-feed.d.ts +21 -2
- package/types/worker-core.d.ts +11 -0
- package/types/worker.d.ts +36 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** Decimals worth showing for a price of this magnitude. */
|
|
2
|
+
export declare function decimalsFor(price: any): 2 | 3 | 6;
|
|
3
|
+
/** 1234 → '1.2k', 1234567 → '1.23M', 12 → '12'. */
|
|
4
|
+
export declare function compact(v: any): string;
|
|
5
|
+
export declare function pct(v: any, digits?: number): string;
|
|
6
|
+
/** Greatest index whose time is <= t (binary search; bars are ascending). */
|
|
7
|
+
export declare function indexForTime(bars: any, t: any): number;
|
|
8
|
+
/** Resolve the report colors: theme palettes, overridden by the chart's own
|
|
9
|
+
* --wick-* variables when readable (browser) and theme is 'auto'. */
|
|
10
|
+
export declare function reportColors(chart: any, theme?: string): {
|
|
11
|
+
bg: string;
|
|
12
|
+
panel: string;
|
|
13
|
+
text: string;
|
|
14
|
+
muted: string;
|
|
15
|
+
up: string;
|
|
16
|
+
down: string;
|
|
17
|
+
accent: string;
|
|
18
|
+
} | {
|
|
19
|
+
bg: string;
|
|
20
|
+
panel: string;
|
|
21
|
+
text: string;
|
|
22
|
+
muted: string;
|
|
23
|
+
up: string;
|
|
24
|
+
down: string;
|
|
25
|
+
accent: string;
|
|
26
|
+
};
|
|
27
|
+
/** Relative luminance of a #hex / rgb() string (0..1, best effort). */
|
|
28
|
+
export declare function luminance(color: any): number;
|
|
29
|
+
/**
|
|
30
|
+
* Build the whole report as data: sizes, bands, stat rows, colors, labels.
|
|
31
|
+
* @param {object} chart a <wick-chart> (public API only: data,
|
|
32
|
+
* getVisibleRange, exportPNG, clientWidth/Height, getAttribute)
|
|
33
|
+
* @param {{title?: string, source?: string, brand?: string, theme?: string,
|
|
34
|
+
* scale?: number, precision?: number}} [opts]
|
|
35
|
+
*/
|
|
36
|
+
export declare function reportModel(chart: object, opts?: {
|
|
37
|
+
title?: string;
|
|
38
|
+
source?: string;
|
|
39
|
+
brand?: string;
|
|
40
|
+
theme?: string;
|
|
41
|
+
scale?: number;
|
|
42
|
+
precision?: number;
|
|
43
|
+
}): {
|
|
44
|
+
scale: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
bands: {
|
|
48
|
+
header: number;
|
|
49
|
+
stats: number;
|
|
50
|
+
footer: number;
|
|
51
|
+
chart: number;
|
|
52
|
+
};
|
|
53
|
+
grid: {
|
|
54
|
+
cols: number;
|
|
55
|
+
};
|
|
56
|
+
title: any;
|
|
57
|
+
brand: string;
|
|
58
|
+
source: string;
|
|
59
|
+
range: {
|
|
60
|
+
from: any;
|
|
61
|
+
to: any;
|
|
62
|
+
};
|
|
63
|
+
last: any;
|
|
64
|
+
precision: number;
|
|
65
|
+
rows: ({
|
|
66
|
+
label: string;
|
|
67
|
+
value: string;
|
|
68
|
+
color: string;
|
|
69
|
+
} | {
|
|
70
|
+
color?: undefined;
|
|
71
|
+
label: string;
|
|
72
|
+
value: string;
|
|
73
|
+
})[];
|
|
74
|
+
generatedAt: number;
|
|
75
|
+
colors: {
|
|
76
|
+
bg: string;
|
|
77
|
+
panel: string;
|
|
78
|
+
text: string;
|
|
79
|
+
muted: string;
|
|
80
|
+
up: string;
|
|
81
|
+
down: string;
|
|
82
|
+
accent: string;
|
|
83
|
+
} | {
|
|
84
|
+
bg: string;
|
|
85
|
+
panel: string;
|
|
86
|
+
text: string;
|
|
87
|
+
muted: string;
|
|
88
|
+
up: string;
|
|
89
|
+
down: string;
|
|
90
|
+
accent: string;
|
|
91
|
+
};
|
|
92
|
+
stats: {
|
|
93
|
+
n: number;
|
|
94
|
+
changePct: number;
|
|
95
|
+
min: number;
|
|
96
|
+
max: number;
|
|
97
|
+
maxDDPct: number;
|
|
98
|
+
annVolPct: number;
|
|
99
|
+
up: number;
|
|
100
|
+
dn: number;
|
|
101
|
+
avgVolume: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Compose the branded report and return it as a PNG data URL (default), a
|
|
106
|
+
* Blob, or the canvas itself.
|
|
107
|
+
* @returns {Promise<string|Blob|HTMLCanvasElement>}
|
|
108
|
+
*/
|
|
109
|
+
export declare function exportReport(chart: any, opts?: {}): Promise<string | Blob | HTMLCanvasElement>;
|
|
110
|
+
/**
|
|
111
|
+
* Compose and trigger a download (browser only).
|
|
112
|
+
* @returns {Promise<void>}
|
|
113
|
+
*/
|
|
114
|
+
export declare function downloadReport(chart: any, filename?: string, opts?: {}): Promise<void>;
|
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
|
};
|
|
@@ -21,11 +20,7 @@ declare class WickChart extends HTMLElementBase {
|
|
|
21
20
|
_hover: {
|
|
22
21
|
index: any;
|
|
23
22
|
x: number;
|
|
24
|
-
y:
|
|
25
|
-
} | {
|
|
26
|
-
index: number;
|
|
27
|
-
x: number;
|
|
28
|
-
y: number;
|
|
23
|
+
y: any;
|
|
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;
|
|
@@ -164,6 +145,19 @@ declare class WickChart extends HTMLElementBase {
|
|
|
164
145
|
panes: any[];
|
|
165
146
|
volume: boolean;
|
|
166
147
|
};
|
|
148
|
+
_workerOn: boolean;
|
|
149
|
+
_epoch: number;
|
|
150
|
+
_workerCache: {
|
|
151
|
+
epoch: number;
|
|
152
|
+
map: {};
|
|
153
|
+
pending: {};
|
|
154
|
+
sent: number;
|
|
155
|
+
};
|
|
156
|
+
_sid: number;
|
|
157
|
+
_onlineSeries: {
|
|
158
|
+
epoch: number;
|
|
159
|
+
map: {};
|
|
160
|
+
};
|
|
167
161
|
_pointers: Map<any, any>;
|
|
168
162
|
_pan: {
|
|
169
163
|
x: number;
|
|
@@ -176,6 +170,13 @@ declare class WickChart extends HTMLElementBase {
|
|
|
176
170
|
idxAtMid: number;
|
|
177
171
|
midX: number;
|
|
178
172
|
};
|
|
173
|
+
_scrub: boolean;
|
|
174
|
+
_pressTimer: number;
|
|
175
|
+
_pressOrigin: {
|
|
176
|
+
pointerId: any;
|
|
177
|
+
x: any;
|
|
178
|
+
y: any;
|
|
179
|
+
};
|
|
179
180
|
_layers: any[];
|
|
180
181
|
_layerClaim: {
|
|
181
182
|
layer: any;
|
|
@@ -187,30 +188,11 @@ declare class WickChart extends HTMLElementBase {
|
|
|
187
188
|
_positions: any[];
|
|
188
189
|
_alerts: any[];
|
|
189
190
|
_seq: number;
|
|
191
|
+
_alertEval: string;
|
|
192
|
+
_lastClosedIdx: number;
|
|
193
|
+
_tz: string;
|
|
194
|
+
_vwapAnchor: string;
|
|
190
195
|
_overlays: any[];
|
|
191
|
-
_scenario: {
|
|
192
|
-
path: {
|
|
193
|
-
h: number;
|
|
194
|
-
price: number;
|
|
195
|
-
}[];
|
|
196
|
-
horizon: number;
|
|
197
|
-
cone: boolean;
|
|
198
|
-
levels: number[];
|
|
199
|
-
color: string | null;
|
|
200
|
-
label: string;
|
|
201
|
-
};
|
|
202
|
-
_riskPlan: {
|
|
203
|
-
entry: number;
|
|
204
|
-
stop: number;
|
|
205
|
-
risk: number;
|
|
206
|
-
direction: 'long' | 'short';
|
|
207
|
-
levels: {
|
|
208
|
-
k: number;
|
|
209
|
-
price: number;
|
|
210
|
-
}[];
|
|
211
|
-
maxK: number;
|
|
212
|
-
label: string;
|
|
213
|
-
};
|
|
214
196
|
_onResize: () => void;
|
|
215
197
|
_onPointerDown: (e: any) => void;
|
|
216
198
|
_onPointerMove: (e: any) => void;
|
|
@@ -219,8 +201,11 @@ declare class WickChart extends HTMLElementBase {
|
|
|
219
201
|
_onWheel: (e: any) => void;
|
|
220
202
|
_onDbl: () => void;
|
|
221
203
|
_onKey: (e: any) => void;
|
|
204
|
+
_onTouchMove: (e: any) => void;
|
|
205
|
+
_onDprChange: () => void;
|
|
222
206
|
tabIndex: number;
|
|
223
207
|
_ro: any;
|
|
208
|
+
_dprMq: MediaQueryList;
|
|
224
209
|
_posVersion: any;
|
|
225
210
|
_pendingRange: {
|
|
226
211
|
from: number;
|
|
@@ -237,9 +222,18 @@ declare class WickChart extends HTMLElementBase {
|
|
|
237
222
|
rawHi: number;
|
|
238
223
|
};
|
|
239
224
|
static get observedAttributes(): string[];
|
|
225
|
+
/**
|
|
226
|
+
* Shared ChartWorkerPool for the worker compute path (set by importing
|
|
227
|
+
* 'wickchart/worker'; null — everything sync — until then).
|
|
228
|
+
* @type {object|null}
|
|
229
|
+
*/
|
|
230
|
+
static _workerPool: object | null;
|
|
240
231
|
constructor();
|
|
241
232
|
connectedCallback(): void;
|
|
242
233
|
disconnectedCallback(): void;
|
|
234
|
+
/** (Re)arm the devicePixelRatio watcher for the current ratio. */
|
|
235
|
+
_watchDpr(): void;
|
|
236
|
+
_unwatchDpr(): void;
|
|
243
237
|
attributeChangedCallback(name: any, _old: any, val: any): void;
|
|
244
238
|
/** Indicator registry (module scope — shared with the legacy alias tag). */
|
|
245
239
|
static _registry(): Map<string, {
|
|
@@ -282,7 +276,7 @@ declare class WickChart extends HTMLElementBase {
|
|
|
282
276
|
smooth?: undefined;
|
|
283
277
|
period?: undefined;
|
|
284
278
|
};
|
|
285
|
-
compute: (bars: any) => number[];
|
|
279
|
+
compute: (bars: any, p: any) => number[];
|
|
286
280
|
color?: undefined;
|
|
287
281
|
guides?: undefined;
|
|
288
282
|
range?: undefined;
|
|
@@ -497,7 +491,7 @@ declare class WickChart extends HTMLElementBase {
|
|
|
497
491
|
*/
|
|
498
492
|
/** @param {import('./core.js').IndicatorDef} def */
|
|
499
493
|
static registerIndicator(name: any, def: import('./core.js').IndicatorDef): void;
|
|
500
|
-
/** The
|
|
494
|
+
/** The tag this class registers as. */
|
|
501
495
|
static get elementName(): string;
|
|
502
496
|
get data(): any[];
|
|
503
497
|
/**
|
|
@@ -578,8 +572,7 @@ declare class WickChart extends HTMLElementBase {
|
|
|
578
572
|
* WickScript predicate (`when`) on every streamed bar and fire on its
|
|
579
573
|
* false→true edge — e.g. `when: 'crossup(rsi(close,14), 30)'` or
|
|
580
574
|
* `when: 'volume > sma(volume,20) * 3'`. Scripted events carry the
|
|
581
|
-
* triggering close as `price` plus the `when` source
|
|
582
|
-
* `hab:alert` alias still dispatched).
|
|
575
|
+
* triggering close as `price` plus the `when` source.
|
|
583
576
|
* @param {{id?: string, price?: number, direction?: 'above'|'below'|'cross',
|
|
584
577
|
* when?: string, once?: boolean}} alert
|
|
585
578
|
* @returns {string|null} the alert id (null when no valid price/when,
|
|
@@ -619,99 +612,34 @@ declare class WickChart extends HTMLElementBase {
|
|
|
619
612
|
addOverlay(ov: any): string | null;
|
|
620
613
|
removeOverlay(id: any): void;
|
|
621
614
|
clearOverlays(): void;
|
|
622
|
-
/**
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* chart.setScenario({ path: [64000, 65500, 68000], label: 'bull case' });
|
|
627
|
-
* chart.setScenario({ horizon: 48, cone: true }); // cone-only
|
|
628
|
-
*
|
|
629
|
-
* The path is an array of prices (or {price} objects) for future bars
|
|
630
|
-
* 1..N; horizon defaults to the path length (1–500). `cone` (default
|
|
631
|
-
* true) draws ±levels·σ bands widening with √h from the current realized
|
|
632
|
-
* vol; `color` accepts up|down|accent or safe CSS colors. Setting a
|
|
633
|
-
* scenario reserves future space on the right; analysis data — excluded
|
|
634
|
-
* from getState/setState.
|
|
635
|
-
* @param {object} spec
|
|
636
|
-
* @returns {object|null} the normalized scenario, or null when invalid
|
|
637
|
-
*/
|
|
638
|
-
setScenario(spec: object): object | null;
|
|
639
|
-
clearScenario(): void;
|
|
640
|
-
/** @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) */
|
|
641
618
|
get scenario(): object | null;
|
|
642
|
-
/**
|
|
643
|
-
*
|
|
644
|
-
* stop| (the risk unit); reward lines are drawn at kR beyond the entry
|
|
645
|
-
* with the risk/reward zones shaded, so sizing and take-profit choices
|
|
646
|
-
* read directly off the chart.
|
|
647
|
-
*
|
|
648
|
-
* chart.setRiskPlan({ entry: 64500, stop: 63800, multiples: [1, 2, 3] });
|
|
649
|
-
* chart.setRiskPlan({ entry: 64500, stop: 63800, targets: [65900, 67300] });
|
|
650
|
-
*
|
|
651
|
-
* Direction is derived (stop below entry ⇒ long). Targets convert to
|
|
652
|
-
* their R multiple; `multiples` win when both are given. Invalid specs
|
|
653
|
-
* clear the plan (replace semantics, like setScenario); excluded from
|
|
654
|
-
* getState/setState — it is app state, not chart state.
|
|
655
|
-
* @param {object} spec
|
|
656
|
-
* @returns {object|null} the normalized plan, or null when invalid
|
|
657
|
-
*/
|
|
658
|
-
setRiskPlan(spec: object): object | null;
|
|
659
|
-
clearRiskPlan(): void;
|
|
660
|
-
/** @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) */
|
|
661
621
|
get riskPlan(): object | null;
|
|
662
|
-
/**
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
aiTools(): any;
|
|
666
|
-
/** System prompt for agent control — paste into any LLM alongside aiTools(). */
|
|
667
|
-
aiPrompt(): string;
|
|
668
|
-
/** Grounding context for a model: current state + visible-window summary. */
|
|
669
|
-
aiContext(): {
|
|
670
|
-
state: import("./core.js").ChartState;
|
|
671
|
-
window: object;
|
|
672
|
-
};
|
|
622
|
+
/** Check alerts against an incoming bar (prev close → new close).
|
|
623
|
+
* Scripted (`when`) alerts evaluate their predicate series, cached per
|
|
624
|
+
* data version, and fire on the false→true edge. */
|
|
673
625
|
/**
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
* self-correct.
|
|
678
|
-
* @param {any} ops
|
|
679
|
-
* @returns {Array<object>}
|
|
626
|
+
* Index of the newest bar known to be final: any bar with a newer bar
|
|
627
|
+
* behind it, plus the front bar when the feed flagged it `closed: true`
|
|
628
|
+
* (Binance's `k.x`). -1 when nothing has closed yet.
|
|
680
629
|
*/
|
|
681
|
-
|
|
630
|
+
_lastClosedIndex(): number;
|
|
631
|
+
/** Re-baseline the closed-bar cursor without firing anything. */
|
|
632
|
+
_syncClosedIdx(): void;
|
|
682
633
|
/**
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
* returns
|
|
688
|
-
* chart.applyAI(ops) with the model's answer.
|
|
689
|
-
*
|
|
690
|
-
* const { results } = await chart.ask('add RSI and mark the demand zone', {
|
|
691
|
-
* run: async (payload) => (await callMyLLM(payload)).ops,
|
|
692
|
-
* });
|
|
693
|
-
*
|
|
694
|
-
* @param {string} instruction natural-language request
|
|
695
|
-
* @param {{run?: (payload: object) => Promise<any>}} [opts]
|
|
634
|
+
* Resolve an alert's evaluation mode: an explicit 'close' / 'live' on the
|
|
635
|
+
* alert wins, otherwise the chart-level `alert-evaluate` default (itself
|
|
636
|
+
* 'live', so 1.x behaviour is unchanged unless asked for).
|
|
637
|
+
* @param {string|undefined} v
|
|
638
|
+
* @returns {'live'|'close'}
|
|
696
639
|
*/
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
payload: {
|
|
701
|
-
system: string;
|
|
702
|
-
instruction: string;
|
|
703
|
-
chart: {
|
|
704
|
-
state: import("./core.js").ChartState;
|
|
705
|
-
window: object;
|
|
706
|
-
};
|
|
707
|
-
tools: any;
|
|
708
|
-
};
|
|
709
|
-
ops: any;
|
|
710
|
-
results: object[];
|
|
711
|
-
}>;
|
|
712
|
-
/** Check alerts against an incoming bar (prev close → new close).
|
|
713
|
-
* Scripted (`when`) alerts evaluate their predicate series, cached per
|
|
714
|
-
* data version, and fire on the false→true edge. */
|
|
640
|
+
_evalMode(v: string | undefined): 'live' | 'close';
|
|
641
|
+
/** Dispatch one alert, retiring it when it was a `once` alert. */
|
|
642
|
+
_fireAlert(alert: any, detail: any): void;
|
|
715
643
|
_checkAlerts(prevClose: any, bar: any): void;
|
|
716
644
|
/** Cached boolean series for a scripted alert's predicate (per data version). */
|
|
717
645
|
_predicateCache(alert: any): any;
|
|
@@ -724,14 +652,18 @@ declare class WickChart extends HTMLElementBase {
|
|
|
724
652
|
get indicators(): any;
|
|
725
653
|
set indicators(v: any);
|
|
726
654
|
static _MAX_SP: number;
|
|
655
|
+
/** Hold this long on a touchscreen to open the crosshair (ms). */
|
|
656
|
+
static _PRESS_MS: number;
|
|
657
|
+
/** Finger travel that cancels the press and makes it a pan (px). */
|
|
658
|
+
static _PRESS_SLOP: number;
|
|
727
659
|
/**
|
|
728
660
|
* Lowest allowed px/bar: either 0.35, or whatever fits the entire
|
|
729
661
|
* dataset on screen — so any history can be zoomed out fully.
|
|
730
662
|
*/
|
|
731
663
|
_minSpacing(): number;
|
|
732
|
-
static _timeToMs(t: any):
|
|
664
|
+
static _timeToMs(t: any): number;
|
|
733
665
|
static _normBar(b: any): {
|
|
734
|
-
time:
|
|
666
|
+
time: number;
|
|
735
667
|
open: any;
|
|
736
668
|
high: any;
|
|
737
669
|
low: any;
|
|
@@ -759,6 +691,33 @@ declare class WickChart extends HTMLElementBase {
|
|
|
759
691
|
_volShadeCache(): any;
|
|
760
692
|
/** Compute (and cache per data version) an indicator entry's series. */
|
|
761
693
|
_indicatorSeries(entry: any): any;
|
|
694
|
+
/**
|
|
695
|
+
* After a live stream tick (append or forming-bar replace), patch every
|
|
696
|
+
* online-capable series by recomputing a bounded tail with the same
|
|
697
|
+
* batch definition — O(warm-up) instead of a full-history recompute per
|
|
698
|
+
* indicator per tick. Bases are seeded by the sync or worker path; bulk
|
|
699
|
+
* loads (epoch changes) reseed automatically.
|
|
700
|
+
*/
|
|
701
|
+
_onlineTick(): void;
|
|
702
|
+
/** Recompute the last K bars of one series in place (K = max(400,
|
|
703
|
+
* 10×period), clamped to the data). False when the series and data
|
|
704
|
+
* lengths can't line up — the caller drops the base and reseeds. */
|
|
705
|
+
_patchSeriesTail(res: any, entry: any, d: any): boolean;
|
|
706
|
+
/** Remember a fresh series as the base for incremental tick updates
|
|
707
|
+
* (online-capable builtins only). */
|
|
708
|
+
_seedOnline(k: any, entry: any, res: any): void;
|
|
709
|
+
/** Bar count from which the worker path engages (below it, sync wins). */
|
|
710
|
+
_workerCols(): {
|
|
711
|
+
time: Float64Array<ArrayBuffer>;
|
|
712
|
+
open: Float64Array<ArrayBuffer>;
|
|
713
|
+
high: Float64Array<ArrayBuffer>;
|
|
714
|
+
low: Float64Array<ArrayBuffer>;
|
|
715
|
+
close: Float64Array<ArrayBuffer>;
|
|
716
|
+
volume: Float64Array<ArrayBuffer>;
|
|
717
|
+
};
|
|
718
|
+
/** Kick an off-thread compute for one indicator (idempotent per epoch). */
|
|
719
|
+
_workerCompute(pool: any, entry: any, k: any): void;
|
|
720
|
+
_workerArrived(k: any, epoch: any, res: any, entry: any): void;
|
|
762
721
|
/** Resolve a line color: #hex / rgb() / CSS name / palette key ('rsi', 'up', …) / cycle.
|
|
763
722
|
* Untrusted values (URL/attribute-sourced) are validated — never interpolated raw. */
|
|
764
723
|
_lineColor(entry: any, line: any, pal: any, cycleIdx: any): any;
|
|
@@ -782,6 +741,8 @@ declare class WickChart extends HTMLElementBase {
|
|
|
782
741
|
* the walk to those bars — used at deep zoom where bars are aggregated
|
|
783
742
|
* into pixel columns (keeps this O(screen) instead of O(visible bars)).
|
|
784
743
|
*/
|
|
744
|
+
/** An instant shifted into the chart's display zone, for the formatters. */
|
|
745
|
+
_zt(t: any): any;
|
|
785
746
|
_timeTicks(i0: any, i1: any, sampleIdx: any): any[];
|
|
786
747
|
_render(): void;
|
|
787
748
|
_pill(x: any, y: any, text: any, bg: any, fg: any, align: string, widthOverride: any): void;
|
|
@@ -873,88 +834,30 @@ declare class WickChart extends HTMLElementBase {
|
|
|
873
834
|
x: number;
|
|
874
835
|
y: number;
|
|
875
836
|
};
|
|
837
|
+
/**
|
|
838
|
+
* Put the crosshair on the bar under a point and announce it. Shared by
|
|
839
|
+
* mouse hover, keyboard walking and the touch scrub gesture.
|
|
840
|
+
*/
|
|
841
|
+
_hoverAt(pt: any): void;
|
|
842
|
+
/**
|
|
843
|
+
* Start the long-press timer for a touch. A touchscreen has no hover, so
|
|
844
|
+
* without this there is no way to read a bar's values on a phone: a tap
|
|
845
|
+
* selects, a drag pans, and the legend never leaves the last candle.
|
|
846
|
+
* Holding still opens the crosshair; moving first cancels and pans.
|
|
847
|
+
*/
|
|
848
|
+
_armPress(pointerId: any, pt: any): void;
|
|
849
|
+
_disarmPress(): void;
|
|
850
|
+
/** Leave scrub mode and put the crosshair away. */
|
|
851
|
+
_endScrub(): void;
|
|
876
852
|
_pointerDown(e: any): void;
|
|
877
853
|
_pointerMove(e: any): void;
|
|
878
854
|
_pointerUp(e: any): void;
|
|
879
855
|
_yToPrice(y: any): number;
|
|
856
|
+
/** Dispatch a `wick:name` event on the element. */
|
|
857
|
+
_fire(name: any, detail: any): void;
|
|
880
858
|
_wheel(e: any): void;
|
|
881
859
|
_keydown(e: any): void;
|
|
882
|
-
/** Lazily-created shared AudioContext (enable within a user gesture). */
|
|
883
|
-
_audio(): any;
|
|
884
|
-
/** Short sine blip; `when` schedules against AudioContext time. */
|
|
885
|
-
_tone(freq: any, dur?: number, when?: number): void;
|
|
886
|
-
/** One tone for a bar's close, pitched by its position on the y-scale. */
|
|
887
|
-
_sonifyBar(i: any): void;
|
|
888
|
-
/** One tone per crosshair bar change (dedupes y-only moves). */
|
|
889
|
-
_maybeSonify(idx: any): void;
|
|
890
|
-
/**
|
|
891
|
-
* Play the visible range as a pitch sweep (~4s), riding the crosshair —
|
|
892
|
-
* the audible equivalent of running your eye along the price line.
|
|
893
|
-
*/
|
|
894
|
-
playRange(): void;
|
|
895
860
|
_emitCrosshair(hover: any): void;
|
|
896
|
-
/** Join/leave the co-view channel named by the `co-view` attribute. */
|
|
897
|
-
_setupCoView(): void;
|
|
898
|
-
/** Broadcast our visible range for presence; throttled unless forced. */
|
|
899
|
-
_coviewSendView(force: any): void;
|
|
900
|
-
_coviewSend(msg: any): void;
|
|
901
|
-
_onCoMessage(m: any): void;
|
|
902
|
-
/** Dispatch `wick:name` (canonical) plus the deprecated `hab:name` alias,
|
|
903
|
-
* so 0.x listeners keep working until 2.0. */
|
|
904
|
-
_fire(name: any, detail: any): void;
|
|
905
|
-
/**
|
|
906
|
-
* Live co-view peers: who else is in the room and the time window each
|
|
907
|
-
* one is looking at — [{ id, name, range: {from, to}, at }], oldest
|
|
908
|
-
* sighting first. Peers fade out ~12 s after their last sighting.
|
|
909
|
-
* @returns {object[]}
|
|
910
|
-
*/
|
|
911
|
-
getPeers(): object[];
|
|
912
|
-
/**
|
|
913
|
-
* Narrated timeline for a window (default: the visible range) — pivot
|
|
914
|
-
* highs/lows, volume spikes, gaps, RSI divergences plus derived legs
|
|
915
|
-
* ("+12.4% over 38 bars"), sorted by index. Pure data, perfect for
|
|
916
|
-
* caption UIs or the walk player.
|
|
917
|
-
* chart.narrate(); // visible range
|
|
918
|
-
* chart.narrate({ from, to }); // times in ms (s accepted)
|
|
919
|
-
* @param {{from?: number, to?: number}} [range]
|
|
920
|
-
* @returns {{i: number, time: number, type: string, side: string, note: string,
|
|
921
|
-
* legPct?: number, legBars?: number}[]}
|
|
922
|
-
*/
|
|
923
|
-
narrate(range?: {
|
|
924
|
-
from?: number;
|
|
925
|
-
to?: number;
|
|
926
|
-
}): {
|
|
927
|
-
i: number;
|
|
928
|
-
time: number;
|
|
929
|
-
type: string;
|
|
930
|
-
side: string;
|
|
931
|
-
note: string;
|
|
932
|
-
legPct?: number;
|
|
933
|
-
legBars?: number;
|
|
934
|
-
}[];
|
|
935
|
-
/**
|
|
936
|
-
* Walk the chart through history like a story: the viewport slides
|
|
937
|
-
* from `from` to `to` while `wick:walk` events announce every step and
|
|
938
|
-
* the narrator's events (spikes, gaps, pivots, legs) as they're crossed.
|
|
939
|
-
* Any user interaction — pointer, wheel, keys, double-click — stops it.
|
|
940
|
-
* chart.walk({ from: 0, to: 500, speed: 120, step: 10 });
|
|
941
|
-
* chart.addEventListener('wick:walk', (e) => showCaption(e.detail));
|
|
942
|
-
* // detail: { phase: 'step'|'end'|'stop', index, events: [...], from, to }
|
|
943
|
-
* @param {{from?: number, to?: number, speed?: number, step?: number}} [opts]
|
|
944
|
-
* from/to are bar indices (default: last ~500 bars → the end)
|
|
945
|
-
* @returns {boolean} true when the walk started
|
|
946
|
-
*/
|
|
947
|
-
walk(opts?: {
|
|
948
|
-
from?: number;
|
|
949
|
-
to?: number;
|
|
950
|
-
speed?: number;
|
|
951
|
-
step?: number;
|
|
952
|
-
}): boolean;
|
|
953
|
-
/**
|
|
954
|
-
* Stop the running walk (if any). Fires a final `wick:walk`
|
|
955
|
-
* { phase: 'stop' } unless called internally.
|
|
956
|
-
*/
|
|
957
|
-
stopWalk(silent: any): void;
|
|
958
861
|
/**
|
|
959
862
|
* Commit a brush selection over [i0, i1]: stores it (draws the band
|
|
960
863
|
* and delta chip) and fires `wick:brush` with the range statistics.
|
|
@@ -966,55 +869,6 @@ declare class WickChart extends HTMLElementBase {
|
|
|
966
869
|
clearBrush(): void;
|
|
967
870
|
/** @returns {object|null} the committed selection { i0, i1, stats } */
|
|
968
871
|
get brushSelection(): object | null;
|
|
969
|
-
/**
|
|
970
|
-
* Capture the current chart state as a story scene: view, series type,
|
|
971
|
-
* indicators, overlays, scenario and risk plan, plus a title/note.
|
|
972
|
-
* Build guided tours by capturing several and playing them back.
|
|
973
|
-
* const story = [
|
|
974
|
-
* chart.captureScene('Overview', 'The full picture'),
|
|
975
|
-
* { title: 'The breakout', range: { from, to }, indicators: 'sma:20' },
|
|
976
|
-
* ];
|
|
977
|
-
* chart.playStory(story);
|
|
978
|
-
* @param {string} [title]
|
|
979
|
-
* @param {string} [note]
|
|
980
|
-
* @returns {object} scene (plain data — snapshot of the moment)
|
|
981
|
-
*/
|
|
982
|
-
captureScene(title?: string, note?: string): object;
|
|
983
|
-
/** @returns {object[]|null} a copy of the last played story */
|
|
984
|
-
getStory(): object[] | null;
|
|
985
|
-
/**
|
|
986
|
-
* Play a story: each scene applies its state (type / indicators /
|
|
987
|
-
* overlays / scenario / risk plan — set or clear), the camera eases
|
|
988
|
-
* to its range, then holds for its dwell. `wick:story` events narrate:
|
|
989
|
-
* { phase: 'scene' | 'end' | 'stop', index, total, scene, title, note }
|
|
990
|
-
* Any user interaction — pointer, wheel, keys, double-click — stops it.
|
|
991
|
-
* @param {object[]} story scenes (invalid entries dropped, max 20)
|
|
992
|
-
* @param {{dwell?: number, panMs?: number, loop?: boolean}} [opts]
|
|
993
|
-
* panMs clamps 100–5000 (default 900); loop replays forever
|
|
994
|
-
* @returns {boolean} true when playback started
|
|
995
|
-
*/
|
|
996
|
-
playStory(story: object[], opts?: {
|
|
997
|
-
dwell?: number;
|
|
998
|
-
panMs?: number;
|
|
999
|
-
loop?: boolean;
|
|
1000
|
-
}): boolean;
|
|
1001
|
-
/**
|
|
1002
|
-
* Stop story playback (if running). Fires a final `wick:story`
|
|
1003
|
-
* { phase: 'stop' } unless called internally.
|
|
1004
|
-
*/
|
|
1005
|
-
stopStory(silent: any): void;
|
|
1006
|
-
/** Apply a scene's state (only the fields it carries). */
|
|
1007
|
-
_applyScene(sc: any): void;
|
|
1008
|
-
/** Map a scene's time range to bar indices (null when not applicable). */
|
|
1009
|
-
_sceneTarget(sc: any): {
|
|
1010
|
-
i0: number;
|
|
1011
|
-
i1: number;
|
|
1012
|
-
};
|
|
1013
|
-
/** Ease the viewport to { i0, i1 } over `ms`; resolves early if the
|
|
1014
|
-
* token changes (superseded or stopped). rAF when available. */
|
|
1015
|
-
_storyTween(target: any, ms: any, token: any): Promise<any>;
|
|
1016
|
-
/** Interrupt narrated playback (walk / story) on user input. */
|
|
1017
|
-
_stopPlayback(): void;
|
|
1018
872
|
_emitRange(): void;
|
|
1019
873
|
}
|
|
1020
874
|
export default WickChart;
|
package/types/wick-feed.d.ts
CHANGED
|
@@ -15,17 +15,36 @@ 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;
|
|
25
25
|
_binance(gen: any, chart: any, sym: any, tfId: any, limit: any, live: any): Promise<void>;
|
|
26
26
|
_pollBinance(gen: any, chart: any, sym: any, tfId: any): void;
|
|
27
27
|
_degrade(gen: any, chart: any, sym: any, tfId: any, limit: any, live: any, err: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Wrap chart.update for aggregated bars: the chart keys bars by timestamp,
|
|
30
|
+
* and two groups can close inside the same millisecond, so emitted times
|
|
31
|
+
* are nudged +1ms to stay strictly increasing (keeps the one-bar-per-
|
|
32
|
+
* timestamp integrity invariant; display-only, values are untouched).
|
|
33
|
+
*/
|
|
34
|
+
_aggEmit(gen: any, chart: any): (bar: any) => void;
|
|
35
|
+
/** Seed + stream one aggregator onto the chart (shared by all sources). */
|
|
36
|
+
_aggAttach(gen: any, chart: any, res: any, bars: any, limit: any, status: any): {
|
|
37
|
+
emit: (bar: any) => void;
|
|
38
|
+
aggregator: any;
|
|
39
|
+
/** Push one print through; emits the closed bar, then the forming one. */
|
|
40
|
+
push(t: any): void;
|
|
41
|
+
};
|
|
42
|
+
_syntheticTrades(gen: any, chart: any, key: any, agg: any, limit: any, live: any, status?: string): void;
|
|
43
|
+
_binanceTrades(gen: any, chart: any, sym: any, agg: any, limit: any, live: any): Promise<void>;
|
|
44
|
+
_pollBinanceTrades(gen: any, chart: any, sym: any, handle: any, fromId: any, agg: any, limit: any, live: any): void;
|
|
45
|
+
_restTrades(gen: any, chart: any, url: any, agg: any, limit: any, live: any): Promise<void>;
|
|
28
46
|
_rest(gen: any, chart: any, url: any, limit: any, live: any): Promise<void>;
|
|
29
47
|
}
|
|
30
48
|
export default WickFeed;
|
|
31
49
|
export { WickFeed };
|
|
50
|
+
export { parseAggregate, TickBarAggregator, aggregateTrades, normalizeTrades, genSyntheticTrades, makeSynthTradeStream, } from './feeds.js';
|