backtest-kit 2.2.15 → 2.2.16

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/build/index.cjs CHANGED
@@ -31716,6 +31716,7 @@ class StorageBacktestUtils {
31716
31716
  ...tick.signal,
31717
31717
  status: "closed",
31718
31718
  priority: Date.now(),
31719
+ pnl: tick.pnl,
31719
31720
  createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
31720
31721
  updatedAt: tick.createdAt,
31721
31722
  });
@@ -31885,6 +31886,7 @@ class StorageLiveUtils {
31885
31886
  ...tick.signal,
31886
31887
  status: "closed",
31887
31888
  priority: Date.now(),
31889
+ pnl: tick.pnl,
31888
31890
  createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
31889
31891
  updatedAt: tick.createdAt,
31890
31892
  });
package/build/index.mjs CHANGED
@@ -31696,6 +31696,7 @@ class StorageBacktestUtils {
31696
31696
  ...tick.signal,
31697
31697
  status: "closed",
31698
31698
  priority: Date.now(),
31699
+ pnl: tick.pnl,
31699
31700
  createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
31700
31701
  updatedAt: tick.createdAt,
31701
31702
  });
@@ -31865,6 +31866,7 @@ class StorageLiveUtils {
31865
31866
  ...tick.signal,
31866
31867
  status: "closed",
31867
31868
  priority: Date.now(),
31869
+ pnl: tick.pnl,
31868
31870
  createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
31869
31871
  updatedAt: tick.createdAt,
31870
31872
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "2.2.15",
3
+ "version": "2.2.16",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -1211,19 +1211,53 @@ interface IPublicSignalRow extends ISignalRow {
1211
1211
  partialExecuted: number;
1212
1212
  }
1213
1213
  /**
1214
- * Storage signal row with creation timestamp taken from IStrategyTickResult.
1214
+ * Base storage signal row fields shared by all status variants.
1215
1215
  * Used for persisting signals with accurate creation time.
1216
1216
  */
1217
- interface IStorageSignalRow extends IPublicSignalRow {
1217
+ interface IStorageSignalRowBase extends IPublicSignalRow {
1218
1218
  /** Creation timestamp taken from IStrategyTickResult */
1219
1219
  createdAt: number;
1220
1220
  /** Creation timestamp taken from IStrategyTickResult */
1221
1221
  updatedAt: number;
1222
1222
  /** Storage adapter rewrite priority. Equal to Date.now for live and backtest both */
1223
1223
  priority: number;
1224
+ }
1225
+ /**
1226
+ * Storage signal row for opened status.
1227
+ */
1228
+ interface IStorageSignalRowOpened extends IStorageSignalRowBase {
1229
+ /** Current status of the signal */
1230
+ status: "opened";
1231
+ }
1232
+ /**
1233
+ * Storage signal row for scheduled status.
1234
+ */
1235
+ interface IStorageSignalRowScheduled extends IStorageSignalRowBase {
1236
+ /** Current status of the signal */
1237
+ status: "scheduled";
1238
+ }
1239
+ /**
1240
+ * Storage signal row for closed status.
1241
+ * Only closed signals have PNL data.
1242
+ */
1243
+ interface IStorageSignalRowClosed extends IStorageSignalRowBase {
1224
1244
  /** Current status of the signal */
1225
- status: "opened" | "scheduled" | "closed" | "cancelled";
1245
+ status: "closed";
1246
+ /** Profit and loss value for the signal when closed */
1247
+ pnl: IStrategyPnL;
1226
1248
  }
1249
+ /**
1250
+ * Storage signal row for cancelled status.
1251
+ */
1252
+ interface IStorageSignalRowCancelled extends IStorageSignalRowBase {
1253
+ /** Current status of the signal */
1254
+ status: "cancelled";
1255
+ }
1256
+ /**
1257
+ * Discriminated union of storage signal rows.
1258
+ * Use type guards: `row.status === "closed"` for type-safe access to pnl.
1259
+ */
1260
+ type IStorageSignalRow = IStorageSignalRowOpened | IStorageSignalRowScheduled | IStorageSignalRowClosed | IStorageSignalRowCancelled;
1227
1261
  /**
1228
1262
  * Risk signal row for internal risk management.
1229
1263
  * Extends ISignalDto to include priceOpen, originalPriceStopLoss and originalPriceTakeProfit.