@stocksharp/trading-controls 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.
Files changed (59) hide show
  1. package/LICENSE +30 -0
  2. package/NOTICE +21 -0
  3. package/README.md +240 -0
  4. package/dist/esm/active-orders-widget.js +382 -0
  5. package/dist/esm/active-orders-widget.js.map +1 -0
  6. package/dist/esm/control-types.js +23 -0
  7. package/dist/esm/control-types.js.map +1 -0
  8. package/dist/esm/dom.js +55 -0
  9. package/dist/esm/dom.js.map +1 -0
  10. package/dist/esm/formatters.js +69 -0
  11. package/dist/esm/formatters.js.map +1 -0
  12. package/dist/esm/index.js +12 -0
  13. package/dist/esm/index.js.map +1 -0
  14. package/dist/esm/positions-widget.js +258 -0
  15. package/dist/esm/positions-widget.js.map +1 -0
  16. package/dist/esm/trade-history-widget.js +197 -0
  17. package/dist/esm/trade-history-widget.js.map +1 -0
  18. package/dist/esm/trading-data.js +26 -0
  19. package/dist/esm/trading-data.js.map +1 -0
  20. package/dist/esm/trading-host.js +79 -0
  21. package/dist/esm/trading-host.js.map +1 -0
  22. package/dist/esm/watchlist-widget.js +481 -0
  23. package/dist/esm/watchlist-widget.js.map +1 -0
  24. package/dist/sstradingcontrols.js +1740 -0
  25. package/dist/sstradingcontrols.js.map +7 -0
  26. package/dist/types/active-orders-widget.d.ts +52 -0
  27. package/dist/types/active-orders-widget.d.ts.map +1 -0
  28. package/dist/types/control-types.d.ts +8 -0
  29. package/dist/types/control-types.d.ts.map +1 -0
  30. package/dist/types/dom.d.ts +6 -0
  31. package/dist/types/dom.d.ts.map +1 -0
  32. package/dist/types/formatters.d.ts +8 -0
  33. package/dist/types/formatters.d.ts.map +1 -0
  34. package/dist/types/index.d.ts +16 -0
  35. package/dist/types/index.d.ts.map +1 -0
  36. package/dist/types/positions-widget.d.ts +37 -0
  37. package/dist/types/positions-widget.d.ts.map +1 -0
  38. package/dist/types/trade-history-widget.d.ts +25 -0
  39. package/dist/types/trade-history-widget.d.ts.map +1 -0
  40. package/dist/types/trading-data.d.ts +55 -0
  41. package/dist/types/trading-data.d.ts.map +1 -0
  42. package/dist/types/trading-host.d.ts +62 -0
  43. package/dist/types/trading-host.d.ts.map +1 -0
  44. package/dist/types/watchlist-widget.d.ts +60 -0
  45. package/dist/types/watchlist-widget.d.ts.map +1 -0
  46. package/package.json +129 -0
  47. package/src/active-orders-widget.ts +411 -0
  48. package/src/control-types.ts +24 -0
  49. package/src/dom.ts +68 -0
  50. package/src/formatters.ts +72 -0
  51. package/src/index.ts +52 -0
  52. package/src/positions-widget.ts +305 -0
  53. package/src/trade-history-widget.ts +221 -0
  54. package/src/trading-data.ts +121 -0
  55. package/src/trading-host.ts +300 -0
  56. package/src/watchlist-widget.ts +513 -0
  57. package/styles/theme.css +86 -0
  58. package/styles/trading-controls.css +469 -0
  59. package/translation-keys.json +58 -0
@@ -0,0 +1,481 @@
1
+ // Watchlist — multi-instance.
2
+ //
3
+ // Builds its own DOM (see `_buildRoot`) rather than cloning a <template> out of
4
+ // the page, so it can be constructed by any host that supplies a `TradingHost`.
5
+ // Each instance has its own search/filter/sort state; favourites are shared,
6
+ // held under one key in the host's preference store.
7
+ //
8
+ // The table is `DataGrid` from `@stocksharp/grids`. The grid holds the FILTERED
9
+ // instruments and does the sorting, which is what makes the two caps mean
10
+ // different things: `renderLimit` caps what gets painted while the export and
11
+ // the subscription sync read the whole filtered set. A live quote patches one
12
+ // cell through the grid's (rowKey, columnKey) lookup instead of repainting — a
13
+ // repaint would restart the flash animation it just triggered.
14
+ import { makeElement, makeIconButton, makePanelId, makePanelRoot } from './dom.js';
15
+ import { ControlTypes } from './control-types.js';
16
+ import { MarketDataLevels, assertHost } from './trading-host.js';
17
+ import { DataGrid } from '@stocksharp/grids/data-grid';
18
+ export class WatchlistWidget {
19
+ static create(hostEl, state, deps) {
20
+ // Assert before building: the markup below is localized through the
21
+ // host, so a missing host has to fail here rather than render a panel
22
+ // captioned with raw English keys.
23
+ const host = assertHost(deps?.host, 'WatchlistWidget');
24
+ const root = WatchlistWidget._buildRoot(host);
25
+ root.id = makePanelId(WatchlistWidget.TYPE);
26
+ hostEl.appendChild(root);
27
+ return new WatchlistWidget(root, state || {}, deps);
28
+ }
29
+ // The panel's markup. The host stylesheet reads this structure, and a
30
+ // docking host lifts `.panel-header`'s children — and, for this panel,
31
+ // `.watchlist-search-row` as well — into its tab strip, which is why the
32
+ // search row is a sibling of the header rather than a child of it.
33
+ //
34
+ // "All" and "Favorites" are the built-in tabs. The rest are appended at
35
+ // runtime from the distinct categories of the loaded instruments, so the
36
+ // tab set is configured through whatever assigns those categories rather
37
+ // than being spelled out here — see _renderCategoryTabs.
38
+ static _buildRoot(host) {
39
+ const search = host.t('SearchInstruments');
40
+ const favorites = host.t('Favorites');
41
+ return makePanelRoot('watchlist-panel', host.t('Watchlist'), [
42
+ makeElement('div', 'panel-header', {}, [
43
+ makeElement('span', '', {}, [host.t('Markets')]),
44
+ makeIconButton('bt-icon-btn panel-export-btn', host.t('ExportToExcel'), 'bi-file-earmark-spreadsheet', { type: 'button' }),
45
+ makeIconButton('bt-icon-btn bt-icon-cancel panel-close-btn', host.t('ClosePanel'), 'bi-x', { type: 'button' }),
46
+ ]),
47
+ makeElement('div', 'watchlist-search-row', {}, [
48
+ makeElement('input', 'form-control form-control-sm watchlist-search-input watchlist-search', { type: 'text', placeholder: search, autocomplete: 'off', 'aria-label': search }, []),
49
+ ]),
50
+ makeElement('div', 'watchlist-tabs', { role: 'tablist', 'aria-label': host.t('WatchlistFilter') }, [
51
+ makeElement('button', 'wl-tab active', { 'data-filter': 'all', role: 'tab', 'aria-selected': 'true' }, [host.t('All')]),
52
+ makeElement('button', 'wl-tab', { 'data-filter': 'favorites', role: 'tab', 'aria-selected': 'false', 'aria-label': favorites, title: favorites }, ['★']),
53
+ ]),
54
+ makeElement('div', 'watchlist-pane', {}, [
55
+ makeElement('table', 'watchlist-table', {}, [
56
+ makeElement('thead', 'watchlist-headers', {}, []),
57
+ makeElement('tbody', 'watchlist-body', {}, []),
58
+ ]),
59
+ ]),
60
+ ]);
61
+ }
62
+ constructor(rootEl, _state, deps) {
63
+ this._host = assertHost(deps?.host, 'WatchlistWidget');
64
+ if (typeof deps?.onSelect !== 'function')
65
+ throw new Error('WatchlistWidget: dep "onSelect" is required');
66
+ this.rootEl = rootEl;
67
+ this._deps = deps;
68
+ this.api = this._host.trading.api;
69
+ this.instruments = [];
70
+ this.stats = new Map();
71
+ this.favorites = new Set(this._loadFavorites());
72
+ this.filter = 'all';
73
+ this.search = '';
74
+ this.currentSymbol = null;
75
+ this._subscribedSyms = new Set();
76
+ this.wsClient = this._host.trading.marketData;
77
+ this.bodyEl = this.rootEl.querySelector('.watchlist-body');
78
+ this.searchEl = this.rootEl.querySelector('.watchlist-search');
79
+ this.tabsEl = this.rootEl.querySelector('.watchlist-tabs');
80
+ this.sortHeaderEl = this.rootEl.querySelector('.watchlist-headers');
81
+ this._closeBtn = this.rootEl.querySelector('.panel-close-btn');
82
+ this._exportBtn = this.rootEl.querySelector('.panel-export-btn');
83
+ this._closeBtn?.addEventListener('click', (e) => {
84
+ e.preventDefault();
85
+ this.dispose();
86
+ this._host.close();
87
+ });
88
+ this._exportBtn?.addEventListener('click', (e) => {
89
+ e.preventDefault();
90
+ this._export();
91
+ });
92
+ this._grid = this.sortHeaderEl && this.bodyEl
93
+ ? new DataGrid({
94
+ head: this.sortHeaderEl,
95
+ body: this.bodyEl,
96
+ columns: this._columns(),
97
+ // Symbol A→Z at rest — an instrument list has no natural "newest",
98
+ // and alphabetical is what the user scans by.
99
+ defaultSort: { col: 'symbol', dir: 'asc' },
100
+ rowKey: (i) => String(i.symbol),
101
+ emptyText: this._host.t('No instruments'),
102
+ rowClass: (i) => (i.symbol === this.currentSymbol ? 'wl-row wl-current' : 'wl-row'),
103
+ bindRow: (tr, i) => tr.addEventListener('click', () => this._deps.onSelect(i.symbol)),
104
+ // Paint a screenful, export and subscribe over the whole filtered set.
105
+ renderLimit: WatchlistWidget.RENDER_CAP,
106
+ // A header click re-renders through the grid, so this is the only
107
+ // place that sees every change to the visible set — including a sort
108
+ // the widget was never told about.
109
+ afterRender: () => {
110
+ this._syncSubs();
111
+ this._publishVisible();
112
+ },
113
+ })
114
+ : null;
115
+ this._bind();
116
+ this._host.register(this);
117
+ // Auto-init data load: a caller that creates the panel expects a working
118
+ // widget without further ceremony. Unconditional — the host port
119
+ // guarantees an API client, so there is no "maybe we can load" state
120
+ // left to branch on.
121
+ void this.init();
122
+ }
123
+ dispose() {
124
+ // Release every live subscription this widget held — the market-data
125
+ // client refcounts them, so another control's subscription survives if
126
+ // it happened to share a symbol with us.
127
+ for (const sym of this._subscribedSyms) {
128
+ try {
129
+ void this.wsClient?.removeSymbol(sym);
130
+ }
131
+ catch { /* socket may be torn down */ }
132
+ }
133
+ this._subscribedSyms.clear();
134
+ this._host.unregister(this);
135
+ try {
136
+ this.rootEl.remove();
137
+ }
138
+ catch { /* already detached */ }
139
+ }
140
+ async init() {
141
+ try {
142
+ this.instruments = await this.api.searchInstruments('');
143
+ }
144
+ catch (err) {
145
+ // Through the port, not the console: this is the diagnostic the
146
+ // user cannot see and support has to, and routing it here is also
147
+ // what makes it assertable.
148
+ this._host.log(`WatchlistWidget: failed to load instruments: ${err}`);
149
+ this.instruments = [];
150
+ }
151
+ this._renderCategoryTabs();
152
+ this._render();
153
+ }
154
+ // Build the filter tabs from the assigned instrument categories. "All" and
155
+ // "Favorites" are built into the markup; here we append one tab per distinct
156
+ // non-empty category found in the loaded instruments. Re-runnable: clears
157
+ // any category tabs a previous load added.
158
+ _renderCategoryTabs() {
159
+ if (!this.tabsEl)
160
+ return;
161
+ this.tabsEl.querySelectorAll('.wl-tab[data-category]').forEach(el => el.remove());
162
+ const cats = Array.from(new Set(this.instruments
163
+ .map(i => (i.category || '').trim())
164
+ .filter(c => c.length > 0)))
165
+ .sort((a, b) => a.localeCompare(b));
166
+ for (const cat of cats) {
167
+ const btn = document.createElement('button');
168
+ btn.className = 'wl-tab';
169
+ btn.setAttribute('role', 'tab');
170
+ btn.setAttribute('aria-selected', 'false');
171
+ btn.dataset.filter = cat;
172
+ btn.dataset.category = '1';
173
+ btn.textContent = cat;
174
+ this.tabsEl.appendChild(btn);
175
+ }
176
+ }
177
+ /// Highlight the instrument the rest of the page is showing. Patches the two
178
+ /// affected rows rather than repainting: a repaint here would restart any
179
+ /// flash animation currently running in a price cell.
180
+ setCurrentSymbol(symbol) {
181
+ const previous = this.currentSymbol;
182
+ this.currentSymbol = symbol;
183
+ if (!this._grid)
184
+ return;
185
+ if (previous)
186
+ this._grid.rowElement(String(previous))?.classList.remove('wl-current');
187
+ if (symbol)
188
+ this._grid.rowElement(String(symbol))?.classList.add('wl-current');
189
+ }
190
+ onPriceUpdate(symbol, price) {
191
+ if (price == null || !isFinite(price))
192
+ return;
193
+ let full = symbol;
194
+ if (!full.includes('@')) {
195
+ const match = this.instruments.find(i => String(i.symbol).split('@')[0] === symbol);
196
+ if (match?.symbol)
197
+ full = match.symbol;
198
+ }
199
+ const cur = this.stats.get(full);
200
+ const prev = cur?.lastPrice;
201
+ // Session-day baseline: first observed live price per (UTC-day, symbol).
202
+ // Kept in the host's cache so reloading the page doesn't jump the
203
+ // baseline mid-day. New UTC day = fresh baseline.
204
+ const baselineKey = WatchlistWidget._baselineKey(full);
205
+ let baseline = cur?.baseline;
206
+ if (baseline == null) {
207
+ const stored = this._host.cache.get(baselineKey, null);
208
+ baseline = stored ? Number(stored) : undefined;
209
+ }
210
+ if (baseline == null || !isFinite(baseline) || baseline === 0) {
211
+ baseline = price;
212
+ this._host.cache.set(baselineKey, String(price));
213
+ }
214
+ const chgPct = baseline ? ((price - baseline) / baseline) * 100 : 0;
215
+ this.stats.set(full, { ...(cur || {}), lastPrice: price, baseline, chgPct });
216
+ this._updateRow(full, prev);
217
+ }
218
+ static _baselineKey(symbol) {
219
+ const day = new Date().toISOString().slice(0, 10); // YYYY-MM-DD (UTC)
220
+ return WatchlistWidget.BASELINE_KEY_PREFIX + day + ':' + symbol;
221
+ }
222
+ _bind() {
223
+ if (this.searchEl) {
224
+ this.searchEl.addEventListener('input', () => {
225
+ this.search = (this.searchEl.value || '').trim().toLowerCase();
226
+ this._render();
227
+ });
228
+ }
229
+ if (this.tabsEl) {
230
+ this.tabsEl.addEventListener('click', (e) => {
231
+ const tgt = e.target;
232
+ const btn = tgt?.closest('.wl-tab');
233
+ if (!btn)
234
+ return;
235
+ this.filter = btn.dataset.filter || 'all';
236
+ this.tabsEl.querySelectorAll('.wl-tab').forEach(b => b.classList.toggle('active', b === btn));
237
+ this._render();
238
+ });
239
+ }
240
+ // Sort header clicks are handled by the grid (wired in the constructor).
241
+ }
242
+ // The instruments matching the search box and the active tab, unsorted —
243
+ // the grid owns the order.
244
+ _filtered() {
245
+ const q = this.search;
246
+ const rows = [];
247
+ for (const inst of this.instruments) {
248
+ const sym = (inst.symbol || '').toUpperCase();
249
+ // Match the "symbol/exchange" (and "symbol@exchange") display form too, so a
250
+ // full "BTC/IMEX" query resolves — not only the bare symbol "BTC".
251
+ const symL = sym.toLowerCase();
252
+ const shortSym = symL.split('@')[0];
253
+ const exch = (inst.exchange || '').toLowerCase();
254
+ const qualified = `${shortSym}/${exch}`;
255
+ const qualifiedAt = `${shortSym}@${exch}`;
256
+ if (q && !symL.includes(q) && !(inst.name || '').toLowerCase().includes(q) && !qualified.includes(q) && !qualifiedAt.includes(q))
257
+ continue;
258
+ if (this.filter === 'favorites') {
259
+ if (!this.favorites.has(sym))
260
+ continue;
261
+ }
262
+ else if (this.filter !== 'all') {
263
+ // Any other filter value is an assigned instrument category,
264
+ // matched case-insensitively.
265
+ if ((inst.category || '').toLowerCase() !== this.filter.toLowerCase())
266
+ continue;
267
+ }
268
+ rows.push(inst);
269
+ }
270
+ return rows;
271
+ }
272
+ _render() {
273
+ this._grid?.setRows(this._filtered());
274
+ }
275
+ // The blotter's single column declaration. Prices and percentages come off
276
+ // the live stats map rather than the instrument row, so a quote arriving
277
+ // between two renders is picked up by the next one.
278
+ _columns() {
279
+ const label = (key) => this._host.t(key);
280
+ return [
281
+ {
282
+ key: 'symbol',
283
+ header: label('Symbol'),
284
+ exportable: true,
285
+ value: (i) => i.symbol,
286
+ cellClass: () => 'wl-sym-cell',
287
+ render: (i) => this._symbolCell(i),
288
+ exportValue: (i) => String(i.symbol).split('@')[0],
289
+ },
290
+ {
291
+ key: 'last',
292
+ header: label('Last'),
293
+ headerClass: 'ta-right',
294
+ exportable: true,
295
+ value: (i) => this._statsOf(i).lastPrice,
296
+ cellClass: () => 'wl-last',
297
+ render: (i) => WatchlistWidget._priceText(this._statsOf(i).lastPrice),
298
+ exportValue: (i) => this._statsOf(i).lastPrice ?? '',
299
+ },
300
+ {
301
+ key: 'chgPct',
302
+ header: label('Change24hPct'),
303
+ headerClass: 'ta-right',
304
+ exportable: true,
305
+ value: (i) => this._statsOf(i).chgPct,
306
+ cellClass: (i) => ('wl-chg ' + WatchlistWidget._changeClass(this._statsOf(i).chgPct)).trim(),
307
+ render: (i) => WatchlistWidget._changeText(this._statsOf(i).chgPct),
308
+ exportValue: (i) => this._statsOf(i).chgPct ?? '',
309
+ },
310
+ ];
311
+ }
312
+ _statsOf(instrument) {
313
+ return this.stats.get(String(instrument.symbol)) ?? {};
314
+ }
315
+ // The favourite star plus the short symbol. The star stops the click from
316
+ // reaching the row, whose own listener switches the host's instrument.
317
+ _symbolCell(instrument) {
318
+ const cell = document.createDocumentFragment();
319
+ const star = document.createElement('button');
320
+ star.type = 'button';
321
+ star.className = this.favorites.has(instrument.symbol) ? 'wl-fav active' : 'wl-fav';
322
+ star.title = this._host.t('Favorite');
323
+ star.textContent = '★';
324
+ star.addEventListener('click', (e) => {
325
+ e.stopPropagation();
326
+ this._toggleFavorite(instrument.symbol);
327
+ });
328
+ cell.appendChild(star);
329
+ const label = document.createElement('span');
330
+ label.className = 'wl-sym';
331
+ label.textContent = String(instrument.symbol).split('@')[0];
332
+ cell.appendChild(label);
333
+ return cell;
334
+ }
335
+ // Export the current filtered+sorted view to .xlsx — every matching
336
+ // instrument, without the RENDER_CAP truncation applied to the DOM.
337
+ _export() {
338
+ this._grid?.download('watchlist', this._host.t('Markets'));
339
+ }
340
+ // Patch the price and change cells of one row in place. A full render would
341
+ // replace the cell element and so cancel the flash animation started here.
342
+ _updateRow(symbol, prevPrice) {
343
+ if (!this._grid)
344
+ return;
345
+ const st = this.stats.get(symbol) || {};
346
+ const lastEl = this._grid.cellElement(String(symbol), 'last');
347
+ const chgEl = this._grid.cellElement(String(symbol), 'chgPct');
348
+ if (lastEl && st.lastPrice != null) {
349
+ lastEl.textContent = WatchlistWidget._priceText(st.lastPrice);
350
+ if (prevPrice != null && st.lastPrice !== prevPrice) {
351
+ lastEl.classList.remove('flash-up', 'flash-down');
352
+ void lastEl.offsetWidth;
353
+ lastEl.classList.add(st.lastPrice > prevPrice ? 'flash-up' : 'flash-down');
354
+ }
355
+ }
356
+ if (chgEl && st.chgPct != null && isFinite(Number(st.chgPct))) {
357
+ chgEl.textContent = WatchlistWidget._changeText(st.chgPct);
358
+ chgEl.classList.remove('up', 'down');
359
+ chgEl.classList.add(WatchlistWidget._changeClass(st.chgPct));
360
+ }
361
+ }
362
+ _toggleFavorite(symbol) {
363
+ if (!this._host.allow('add to favorites'))
364
+ return;
365
+ if (this.favorites.has(symbol))
366
+ this.favorites.delete(symbol);
367
+ else
368
+ this.favorites.add(symbol);
369
+ this._saveFavorites();
370
+ // Broadcast the change to every other watchlist instance so they reflect
371
+ // the new state without a fresh fetch.
372
+ this._host.broadcast(w => {
373
+ if (w !== this) {
374
+ w.favorites = new Set(this.favorites);
375
+ w._render();
376
+ }
377
+ });
378
+ this._render();
379
+ }
380
+ _loadFavorites() {
381
+ try {
382
+ const raw = this._host.preferences.get(WatchlistWidget.FAVORITES_KEY, null);
383
+ return raw ? JSON.parse(raw) : [];
384
+ }
385
+ catch {
386
+ return [];
387
+ }
388
+ }
389
+ _saveFavorites() {
390
+ try {
391
+ this._host.preferences.set(WatchlistWidget.FAVORITES_KEY, JSON.stringify(Array.from(this.favorites)));
392
+ }
393
+ catch { /* store may be unavailable */ }
394
+ }
395
+ // The symbols at the top of the current order — the ones a user is actually
396
+ // looking at, and the set both the subscriptions and the host's ticker are
397
+ // sized to.
398
+ _visible() {
399
+ return this._grid ? this._grid.sortedRows().slice(0, WatchlistWidget.VISIBLE_CAP) : [];
400
+ }
401
+ // Diff the desired set of visible symbols against currently-held live-price
402
+ // subscriptions, then add/remove to converge. Called after every render that
403
+ // may have changed the visible list (filter, sort, search). add/removeSymbol
404
+ // refcount internally, so another control's subscription on the same symbol
405
+ // is not affected.
406
+ _syncSubs() {
407
+ if (!this.wsClient)
408
+ return;
409
+ const desired = new Set(this._visible().map(i => String(i.symbol).split('@')[0]));
410
+ for (const sym of this._subscribedSyms) {
411
+ if (!desired.has(sym)) {
412
+ try {
413
+ void this.wsClient.removeSymbol(sym);
414
+ }
415
+ catch { /* socket race */ }
416
+ this._subscribedSyms.delete(sym);
417
+ }
418
+ }
419
+ // Stagger the subscribe burst — firing every watchlist symbol
420
+ // simultaneously while a chart is fetching its history starves the
421
+ // adapter and stalls the chart's snapshot. 80ms between calls keeps the
422
+ // pipe quiet enough for that fetch to return on time, while still
423
+ // feeling instant to the user.
424
+ let i = 0;
425
+ for (const sym of desired) {
426
+ if (this._subscribedSyms.has(sym))
427
+ continue;
428
+ this._subscribedSyms.add(sym);
429
+ setTimeout(() => {
430
+ try {
431
+ void this.wsClient.addSymbol(sym, MarketDataLevels.Quotes);
432
+ }
433
+ catch { /* socket race */ }
434
+ }, i * 80);
435
+ i++;
436
+ }
437
+ }
438
+ // Tell the host which symbols are on screen. Only the primary instance
439
+ // speaks for the page: duplicated watchlist panels have their own filters,
440
+ // and the page has one ticker for them to fight over.
441
+ _publishVisible() {
442
+ if (!this._host.isPrimary)
443
+ return;
444
+ this._host.ticker.publish(this._visible().map(i => String(i.symbol)), this.stats);
445
+ }
446
+ static _priceText(price) {
447
+ const n = Number(price);
448
+ if (price == null || !isFinite(n) || n === 0)
449
+ return '--';
450
+ if (n >= 1)
451
+ return n.toFixed(2);
452
+ if (n >= 0.01)
453
+ return n.toFixed(4);
454
+ return n.toFixed(6);
455
+ }
456
+ static _changeText(chgPct) {
457
+ const pct = Number(chgPct);
458
+ if (chgPct == null || !isFinite(pct))
459
+ return '--';
460
+ return `${pct >= 0 ? '+' : ''}${pct.toFixed(2)}%`;
461
+ }
462
+ static _changeClass(chgPct) {
463
+ const pct = Number(chgPct);
464
+ if (chgPct == null || !isFinite(pct))
465
+ return '';
466
+ return pct >= 0 ? 'up' : 'down';
467
+ }
468
+ }
469
+ WatchlistWidget.FAVORITES_KEY = 'terminal_watchlist_favorites';
470
+ // Cache-key prefix for the per-session baseline price used to compute the
471
+ // change %. Day-scoped so the baseline resets every UTC day and the
472
+ // percent matches "since today open" intuitively. (Without a REST bars
473
+ // endpoint there is no broker-side day-open available, and the watchlist
474
+ // deliberately avoids REST — the live stream is its only source.) It goes
475
+ // in the host's cache rather than its preferences: one key per symbol per
476
+ // day is scratch, not a setting worth syncing.
477
+ WatchlistWidget.BASELINE_KEY_PREFIX = 'wlBaseline:';
478
+ WatchlistWidget.VISIBLE_CAP = 30;
479
+ WatchlistWidget.RENDER_CAP = 300;
480
+ WatchlistWidget.TYPE = ControlTypes.Watchlist;
481
+ //# sourceMappingURL=watchlist-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchlist-widget.js","sourceRoot":"","sources":["../../src/watchlist-widget.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;AAC7E,qDAAqD;AACrD,EAAE;AACF,gFAAgF;AAChF,0EAA0E;AAC1E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,+DAA+D;AAC/D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACnF,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