@stocksharp/trading-controls 1.2.0 → 1.3.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 +95 -16
- package/dist/esm/black-scholes.js +147 -0
- package/dist/esm/black-scholes.js.map +1 -0
- package/dist/esm/control-types.js +4 -0
- package/dist/esm/control-types.js.map +1 -1
- package/dist/esm/index.js +18 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/log-monitor-widget.js +265 -0
- package/dist/esm/log-monitor-widget.js.map +1 -0
- package/dist/esm/log-tree.js +96 -0
- package/dist/esm/log-tree.js.map +1 -0
- package/dist/esm/option-desk-widget.js +322 -0
- package/dist/esm/option-desk-widget.js.map +1 -0
- package/dist/esm/pnl-curve.js +129 -0
- package/dist/esm/pnl-curve.js.map +1 -0
- package/dist/esm/statistics-widget.js +194 -0
- package/dist/esm/statistics-widget.js.map +1 -0
- package/dist/esm/strategies-widget.js +348 -0
- package/dist/esm/strategies-widget.js.map +1 -0
- package/dist/sstradingcontrols.js +1307 -47
- package/dist/sstradingcontrols.js.map +4 -4
- package/dist/types/black-scholes.d.ts +28 -0
- package/dist/types/black-scholes.d.ts.map +1 -0
- package/dist/types/control-types.d.ts +4 -0
- package/dist/types/control-types.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/log-monitor-widget.d.ts +42 -0
- package/dist/types/log-monitor-widget.d.ts.map +1 -0
- package/dist/types/log-tree.d.ts +34 -0
- package/dist/types/log-tree.d.ts.map +1 -0
- package/dist/types/option-desk-widget.d.ts +68 -0
- package/dist/types/option-desk-widget.d.ts.map +1 -0
- package/dist/types/pnl-curve.d.ts +43 -0
- package/dist/types/pnl-curve.d.ts.map +1 -0
- package/dist/types/statistics-widget.d.ts +29 -0
- package/dist/types/statistics-widget.d.ts.map +1 -0
- package/dist/types/strategies-widget.d.ts +63 -0
- package/dist/types/strategies-widget.d.ts.map +1 -0
- package/dist/types/trading-data.d.ts +9 -0
- package/dist/types/trading-data.d.ts.map +1 -1
- package/package.json +27 -2
- package/screenshots/log-monitor.png +0 -0
- package/screenshots/option-desk.png +0 -0
- package/screenshots/panels.jpg +0 -0
- package/screenshots/statistics.png +0 -0
- package/screenshots/strategies.png +0 -0
- package/src/black-scholes.ts +199 -0
- package/src/control-types.ts +4 -0
- package/src/index.ts +41 -0
- package/src/log-monitor-widget.ts +312 -0
- package/src/log-tree.ts +131 -0
- package/src/option-desk-widget.ts +422 -0
- package/src/pnl-curve.ts +204 -0
- package/src/statistics-widget.ts +226 -0
- package/src/strategies-widget.ts +435 -0
- package/src/trading-data.ts +22 -0
- package/styles/trading-controls.css +356 -0
- package/translation-keys.json +70 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Strategy statistics — multi-instance.
|
|
2
|
+
//
|
|
3
|
+
// A read-only table of everything a strategy reports about itself: net profit, drawdown, trade
|
|
4
|
+
// counts, latencies. One row per parameter, grouped by the area it belongs to.
|
|
5
|
+
//
|
|
6
|
+
// The desktop grid derives its rows by reflecting over the strategy's statistic parameters, and
|
|
7
|
+
// a browser has no equivalent - so the rows arrive from the consumer already resolved, name and
|
|
8
|
+
// description translated, with the two things that decide where a row sits: a stable category
|
|
9
|
+
// key and the registry order. Both matter. Grouping on the translated category would regroup
|
|
10
|
+
// the table when the language changes, and sorting by name or by value would scatter parameters
|
|
11
|
+
// that are read together.
|
|
12
|
+
import { makeElement, makeIconButton, makePanelId, makePanelRoot } from './dom.js';
|
|
13
|
+
import { ControlTypes } from './control-types.js';
|
|
14
|
+
import { makeGridMenu } from './grid-menu.js';
|
|
15
|
+
import { assertHost } from './trading-host.js';
|
|
16
|
+
import { DataGrid } from '@stocksharp/grids/data-grid';
|
|
17
|
+
/// Give every category the place of its first parameter.
|
|
18
|
+
///
|
|
19
|
+
/// Taken from the rows rather than assumed: the registry bands its orders by category today
|
|
20
|
+
/// - profit below a hundred, trades from a hundred - but a consumer numbering them some
|
|
21
|
+
/// other way still gets its groups in the order it asked for.
|
|
22
|
+
function rank(rows) {
|
|
23
|
+
const first = new Map();
|
|
24
|
+
for (const row of rows) {
|
|
25
|
+
const seen = first.get(row.category);
|
|
26
|
+
if (seen === undefined || row.order < seen)
|
|
27
|
+
first.set(row.category, row.order);
|
|
28
|
+
}
|
|
29
|
+
return rows.map(row => ({ ...row, categoryRank: first.get(row.category) ?? row.order }));
|
|
30
|
+
}
|
|
31
|
+
export class StatisticsWidget {
|
|
32
|
+
static create(hostEl, state, deps) {
|
|
33
|
+
const host = assertHost(deps?.host, 'StatisticsWidget');
|
|
34
|
+
const root = StatisticsWidget._buildRoot(host);
|
|
35
|
+
root.id = makePanelId(StatisticsWidget.TYPE);
|
|
36
|
+
hostEl.appendChild(root);
|
|
37
|
+
return new StatisticsWidget(root, state || {}, deps);
|
|
38
|
+
}
|
|
39
|
+
// The panel's markup. No rail action but the export: a statistic is produced by the
|
|
40
|
+
// strategy and there is nothing here to cancel, reload or edit.
|
|
41
|
+
static _buildRoot(host) {
|
|
42
|
+
const title = host.t('Statistics');
|
|
43
|
+
return makePanelRoot('statistics-panel', title, [
|
|
44
|
+
makeElement('div', 'panel-header', {}, [
|
|
45
|
+
makeElement('span', '', {}, [title]),
|
|
46
|
+
makeIconButton('bt-icon-btn bt-icon-cancel panel-close-btn', host.t('ClosePanel'), 'bi-x', { type: 'button' }),
|
|
47
|
+
]),
|
|
48
|
+
makeElement('div', 'panel-body panel-body-with-rail', {}, [
|
|
49
|
+
makeElement('div', 'panel-body-content', {}, [
|
|
50
|
+
makeElement('table', 'terminal-table statistics-table', { role: 'table', 'aria-label': host.t('StatisticsList') }, [
|
|
51
|
+
makeElement('thead', '', {}, []),
|
|
52
|
+
makeElement('tbody', 'statistics-body', {}, []),
|
|
53
|
+
]),
|
|
54
|
+
]),
|
|
55
|
+
makeElement('div', 'panel-rail', { role: 'toolbar', 'aria-label': host.t('StatisticsActions') }, [
|
|
56
|
+
makeIconButton('bt-icon-btn panel-export-btn', host.t('ExportToExcel'), 'bi-file-earmark-spreadsheet', {}),
|
|
57
|
+
]),
|
|
58
|
+
]),
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
constructor(rootEl, _state, deps) {
|
|
62
|
+
this._host = assertHost(deps?.host, 'StatisticsWidget');
|
|
63
|
+
this.rootEl = rootEl;
|
|
64
|
+
this.el = this.rootEl.querySelector('.statistics-body');
|
|
65
|
+
this._closeBtn = this.rootEl.querySelector('.panel-close-btn');
|
|
66
|
+
this._exportBtn = this.rootEl.querySelector('.panel-export-btn');
|
|
67
|
+
this._rows = [];
|
|
68
|
+
this._closeBtn?.addEventListener('click', (e) => {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
this._host.close();
|
|
71
|
+
});
|
|
72
|
+
this._exportBtn?.addEventListener('click', (e) => {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
this._export();
|
|
75
|
+
});
|
|
76
|
+
const head = this.rootEl.querySelector('.statistics-table thead');
|
|
77
|
+
this._grid = head && this.el
|
|
78
|
+
? new DataGrid({
|
|
79
|
+
head: head,
|
|
80
|
+
body: this.el,
|
|
81
|
+
columns: this._columns(),
|
|
82
|
+
// Not a sort the reader chose: the registry hands every parameter an order, and
|
|
83
|
+
// the bands it assigns are what puts profit above drawdown above trade counts.
|
|
84
|
+
defaultSort: { col: 'order', dir: 'asc' },
|
|
85
|
+
rowKey: (r) => String(r.key),
|
|
86
|
+
emptyText: this._host.t('NoStatistics'),
|
|
87
|
+
contextMenu: makeGridMenu(this._host),
|
|
88
|
+
// The groups sit where the registry order puts them, not where the
|
|
89
|
+
// alphabet would: profit, then trades, then positions, then orders.
|
|
90
|
+
groupOrder: 'rows',
|
|
91
|
+
selection: 'multi',
|
|
92
|
+
})
|
|
93
|
+
: null;
|
|
94
|
+
// Grouped on the key, never on the caption: the caption is translated and would
|
|
95
|
+
// regroup the table under the reader's language. Neither the key nor the order is a
|
|
96
|
+
// column anyone reads, so both are hidden - declared, so the grid can group and sort
|
|
97
|
+
// on them, and out of the way.
|
|
98
|
+
this._grid?.setState({ group: 'category', hidden: ['category', 'order'] });
|
|
99
|
+
this._host.register(this);
|
|
100
|
+
}
|
|
101
|
+
dispose() {
|
|
102
|
+
this._grid?.destroy();
|
|
103
|
+
this._host.unregister(this);
|
|
104
|
+
try {
|
|
105
|
+
this.rootEl.remove();
|
|
106
|
+
}
|
|
107
|
+
catch { /* already detached */ }
|
|
108
|
+
}
|
|
109
|
+
/// Show these statistics. The whole set at once: a strategy publishes its parameters as one
|
|
110
|
+
/// table and a row that vanished from it has stopped existing, not stopped changing.
|
|
111
|
+
update(rows) {
|
|
112
|
+
this._rows = rank(rows || []);
|
|
113
|
+
this._grid?.setRows(this._rows);
|
|
114
|
+
}
|
|
115
|
+
_export() {
|
|
116
|
+
this._grid?.download('statistics', this._host.t('Statistics'));
|
|
117
|
+
}
|
|
118
|
+
// Two visible columns and one that only groups. The order column is hidden as well: it
|
|
119
|
+
// decides the sort and means nothing to a reader.
|
|
120
|
+
_columns() {
|
|
121
|
+
const label = (key) => this._host.t(key);
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
key: 'category',
|
|
125
|
+
header: label('Category'),
|
|
126
|
+
exportable: false,
|
|
127
|
+
// The group's place, not its name: groups are laid out in the order the
|
|
128
|
+
// registry gives their parameters, so profit comes before trade counts.
|
|
129
|
+
// Grouping on the name would order them alphabetically, and on the
|
|
130
|
+
// translated name would reorder them with the reader's language.
|
|
131
|
+
value: (r) => r.categoryRank,
|
|
132
|
+
text: (r) => r.categoryText || r.category,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
key: 'order',
|
|
136
|
+
header: label('Order'),
|
|
137
|
+
exportable: false,
|
|
138
|
+
value: (r) => r.order,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
key: 'name',
|
|
142
|
+
header: label('Name'),
|
|
143
|
+
exportable: true,
|
|
144
|
+
value: (r) => r.name,
|
|
145
|
+
bindCell: (td, r) => {
|
|
146
|
+
if (r.description)
|
|
147
|
+
td.setAttribute('title', r.description);
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
key: 'value',
|
|
152
|
+
header: label('Value'),
|
|
153
|
+
exportable: true,
|
|
154
|
+
cellClass: () => 'statistic-value',
|
|
155
|
+
// Sorts on the raw value so a number sorts as a number, reads as the text below.
|
|
156
|
+
value: (r) => r.value,
|
|
157
|
+
render: (r) => formatStatistic(r.value),
|
|
158
|
+
exportValue: (r) => r.value ?? '',
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
StatisticsWidget.TYPE = ControlTypes.Statistics;
|
|
164
|
+
/// A statistic as text.
|
|
165
|
+
///
|
|
166
|
+
/// Three shapes reach this: a number, a moment, and everything else. A number is rounded to two
|
|
167
|
+
/// places and shown without trailing zeros - a profit of 11055.75 and a count of 1340 both read
|
|
168
|
+
/// the way they are meant to. A moment is a date: these are run-level facts (the day of the
|
|
169
|
+
/// maximum drawdown), and the hour would be noise. Anything with no value yet is a blank cell
|
|
170
|
+
/// rather than a zero, which would read as a measured nothing.
|
|
171
|
+
export function formatStatistic(value) {
|
|
172
|
+
if (value === null || value === undefined || value === '')
|
|
173
|
+
return '';
|
|
174
|
+
if (typeof value === 'number') {
|
|
175
|
+
if (!isFinite(value))
|
|
176
|
+
return '';
|
|
177
|
+
return String(Math.round(value * 100) / 100);
|
|
178
|
+
}
|
|
179
|
+
if (value instanceof Date)
|
|
180
|
+
return isoDate(value);
|
|
181
|
+
if (typeof value === 'string') {
|
|
182
|
+
// A date only when it is unambiguously one: a bare number in a string stays a number,
|
|
183
|
+
// and a name stays a name.
|
|
184
|
+
const at = /^\d{4}-\d{2}-\d{2}([T ]|$)/.test(value) ? new Date(value) : null;
|
|
185
|
+
if (at !== null && !isNaN(at.getTime()))
|
|
186
|
+
return isoDate(at);
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
return String(value);
|
|
190
|
+
}
|
|
191
|
+
function isoDate(at) {
|
|
192
|
+
return at.toISOString().slice(0, 10);
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=statistics-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistics-widget.js","sourceRoot":"","sources":["../../src/statistics-widget.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,+FAA+F;AAC/F,+EAA+E;AAC/E,EAAE;AACF,gGAAgG;AAChG,gGAAgG;AAChG,8FAA8F;AAC9F,6FAA6F;AAC7F,gGAAgG;AAChG,0BAA0B;AAC1B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAc,MAAM,oCAAoC,CAAC;AAY1E,yDAAyD;AACzD,GAAG;AACH,4FAA4F;AAC5F,wFAAwF;AACxF,8DAA8D;AAC9D,SAAS,IAAI,CAAC,IAA6B;IACvC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,KAAK,GAAG,IAAI;YAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,KAAK,C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C,KAAK,CAAC,CAAC;IAEjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,sFAAsF;QACtF,2BAA2B;QAC3B,MAAM,EAAE,GAAG,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7E,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;YAAE,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5D,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,OAAO,CAAC,EAAQ;IACrB,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// Strategies dashboard — multi-instance.
|
|
2
|
+
//
|
|
3
|
+
// A row per strategy: what state it is in, what it is trading, what it has done, and the
|
|
4
|
+
// controls to start it, stop it and flatten it. This is the panel a browser client exists for -
|
|
5
|
+
// the strategies run on a server and the page is how someone reaches them.
|
|
6
|
+
//
|
|
7
|
+
// Three deliberate departures from the desktop version, each because copying it would carry a
|
|
8
|
+
// defect across. Its Settings button is wired to a disabled command in both shipped hosts, so a
|
|
9
|
+
// viewer sees a permanently dead control - that button is not here, and the rest are declared
|
|
10
|
+
// through deps, so a host that cannot do a thing does not show a button for it. Its P&L
|
|
11
|
+
// sparkline is filled green unconditionally, which paints a losing run in the winning colour;
|
|
12
|
+
// here the curve is coloured by where the run ended. And its P&L change is measured from the
|
|
13
|
+
// first non-zero P&L and never re-anchored, so a restarted strategy keeps measuring from before
|
|
14
|
+
// the restart; here the consumer states the number it means.
|
|
15
|
+
import { formatPnl, formatQty } from './formatters.js';
|
|
16
|
+
import { makeElement, makeIconButton, makePanelId, makePanelRoot } from './dom.js';
|
|
17
|
+
import { ControlTypes } from './control-types.js';
|
|
18
|
+
import { makeGridMenu } from './grid-menu.js';
|
|
19
|
+
import { assertHost } from './trading-host.js';
|
|
20
|
+
import { drawPnlCurve, pnlCurve } from './pnl-curve.js';
|
|
21
|
+
import { DataGrid } from '@stocksharp/grids/data-grid';
|
|
22
|
+
/// The states a strategy moves through, as the wire spells them.
|
|
23
|
+
export const StrategyStates = {
|
|
24
|
+
Stopped: 'stopped',
|
|
25
|
+
Starting: 'starting',
|
|
26
|
+
Started: 'started',
|
|
27
|
+
Stopping: 'stopping',
|
|
28
|
+
};
|
|
29
|
+
const SPARK_WIDTH = 140;
|
|
30
|
+
const SPARK_HEIGHT = 26;
|
|
31
|
+
export class StrategiesWidget {
|
|
32
|
+
static create(hostEl, state, deps) {
|
|
33
|
+
const host = assertHost(deps?.host, 'StrategiesWidget');
|
|
34
|
+
const root = StrategiesWidget._buildRoot(host);
|
|
35
|
+
root.id = makePanelId(StrategiesWidget.TYPE);
|
|
36
|
+
hostEl.appendChild(root);
|
|
37
|
+
return new StrategiesWidget(root, state || {}, deps);
|
|
38
|
+
}
|
|
39
|
+
static _buildRoot(host) {
|
|
40
|
+
const title = host.t('Strategies');
|
|
41
|
+
return makePanelRoot('strategies-panel', title, [
|
|
42
|
+
makeElement('div', 'panel-header', {}, [
|
|
43
|
+
makeElement('span', '', {}, [title]),
|
|
44
|
+
makeIconButton('bt-icon-btn bt-icon-cancel panel-close-btn', host.t('ClosePanel'), 'bi-x', { type: 'button' }),
|
|
45
|
+
]),
|
|
46
|
+
makeElement('div', 'panel-body panel-body-with-rail', {}, [
|
|
47
|
+
makeElement('div', 'panel-body-content', {}, [
|
|
48
|
+
makeElement('table', 'terminal-table strategies-table', { role: 'table', 'aria-label': host.t('StrategiesList') }, [
|
|
49
|
+
makeElement('thead', '', {}, []),
|
|
50
|
+
makeElement('tbody', 'strategies-body', {}, []),
|
|
51
|
+
]),
|
|
52
|
+
]),
|
|
53
|
+
makeElement('div', 'panel-rail', { role: 'toolbar', 'aria-label': host.t('StrategiesActions') }, [
|
|
54
|
+
makeIconButton('bt-icon-btn panel-export-btn', host.t('ExportToExcel'), 'bi-file-earmark-spreadsheet', {}),
|
|
55
|
+
]),
|
|
56
|
+
]),
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
constructor(rootEl, _state, deps) {
|
|
60
|
+
this._host = assertHost(deps?.host, 'StrategiesWidget');
|
|
61
|
+
this._deps = deps;
|
|
62
|
+
this.rootEl = rootEl;
|
|
63
|
+
this.el = this.rootEl.querySelector('.strategies-body');
|
|
64
|
+
this._closeBtn = this.rootEl.querySelector('.panel-close-btn');
|
|
65
|
+
this._exportBtn = this.rootEl.querySelector('.panel-export-btn');
|
|
66
|
+
this._rows = [];
|
|
67
|
+
this._closeBtn?.addEventListener('click', (e) => { e.preventDefault(); this._host.close(); });
|
|
68
|
+
this._exportBtn?.addEventListener('click', (e) => { e.preventDefault(); this._export(); });
|
|
69
|
+
const head = this.rootEl.querySelector('.strategies-table thead');
|
|
70
|
+
this._grid = head && this.el
|
|
71
|
+
? new DataGrid({
|
|
72
|
+
head: head,
|
|
73
|
+
body: this.el,
|
|
74
|
+
columns: this._columns(),
|
|
75
|
+
// By name: a dashboard is a list someone reads down looking for one strategy,
|
|
76
|
+
// and a list that reorders itself as P&L moves cannot be read that way.
|
|
77
|
+
defaultSort: { col: 'name', dir: 'asc' },
|
|
78
|
+
rowKey: (s) => String(s.id),
|
|
79
|
+
emptyText: this._host.t('NoStrategies'),
|
|
80
|
+
rowClass: (s) => `strategy-row strategy-${s.state}${s.error ? ' strategy-failed' : ''}`,
|
|
81
|
+
contextMenu: makeGridMenu(this._host),
|
|
82
|
+
selection: 'multi',
|
|
83
|
+
})
|
|
84
|
+
: null;
|
|
85
|
+
this._host.register(this);
|
|
86
|
+
}
|
|
87
|
+
dispose() {
|
|
88
|
+
this._grid?.destroy();
|
|
89
|
+
this._host.unregister(this);
|
|
90
|
+
try {
|
|
91
|
+
this.rootEl.remove();
|
|
92
|
+
}
|
|
93
|
+
catch { /* already detached */ }
|
|
94
|
+
}
|
|
95
|
+
/// Show these strategies. The whole set: one that is gone from it has been removed, and
|
|
96
|
+
/// leaving its row behind would offer a Stop for something that no longer runs.
|
|
97
|
+
update(rows) {
|
|
98
|
+
this._rows = rows || [];
|
|
99
|
+
this._grid?.setRows(this._rows);
|
|
100
|
+
}
|
|
101
|
+
_export() {
|
|
102
|
+
this._grid?.download('strategies', this._host.t('Strategies'));
|
|
103
|
+
}
|
|
104
|
+
_columns() {
|
|
105
|
+
const label = (key) => this._host.t(key);
|
|
106
|
+
const presentation = this._host.presentation;
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
key: 'state',
|
|
110
|
+
header: label('State'),
|
|
111
|
+
exportable: true,
|
|
112
|
+
value: (s) => s.state,
|
|
113
|
+
render: (s) => this._stateCell(s),
|
|
114
|
+
cellClass: (s) => `strategy-state strategy-state-${s.state}`,
|
|
115
|
+
exportValue: (s) => s.state,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: 'actions',
|
|
119
|
+
header: label('Actions'),
|
|
120
|
+
headerHidden: true,
|
|
121
|
+
exportable: false,
|
|
122
|
+
cellClass: () => 'strategy-actions',
|
|
123
|
+
render: (s) => this._actionCell(s),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
key: 'online',
|
|
127
|
+
header: label('Online'),
|
|
128
|
+
exportable: true,
|
|
129
|
+
value: (s) => (s.online ? 1 : 0),
|
|
130
|
+
render: (s) => (s.online ? '●' : '○'),
|
|
131
|
+
cellClass: (s) => (s.online ? 'strategy-online is-on' : 'strategy-online'),
|
|
132
|
+
exportValue: (s) => (s.online ? label('Yes') : label('No')),
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
key: 'tradingMode',
|
|
136
|
+
header: label('Trading'),
|
|
137
|
+
exportable: true,
|
|
138
|
+
value: (s) => s.tradingMode ?? '',
|
|
139
|
+
render: (s) => this._tradingCell(s),
|
|
140
|
+
exportValue: (s) => s.tradingMode ?? '',
|
|
141
|
+
},
|
|
142
|
+
{ key: 'name', header: label('Name'), exportable: true, value: (s) => s.name },
|
|
143
|
+
{ key: 'portfolio', header: label('Portfolio'), exportable: true, value: (s) => s.portfolio ?? '' },
|
|
144
|
+
{ key: 'security', header: label('Sym'), exportable: true, value: (s) => s.security ?? '' },
|
|
145
|
+
{
|
|
146
|
+
key: 'position',
|
|
147
|
+
header: label('Position'),
|
|
148
|
+
exportable: true,
|
|
149
|
+
value: (s) => s.position ?? 0,
|
|
150
|
+
render: (s) => this._positionCell(s),
|
|
151
|
+
cellClass: (s) => `strategy-position ${presentation.pnlClass(s.position ?? 0)}`,
|
|
152
|
+
exportValue: (s) => s.position ?? 0,
|
|
153
|
+
},
|
|
154
|
+
{ key: 'orders', header: label('OrderCount'), exportable: true, value: (s) => s.ordersCount ?? 0 },
|
|
155
|
+
{ key: 'trades', header: label('NumOfTrades'), exportable: true, value: (s) => s.tradesCount ?? 0 },
|
|
156
|
+
{
|
|
157
|
+
key: 'pnlChange',
|
|
158
|
+
header: label('PnLChange'),
|
|
159
|
+
exportable: true,
|
|
160
|
+
value: (s) => s.pnlChange ?? 0,
|
|
161
|
+
render: (s) => `${direction(s.pnlChange ?? 0)} ${formatPnl(s.pnlChange ?? 0)}`,
|
|
162
|
+
cellClass: (s) => presentation.pnlClass(s.pnlChange ?? 0),
|
|
163
|
+
exportValue: (s) => s.pnlChange ?? 0,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: 'pnlChart',
|
|
167
|
+
header: label('PnLChart'),
|
|
168
|
+
exportable: false,
|
|
169
|
+
cellClass: () => 'strategy-spark',
|
|
170
|
+
render: (s) => this._sparkline(s),
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
key: 'realized',
|
|
174
|
+
header: label('RealizedProfit'),
|
|
175
|
+
exportable: true,
|
|
176
|
+
value: (s) => s.realized ?? 0,
|
|
177
|
+
render: (s) => formatPnl(s.realized ?? 0),
|
|
178
|
+
cellClass: (s) => presentation.pnlClass(s.realized ?? 0),
|
|
179
|
+
exportValue: (s) => s.realized ?? 0,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: 'unrealized',
|
|
183
|
+
header: label('UnrealizedProfit'),
|
|
184
|
+
exportable: true,
|
|
185
|
+
value: (s) => s.unrealized ?? 0,
|
|
186
|
+
render: (s) => formatPnl(s.unrealized ?? 0),
|
|
187
|
+
cellClass: (s) => presentation.pnlClass(s.unrealized ?? 0),
|
|
188
|
+
exportValue: (s) => s.unrealized ?? 0,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
key: 'error',
|
|
192
|
+
header: label('Error'),
|
|
193
|
+
exportable: true,
|
|
194
|
+
cellClass: () => 'strategy-error',
|
|
195
|
+
value: (s) => s.error ?? '',
|
|
196
|
+
},
|
|
197
|
+
];
|
|
198
|
+
}
|
|
199
|
+
// A dot and the state's own word. The dot is what is read across a list of twenty; the word
|
|
200
|
+
// is what tells Starting from Started, which a colour alone cannot.
|
|
201
|
+
_stateCell(row) {
|
|
202
|
+
const cell = document.createDocumentFragment();
|
|
203
|
+
const failed = row.error !== undefined && row.error !== null && String(row.error).length > 0;
|
|
204
|
+
const dot = document.createElement('span');
|
|
205
|
+
dot.className = 'strategy-dot';
|
|
206
|
+
dot.textContent = '●';
|
|
207
|
+
// The reason sits on the dot as well as on the word: the dot is what a reader looks at
|
|
208
|
+
// first, and a tooltip only the word carries is one nobody finds.
|
|
209
|
+
if (failed)
|
|
210
|
+
dot.title = String(row.error);
|
|
211
|
+
cell.appendChild(dot);
|
|
212
|
+
const text = document.createElement('span');
|
|
213
|
+
text.className = 'strategy-state-text';
|
|
214
|
+
// A run that stopped because something went wrong says so, rather than reading exactly
|
|
215
|
+
// like one the user stopped and differing only by the colour of the dot. The colour is
|
|
216
|
+
// the same statement made a second time, for a board too narrow to show the error
|
|
217
|
+
// column; the word is what a reader gets first.
|
|
218
|
+
text.textContent = failed && row.state === StrategyStates.Stopped
|
|
219
|
+
? this._host.t('Error')
|
|
220
|
+
: stateText(this._host, row.state);
|
|
221
|
+
if (failed)
|
|
222
|
+
text.title = String(row.error);
|
|
223
|
+
cell.appendChild(text);
|
|
224
|
+
return cell;
|
|
225
|
+
}
|
|
226
|
+
// Only the buttons this host can actually carry out, and only where the state allows them.
|
|
227
|
+
// A strategy that is already running has nothing to start.
|
|
228
|
+
_actionCell(row) {
|
|
229
|
+
const cell = document.createDocumentFragment();
|
|
230
|
+
const deps = this._deps;
|
|
231
|
+
const add = (action, when, title, icon, cls) => {
|
|
232
|
+
if (action === undefined)
|
|
233
|
+
return;
|
|
234
|
+
const button = makeIconButton(`bt-icon-btn ${cls}`, title, icon, { type: 'button' });
|
|
235
|
+
if (!when)
|
|
236
|
+
button.disabled = true;
|
|
237
|
+
else
|
|
238
|
+
button.addEventListener('click', () => action.call(deps, row.id));
|
|
239
|
+
cell.appendChild(button);
|
|
240
|
+
};
|
|
241
|
+
add(deps.start, row.state === StrategyStates.Stopped, this._host.t('Start'), 'bi-play-fill', 'strategy-start-btn');
|
|
242
|
+
add(deps.stop, row.state === StrategyStates.Started, this._host.t('Stop'), 'bi-stop-fill', 'strategy-stop-btn');
|
|
243
|
+
add(deps.riskRules, true, this._host.t('RiskManagement'), 'bi-shield-exclamation', 'strategy-risk-btn');
|
|
244
|
+
add(deps.openStrategy, true, this._host.t('OpenStrategy'), 'bi-box-arrow-up-right', 'strategy-open-btn');
|
|
245
|
+
return cell;
|
|
246
|
+
}
|
|
247
|
+
// The position, and next to it the one gesture that acts on it. Flattening is only
|
|
248
|
+
// meaningful while the strategy runs and only when it holds something.
|
|
249
|
+
_positionCell(row) {
|
|
250
|
+
const position = row.position ?? 0;
|
|
251
|
+
const text = formatQty(position);
|
|
252
|
+
if (this._deps.closePosition === undefined)
|
|
253
|
+
return text;
|
|
254
|
+
const cell = document.createDocumentFragment();
|
|
255
|
+
// The figure sits in a box of a fixed least width, so the button beside it stays put
|
|
256
|
+
// when a minus sign appears or a digit is dropped. Without it the whole column shifts
|
|
257
|
+
// every time a position crosses zero.
|
|
258
|
+
const value = makeElement('span', 'strategy-position-value', {}, [text]);
|
|
259
|
+
cell.appendChild(value);
|
|
260
|
+
const button = makeIconButton('bt-icon-btn strategy-flatten-btn', this._host.t('ClosePosition'), 'bi-x-octagon', { type: 'button' });
|
|
261
|
+
if (row.state !== StrategyStates.Started || position === 0)
|
|
262
|
+
button.disabled = true;
|
|
263
|
+
else
|
|
264
|
+
button.addEventListener('click', () => this._deps.closePosition?.(row.id));
|
|
265
|
+
cell.appendChild(button);
|
|
266
|
+
return cell;
|
|
267
|
+
}
|
|
268
|
+
// The one editable cell, and only when the host can carry the change out.
|
|
269
|
+
_tradingCell(row) {
|
|
270
|
+
const modes = this._deps.tradingModes ?? [];
|
|
271
|
+
if (this._deps.setTradingMode === undefined || modes.length === 0)
|
|
272
|
+
return row.tradingMode ?? '';
|
|
273
|
+
const select = document.createElement('select');
|
|
274
|
+
select.className = 'form-control form-control-sm strategy-mode';
|
|
275
|
+
// Only on a stopped run, the way start is only on a stopped one and stop only on a
|
|
276
|
+
// started one: the mode is what the run will be started with, not a lever to pull while
|
|
277
|
+
// it is trading.
|
|
278
|
+
select.disabled = row.state !== StrategyStates.Stopped;
|
|
279
|
+
for (const mode of modes) {
|
|
280
|
+
const option = document.createElement('option');
|
|
281
|
+
option.value = mode;
|
|
282
|
+
option.textContent = this._host.t(mode);
|
|
283
|
+
if (mode === row.tradingMode)
|
|
284
|
+
option.selected = true;
|
|
285
|
+
select.appendChild(option);
|
|
286
|
+
}
|
|
287
|
+
if (!select.disabled)
|
|
288
|
+
select.addEventListener('change', () => this._deps.setTradingMode?.(row.id, select.value));
|
|
289
|
+
return select;
|
|
290
|
+
}
|
|
291
|
+
// The run's own curve, at the size a cell has. Coloured by where it ended, which is the
|
|
292
|
+
// whole reason a glance at the column tells one strategy from another.
|
|
293
|
+
_sparkline(row) {
|
|
294
|
+
const box = { width: SPARK_WIDTH, height: SPARK_HEIGHT, padX: 1, padY: 2 };
|
|
295
|
+
const curve = pnlCurve(row.pnl ?? [], box);
|
|
296
|
+
if (curve === null)
|
|
297
|
+
return '';
|
|
298
|
+
const canvas = document.createElement('canvas');
|
|
299
|
+
canvas.className = 'strategy-spark-canvas';
|
|
300
|
+
// Two sizes, and they are not the same one. The backing store is in device pixels, so
|
|
301
|
+
// a curve on a 2x screen is drawn at 2x; the CSS box stays the size the column has.
|
|
302
|
+
// Sized only in CSS pixels, as this was, every stroke lands on half the pixels it
|
|
303
|
+
// should and the whole sparkline reads as a smudge.
|
|
304
|
+
const ratio = typeof window === 'undefined' ? 1 : (window.devicePixelRatio || 1);
|
|
305
|
+
canvas.width = Math.round(box.width * ratio);
|
|
306
|
+
canvas.height = Math.round(box.height * ratio);
|
|
307
|
+
canvas.style.width = `${box.width}px`;
|
|
308
|
+
canvas.style.height = `${box.height}px`;
|
|
309
|
+
const ctx = canvas.getContext('2d');
|
|
310
|
+
if (ctx !== null) {
|
|
311
|
+
const palette = this._host.presentation.canvasPalette();
|
|
312
|
+
const scaled = { width: canvas.width, height: canvas.height, padX: box.padX * ratio, padY: box.padY * ratio };
|
|
313
|
+
drawPnlCurve(ctx, pnlCurve(row.pnl ?? [], scaled) ?? curve, scaled, {
|
|
314
|
+
up: palette.up,
|
|
315
|
+
down: palette.down,
|
|
316
|
+
baseline: palette.grid,
|
|
317
|
+
lineWidth: 1.5 * ratio,
|
|
318
|
+
fillOpacity: 0.35,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
return canvas;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
StrategiesWidget.TYPE = ControlTypes.Strategies;
|
|
325
|
+
/// What a state is called here.
|
|
326
|
+
///
|
|
327
|
+
/// Each key is a literal at the point it is asked for, rather than one value picked and then
|
|
328
|
+
/// translated: `translation-keys.json` is generated by scanning the sources for exactly that
|
|
329
|
+
/// shape, so a key assembled from a value never reaches the list, no host learns to translate
|
|
330
|
+
/// it, and it arrives at the user as itself.
|
|
331
|
+
function stateText(host, state) {
|
|
332
|
+
switch (state) {
|
|
333
|
+
case StrategyStates.Started: return host.t('Started');
|
|
334
|
+
case StrategyStates.Starting: return host.t('Starting');
|
|
335
|
+
case StrategyStates.Stopping: return host.t('Stopping');
|
|
336
|
+
default: return host.t('Stopped');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/// Which way a figure moved, as one character. Blank for no change: an arrow that always points
|
|
340
|
+
/// somewhere says a strategy is moving when it is not.
|
|
341
|
+
function direction(value) {
|
|
342
|
+
if (value > 0)
|
|
343
|
+
return '▲';
|
|
344
|
+
if (value < 0)
|
|
345
|
+
return '▼';
|
|
346
|
+
return '';
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=strategies-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategies-widget.js","sourceRoot":"","sources":["../../src/strategies-widget.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,yFAAyF;AACzF,gGAAgG;AAChG,2EAA2E;AAC3E,EAAE;AACF,8FAA8F;AAC9F,gGAAgG;AAChG,8FAA8F;AAC9F,wFAAwF;AACxF,8FAA8F;AAC9F,6FAA6F;AAC7F,gGAAgG;AAChG,6DAA6D;AAC7D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;A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