backtest-kit 1.4.15 → 1.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "1.4.15",
3
+ "version": "1.5.1",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -31,6 +31,15 @@ declare const GLOBAL_CONFIG: {
31
31
  * Default: 1440 minutes (1 day)
32
32
  */
33
33
  CC_MAX_SIGNAL_LIFETIME_MINUTES: number;
34
+ /**
35
+ * Maximum time allowed for signal generation (in seconds).
36
+ * Prevents long-running or stuck signal generation routines from blocking
37
+ * execution or consuming resources indefinitely. If generation exceeds this
38
+ * threshold the attempt should be aborted, logged and optionally retried.
39
+ *
40
+ * Default: 180 seconds (3 minutes)
41
+ */
42
+ CC_MAX_SIGNAL_GENERATION_SECONDS: number;
34
43
  /**
35
44
  * Number of retries for getCandles function
36
45
  * Default: 3 retries
@@ -723,7 +732,7 @@ interface IPartial {
723
732
  * // Memoized instance cleared from getPartial cache
724
733
  * ```
725
734
  */
726
- clear(symbol: string, data: ISignalRow, priceClose: number): Promise<void>;
735
+ clear(symbol: string, data: ISignalRow, priceClose: number, backtest: boolean): Promise<void>;
727
736
  }
728
737
 
729
738
  /**
@@ -918,6 +927,10 @@ interface IStrategyTickResultActive {
918
927
  exchangeName: ExchangeName;
919
928
  /** Trading pair symbol (e.g., "BTCUSDT") */
920
929
  symbol: string;
930
+ /** Percentage progress towards take profit (0-100%, 0 if moving towards SL) */
931
+ percentTp: number;
932
+ /** Percentage progress towards stop loss (0-100%, 0 if moving towards TP) */
933
+ percentSl: number;
921
934
  }
922
935
  /**
923
936
  * Tick result: signal closed with PNL.
@@ -3764,6 +3777,10 @@ interface TickEvent {
3764
3777
  takeProfit?: number;
3765
3778
  /** Stop loss price (only for opened/active/closed) */
3766
3779
  stopLoss?: number;
3780
+ /** Percentage progress towards take profit (only for active) */
3781
+ percentTp?: number;
3782
+ /** Percentage progress towards stop loss (only for active) */
3783
+ percentSl?: number;
3767
3784
  /** PNL percentage (only for closed) */
3768
3785
  pnl?: number;
3769
3786
  /** Close reason (only for closed) */
@@ -8661,7 +8678,7 @@ declare class PartialConnectionService implements IPartial {
8661
8678
  * @param priceClose - Final closing price
8662
8679
  * @returns Promise that resolves when clear is complete
8663
8680
  */
8664
- clear: (symbol: string, data: ISignalRow, priceClose: number) => Promise<void>;
8681
+ clear: (symbol: string, data: ISignalRow, priceClose: number, backtest: boolean) => Promise<void>;
8665
8682
  }
8666
8683
 
8667
8684
  /**
@@ -8742,7 +8759,7 @@ declare class PartialGlobalService {
8742
8759
  * @param priceClose - Final closing price
8743
8760
  * @returns Promise that resolves when clear is complete
8744
8761
  */
8745
- clear: (symbol: string, data: ISignalRow, priceClose: number) => Promise<void>;
8762
+ clear: (symbol: string, data: ISignalRow, priceClose: number, backtest: boolean) => Promise<void>;
8746
8763
  }
8747
8764
 
8748
8765
  /**