backtest-kit 1.11.6 → 1.11.7

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
@@ -10217,6 +10217,48 @@ const partial_columns = [
10217
10217
  format: (data) => `${data.currentPrice.toFixed(8)} USD`,
10218
10218
  isVisible: () => true,
10219
10219
  },
10220
+ {
10221
+ key: "priceOpen",
10222
+ label: "Entry Price",
10223
+ format: (data) => (data.priceOpen ? `${data.priceOpen.toFixed(8)} USD` : "N/A"),
10224
+ isVisible: () => true,
10225
+ },
10226
+ {
10227
+ key: "priceTakeProfit",
10228
+ label: "Take Profit",
10229
+ format: (data) => (data.priceTakeProfit ? `${data.priceTakeProfit.toFixed(8)} USD` : "N/A"),
10230
+ isVisible: () => true,
10231
+ },
10232
+ {
10233
+ key: "priceStopLoss",
10234
+ label: "Stop Loss",
10235
+ format: (data) => (data.priceStopLoss ? `${data.priceStopLoss.toFixed(8)} USD` : "N/A"),
10236
+ isVisible: () => true,
10237
+ },
10238
+ {
10239
+ key: "originalPriceTakeProfit",
10240
+ label: "Original TP",
10241
+ format: (data) => (data.originalPriceTakeProfit ? `${data.originalPriceTakeProfit.toFixed(8)} USD` : "N/A"),
10242
+ isVisible: () => true,
10243
+ },
10244
+ {
10245
+ key: "originalPriceStopLoss",
10246
+ label: "Original SL",
10247
+ format: (data) => (data.originalPriceStopLoss ? `${data.originalPriceStopLoss.toFixed(8)} USD` : "N/A"),
10248
+ isVisible: () => true,
10249
+ },
10250
+ {
10251
+ key: "totalExecuted",
10252
+ label: "Total Executed %",
10253
+ format: (data) => (data.totalExecuted !== undefined ? `${data.totalExecuted.toFixed(2)}%` : "N/A"),
10254
+ isVisible: () => true,
10255
+ },
10256
+ {
10257
+ key: "note",
10258
+ label: "Note",
10259
+ format: (data) => data.note || "",
10260
+ isVisible: () => GLOBAL_CONFIG.CC_REPORT_SHOW_SIGNAL_NOTE,
10261
+ },
10220
10262
  {
10221
10263
  key: "timestamp",
10222
10264
  label: "Timestamp",
@@ -10303,6 +10345,42 @@ const breakeven_columns = [
10303
10345
  format: (data) => `${data.currentPrice.toFixed(8)} USD`,
10304
10346
  isVisible: () => true,
10305
10347
  },
10348
+ {
10349
+ key: "priceTakeProfit",
10350
+ label: "Take Profit",
10351
+ format: (data) => (data.priceTakeProfit ? `${data.priceTakeProfit.toFixed(8)} USD` : "N/A"),
10352
+ isVisible: () => true,
10353
+ },
10354
+ {
10355
+ key: "priceStopLoss",
10356
+ label: "Stop Loss",
10357
+ format: (data) => (data.priceStopLoss ? `${data.priceStopLoss.toFixed(8)} USD` : "N/A"),
10358
+ isVisible: () => true,
10359
+ },
10360
+ {
10361
+ key: "originalPriceTakeProfit",
10362
+ label: "Original TP",
10363
+ format: (data) => (data.originalPriceTakeProfit ? `${data.originalPriceTakeProfit.toFixed(8)} USD` : "N/A"),
10364
+ isVisible: () => true,
10365
+ },
10366
+ {
10367
+ key: "originalPriceStopLoss",
10368
+ label: "Original SL",
10369
+ format: (data) => (data.originalPriceStopLoss ? `${data.originalPriceStopLoss.toFixed(8)} USD` : "N/A"),
10370
+ isVisible: () => true,
10371
+ },
10372
+ {
10373
+ key: "totalExecuted",
10374
+ label: "Total Executed %",
10375
+ format: (data) => (data.totalExecuted !== undefined ? `${data.totalExecuted.toFixed(2)}%` : "N/A"),
10376
+ isVisible: () => true,
10377
+ },
10378
+ {
10379
+ key: "note",
10380
+ label: "Note",
10381
+ format: (data) => data.note || "",
10382
+ isVisible: () => GLOBAL_CONFIG.CC_REPORT_SHOW_SIGNAL_NOTE,
10383
+ },
10306
10384
  {
10307
10385
  key: "timestamp",
10308
10386
  label: "Timestamp",
@@ -16902,6 +16980,13 @@ let ReportStorage$2 = class ReportStorage {
16902
16980
  position: data.position,
16903
16981
  currentPrice,
16904
16982
  level,
16983
+ priceOpen: data.priceOpen,
16984
+ priceTakeProfit: data.priceTakeProfit,
16985
+ priceStopLoss: data.priceStopLoss,
16986
+ originalPriceTakeProfit: data.originalPriceTakeProfit,
16987
+ originalPriceStopLoss: data.originalPriceStopLoss,
16988
+ totalExecuted: data.totalExecuted,
16989
+ note: data.note,
16905
16990
  backtest,
16906
16991
  });
16907
16992
  // Trim queue if exceeded MAX_EVENTS
@@ -16927,6 +17012,13 @@ let ReportStorage$2 = class ReportStorage {
16927
17012
  position: data.position,
16928
17013
  currentPrice,
16929
17014
  level,
17015
+ priceOpen: data.priceOpen,
17016
+ priceTakeProfit: data.priceTakeProfit,
17017
+ priceStopLoss: data.priceStopLoss,
17018
+ originalPriceTakeProfit: data.originalPriceTakeProfit,
17019
+ originalPriceStopLoss: data.originalPriceStopLoss,
17020
+ totalExecuted: data.totalExecuted,
17021
+ note: data.note,
16930
17022
  backtest,
16931
17023
  });
16932
17024
  // Trim queue if exceeded MAX_EVENTS
@@ -17979,7 +18071,7 @@ let ReportStorage$1 = class ReportStorage {
17979
18071
  /**
17980
18072
  * Adds a breakeven event to the storage.
17981
18073
  *
17982
- * @param data - Signal row data
18074
+ * @param data - Signal row data with original prices
17983
18075
  * @param currentPrice - Current market price when breakeven was reached
17984
18076
  * @param backtest - True if backtest mode
17985
18077
  * @param timestamp - Event timestamp in milliseconds
@@ -17993,6 +18085,12 @@ let ReportStorage$1 = class ReportStorage {
17993
18085
  position: data.position,
17994
18086
  currentPrice,
17995
18087
  priceOpen: data.priceOpen,
18088
+ priceTakeProfit: data.priceTakeProfit,
18089
+ priceStopLoss: data.priceStopLoss,
18090
+ originalPriceTakeProfit: data.originalPriceTakeProfit,
18091
+ originalPriceStopLoss: data.originalPriceStopLoss,
18092
+ totalExecuted: data.totalExecuted,
18093
+ note: data.note,
17996
18094
  backtest,
17997
18095
  });
17998
18096
  // Trim queue if exceeded MAX_EVENTS
@@ -20575,6 +20673,9 @@ class PartialReportService {
20575
20673
  priceOpen: data.data.priceOpen,
20576
20674
  priceTakeProfit: data.data.priceTakeProfit,
20577
20675
  priceStopLoss: data.data.priceStopLoss,
20676
+ originalPriceTakeProfit: data.data.originalPriceTakeProfit,
20677
+ originalPriceStopLoss: data.data.originalPriceStopLoss,
20678
+ totalExecuted: data.data.totalExecuted,
20578
20679
  _partial: data.data._partial,
20579
20680
  note: data.data.note,
20580
20681
  pendingAt: data.data.pendingAt,
@@ -20613,6 +20714,9 @@ class PartialReportService {
20613
20714
  priceOpen: data.data.priceOpen,
20614
20715
  priceTakeProfit: data.data.priceTakeProfit,
20615
20716
  priceStopLoss: data.data.priceStopLoss,
20717
+ originalPriceTakeProfit: data.data.originalPriceTakeProfit,
20718
+ originalPriceStopLoss: data.data.originalPriceStopLoss,
20719
+ totalExecuted: data.data.totalExecuted,
20616
20720
  _partial: data.data._partial,
20617
20721
  note: data.data.note,
20618
20722
  pendingAt: data.data.pendingAt,
@@ -20732,6 +20836,9 @@ class BreakevenReportService {
20732
20836
  priceOpen: data.data.priceOpen,
20733
20837
  priceTakeProfit: data.data.priceTakeProfit,
20734
20838
  priceStopLoss: data.data.priceStopLoss,
20839
+ originalPriceTakeProfit: data.data.originalPriceTakeProfit,
20840
+ originalPriceStopLoss: data.data.originalPriceStopLoss,
20841
+ totalExecuted: data.data.totalExecuted,
20735
20842
  _partial: data.data._partial,
20736
20843
  note: data.data.note,
20737
20844
  pendingAt: data.data.pendingAt,
package/build/index.mjs CHANGED
@@ -10197,6 +10197,48 @@ const partial_columns = [
10197
10197
  format: (data) => `${data.currentPrice.toFixed(8)} USD`,
10198
10198
  isVisible: () => true,
10199
10199
  },
10200
+ {
10201
+ key: "priceOpen",
10202
+ label: "Entry Price",
10203
+ format: (data) => (data.priceOpen ? `${data.priceOpen.toFixed(8)} USD` : "N/A"),
10204
+ isVisible: () => true,
10205
+ },
10206
+ {
10207
+ key: "priceTakeProfit",
10208
+ label: "Take Profit",
10209
+ format: (data) => (data.priceTakeProfit ? `${data.priceTakeProfit.toFixed(8)} USD` : "N/A"),
10210
+ isVisible: () => true,
10211
+ },
10212
+ {
10213
+ key: "priceStopLoss",
10214
+ label: "Stop Loss",
10215
+ format: (data) => (data.priceStopLoss ? `${data.priceStopLoss.toFixed(8)} USD` : "N/A"),
10216
+ isVisible: () => true,
10217
+ },
10218
+ {
10219
+ key: "originalPriceTakeProfit",
10220
+ label: "Original TP",
10221
+ format: (data) => (data.originalPriceTakeProfit ? `${data.originalPriceTakeProfit.toFixed(8)} USD` : "N/A"),
10222
+ isVisible: () => true,
10223
+ },
10224
+ {
10225
+ key: "originalPriceStopLoss",
10226
+ label: "Original SL",
10227
+ format: (data) => (data.originalPriceStopLoss ? `${data.originalPriceStopLoss.toFixed(8)} USD` : "N/A"),
10228
+ isVisible: () => true,
10229
+ },
10230
+ {
10231
+ key: "totalExecuted",
10232
+ label: "Total Executed %",
10233
+ format: (data) => (data.totalExecuted !== undefined ? `${data.totalExecuted.toFixed(2)}%` : "N/A"),
10234
+ isVisible: () => true,
10235
+ },
10236
+ {
10237
+ key: "note",
10238
+ label: "Note",
10239
+ format: (data) => data.note || "",
10240
+ isVisible: () => GLOBAL_CONFIG.CC_REPORT_SHOW_SIGNAL_NOTE,
10241
+ },
10200
10242
  {
10201
10243
  key: "timestamp",
10202
10244
  label: "Timestamp",
@@ -10283,6 +10325,42 @@ const breakeven_columns = [
10283
10325
  format: (data) => `${data.currentPrice.toFixed(8)} USD`,
10284
10326
  isVisible: () => true,
10285
10327
  },
10328
+ {
10329
+ key: "priceTakeProfit",
10330
+ label: "Take Profit",
10331
+ format: (data) => (data.priceTakeProfit ? `${data.priceTakeProfit.toFixed(8)} USD` : "N/A"),
10332
+ isVisible: () => true,
10333
+ },
10334
+ {
10335
+ key: "priceStopLoss",
10336
+ label: "Stop Loss",
10337
+ format: (data) => (data.priceStopLoss ? `${data.priceStopLoss.toFixed(8)} USD` : "N/A"),
10338
+ isVisible: () => true,
10339
+ },
10340
+ {
10341
+ key: "originalPriceTakeProfit",
10342
+ label: "Original TP",
10343
+ format: (data) => (data.originalPriceTakeProfit ? `${data.originalPriceTakeProfit.toFixed(8)} USD` : "N/A"),
10344
+ isVisible: () => true,
10345
+ },
10346
+ {
10347
+ key: "originalPriceStopLoss",
10348
+ label: "Original SL",
10349
+ format: (data) => (data.originalPriceStopLoss ? `${data.originalPriceStopLoss.toFixed(8)} USD` : "N/A"),
10350
+ isVisible: () => true,
10351
+ },
10352
+ {
10353
+ key: "totalExecuted",
10354
+ label: "Total Executed %",
10355
+ format: (data) => (data.totalExecuted !== undefined ? `${data.totalExecuted.toFixed(2)}%` : "N/A"),
10356
+ isVisible: () => true,
10357
+ },
10358
+ {
10359
+ key: "note",
10360
+ label: "Note",
10361
+ format: (data) => data.note || "",
10362
+ isVisible: () => GLOBAL_CONFIG.CC_REPORT_SHOW_SIGNAL_NOTE,
10363
+ },
10286
10364
  {
10287
10365
  key: "timestamp",
10288
10366
  label: "Timestamp",
@@ -16882,6 +16960,13 @@ let ReportStorage$2 = class ReportStorage {
16882
16960
  position: data.position,
16883
16961
  currentPrice,
16884
16962
  level,
16963
+ priceOpen: data.priceOpen,
16964
+ priceTakeProfit: data.priceTakeProfit,
16965
+ priceStopLoss: data.priceStopLoss,
16966
+ originalPriceTakeProfit: data.originalPriceTakeProfit,
16967
+ originalPriceStopLoss: data.originalPriceStopLoss,
16968
+ totalExecuted: data.totalExecuted,
16969
+ note: data.note,
16885
16970
  backtest,
16886
16971
  });
16887
16972
  // Trim queue if exceeded MAX_EVENTS
@@ -16907,6 +16992,13 @@ let ReportStorage$2 = class ReportStorage {
16907
16992
  position: data.position,
16908
16993
  currentPrice,
16909
16994
  level,
16995
+ priceOpen: data.priceOpen,
16996
+ priceTakeProfit: data.priceTakeProfit,
16997
+ priceStopLoss: data.priceStopLoss,
16998
+ originalPriceTakeProfit: data.originalPriceTakeProfit,
16999
+ originalPriceStopLoss: data.originalPriceStopLoss,
17000
+ totalExecuted: data.totalExecuted,
17001
+ note: data.note,
16910
17002
  backtest,
16911
17003
  });
16912
17004
  // Trim queue if exceeded MAX_EVENTS
@@ -17959,7 +18051,7 @@ let ReportStorage$1 = class ReportStorage {
17959
18051
  /**
17960
18052
  * Adds a breakeven event to the storage.
17961
18053
  *
17962
- * @param data - Signal row data
18054
+ * @param data - Signal row data with original prices
17963
18055
  * @param currentPrice - Current market price when breakeven was reached
17964
18056
  * @param backtest - True if backtest mode
17965
18057
  * @param timestamp - Event timestamp in milliseconds
@@ -17973,6 +18065,12 @@ let ReportStorage$1 = class ReportStorage {
17973
18065
  position: data.position,
17974
18066
  currentPrice,
17975
18067
  priceOpen: data.priceOpen,
18068
+ priceTakeProfit: data.priceTakeProfit,
18069
+ priceStopLoss: data.priceStopLoss,
18070
+ originalPriceTakeProfit: data.originalPriceTakeProfit,
18071
+ originalPriceStopLoss: data.originalPriceStopLoss,
18072
+ totalExecuted: data.totalExecuted,
18073
+ note: data.note,
17976
18074
  backtest,
17977
18075
  });
17978
18076
  // Trim queue if exceeded MAX_EVENTS
@@ -20555,6 +20653,9 @@ class PartialReportService {
20555
20653
  priceOpen: data.data.priceOpen,
20556
20654
  priceTakeProfit: data.data.priceTakeProfit,
20557
20655
  priceStopLoss: data.data.priceStopLoss,
20656
+ originalPriceTakeProfit: data.data.originalPriceTakeProfit,
20657
+ originalPriceStopLoss: data.data.originalPriceStopLoss,
20658
+ totalExecuted: data.data.totalExecuted,
20558
20659
  _partial: data.data._partial,
20559
20660
  note: data.data.note,
20560
20661
  pendingAt: data.data.pendingAt,
@@ -20593,6 +20694,9 @@ class PartialReportService {
20593
20694
  priceOpen: data.data.priceOpen,
20594
20695
  priceTakeProfit: data.data.priceTakeProfit,
20595
20696
  priceStopLoss: data.data.priceStopLoss,
20697
+ originalPriceTakeProfit: data.data.originalPriceTakeProfit,
20698
+ originalPriceStopLoss: data.data.originalPriceStopLoss,
20699
+ totalExecuted: data.data.totalExecuted,
20596
20700
  _partial: data.data._partial,
20597
20701
  note: data.data.note,
20598
20702
  pendingAt: data.data.pendingAt,
@@ -20712,6 +20816,9 @@ class BreakevenReportService {
20712
20816
  priceOpen: data.data.priceOpen,
20713
20817
  priceTakeProfit: data.data.priceTakeProfit,
20714
20818
  priceStopLoss: data.data.priceStopLoss,
20819
+ originalPriceTakeProfit: data.data.originalPriceTakeProfit,
20820
+ originalPriceStopLoss: data.data.originalPriceStopLoss,
20821
+ totalExecuted: data.data.totalExecuted,
20715
20822
  _partial: data.data._partial,
20716
20823
  note: data.data.note,
20717
20824
  pendingAt: data.data.pendingAt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "1.11.6",
3
+ "version": "1.11.7",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -1900,6 +1900,18 @@ interface BreakevenEvent {
1900
1900
  currentPrice: number;
1901
1901
  /** Entry price (breakeven level) */
1902
1902
  priceOpen: number;
1903
+ /** Take profit target price */
1904
+ priceTakeProfit?: number;
1905
+ /** Stop loss exit price */
1906
+ priceStopLoss?: number;
1907
+ /** Original take profit price set at signal creation */
1908
+ originalPriceTakeProfit?: number;
1909
+ /** Original stop loss price set at signal creation */
1910
+ originalPriceStopLoss?: number;
1911
+ /** Total executed percentage from partial closes */
1912
+ totalExecuted?: number;
1913
+ /** Human-readable description of signal reason */
1914
+ note?: string;
1903
1915
  /** True if backtest mode, false if live mode */
1904
1916
  backtest: boolean;
1905
1917
  }
@@ -3854,10 +3866,10 @@ interface PartialProfitContract {
3854
3866
  */
3855
3867
  frameName: FrameName;
3856
3868
  /**
3857
- * Complete signal row data.
3858
- * Contains all signal information: id, position, priceOpen, priceTakeProfit, priceStopLoss, etc.
3869
+ * Complete signal row data with original prices.
3870
+ * Contains all signal information including originalPriceStopLoss, originalPriceTakeProfit, and totalExecuted.
3859
3871
  */
3860
- data: ISignalRow;
3872
+ data: IPublicSignalRow;
3861
3873
  /**
3862
3874
  * Current market price at which this profit level was reached.
3863
3875
  * Used to calculate actual profit percentage.
@@ -3954,10 +3966,10 @@ interface PartialLossContract {
3954
3966
  */
3955
3967
  frameName: FrameName;
3956
3968
  /**
3957
- * Complete signal row data.
3958
- * Contains all signal information: id, position, priceOpen, priceTakeProfit, priceStopLoss, etc.
3969
+ * Complete signal row data with original prices.
3970
+ * Contains all signal information including originalPriceStopLoss, originalPriceTakeProfit, and totalExecuted.
3959
3971
  */
3960
- data: ISignalRow;
3972
+ data: IPublicSignalRow;
3961
3973
  /**
3962
3974
  * Current market price at which this loss level was reached.
3963
3975
  * Used to calculate actual loss percentage.
@@ -4059,10 +4071,10 @@ interface BreakevenContract {
4059
4071
  */
4060
4072
  frameName: FrameName;
4061
4073
  /**
4062
- * Complete signal row data.
4063
- * Contains all signal information: id, position, priceOpen, priceTakeProfit, priceStopLoss, etc.
4074
+ * Complete signal row data with original prices.
4075
+ * Contains all signal information including originalPriceStopLoss, originalPriceTakeProfit, and totalExecuted.
4064
4076
  */
4065
- data: ISignalRow;
4077
+ data: IPublicSignalRow;
4066
4078
  /**
4067
4079
  * Current market price at which breakeven was triggered.
4068
4080
  * Used to verify threshold calculation.
@@ -5985,6 +5997,20 @@ interface PartialEvent {
5985
5997
  currentPrice: number;
5986
5998
  /** Profit/loss level reached (10, 20, 30, etc) */
5987
5999
  level: PartialLevel;
6000
+ /** Entry price for the position */
6001
+ priceOpen?: number;
6002
+ /** Take profit target price */
6003
+ priceTakeProfit?: number;
6004
+ /** Stop loss exit price */
6005
+ priceStopLoss?: number;
6006
+ /** Original take profit price set at signal creation */
6007
+ originalPriceTakeProfit?: number;
6008
+ /** Original stop loss price set at signal creation */
6009
+ originalPriceStopLoss?: number;
6010
+ /** Total executed percentage from partial closes */
6011
+ totalExecuted?: number;
6012
+ /** Human-readable description of signal reason */
6013
+ note?: string;
5988
6014
  /** True if backtest mode, false if live mode */
5989
6015
  backtest: boolean;
5990
6016
  }
@@ -12443,7 +12469,7 @@ declare class PartialConnectionService implements IPartial {
12443
12469
  * @param priceClose - Final closing price
12444
12470
  * @returns Promise that resolves when clear is complete
12445
12471
  */
12446
- clear: (symbol: string, data: ISignalRow, priceClose: number, backtest: boolean) => Promise<void>;
12472
+ clear: (symbol: string, data: IPublicSignalRow, priceClose: number, backtest: boolean) => Promise<void>;
12447
12473
  }
12448
12474
 
12449
12475
  /**
@@ -12525,7 +12551,7 @@ declare class BreakevenConnectionService implements IBreakeven {
12525
12551
  * @param backtest - True if backtest mode, false if live mode
12526
12552
  * @returns Promise that resolves when clear is complete
12527
12553
  */
12528
- clear: (symbol: string, data: ISignalRow, priceClose: number, backtest: boolean) => Promise<void>;
12554
+ clear: (symbol: string, data: IPublicSignalRow, priceClose: number, backtest: boolean) => Promise<void>;
12529
12555
  }
12530
12556
 
12531
12557
  /**
@@ -15144,7 +15170,7 @@ declare class PartialGlobalService implements TPartial {
15144
15170
  * @param priceClose - Final closing price
15145
15171
  * @returns Promise that resolves when clear is complete
15146
15172
  */
15147
- clear: (symbol: string, data: ISignalRow, priceClose: number, backtest: boolean) => Promise<void>;
15173
+ clear: (symbol: string, data: IPublicSignalRow, priceClose: number, backtest: boolean) => Promise<void>;
15148
15174
  }
15149
15175
 
15150
15176
  /**
@@ -15247,7 +15273,7 @@ declare class BreakevenGlobalService implements TBreakeven {
15247
15273
  * @param backtest - True if backtest mode, false if live mode
15248
15274
  * @returns Promise that resolves when clear is complete
15249
15275
  */
15250
- clear: (symbol: string, data: ISignalRow, priceClose: number, backtest: boolean) => Promise<void>;
15276
+ clear: (symbol: string, data: IPublicSignalRow, priceClose: number, backtest: boolean) => Promise<void>;
15251
15277
  }
15252
15278
 
15253
15279
  /**