@backtest-kit/ui 9.5.0 → 9.7.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 (37) hide show
  1. package/README.md +254 -254
  2. package/build/index.cjs +243 -170
  3. package/build/index.mjs +122 -67
  4. package/build/modules/frontend/build/3rdparty/ace_1.4.12/ace.js +21337 -21337
  5. package/build/modules/frontend/build/3rdparty/ace_1.4.12/mode-javascript.js +797 -797
  6. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-chrome.js +137 -137
  7. package/build/modules/frontend/build/3rdparty/ace_1.4.12/theme-twilight.js +115 -115
  8. package/build/modules/frontend/build/3rdparty/ace_1.4.12/worker-javascript.js +15012 -15012
  9. package/build/modules/frontend/build/3rdparty/qfchart_0.8.7/echarts.min.js +45 -45
  10. package/build/modules/frontend/build/assets/{Article-CPvMAlis.js → Article-CSLbW4S3.js} +1 -1
  11. package/build/modules/frontend/build/assets/{Background-BcBJxoQM.js → Background-D7AbUVrH.js} +1 -1
  12. package/build/modules/frontend/build/assets/{IconPhoto-C_ikll5b.js → IconPhoto-dJuN2ucb.js} +1 -1
  13. package/build/modules/frontend/build/assets/{KeyboardArrowLeft-wo8yIkQt.js → KeyboardArrowLeft-BC2GbqOB.js} +1 -1
  14. package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-B2Y3DrmN.js → PictureAsPdfOutlined-BkS0a0A0.js} +1 -1
  15. package/build/modules/frontend/build/assets/{Refresh-DWwANC2C.js → Refresh-GywkMeC9.js} +1 -1
  16. package/build/modules/frontend/build/assets/emitters-D2HKeJSt.js +1 -0
  17. package/build/modules/frontend/build/assets/{hasRouteMatch-DxP9EIea.js → hasRouteMatch-DaOdXEtJ.js} +1 -1
  18. package/build/modules/frontend/build/assets/{html2canvas-BEYpPxnI.js → html2canvas-D40IxDXU.js} +1 -1
  19. package/build/modules/frontend/build/assets/{index-Csk3lyh_.js → index-BDWtjw8t.js} +1 -1
  20. package/build/modules/frontend/build/assets/{index-U9wO0mPn.js → index-BjNxXXRd.js} +1 -1
  21. package/build/modules/frontend/build/assets/{index-BLgqZVUW.js → index-BoVUr2mk.js} +5 -5
  22. package/build/modules/frontend/build/assets/{index-Ct4kOSwZ.js → index-C7fDq8VY.js} +1 -1
  23. package/build/modules/frontend/build/assets/{index-xcEpTc6J.js → index-CcP46J0C.js} +1 -1
  24. package/build/modules/frontend/build/assets/{index-DYIV_QwZ.js → index-CcnWYHDR.js} +1 -1
  25. package/build/modules/frontend/build/assets/{index-nQBp5LZR.js → index-CePvvRqq.js} +1 -1
  26. package/build/modules/frontend/build/assets/{index-Bd51gA9H.js → index-CknRQapy.js} +1 -1
  27. package/build/modules/frontend/build/assets/{index-C2FRNjrR.js → index-CyN7sutq.js} +1 -1
  28. package/build/modules/frontend/build/assets/{index-5Dtu864w.js → index-D9GOtTmB.js} +1 -1
  29. package/build/modules/frontend/build/assets/{index-BqQhlvLk.js → index-DWnTHxHy.js} +1 -1
  30. package/build/modules/frontend/build/assets/{index-Q1e8Guut.js → index-IkD99_6_.js} +1 -1
  31. package/build/modules/frontend/build/assets/{index-BW6mJqS7.js → index-zihyCAvY.js} +1 -1
  32. package/build/modules/frontend/build/assets/{index.es-FwYn4ntA.js → index.es-ByhwyzTS.js} +1 -1
  33. package/build/modules/frontend/build/assets/{markdownit-DifHDTjI.js → markdownit-DHhYBfkC.js} +1 -1
  34. package/build/modules/frontend/build/index.html +87 -87
  35. package/build/modules/frontend/build/manifest.json +23 -23
  36. package/package.json +118 -118
  37. package/build/modules/frontend/build/assets/emitters-Dr0rm1Id.js +0 -1
package/README.md CHANGED
@@ -1,254 +1,254 @@
1
- <img src="https://github.com/tripolskypetr/backtest-kit/raw/refs/heads/master/assets/decart.svg" height="45px" align="right">
2
-
3
- # 📊 @backtest-kit/ui
4
-
5
- > Full-stack UI framework for visualizing cryptocurrency trading signals, backtests, and real-time market data. Combines a Node.js backend server with a React dashboard - all in one package.
6
-
7
- ![screenshot](https://raw.githubusercontent.com/tripolskypetr/backtest-kit/HEAD/assets/screenshots/screenshot16.png)
8
-
9
- [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/tripolskypetr/backtest-kit)
10
- [![npm](https://img.shields.io/npm/v/@backtest-kit/ui.svg?style=flat-square)](https://npmjs.org/package/@backtest-kit/ui)
11
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue)]()
12
-
13
- Interactive dashboard for backtest-kit with signal visualization, candle charts, risk analysis, and notification management. Built with React 18, Material-UI, and Lightweight Charts.
14
-
15
- 📚 **[Backtest Kit Docs](https://backtest-kit.github.io/documents/article_07_ai_news_trading_signals.html)** | 🌟 **[GitHub](https://github.com/tripolskypetr/backtest-kit)**
16
-
17
- > **New to backtest-kit?** The fastest way to get a real, production-ready setup is to clone the [reference implementation](https://github.com/tripolskypetr/backtest-kit/tree/master/example) — a fully working news-sentiment AI trading system with LLM forecasting, multi-timeframe data, and a documented February 2026 backtest. Start there instead of from scratch.
18
-
19
- ## ✨ Features
20
-
21
- - 📈 **Interactive Charts**: Candlestick visualization with Lightweight Charts (1m, 15m, 1h timeframes)
22
- - 🎯 **Signal Tracking**: View opened, closed, scheduled, and cancelled signals with full details
23
- - 📊 **Risk Analysis**: Monitor risk rejections and position management
24
- - 🔔 **Notifications**: Real-time notification system for all trading events
25
- - 💹 **Trailing & Breakeven**: Visualize trailing stop/take and breakeven events
26
- - 🌐 **Multi-Exchange**: Support for 100+ exchanges via CCXT integration
27
- - 🎨 **Material Design**: Beautiful UI with MUI 5 and Mantine components
28
- - 🌍 **i18n Ready**: Internationalization support built-in
29
-
30
- ## 📋 What It Does
31
-
32
- `@backtest-kit/ui` provides both backend API and frontend dashboard:
33
-
34
- | Component | Description |
35
- |-----------|-------------|
36
- | **`serve()`** | Start HTTP server with REST API endpoints |
37
- | **`getRouter()`** | Get expressjs-compatible router for custom middleware integration |
38
-
39
- ## 🚀 Installation
40
-
41
- ```bash
42
- npm install @backtest-kit/ui backtest-kit ccxt
43
- ```
44
-
45
- ## 📖 Usage
46
-
47
- ### Quick Start - Launch Dashboard
48
-
49
- ```typescript
50
- import { serve } from '@backtest-kit/ui';
51
-
52
- // Start the UI server
53
- serve('0.0.0.0', 60050);
54
-
55
- // Dashboard available at http://localhost:60050
56
- ```
57
-
58
- ### Custom Logger Integration
59
-
60
- ```typescript
61
- import { setLogger } from '@backtest-kit/ui';
62
-
63
- setLogger({
64
- log: (msg) => console.log(`[UI] ${msg}`),
65
- warn: (msg) => console.warn(`[UI] ${msg}`),
66
- error: (msg) => console.error(`[UI] ${msg}`),
67
- });
68
- ```
69
-
70
- ## 📐 Dashboard Revenue Math
71
-
72
- The **Revenue** metrics on the dashboard are calculated in **dollar terms** by summing the `pnlCost` field from all closed signals within each time window.
73
-
74
- ### Dollar PnL formula
75
-
76
- ```
77
- revenue[window] = Σ signal.pnl.pnlCost (for all closed signals in that window)
78
- ```
79
-
80
- `pnlCost` is computed by the backend (`toProfitLossDto`) as:
81
-
82
- ```
83
- pnlCost = (pnlPercentage / 100) × pnlEntries
84
- ```
85
-
86
- | Field | Source | Description |
87
- |-------|--------|-------------|
88
- | `pnl.pnlCost` | `IStorageSignalRow` | Absolute P&L in USD — the only value summed for revenue |
89
- | `pnl.pnlPercentage` | `IStorageSignalRow` | Percentage P&L (accounts for DCA-weighted entry price, slippage, and fees) |
90
- | `pnl.pnlEntries` | `IStorageSignalRow` | Total invested capital in USD — sum of all entry costs (`Σ entry.cost`) |
91
-
92
- **Example** (1 DCA entry at $100, position closed +5%):
93
-
94
- | DCA entries | `pnlEntries` | `pnlPercentage` | `pnlCost` |
95
- |:-----------:|-------------:|----------------:|----------:|
96
- | 1 | $100 | 5 % | +$5.00 |
97
- | 2 | $200 | 5 % | +$10.00 |
98
- | 3 | $300 | 5 % | +$15.00 |
99
-
100
- ### Time windows
101
-
102
- The anchor point depends on execution mode:
103
-
104
- - **Backtest mode** — latest `updatedAt` across all closed signals (time windows are relative to the end of the run)
105
- - **Live mode** — `Date.now()` (wall-clock time)
106
-
107
- | Window | Range |
108
- |--------|-------|
109
- | Today | `>= startOf(anchorDay)` |
110
- | Yesterday | `[anchorDay − 1d, anchorDay)` |
111
- | 7 days | `>= anchorDay − 7d` |
112
- | 31 days | `>= anchorDay − 31d` |
113
-
114
- Revenue and signal count are tracked separately for each window and aggregated across all symbols on the Dashboard.
115
-
116
- ## 📐 Position PNL Math
117
-
118
- ### Effective entry price (DCA-weighted)
119
-
120
- When multiple DCA entries exist, the effective open price is a **cost-weighted harmonic mean**:
121
-
122
- ```
123
- effectivePrice = Σcost / Σ(cost / price)
124
- ```
125
-
126
- This is the correct formula for fixed-dollar entries (not simple average), because buying $100 worth at different prices gives different coin quantities.
127
-
128
- ### Partial closes (PP/PL)
129
-
130
- Each partial stores a `costBasisAtClose` snapshot — the running dollar cost-basis **before** that partial fired. This avoids replaying the full entry history on every call.
131
-
132
- **Cost-basis replay:**
133
-
134
- ```
135
- for each partial[i]:
136
- closedDollar += (percent[i] / 100) × costBasisAtClose[i]
137
- remainingCostBasis = costBasisAtClose[i] × (1 - percent[i] / 100)
138
-
139
- # DCA entries added AFTER the last partial are appended:
140
- remainingCostBasis += Σ entry.cost for entries[lastEntryCount..]
141
-
142
- totalClosedPercent = closedDollar / totalInvested × 100
143
- ```
144
-
145
- **Effective price through partials** is computed iteratively so that a partial sell does not change the entry price of the remaining coins:
146
-
147
- ```
148
- # partial[0]:
149
- effPrice = costBasisAtClose[0] / Σ(cost/price for entries[0..cnt[0]])
150
-
151
- # partial[j]:
152
- remainingCB = prev.costBasisAtClose × (1 - prev.percent / 100)
153
- oldCoins = remainingCB / effPrice ← coins still held
154
- newCoins = Σ(cost/price for DCA entries between j-1 and j)
155
- effPrice = (remainingCB + newCost) / (oldCoins + newCoins)
156
- ```
157
-
158
- ### toProfitLossDto — weighted PNL with slippage & fees
159
-
160
- **Without partials:**
161
-
162
- ```
163
- priceOpenSlip = effectivePrice × (1 ± slippage)
164
- priceCloseSlip = priceClose × (1 ∓ slippage)
165
-
166
- pnlPercentage = (priceCloseSlip - priceOpenSlip) / priceOpenSlip × 100
167
- fee = CC_PERCENT_FEE × (1 + priceCloseSlip / priceOpenSlip)
168
- pnlPercentage -= fee
169
- ```
170
-
171
- **With partials — dollar-weighted sum:**
172
-
173
- ```
174
- weight[i] = (percent[i] / 100 × costBasisAtClose[i]) / totalInvested
175
-
176
- totalWeightedPnl = Σ weight[i] × pnl[i] # each partial at its own effectivePrice
177
- + remainingWeight × pnlRemaining # rest closed at final priceClose
178
-
179
- fee = CC_PERCENT_FEE # open (once)
180
- + Σ CC_PERCENT_FEE × weight[i] × (closeSlip[i] / openSlip[i]) # per partial
181
- + CC_PERCENT_FEE × remainingWeight × (closeSlip / openSlip) # final close
182
-
183
- pnlPercentage = totalWeightedPnl - fee
184
- pnlCost = pnlPercentage / 100 × totalInvested
185
- ```
186
-
187
- | Field | Description |
188
- |-------|-------------|
189
- | `totalInvested` | `Σ entry.cost` (or `CC_POSITION_ENTRY_COST` if no `_entry`) |
190
- | `weight[i]` | Real dollar share of each partial relative to `totalInvested` |
191
- | `effectivePrice` at partial `i` | Computed via iterative `costBasisAtClose` replay up to `partials[i]` |
192
- | `priceOpen` in result | `getEffectivePriceOpen(signal)` — DCA-weighted harmonic mean across all entries |
193
-
194
- ## 🖥️ Dashboard Views
195
-
196
- The frontend provides specialized views for different trading events:
197
-
198
- | View | Description |
199
- |------|-------------|
200
- | **Signal Opened** | Entry details with chart visualization |
201
- | **Signal Closed** | Exit details with PnL analysis |
202
- | **Signal Scheduled** | Pending orders awaiting activation |
203
- | **Signal Cancelled** | Cancelled orders with reasons |
204
- | **Risk Rejection** | Signals rejected by risk management |
205
- | **Partial Profit/Loss** | Partial position closures |
206
- | **Trailing Stop/Take** | Trailing adjustments visualization |
207
- | **Breakeven** | Breakeven level adjustments |
208
-
209
- Each view includes:
210
- - 📋 Detailed information form
211
- - 📈 1m, 15m, 1h candlestick charts
212
- - 📥 JSON export for all data
213
-
214
- ## 💡 Why Use @backtest-kit/ui?
215
-
216
- Instead of building custom dashboards:
217
-
218
- **Without backtest-kit**
219
-
220
- ```typescript
221
- // ❌ Without @backtest-kit/ui
222
- // Build your own React app
223
- // Implement chart components
224
- // Create signal visualization
225
- // Handle notifications
226
- // Write API endpoints
227
- // ... weeks of development
228
- ```
229
-
230
- **With backtest-kit**
231
-
232
- ```typescript
233
- // ✅ With @backtest-kit/ui
234
- import { serve } from '@backtest-kit/ui';
235
-
236
- serve(); // Full dashboard ready!
237
- ```
238
-
239
- **Benefits:**
240
-
241
- - 📊 Production-ready trading dashboard out of the box
242
- - 📈 Professional chart visualization with price lines and markers
243
- - 🔔 Complete notification system for all trading events
244
- - 🎨 Beautiful Material Design interface
245
- - ⚡ Fast development - focus on strategy, not UI
246
- - 🛡️ Full TypeScript support
247
-
248
- ## 🤝 Contribute
249
-
250
- Fork/PR on [GitHub](https://github.com/tripolskypetr/backtest-kit).
251
-
252
- ## 📜 License
253
-
254
- MIT © [tripolskypetr](https://github.com/tripolskypetr)
1
+ <img src="https://github.com/tripolskypetr/backtest-kit/raw/refs/heads/master/assets/decart.svg" height="45px" align="right">
2
+
3
+ # 📊 @backtest-kit/ui
4
+
5
+ > Full-stack UI framework for visualizing cryptocurrency trading signals, backtests, and real-time market data. Combines a Node.js backend server with a React dashboard - all in one package.
6
+
7
+ ![screenshot](https://raw.githubusercontent.com/tripolskypetr/backtest-kit/HEAD/assets/screenshots/screenshot16.png)
8
+
9
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/tripolskypetr/backtest-kit)
10
+ [![npm](https://img.shields.io/npm/v/@backtest-kit/ui.svg?style=flat-square)](https://npmjs.org/package/@backtest-kit/ui)
11
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue)]()
12
+
13
+ Interactive dashboard for backtest-kit with signal visualization, candle charts, risk analysis, and notification management. Built with React 18, Material-UI, and Lightweight Charts.
14
+
15
+ 📚 **[Backtest Kit Docs](https://backtest-kit.github.io/documents/article_07_ai_news_trading_signals.html)** | 🌟 **[GitHub](https://github.com/tripolskypetr/backtest-kit)**
16
+
17
+ > **New to backtest-kit?** The fastest way to get a real, production-ready setup is to clone the [reference implementation](https://github.com/tripolskypetr/backtest-kit/tree/master/example) — a fully working news-sentiment AI trading system with LLM forecasting, multi-timeframe data, and a documented February 2026 backtest. Start there instead of from scratch.
18
+
19
+ ## ✨ Features
20
+
21
+ - 📈 **Interactive Charts**: Candlestick visualization with Lightweight Charts (1m, 15m, 1h timeframes)
22
+ - 🎯 **Signal Tracking**: View opened, closed, scheduled, and cancelled signals with full details
23
+ - 📊 **Risk Analysis**: Monitor risk rejections and position management
24
+ - 🔔 **Notifications**: Real-time notification system for all trading events
25
+ - 💹 **Trailing & Breakeven**: Visualize trailing stop/take and breakeven events
26
+ - 🌐 **Multi-Exchange**: Support for 100+ exchanges via CCXT integration
27
+ - 🎨 **Material Design**: Beautiful UI with MUI 5 and Mantine components
28
+ - 🌍 **i18n Ready**: Internationalization support built-in
29
+
30
+ ## 📋 What It Does
31
+
32
+ `@backtest-kit/ui` provides both backend API and frontend dashboard:
33
+
34
+ | Component | Description |
35
+ |-----------|-------------|
36
+ | **`serve()`** | Start HTTP server with REST API endpoints |
37
+ | **`getRouter()`** | Get expressjs-compatible router for custom middleware integration |
38
+
39
+ ## 🚀 Installation
40
+
41
+ ```bash
42
+ npm install @backtest-kit/ui backtest-kit ccxt
43
+ ```
44
+
45
+ ## 📖 Usage
46
+
47
+ ### Quick Start - Launch Dashboard
48
+
49
+ ```typescript
50
+ import { serve } from '@backtest-kit/ui';
51
+
52
+ // Start the UI server
53
+ serve('0.0.0.0', 60050);
54
+
55
+ // Dashboard available at http://localhost:60050
56
+ ```
57
+
58
+ ### Custom Logger Integration
59
+
60
+ ```typescript
61
+ import { setLogger } from '@backtest-kit/ui';
62
+
63
+ setLogger({
64
+ log: (msg) => console.log(`[UI] ${msg}`),
65
+ warn: (msg) => console.warn(`[UI] ${msg}`),
66
+ error: (msg) => console.error(`[UI] ${msg}`),
67
+ });
68
+ ```
69
+
70
+ ## 📐 Dashboard Revenue Math
71
+
72
+ The **Revenue** metrics on the dashboard are calculated in **dollar terms** by summing the `pnlCost` field from all closed signals within each time window.
73
+
74
+ ### Dollar PnL formula
75
+
76
+ ```
77
+ revenue[window] = Σ signal.pnl.pnlCost (for all closed signals in that window)
78
+ ```
79
+
80
+ `pnlCost` is computed by the backend (`toProfitLossDto`) as:
81
+
82
+ ```
83
+ pnlCost = (pnlPercentage / 100) × pnlEntries
84
+ ```
85
+
86
+ | Field | Source | Description |
87
+ |-------|--------|-------------|
88
+ | `pnl.pnlCost` | `IStorageSignalRow` | Absolute P&L in USD — the only value summed for revenue |
89
+ | `pnl.pnlPercentage` | `IStorageSignalRow` | Percentage P&L (accounts for DCA-weighted entry price, slippage, and fees) |
90
+ | `pnl.pnlEntries` | `IStorageSignalRow` | Total invested capital in USD — sum of all entry costs (`Σ entry.cost`) |
91
+
92
+ **Example** (1 DCA entry at $100, position closed +5%):
93
+
94
+ | DCA entries | `pnlEntries` | `pnlPercentage` | `pnlCost` |
95
+ |:-----------:|-------------:|----------------:|----------:|
96
+ | 1 | $100 | 5 % | +$5.00 |
97
+ | 2 | $200 | 5 % | +$10.00 |
98
+ | 3 | $300 | 5 % | +$15.00 |
99
+
100
+ ### Time windows
101
+
102
+ The anchor point depends on execution mode:
103
+
104
+ - **Backtest mode** — latest `updatedAt` across all closed signals (time windows are relative to the end of the run)
105
+ - **Live mode** — `Date.now()` (wall-clock time)
106
+
107
+ | Window | Range |
108
+ |--------|-------|
109
+ | Today | `>= startOf(anchorDay)` |
110
+ | Yesterday | `[anchorDay − 1d, anchorDay)` |
111
+ | 7 days | `>= anchorDay − 7d` |
112
+ | 31 days | `>= anchorDay − 31d` |
113
+
114
+ Revenue and signal count are tracked separately for each window and aggregated across all symbols on the Dashboard.
115
+
116
+ ## 📐 Position PNL Math
117
+
118
+ ### Effective entry price (DCA-weighted)
119
+
120
+ When multiple DCA entries exist, the effective open price is a **cost-weighted harmonic mean**:
121
+
122
+ ```
123
+ effectivePrice = Σcost / Σ(cost / price)
124
+ ```
125
+
126
+ This is the correct formula for fixed-dollar entries (not simple average), because buying $100 worth at different prices gives different coin quantities.
127
+
128
+ ### Partial closes (PP/PL)
129
+
130
+ Each partial stores a `costBasisAtClose` snapshot — the running dollar cost-basis **before** that partial fired. This avoids replaying the full entry history on every call.
131
+
132
+ **Cost-basis replay:**
133
+
134
+ ```
135
+ for each partial[i]:
136
+ closedDollar += (percent[i] / 100) × costBasisAtClose[i]
137
+ remainingCostBasis = costBasisAtClose[i] × (1 - percent[i] / 100)
138
+
139
+ # DCA entries added AFTER the last partial are appended:
140
+ remainingCostBasis += Σ entry.cost for entries[lastEntryCount..]
141
+
142
+ totalClosedPercent = closedDollar / totalInvested × 100
143
+ ```
144
+
145
+ **Effective price through partials** is computed iteratively so that a partial sell does not change the entry price of the remaining coins:
146
+
147
+ ```
148
+ # partial[0]:
149
+ effPrice = costBasisAtClose[0] / Σ(cost/price for entries[0..cnt[0]])
150
+
151
+ # partial[j]:
152
+ remainingCB = prev.costBasisAtClose × (1 - prev.percent / 100)
153
+ oldCoins = remainingCB / effPrice ← coins still held
154
+ newCoins = Σ(cost/price for DCA entries between j-1 and j)
155
+ effPrice = (remainingCB + newCost) / (oldCoins + newCoins)
156
+ ```
157
+
158
+ ### toProfitLossDto — weighted PNL with slippage & fees
159
+
160
+ **Without partials:**
161
+
162
+ ```
163
+ priceOpenSlip = effectivePrice × (1 ± slippage)
164
+ priceCloseSlip = priceClose × (1 ∓ slippage)
165
+
166
+ pnlPercentage = (priceCloseSlip - priceOpenSlip) / priceOpenSlip × 100
167
+ fee = CC_PERCENT_FEE × (1 + priceCloseSlip / priceOpenSlip)
168
+ pnlPercentage -= fee
169
+ ```
170
+
171
+ **With partials — dollar-weighted sum:**
172
+
173
+ ```
174
+ weight[i] = (percent[i] / 100 × costBasisAtClose[i]) / totalInvested
175
+
176
+ totalWeightedPnl = Σ weight[i] × pnl[i] # each partial at its own effectivePrice
177
+ + remainingWeight × pnlRemaining # rest closed at final priceClose
178
+
179
+ fee = CC_PERCENT_FEE # open (once)
180
+ + Σ CC_PERCENT_FEE × weight[i] × (closeSlip[i] / openSlip[i]) # per partial
181
+ + CC_PERCENT_FEE × remainingWeight × (closeSlip / openSlip) # final close
182
+
183
+ pnlPercentage = totalWeightedPnl - fee
184
+ pnlCost = pnlPercentage / 100 × totalInvested
185
+ ```
186
+
187
+ | Field | Description |
188
+ |-------|-------------|
189
+ | `totalInvested` | `Σ entry.cost` (or `CC_POSITION_ENTRY_COST` if no `_entry`) |
190
+ | `weight[i]` | Real dollar share of each partial relative to `totalInvested` |
191
+ | `effectivePrice` at partial `i` | Computed via iterative `costBasisAtClose` replay up to `partials[i]` |
192
+ | `priceOpen` in result | `getEffectivePriceOpen(signal)` — DCA-weighted harmonic mean across all entries |
193
+
194
+ ## 🖥️ Dashboard Views
195
+
196
+ The frontend provides specialized views for different trading events:
197
+
198
+ | View | Description |
199
+ |------|-------------|
200
+ | **Signal Opened** | Entry details with chart visualization |
201
+ | **Signal Closed** | Exit details with PnL analysis |
202
+ | **Signal Scheduled** | Pending orders awaiting activation |
203
+ | **Signal Cancelled** | Cancelled orders with reasons |
204
+ | **Risk Rejection** | Signals rejected by risk management |
205
+ | **Partial Profit/Loss** | Partial position closures |
206
+ | **Trailing Stop/Take** | Trailing adjustments visualization |
207
+ | **Breakeven** | Breakeven level adjustments |
208
+
209
+ Each view includes:
210
+ - 📋 Detailed information form
211
+ - 📈 1m, 15m, 1h candlestick charts
212
+ - 📥 JSON export for all data
213
+
214
+ ## 💡 Why Use @backtest-kit/ui?
215
+
216
+ Instead of building custom dashboards:
217
+
218
+ **Without backtest-kit**
219
+
220
+ ```typescript
221
+ // ❌ Without @backtest-kit/ui
222
+ // Build your own React app
223
+ // Implement chart components
224
+ // Create signal visualization
225
+ // Handle notifications
226
+ // Write API endpoints
227
+ // ... weeks of development
228
+ ```
229
+
230
+ **With backtest-kit**
231
+
232
+ ```typescript
233
+ // ✅ With @backtest-kit/ui
234
+ import { serve } from '@backtest-kit/ui';
235
+
236
+ serve(); // Full dashboard ready!
237
+ ```
238
+
239
+ **Benefits:**
240
+
241
+ - 📊 Production-ready trading dashboard out of the box
242
+ - 📈 Professional chart visualization with price lines and markers
243
+ - 🔔 Complete notification system for all trading events
244
+ - 🎨 Beautiful Material Design interface
245
+ - ⚡ Fast development - focus on strategy, not UI
246
+ - 🛡️ Full TypeScript support
247
+
248
+ ## 🤝 Contribute
249
+
250
+ Fork/PR on [GitHub](https://github.com/tripolskypetr/backtest-kit).
251
+
252
+ ## 📜 License
253
+
254
+ MIT © [tripolskypetr](https://github.com/tripolskypetr)