@tradejs/core 3.1.27-beta.245 → 3.1.27-beta.248
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/dist/runtimeTrades.js +8 -8
- package/dist/runtimeTrades.mjs +8 -8
- package/package.json +2 -2
package/dist/runtimeTrades.js
CHANGED
|
@@ -279,7 +279,9 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
279
279
|
startTime,
|
|
280
280
|
endTime
|
|
281
281
|
}) => {
|
|
282
|
-
const
|
|
282
|
+
const activeTrades = trades.filter(({ status }) => status === "active");
|
|
283
|
+
const closedTrades = trades.filter(({ status }) => status === "closed");
|
|
284
|
+
const resolvedTrades = resolveTradesWithKnownPnl(closedTrades, endTime);
|
|
283
285
|
const orderLog = [[startTime, INITIAL_BACKTEST_AMOUNT]];
|
|
284
286
|
let runningAmount = INITIAL_BACKTEST_AMOUNT;
|
|
285
287
|
for (const trade of resolvedTrades) {
|
|
@@ -311,14 +313,14 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
311
313
|
const amounts = orderLog.map(([, value]) => value);
|
|
312
314
|
const maxDrawdown = calculateMaxDrawdown(amounts);
|
|
313
315
|
const streaks = calculateStreaks(pnls);
|
|
314
|
-
const stat =
|
|
316
|
+
const stat = closedTrades.length ? {
|
|
315
317
|
periodDays: roundValue(periodDays),
|
|
316
318
|
periodMonths: roundValue(periodMonths),
|
|
317
|
-
orders:
|
|
319
|
+
orders: closedTrades.length,
|
|
318
320
|
wins,
|
|
319
321
|
losses,
|
|
320
|
-
ordersPerMonth: periodMonths ? roundValue(
|
|
321
|
-
exposure: calculateExposurePercent(
|
|
322
|
+
ordersPerMonth: periodMonths ? roundValue(closedTrades.length / periodMonths) : 0,
|
|
323
|
+
exposure: calculateExposurePercent(closedTrades, startTime, endTime),
|
|
322
324
|
amount: roundValue(amount),
|
|
323
325
|
maxAmount: roundValue(Math.max(...amounts)),
|
|
324
326
|
minAmount: roundValue(Math.min(...amounts)),
|
|
@@ -327,7 +329,7 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
327
329
|
cagr: roundValue(cagr),
|
|
328
330
|
maxDrawdown,
|
|
329
331
|
calmar: maxDrawdown > 0 ? roundValue(cagr / maxDrawdown) : null,
|
|
330
|
-
winRate: roundValue(wins /
|
|
332
|
+
winRate: roundValue(wins / closedTrades.length * 100),
|
|
331
333
|
riskRewardRatio: averageLoss > 0 ? roundValue(averageWin / averageLoss) : null,
|
|
332
334
|
expectancy: returnSeries.length ? roundValue(
|
|
333
335
|
returnSeries.reduce((sum, value) => sum + value, 0) / returnSeries.length * 100
|
|
@@ -336,8 +338,6 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
336
338
|
sharpeRatio: calculateSharpeRatio(orderLog, startTime, endTime),
|
|
337
339
|
score: 0
|
|
338
340
|
} : createEmptyStat(startTime, endTime);
|
|
339
|
-
const activeTrades = trades.filter(({ status }) => status === "active");
|
|
340
|
-
const closedTrades = trades.filter(({ status }) => status === "closed");
|
|
341
341
|
const sumPnl = (rows, primary) => roundValue(
|
|
342
342
|
rows.reduce((sum, trade) => {
|
|
343
343
|
const value = trade[primary] ?? trade.currentPnl;
|
package/dist/runtimeTrades.mjs
CHANGED
|
@@ -183,7 +183,9 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
183
183
|
startTime,
|
|
184
184
|
endTime
|
|
185
185
|
}) => {
|
|
186
|
-
const
|
|
186
|
+
const activeTrades = trades.filter(({ status }) => status === "active");
|
|
187
|
+
const closedTrades = trades.filter(({ status }) => status === "closed");
|
|
188
|
+
const resolvedTrades = resolveTradesWithKnownPnl(closedTrades, endTime);
|
|
187
189
|
const orderLog = [[startTime, INITIAL_BACKTEST_AMOUNT]];
|
|
188
190
|
let runningAmount = INITIAL_BACKTEST_AMOUNT;
|
|
189
191
|
for (const trade of resolvedTrades) {
|
|
@@ -215,14 +217,14 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
215
217
|
const amounts = orderLog.map(([, value]) => value);
|
|
216
218
|
const maxDrawdown = calculateMaxDrawdown(amounts);
|
|
217
219
|
const streaks = calculateStreaks(pnls);
|
|
218
|
-
const stat =
|
|
220
|
+
const stat = closedTrades.length ? {
|
|
219
221
|
periodDays: roundValue(periodDays),
|
|
220
222
|
periodMonths: roundValue(periodMonths),
|
|
221
|
-
orders:
|
|
223
|
+
orders: closedTrades.length,
|
|
222
224
|
wins,
|
|
223
225
|
losses,
|
|
224
|
-
ordersPerMonth: periodMonths ? roundValue(
|
|
225
|
-
exposure: calculateExposurePercent(
|
|
226
|
+
ordersPerMonth: periodMonths ? roundValue(closedTrades.length / periodMonths) : 0,
|
|
227
|
+
exposure: calculateExposurePercent(closedTrades, startTime, endTime),
|
|
226
228
|
amount: roundValue(amount),
|
|
227
229
|
maxAmount: roundValue(Math.max(...amounts)),
|
|
228
230
|
minAmount: roundValue(Math.min(...amounts)),
|
|
@@ -231,7 +233,7 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
231
233
|
cagr: roundValue(cagr),
|
|
232
234
|
maxDrawdown,
|
|
233
235
|
calmar: maxDrawdown > 0 ? roundValue(cagr / maxDrawdown) : null,
|
|
234
|
-
winRate: roundValue(wins /
|
|
236
|
+
winRate: roundValue(wins / closedTrades.length * 100),
|
|
235
237
|
riskRewardRatio: averageLoss > 0 ? roundValue(averageWin / averageLoss) : null,
|
|
236
238
|
expectancy: returnSeries.length ? roundValue(
|
|
237
239
|
returnSeries.reduce((sum, value) => sum + value, 0) / returnSeries.length * 100
|
|
@@ -240,8 +242,6 @@ var buildRuntimeStrategyAnalytics = ({
|
|
|
240
242
|
sharpeRatio: calculateSharpeRatio(orderLog, startTime, endTime),
|
|
241
243
|
score: 0
|
|
242
244
|
} : createEmptyStat(startTime, endTime);
|
|
243
|
-
const activeTrades = trades.filter(({ status }) => status === "active");
|
|
244
|
-
const closedTrades = trades.filter(({ status }) => status === "closed");
|
|
245
245
|
const sumPnl = (rows, primary) => roundValue(
|
|
246
246
|
rows.reduce((sum, trade) => {
|
|
247
247
|
const value = trade[primary] ?? trade.currentPnl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/core",
|
|
3
|
-
"version": "3.1.27-beta.
|
|
3
|
+
"version": "3.1.27-beta.248",
|
|
4
4
|
"description": "MIT-licensed browser-safe API for TradeJS config, strategy authoring, figures, and shared helpers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tradejs",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"@tradejs/types": "^3.1.27-beta.
|
|
135
|
+
"@tradejs/types": "^3.1.27-beta.248",
|
|
136
136
|
"date-fns": "^3.6.0",
|
|
137
137
|
"fast-technical-indicators": "^1.1.4",
|
|
138
138
|
"klinecharts": "10.0.0-alpha9",
|