backtest-kit 2.2.23 → 2.2.25

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
@@ -2894,6 +2894,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2894
2894
  timestamp,
2895
2895
  position: publicSignal.position,
2896
2896
  priceOpen: publicSignal.priceOpen,
2897
+ signalId: publicSignal.id,
2897
2898
  priceTakeProfit: publicSignal.priceTakeProfit,
2898
2899
  priceStopLoss: publicSignal.priceStopLoss,
2899
2900
  originalPriceTakeProfit: publicSignal.originalPriceTakeProfit,
@@ -2916,6 +2917,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2916
2917
  timestamp,
2917
2918
  position: publicSignal.position,
2918
2919
  priceOpen: publicSignal.priceOpen,
2920
+ signalId: publicSignal.id,
2919
2921
  priceTakeProfit: publicSignal.priceTakeProfit,
2920
2922
  priceStopLoss: publicSignal.priceStopLoss,
2921
2923
  originalPriceTakeProfit: publicSignal.originalPriceTakeProfit,
@@ -2935,6 +2937,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2935
2937
  backtest: commit.backtest,
2936
2938
  currentPrice: commit.currentPrice,
2937
2939
  timestamp,
2940
+ signalId: publicSignal.id,
2938
2941
  position: publicSignal.position,
2939
2942
  priceOpen: publicSignal.priceOpen,
2940
2943
  priceTakeProfit: publicSignal.priceTakeProfit,
@@ -2957,6 +2960,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2957
2960
  percentShift: commit.percentShift,
2958
2961
  currentPrice: commit.currentPrice,
2959
2962
  timestamp,
2963
+ signalId: publicSignal.id,
2960
2964
  position: publicSignal.position,
2961
2965
  priceOpen: publicSignal.priceOpen,
2962
2966
  priceTakeProfit: publicSignal.priceTakeProfit,
@@ -2979,6 +2983,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2979
2983
  percentShift: commit.percentShift,
2980
2984
  currentPrice: commit.currentPrice,
2981
2985
  timestamp,
2986
+ signalId: publicSignal.id,
2982
2987
  position: publicSignal.position,
2983
2988
  priceOpen: publicSignal.priceOpen,
2984
2989
  priceTakeProfit: publicSignal.priceTakeProfit,
@@ -5763,6 +5768,7 @@ class ClientStrategy {
5763
5768
  strategyName: this.params.strategyName,
5764
5769
  exchangeName: this.params.exchangeName,
5765
5770
  frameName: this.params.frameName,
5771
+ signalId: this._cancelledSignal.id,
5766
5772
  backtest,
5767
5773
  cancelId,
5768
5774
  timestamp: this.params.execution.context.when.getTime(),
@@ -5779,6 +5785,7 @@ class ClientStrategy {
5779
5785
  strategyName: this.params.strategyName,
5780
5786
  exchangeName: this.params.exchangeName,
5781
5787
  frameName: this.params.frameName,
5788
+ signalId: this._cancelledSignal.id,
5782
5789
  backtest,
5783
5790
  cancelId,
5784
5791
  timestamp: this.params.execution.context.when.getTime(),
@@ -5829,6 +5836,7 @@ class ClientStrategy {
5829
5836
  strategyName: this.params.strategyName,
5830
5837
  exchangeName: this.params.exchangeName,
5831
5838
  frameName: this.params.frameName,
5839
+ signalId: this._closedSignal.id,
5832
5840
  backtest,
5833
5841
  closeId,
5834
5842
  timestamp: this.params.execution.context.when.getTime(),
@@ -5845,6 +5853,7 @@ class ClientStrategy {
5845
5853
  strategyName: this.params.strategyName,
5846
5854
  exchangeName: this.params.exchangeName,
5847
5855
  frameName: this.params.frameName,
5856
+ signalId: this._closedSignal.id,
5848
5857
  backtest,
5849
5858
  closeId,
5850
5859
  timestamp: this.params.execution.context.when.getTime(),
@@ -33861,6 +33870,8 @@ class NotificationInstance {
33861
33870
  priceOpen: data.signal.priceOpen,
33862
33871
  priceTakeProfit: data.signal.priceTakeProfit,
33863
33872
  priceStopLoss: data.signal.priceStopLoss,
33873
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33874
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33864
33875
  note: data.signal.note,
33865
33876
  scheduledAt: data.signal.scheduledAt,
33866
33877
  pendingAt: data.signal.pendingAt,
@@ -33882,6 +33893,10 @@ class NotificationInstance {
33882
33893
  position: data.signal.position,
33883
33894
  priceOpen: data.signal.priceOpen,
33884
33895
  priceClose: data.currentPrice,
33896
+ priceTakeProfit: data.signal.priceTakeProfit,
33897
+ priceStopLoss: data.signal.priceStopLoss,
33898
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33899
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33885
33900
  pnlPercentage: data.pnl.pnlPercentage,
33886
33901
  closeReason: data.closeReason,
33887
33902
  duration: durationMin,
@@ -33903,6 +33918,10 @@ class NotificationInstance {
33903
33918
  signalId: data.signal.id,
33904
33919
  position: data.signal.position,
33905
33920
  priceOpen: data.signal.priceOpen,
33921
+ priceTakeProfit: data.signal.priceTakeProfit,
33922
+ priceStopLoss: data.signal.priceStopLoss,
33923
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33924
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33906
33925
  scheduledAt: data.signal.scheduledAt,
33907
33926
  currentPrice: data.currentPrice,
33908
33927
  createdAt: data.createdAt,
@@ -33921,6 +33940,10 @@ class NotificationInstance {
33921
33940
  exchangeName: data.exchangeName,
33922
33941
  signalId: data.signal.id,
33923
33942
  position: data.signal.position,
33943
+ priceTakeProfit: data.signal.priceTakeProfit,
33944
+ priceStopLoss: data.signal.priceStopLoss,
33945
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33946
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33924
33947
  cancelReason: data.reason,
33925
33948
  cancelId: data.cancelId,
33926
33949
  duration: durationMin,
@@ -34020,6 +34043,7 @@ class NotificationInstance {
34020
34043
  symbol: data.symbol,
34021
34044
  strategyName: data.strategyName,
34022
34045
  exchangeName: data.exchangeName,
34046
+ signalId: data.signalId,
34023
34047
  percentToClose: data.percentToClose,
34024
34048
  currentPrice: data.currentPrice,
34025
34049
  position: data.position,
@@ -34042,6 +34066,7 @@ class NotificationInstance {
34042
34066
  symbol: data.symbol,
34043
34067
  strategyName: data.strategyName,
34044
34068
  exchangeName: data.exchangeName,
34069
+ signalId: data.signalId,
34045
34070
  percentToClose: data.percentToClose,
34046
34071
  currentPrice: data.currentPrice,
34047
34072
  position: data.position,
@@ -34064,6 +34089,7 @@ class NotificationInstance {
34064
34089
  symbol: data.symbol,
34065
34090
  strategyName: data.strategyName,
34066
34091
  exchangeName: data.exchangeName,
34092
+ signalId: data.signalId,
34067
34093
  currentPrice: data.currentPrice,
34068
34094
  position: data.position,
34069
34095
  priceOpen: data.priceOpen,
@@ -34085,6 +34111,7 @@ class NotificationInstance {
34085
34111
  symbol: data.symbol,
34086
34112
  strategyName: data.strategyName,
34087
34113
  exchangeName: data.exchangeName,
34114
+ signalId: data.signalId,
34088
34115
  percentShift: data.percentShift,
34089
34116
  currentPrice: data.currentPrice,
34090
34117
  position: data.position,
@@ -34107,6 +34134,7 @@ class NotificationInstance {
34107
34134
  symbol: data.symbol,
34108
34135
  strategyName: data.strategyName,
34109
34136
  exchangeName: data.exchangeName,
34137
+ signalId: data.signalId,
34110
34138
  percentShift: data.percentShift,
34111
34139
  currentPrice: data.currentPrice,
34112
34140
  position: data.position,
package/build/index.mjs CHANGED
@@ -2874,6 +2874,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2874
2874
  timestamp,
2875
2875
  position: publicSignal.position,
2876
2876
  priceOpen: publicSignal.priceOpen,
2877
+ signalId: publicSignal.id,
2877
2878
  priceTakeProfit: publicSignal.priceTakeProfit,
2878
2879
  priceStopLoss: publicSignal.priceStopLoss,
2879
2880
  originalPriceTakeProfit: publicSignal.originalPriceTakeProfit,
@@ -2896,6 +2897,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2896
2897
  timestamp,
2897
2898
  position: publicSignal.position,
2898
2899
  priceOpen: publicSignal.priceOpen,
2900
+ signalId: publicSignal.id,
2899
2901
  priceTakeProfit: publicSignal.priceTakeProfit,
2900
2902
  priceStopLoss: publicSignal.priceStopLoss,
2901
2903
  originalPriceTakeProfit: publicSignal.originalPriceTakeProfit,
@@ -2915,6 +2917,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2915
2917
  backtest: commit.backtest,
2916
2918
  currentPrice: commit.currentPrice,
2917
2919
  timestamp,
2920
+ signalId: publicSignal.id,
2918
2921
  position: publicSignal.position,
2919
2922
  priceOpen: publicSignal.priceOpen,
2920
2923
  priceTakeProfit: publicSignal.priceTakeProfit,
@@ -2937,6 +2940,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2937
2940
  percentShift: commit.percentShift,
2938
2941
  currentPrice: commit.currentPrice,
2939
2942
  timestamp,
2943
+ signalId: publicSignal.id,
2940
2944
  position: publicSignal.position,
2941
2945
  priceOpen: publicSignal.priceOpen,
2942
2946
  priceTakeProfit: publicSignal.priceTakeProfit,
@@ -2959,6 +2963,7 @@ const PROCESS_COMMIT_QUEUE_FN = async (self, timestamp) => {
2959
2963
  percentShift: commit.percentShift,
2960
2964
  currentPrice: commit.currentPrice,
2961
2965
  timestamp,
2966
+ signalId: publicSignal.id,
2962
2967
  position: publicSignal.position,
2963
2968
  priceOpen: publicSignal.priceOpen,
2964
2969
  priceTakeProfit: publicSignal.priceTakeProfit,
@@ -5743,6 +5748,7 @@ class ClientStrategy {
5743
5748
  strategyName: this.params.strategyName,
5744
5749
  exchangeName: this.params.exchangeName,
5745
5750
  frameName: this.params.frameName,
5751
+ signalId: this._cancelledSignal.id,
5746
5752
  backtest,
5747
5753
  cancelId,
5748
5754
  timestamp: this.params.execution.context.when.getTime(),
@@ -5759,6 +5765,7 @@ class ClientStrategy {
5759
5765
  strategyName: this.params.strategyName,
5760
5766
  exchangeName: this.params.exchangeName,
5761
5767
  frameName: this.params.frameName,
5768
+ signalId: this._cancelledSignal.id,
5762
5769
  backtest,
5763
5770
  cancelId,
5764
5771
  timestamp: this.params.execution.context.when.getTime(),
@@ -5809,6 +5816,7 @@ class ClientStrategy {
5809
5816
  strategyName: this.params.strategyName,
5810
5817
  exchangeName: this.params.exchangeName,
5811
5818
  frameName: this.params.frameName,
5819
+ signalId: this._closedSignal.id,
5812
5820
  backtest,
5813
5821
  closeId,
5814
5822
  timestamp: this.params.execution.context.when.getTime(),
@@ -5825,6 +5833,7 @@ class ClientStrategy {
5825
5833
  strategyName: this.params.strategyName,
5826
5834
  exchangeName: this.params.exchangeName,
5827
5835
  frameName: this.params.frameName,
5836
+ signalId: this._closedSignal.id,
5828
5837
  backtest,
5829
5838
  closeId,
5830
5839
  timestamp: this.params.execution.context.when.getTime(),
@@ -33841,6 +33850,8 @@ class NotificationInstance {
33841
33850
  priceOpen: data.signal.priceOpen,
33842
33851
  priceTakeProfit: data.signal.priceTakeProfit,
33843
33852
  priceStopLoss: data.signal.priceStopLoss,
33853
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33854
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33844
33855
  note: data.signal.note,
33845
33856
  scheduledAt: data.signal.scheduledAt,
33846
33857
  pendingAt: data.signal.pendingAt,
@@ -33862,6 +33873,10 @@ class NotificationInstance {
33862
33873
  position: data.signal.position,
33863
33874
  priceOpen: data.signal.priceOpen,
33864
33875
  priceClose: data.currentPrice,
33876
+ priceTakeProfit: data.signal.priceTakeProfit,
33877
+ priceStopLoss: data.signal.priceStopLoss,
33878
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33879
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33865
33880
  pnlPercentage: data.pnl.pnlPercentage,
33866
33881
  closeReason: data.closeReason,
33867
33882
  duration: durationMin,
@@ -33883,6 +33898,10 @@ class NotificationInstance {
33883
33898
  signalId: data.signal.id,
33884
33899
  position: data.signal.position,
33885
33900
  priceOpen: data.signal.priceOpen,
33901
+ priceTakeProfit: data.signal.priceTakeProfit,
33902
+ priceStopLoss: data.signal.priceStopLoss,
33903
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33904
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33886
33905
  scheduledAt: data.signal.scheduledAt,
33887
33906
  currentPrice: data.currentPrice,
33888
33907
  createdAt: data.createdAt,
@@ -33901,6 +33920,10 @@ class NotificationInstance {
33901
33920
  exchangeName: data.exchangeName,
33902
33921
  signalId: data.signal.id,
33903
33922
  position: data.signal.position,
33923
+ priceTakeProfit: data.signal.priceTakeProfit,
33924
+ priceStopLoss: data.signal.priceStopLoss,
33925
+ originalPriceTakeProfit: data.signal.originalPriceTakeProfit,
33926
+ originalPriceStopLoss: data.signal.originalPriceStopLoss,
33904
33927
  cancelReason: data.reason,
33905
33928
  cancelId: data.cancelId,
33906
33929
  duration: durationMin,
@@ -34000,6 +34023,7 @@ class NotificationInstance {
34000
34023
  symbol: data.symbol,
34001
34024
  strategyName: data.strategyName,
34002
34025
  exchangeName: data.exchangeName,
34026
+ signalId: data.signalId,
34003
34027
  percentToClose: data.percentToClose,
34004
34028
  currentPrice: data.currentPrice,
34005
34029
  position: data.position,
@@ -34022,6 +34046,7 @@ class NotificationInstance {
34022
34046
  symbol: data.symbol,
34023
34047
  strategyName: data.strategyName,
34024
34048
  exchangeName: data.exchangeName,
34049
+ signalId: data.signalId,
34025
34050
  percentToClose: data.percentToClose,
34026
34051
  currentPrice: data.currentPrice,
34027
34052
  position: data.position,
@@ -34044,6 +34069,7 @@ class NotificationInstance {
34044
34069
  symbol: data.symbol,
34045
34070
  strategyName: data.strategyName,
34046
34071
  exchangeName: data.exchangeName,
34072
+ signalId: data.signalId,
34047
34073
  currentPrice: data.currentPrice,
34048
34074
  position: data.position,
34049
34075
  priceOpen: data.priceOpen,
@@ -34065,6 +34091,7 @@ class NotificationInstance {
34065
34091
  symbol: data.symbol,
34066
34092
  strategyName: data.strategyName,
34067
34093
  exchangeName: data.exchangeName,
34094
+ signalId: data.signalId,
34068
34095
  percentShift: data.percentShift,
34069
34096
  currentPrice: data.currentPrice,
34070
34097
  position: data.position,
@@ -34087,6 +34114,7 @@ class NotificationInstance {
34087
34114
  symbol: data.symbol,
34088
34115
  strategyName: data.strategyName,
34089
34116
  exchangeName: data.exchangeName,
34117
+ signalId: data.signalId,
34090
34118
  percentShift: data.percentShift,
34091
34119
  currentPrice: data.currentPrice,
34092
34120
  position: data.position,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "2.2.23",
3
+ "version": "2.2.25",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -1012,6 +1012,8 @@ interface SignalCommitBase {
1012
1012
  exchangeName: ExchangeName;
1013
1013
  frameName: FrameName;
1014
1014
  backtest: boolean;
1015
+ /** Unique signal identifier (UUID v4) */
1016
+ signalId: string;
1015
1017
  /** Timestamp from execution context (tick's when or backtest candle timestamp) */
1016
1018
  timestamp: number;
1017
1019
  }
@@ -6632,6 +6634,10 @@ interface SignalOpenedNotification {
6632
6634
  priceTakeProfit: number;
6633
6635
  /** Stop loss exit price */
6634
6636
  priceStopLoss: number;
6637
+ /** Original take profit price before any trailing adjustments */
6638
+ originalPriceTakeProfit: number;
6639
+ /** Original stop loss price before any trailing adjustments */
6640
+ originalPriceStopLoss: number;
6635
6641
  /** Optional human-readable description of signal reason */
6636
6642
  note?: string;
6637
6643
  /** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
@@ -6668,6 +6674,14 @@ interface SignalClosedNotification {
6668
6674
  priceOpen: number;
6669
6675
  /** Exit price when position was closed */
6670
6676
  priceClose: number;
6677
+ /** Take profit target price */
6678
+ priceTakeProfit: number;
6679
+ /** Stop loss exit price */
6680
+ priceStopLoss: number;
6681
+ /** Original take profit price before any trailing adjustments */
6682
+ originalPriceTakeProfit: number;
6683
+ /** Original stop loss price before any trailing adjustments */
6684
+ originalPriceStopLoss: number;
6671
6685
  /** Profit/loss as percentage (e.g., 1.5 for +1.5%, -2.3 for -2.3%) */
6672
6686
  pnlPercentage: number;
6673
6687
  /** Why signal closed (time_expired | take_profit | stop_loss | closed) */
@@ -6832,6 +6846,8 @@ interface PartialProfitCommitNotification {
6832
6846
  strategyName: StrategyName;
6833
6847
  /** Exchange name where signal was executed */
6834
6848
  exchangeName: ExchangeName;
6849
+ /** Unique signal identifier (UUID v4) */
6850
+ signalId: string;
6835
6851
  /** Percentage of position closed (0-100) */
6836
6852
  percentToClose: number;
6837
6853
  /** Current market price when partial was executed */
@@ -6874,6 +6890,8 @@ interface PartialLossCommitNotification {
6874
6890
  strategyName: StrategyName;
6875
6891
  /** Exchange name where signal was executed */
6876
6892
  exchangeName: ExchangeName;
6893
+ /** Unique signal identifier (UUID v4) */
6894
+ signalId: string;
6877
6895
  /** Percentage of position closed (0-100) */
6878
6896
  percentToClose: number;
6879
6897
  /** Current market price when partial was executed */
@@ -6916,6 +6934,8 @@ interface BreakevenCommitNotification {
6916
6934
  strategyName: StrategyName;
6917
6935
  /** Exchange name where signal was executed */
6918
6936
  exchangeName: ExchangeName;
6937
+ /** Unique signal identifier (UUID v4) */
6938
+ signalId: string;
6919
6939
  /** Current market price when breakeven was executed */
6920
6940
  currentPrice: number;
6921
6941
  /** Trade direction: "long" (buy) or "short" (sell) */
@@ -6956,6 +6976,8 @@ interface TrailingStopCommitNotification {
6956
6976
  strategyName: StrategyName;
6957
6977
  /** Exchange name where signal was executed */
6958
6978
  exchangeName: ExchangeName;
6979
+ /** Unique signal identifier (UUID v4) */
6980
+ signalId: string;
6959
6981
  /** Percentage shift of original SL distance (-100 to 100) */
6960
6982
  percentShift: number;
6961
6983
  /** Current market price when trailing stop was executed */
@@ -6998,6 +7020,8 @@ interface TrailingTakeCommitNotification {
6998
7020
  strategyName: StrategyName;
6999
7021
  /** Exchange name where signal was executed */
7000
7022
  exchangeName: ExchangeName;
7023
+ /** Unique signal identifier (UUID v4) */
7024
+ signalId: string;
7001
7025
  /** Percentage shift of original TP distance (-100 to 100) */
7002
7026
  percentShift: number;
7003
7027
  /** Current market price when trailing take was executed */
@@ -7090,6 +7114,14 @@ interface SignalScheduledNotification {
7090
7114
  position: "long" | "short";
7091
7115
  /** Target entry price for activation */
7092
7116
  priceOpen: number;
7117
+ /** Take profit target price */
7118
+ priceTakeProfit: number;
7119
+ /** Stop loss exit price */
7120
+ priceStopLoss: number;
7121
+ /** Original take profit price before any trailing adjustments */
7122
+ originalPriceTakeProfit: number;
7123
+ /** Original stop loss price before any trailing adjustments */
7124
+ originalPriceStopLoss: number;
7093
7125
  /** Unix timestamp in milliseconds when signal was scheduled */
7094
7126
  scheduledAt: number;
7095
7127
  /** Current market price when signal was scheduled */
@@ -7120,6 +7152,14 @@ interface SignalCancelledNotification {
7120
7152
  signalId: string;
7121
7153
  /** Trade direction: "long" (buy) or "short" (sell) */
7122
7154
  position: "long" | "short";
7155
+ /** Take profit target price */
7156
+ priceTakeProfit: number;
7157
+ /** Stop loss exit price */
7158
+ priceStopLoss: number;
7159
+ /** Original take profit price before any trailing adjustments */
7160
+ originalPriceTakeProfit: number;
7161
+ /** Original stop loss price before any trailing adjustments */
7162
+ originalPriceStopLoss: number;
7123
7163
  /** Why signal was cancelled (timeout | price_reject | user) */
7124
7164
  cancelReason: string;
7125
7165
  /** Optional cancellation identifier (provided when user calls cancel()) */