backtest-kit 6.9.0 → 6.10.0

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": "6.9.0",
3
+ "version": "6.10.0",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -68,7 +68,7 @@
68
68
  "ts-morph": "27.0.2",
69
69
  "tslib": "2.7.0",
70
70
  "typedoc": "0.27.9",
71
- "worker-testbed": "1.0.12"
71
+ "worker-testbed": "2.0.0"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "typescript": "^5.0.0"
@@ -77,7 +77,7 @@
77
77
  "di-kit": "^1.1.1",
78
78
  "di-scoped": "^1.0.21",
79
79
  "di-singleton": "^1.0.5",
80
- "functools-kit": "^1.1.1",
80
+ "functools-kit": "^2.0.1",
81
81
  "get-moment-stamp": "^1.1.2"
82
82
  },
83
83
  "publishConfig": {
package/types.d.ts CHANGED
@@ -3630,6 +3630,46 @@ interface IStrategy {
3630
3630
  * @returns Promise resolving to PnL cost or null
3631
3631
  */
3632
3632
  getPositionMaxDrawdownPnlCost: (symbol: string) => Promise<number | null>;
3633
+ /**
3634
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
3635
+ *
3636
+ * Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
3637
+ *
3638
+ * @param symbol - Trading pair symbol
3639
+ * @param currentPrice - Current market price
3640
+ * @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
3641
+ */
3642
+ getPositionHighestProfitDistancePnlPercentage: (symbol: string, currentPrice: number) => Promise<number | null>;
3643
+ /**
3644
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
3645
+ *
3646
+ * Computed as: max(0, peakPnlCost - currentPnlCost).
3647
+ *
3648
+ * @param symbol - Trading pair symbol
3649
+ * @param currentPrice - Current market price
3650
+ * @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
3651
+ */
3652
+ getPositionHighestProfitDistancePnlCost: (symbol: string, currentPrice: number) => Promise<number | null>;
3653
+ /**
3654
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
3655
+ *
3656
+ * Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
3657
+ *
3658
+ * @param symbol - Trading pair symbol
3659
+ * @param currentPrice - Current market price
3660
+ * @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
3661
+ */
3662
+ getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, currentPrice: number) => Promise<number | null>;
3663
+ /**
3664
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
3665
+ *
3666
+ * Computed as: max(0, currentPnlCost - fallPnlCost).
3667
+ *
3668
+ * @param symbol - Trading pair symbol
3669
+ * @param currentPrice - Current market price
3670
+ * @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
3671
+ */
3672
+ getPositionHighestMaxDrawdownPnlCost: (symbol: string, currentPrice: number) => Promise<number | null>;
3633
3673
  /**
3634
3674
  * Disposes the strategy instance and cleans up resources.
3635
3675
  *
@@ -5590,6 +5630,78 @@ declare function getPositionMaxDrawdownPnlPercentage(symbol: string): Promise<nu
5590
5630
  * ```
5591
5631
  */
5592
5632
  declare function getPositionMaxDrawdownPnlCost(symbol: string): Promise<number>;
5633
+ /**
5634
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
5635
+ *
5636
+ * Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
5637
+ * Returns null if no pending signal exists.
5638
+ *
5639
+ * @param symbol - Trading pair symbol
5640
+ * @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
5641
+ *
5642
+ * @example
5643
+ * ```typescript
5644
+ * import { getPositionHighestProfitDistancePnlPercentage } from "backtest-kit";
5645
+ *
5646
+ * const dist = await getPositionHighestProfitDistancePnlPercentage("BTCUSDT");
5647
+ * // e.g. 1.5 (gave back 1.5% from peak)
5648
+ * ```
5649
+ */
5650
+ declare function getPositionHighestProfitDistancePnlPercentage(symbol: string): Promise<number>;
5651
+ /**
5652
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
5653
+ *
5654
+ * Computed as: max(0, peakPnlCost - currentPnlCost).
5655
+ * Returns null if no pending signal exists.
5656
+ *
5657
+ * @param symbol - Trading pair symbol
5658
+ * @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
5659
+ *
5660
+ * @example
5661
+ * ```typescript
5662
+ * import { getPositionHighestProfitDistancePnlCost } from "backtest-kit";
5663
+ *
5664
+ * const dist = await getPositionHighestProfitDistancePnlCost("BTCUSDT");
5665
+ * // e.g. 3.2 (gave back $3.2 from peak)
5666
+ * ```
5667
+ */
5668
+ declare function getPositionHighestProfitDistancePnlCost(symbol: string): Promise<number>;
5669
+ /**
5670
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
5671
+ *
5672
+ * Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
5673
+ * Returns null if no pending signal exists.
5674
+ *
5675
+ * @param symbol - Trading pair symbol
5676
+ * @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
5677
+ *
5678
+ * @example
5679
+ * ```typescript
5680
+ * import { getPositionHighestMaxDrawdownPnlPercentage } from "backtest-kit";
5681
+ *
5682
+ * const dist = await getPositionHighestMaxDrawdownPnlPercentage("BTCUSDT");
5683
+ * // e.g. 2.1 (recovered 2.1% from trough)
5684
+ * ```
5685
+ */
5686
+ declare function getPositionHighestMaxDrawdownPnlPercentage(symbol: string): Promise<number>;
5687
+ /**
5688
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
5689
+ *
5690
+ * Computed as: max(0, currentPnlCost - fallPnlCost).
5691
+ * Returns null if no pending signal exists.
5692
+ *
5693
+ * @param symbol - Trading pair symbol
5694
+ * @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
5695
+ *
5696
+ * @example
5697
+ * ```typescript
5698
+ * import { getPositionHighestMaxDrawdownPnlCost } from "backtest-kit";
5699
+ *
5700
+ * const dist = await getPositionHighestMaxDrawdownPnlCost("BTCUSDT");
5701
+ * // e.g. 4.8 (recovered $4.8 from trough)
5702
+ * ```
5703
+ */
5704
+ declare function getPositionHighestMaxDrawdownPnlCost(symbol: string): Promise<number>;
5593
5705
  /**
5594
5706
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
5595
5707
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -13899,6 +14011,66 @@ declare class BacktestUtils {
13899
14011
  exchangeName: ExchangeName;
13900
14012
  frameName: FrameName;
13901
14013
  }) => Promise<number>;
14014
+ /**
14015
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
14016
+ *
14017
+ * Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
14018
+ * Returns null if no pending signal exists.
14019
+ *
14020
+ * @param symbol - Trading pair symbol
14021
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14022
+ * @returns drawdown distance in PnL% (≥ 0) or null if no active position
14023
+ */
14024
+ getPositionHighestProfitDistancePnlPercentage: (symbol: string, context: {
14025
+ strategyName: StrategyName;
14026
+ exchangeName: ExchangeName;
14027
+ frameName: FrameName;
14028
+ }) => Promise<number>;
14029
+ /**
14030
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
14031
+ *
14032
+ * Computed as: max(0, peakPnlCost - currentPnlCost).
14033
+ * Returns null if no pending signal exists.
14034
+ *
14035
+ * @param symbol - Trading pair symbol
14036
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14037
+ * @returns drawdown distance in PnL cost (≥ 0) or null if no active position
14038
+ */
14039
+ getPositionHighestProfitDistancePnlCost: (symbol: string, context: {
14040
+ strategyName: StrategyName;
14041
+ exchangeName: ExchangeName;
14042
+ frameName: FrameName;
14043
+ }) => Promise<number>;
14044
+ /**
14045
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
14046
+ *
14047
+ * Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
14048
+ * Returns null if no pending signal exists.
14049
+ *
14050
+ * @param symbol - Trading pair symbol
14051
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14052
+ * @returns recovery distance in PnL% (≥ 0) or null if no active position
14053
+ */
14054
+ getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, context: {
14055
+ strategyName: StrategyName;
14056
+ exchangeName: ExchangeName;
14057
+ frameName: FrameName;
14058
+ }) => Promise<number>;
14059
+ /**
14060
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
14061
+ *
14062
+ * Computed as: max(0, currentPnlCost - fallPnlCost).
14063
+ * Returns null if no pending signal exists.
14064
+ *
14065
+ * @param symbol - Trading pair symbol
14066
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14067
+ * @returns recovery distance in PnL cost (≥ 0) or null if no active position
14068
+ */
14069
+ getPositionHighestMaxDrawdownPnlCost: (symbol: string, context: {
14070
+ strategyName: StrategyName;
14071
+ exchangeName: ExchangeName;
14072
+ frameName: FrameName;
14073
+ }) => Promise<number>;
13902
14074
  /**
13903
14075
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
13904
14076
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -15257,6 +15429,62 @@ declare class LiveUtils {
15257
15429
  strategyName: StrategyName;
15258
15430
  exchangeName: ExchangeName;
15259
15431
  }) => Promise<number>;
15432
+ /**
15433
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
15434
+ *
15435
+ * Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
15436
+ * Returns null if no pending signal exists.
15437
+ *
15438
+ * @param symbol - Trading pair symbol
15439
+ * @param context - Execution context with strategyName and exchangeName
15440
+ * @returns drawdown distance in PnL% (≥ 0) or null if no active position
15441
+ */
15442
+ getPositionHighestProfitDistancePnlPercentage: (symbol: string, context: {
15443
+ strategyName: StrategyName;
15444
+ exchangeName: ExchangeName;
15445
+ }) => Promise<number>;
15446
+ /**
15447
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
15448
+ *
15449
+ * Computed as: max(0, peakPnlCost - currentPnlCost).
15450
+ * Returns null if no pending signal exists.
15451
+ *
15452
+ * @param symbol - Trading pair symbol
15453
+ * @param context - Execution context with strategyName and exchangeName
15454
+ * @returns drawdown distance in PnL cost (≥ 0) or null if no active position
15455
+ */
15456
+ getPositionHighestProfitDistancePnlCost: (symbol: string, context: {
15457
+ strategyName: StrategyName;
15458
+ exchangeName: ExchangeName;
15459
+ }) => Promise<number>;
15460
+ /**
15461
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
15462
+ *
15463
+ * Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
15464
+ * Returns null if no pending signal exists.
15465
+ *
15466
+ * @param symbol - Trading pair symbol
15467
+ * @param context - Execution context with strategyName and exchangeName
15468
+ * @returns recovery distance in PnL% (≥ 0) or null if no active position
15469
+ */
15470
+ getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, context: {
15471
+ strategyName: StrategyName;
15472
+ exchangeName: ExchangeName;
15473
+ }) => Promise<number>;
15474
+ /**
15475
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
15476
+ *
15477
+ * Computed as: max(0, currentPnlCost - fallPnlCost).
15478
+ * Returns null if no pending signal exists.
15479
+ *
15480
+ * @param symbol - Trading pair symbol
15481
+ * @param context - Execution context with strategyName and exchangeName
15482
+ * @returns recovery distance in PnL cost (≥ 0) or null if no active position
15483
+ */
15484
+ getPositionHighestMaxDrawdownPnlCost: (symbol: string, context: {
15485
+ strategyName: StrategyName;
15486
+ exchangeName: ExchangeName;
15487
+ }) => Promise<number>;
15260
15488
  /**
15261
15489
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
15262
15490
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -20168,18 +20396,15 @@ declare class CacheUtils {
20168
20396
  declare const Cache: CacheUtils;
20169
20397
 
20170
20398
  /**
20171
- * Signal function type for in-memory once-per-interval firing.
20172
- * Called at most once per interval boundary per symbol.
20173
- * Must return a non-null `ISignalIntervalDto` to start the interval countdown,
20174
- * or `null` to defer firing until the next call.
20399
+ * User-implemented function fired once per interval boundary.
20400
+ * Receives `when` from the caller (sourced from execution context).
20175
20401
  */
20176
- type TIntervalFn = (symbol: string, when: Date) => Promise<ISignalIntervalDto | null>;
20402
+ type TIntervalFn<T extends object = object> = (symbol: string, when: Date) => Promise<T | null>;
20177
20403
  /**
20178
- * Signal function type for persistent file-based once-per-interval firing.
20179
- * First argument is always `symbol: string`, followed by optional spread args.
20180
- * Fired state survives process restarts via `PersistIntervalAdapter`.
20404
+ * Wrapped function returned by `Interval.fn` and `Interval.file`.
20405
+ * `when` is resolved internally from the execution context callers pass only `symbol`.
20181
20406
  */
20182
- type TIntervalFileFn = (symbol: string, ...args: any[]) => Promise<ISignalIntervalDto | null>;
20407
+ type TIntervalWrappedFn<T extends object = object> = (symbol: string) => Promise<T | null>;
20183
20408
  /**
20184
20409
  * Utility class for wrapping signal functions with once-per-interval firing.
20185
20410
  * Provides two modes: in-memory (`fn`) and persistent file-based (`file`).
@@ -20190,8 +20415,8 @@ type TIntervalFileFn = (symbol: string, ...args: any[]) => Promise<ISignalInterv
20190
20415
  * import { Interval } from "./classes/Interval";
20191
20416
  *
20192
20417
  * const fireOncePerHour = Interval.fn(mySignalFn, { interval: "1h" });
20193
- * await fireOncePerHour("BTCUSDT", when); // fn called — returns its result
20194
- * await fireOncePerHour("BTCUSDT", when); // returns null (same interval)
20418
+ * await fireOncePerHour("BTCUSDT"); // fn called — returns its result
20419
+ * await fireOncePerHour("BTCUSDT"); // returns null (same interval)
20195
20420
  * ```
20196
20421
  */
20197
20422
  declare class IntervalUtils {
@@ -20216,19 +20441,19 @@ declare class IntervalUtils {
20216
20441
  *
20217
20442
  * @param run - Signal function to wrap
20218
20443
  * @param context.interval - Candle interval that controls the firing boundary
20219
- * @returns Wrapped function with the same signature as `TIntervalFn`, plus a `clear()` method
20444
+ * @returns Wrapped function with the same signature as `TIntervalFn<T>`, plus a `clear()` method
20220
20445
  *
20221
20446
  * @example
20222
20447
  * ```typescript
20223
20448
  * const fireOnce = Interval.fn(mySignalFn, { interval: "15m" });
20224
20449
  *
20225
- * await fireOnce("BTCUSDT", when); // → signal or null (fn called)
20226
- * await fireOnce("BTCUSDT", when); // → null (same interval, skipped)
20450
+ * await fireOnce("BTCUSDT"); // → T or null (fn called)
20451
+ * await fireOnce("BTCUSDT"); // → null (same interval, skipped)
20227
20452
  * ```
20228
20453
  */
20229
- fn: (run: TIntervalFn, context: {
20454
+ fn: <T extends object>(run: TIntervalFn<T>, context: {
20230
20455
  interval: CandleInterval;
20231
- }) => TIntervalFn & {
20456
+ }) => TIntervalWrappedFn<T> & {
20232
20457
  clear(): void;
20233
20458
  };
20234
20459
  /**
@@ -20250,15 +20475,15 @@ declare class IntervalUtils {
20250
20475
  *
20251
20476
  * @example
20252
20477
  * ```typescript
20253
- * const fetchSignal = async (symbol: string, period: number) => { ... };
20478
+ * const fetchSignal = async (symbol: string, when: Date) => { ... };
20254
20479
  * const fireOnce = Interval.file(fetchSignal, { interval: "1h", name: "fetchSignal" });
20255
20480
  * await fireOnce.clear(); // delete disk records so the function fires again next call
20256
20481
  * ```
20257
20482
  */
20258
- file: <T extends TIntervalFileFn>(run: T, context: {
20483
+ file: <T extends object>(run: TIntervalFn<T>, context: {
20259
20484
  interval: CandleInterval;
20260
20485
  name: string;
20261
- }) => T & {
20486
+ }) => TIntervalWrappedFn<T> & {
20262
20487
  clear(): Promise<void>;
20263
20488
  };
20264
20489
  /**
@@ -20276,7 +20501,7 @@ declare class IntervalUtils {
20276
20501
  * Interval.dispose(mySignalFn);
20277
20502
  * ```
20278
20503
  */
20279
- dispose: (run: TIntervalFn) => void;
20504
+ dispose: (run: TIntervalFn<object>) => void;
20280
20505
  /**
20281
20506
  * Clears all memoized `IntervalFnInstance` and `IntervalFileInstance` objects and
20282
20507
  * resets the `IntervalFileInstance` index counter.
@@ -25064,6 +25289,74 @@ declare class StrategyConnectionService implements TStrategy$1 {
25064
25289
  exchangeName: ExchangeName;
25065
25290
  frameName: FrameName;
25066
25291
  }) => Promise<number | null>;
25292
+ /**
25293
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
25294
+ *
25295
+ * Resolves current price via priceMetaService and delegates to
25296
+ * ClientStrategy.getPositionHighestProfitDistancePnlPercentage().
25297
+ * Returns null if no pending signal exists.
25298
+ *
25299
+ * @param backtest - Whether running in backtest mode
25300
+ * @param symbol - Trading pair symbol
25301
+ * @param context - Execution context with strategyName, exchangeName, frameName
25302
+ * @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
25303
+ */
25304
+ getPositionHighestProfitDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
25305
+ strategyName: StrategyName;
25306
+ exchangeName: ExchangeName;
25307
+ frameName: FrameName;
25308
+ }) => Promise<number | null>;
25309
+ /**
25310
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
25311
+ *
25312
+ * Resolves current price via priceMetaService and delegates to
25313
+ * ClientStrategy.getPositionHighestProfitDistancePnlCost().
25314
+ * Returns null if no pending signal exists.
25315
+ *
25316
+ * @param backtest - Whether running in backtest mode
25317
+ * @param symbol - Trading pair symbol
25318
+ * @param context - Execution context with strategyName, exchangeName, frameName
25319
+ * @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
25320
+ */
25321
+ getPositionHighestProfitDistancePnlCost: (backtest: boolean, symbol: string, context: {
25322
+ strategyName: StrategyName;
25323
+ exchangeName: ExchangeName;
25324
+ frameName: FrameName;
25325
+ }) => Promise<number | null>;
25326
+ /**
25327
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
25328
+ *
25329
+ * Resolves current price via priceMetaService and delegates to
25330
+ * ClientStrategy.getPositionHighestMaxDrawdownPnlPercentage().
25331
+ * Returns null if no pending signal exists.
25332
+ *
25333
+ * @param backtest - Whether running in backtest mode
25334
+ * @param symbol - Trading pair symbol
25335
+ * @param context - Execution context with strategyName, exchangeName, frameName
25336
+ * @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
25337
+ */
25338
+ getPositionHighestMaxDrawdownPnlPercentage: (backtest: boolean, symbol: string, context: {
25339
+ strategyName: StrategyName;
25340
+ exchangeName: ExchangeName;
25341
+ frameName: FrameName;
25342
+ }) => Promise<number | null>;
25343
+ /**
25344
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
25345
+ *
25346
+ * Resolves current price via priceMetaService and delegates to
25347
+ * ClientStrategy.getPositionHighestMaxDrawdownPnlCost().
25348
+ * Returns null if no pending signal exists.
25349
+ *
25350
+ * @param backtest - Whether running in backtest mode
25351
+ * @param symbol - Trading pair symbol
25352
+ * @param context - Execution context with strategyName, exchangeName, frameName
25353
+ * @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
25354
+ */
25355
+ getPositionHighestMaxDrawdownPnlCost: (backtest: boolean, symbol: string, context: {
25356
+ strategyName: StrategyName;
25357
+ exchangeName: ExchangeName;
25358
+ frameName: FrameName;
25359
+ }) => Promise<number | null>;
25067
25360
  /**
25068
25361
  * Disposes the ClientStrategy instance for the given context.
25069
25362
  *
@@ -27235,6 +27528,70 @@ declare class StrategyCoreService implements TStrategy {
27235
27528
  exchangeName: ExchangeName;
27236
27529
  frameName: FrameName;
27237
27530
  }) => Promise<number | null>;
27531
+ /**
27532
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
27533
+ *
27534
+ * Delegates to StrategyConnectionService.getPositionHighestProfitDistancePnlPercentage().
27535
+ * Returns null if no pending signal exists.
27536
+ *
27537
+ * @param backtest - Whether running in backtest mode
27538
+ * @param symbol - Trading pair symbol
27539
+ * @param context - Execution context with strategyName, exchangeName, frameName
27540
+ * @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
27541
+ */
27542
+ getPositionHighestProfitDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
27543
+ strategyName: StrategyName;
27544
+ exchangeName: ExchangeName;
27545
+ frameName: FrameName;
27546
+ }) => Promise<number | null>;
27547
+ /**
27548
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
27549
+ *
27550
+ * Delegates to StrategyConnectionService.getPositionHighestProfitDistancePnlCost().
27551
+ * Returns null if no pending signal exists.
27552
+ *
27553
+ * @param backtest - Whether running in backtest mode
27554
+ * @param symbol - Trading pair symbol
27555
+ * @param context - Execution context with strategyName, exchangeName, frameName
27556
+ * @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
27557
+ */
27558
+ getPositionHighestProfitDistancePnlCost: (backtest: boolean, symbol: string, context: {
27559
+ strategyName: StrategyName;
27560
+ exchangeName: ExchangeName;
27561
+ frameName: FrameName;
27562
+ }) => Promise<number | null>;
27563
+ /**
27564
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
27565
+ *
27566
+ * Delegates to StrategyConnectionService.getPositionHighestMaxDrawdownPnlPercentage().
27567
+ * Returns null if no pending signal exists.
27568
+ *
27569
+ * @param backtest - Whether running in backtest mode
27570
+ * @param symbol - Trading pair symbol
27571
+ * @param context - Execution context with strategyName, exchangeName, frameName
27572
+ * @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
27573
+ */
27574
+ getPositionHighestMaxDrawdownPnlPercentage: (backtest: boolean, symbol: string, context: {
27575
+ strategyName: StrategyName;
27576
+ exchangeName: ExchangeName;
27577
+ frameName: FrameName;
27578
+ }) => Promise<number | null>;
27579
+ /**
27580
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
27581
+ *
27582
+ * Delegates to StrategyConnectionService.getPositionHighestMaxDrawdownPnlCost().
27583
+ * Returns null if no pending signal exists.
27584
+ *
27585
+ * @param backtest - Whether running in backtest mode
27586
+ * @param symbol - Trading pair symbol
27587
+ * @param context - Execution context with strategyName, exchangeName, frameName
27588
+ * @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
27589
+ */
27590
+ getPositionHighestMaxDrawdownPnlCost: (backtest: boolean, symbol: string, context: {
27591
+ strategyName: StrategyName;
27592
+ exchangeName: ExchangeName;
27593
+ frameName: FrameName;
27594
+ }) => Promise<number | null>;
27238
27595
  }
27239
27596
 
27240
27597
  /**
@@ -30086,4 +30443,4 @@ declare const getTotalClosed: (signal: Signal) => {
30086
30443
  remainingCostBasis: number;
30087
30444
  };
30088
30445
 
30089
- export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, Dump, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IDumpContext, type IDumpInstance, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type IMemoryInstance, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Interval, type IntervalData, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MarkdownWriter, MaxDrawdown, type MaxDrawdownContract, type MaxDrawdownEvent, type MaxDrawdownStatisticsModel, type MeasureData, Memory, type MemoryData, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistIntervalAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, ReportWriter, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };
30446
+ export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, Dump, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IDumpContext, type IDumpInstance, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type IMemoryInstance, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalIntervalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Interval, type IntervalData, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MarkdownWriter, MaxDrawdown, type MaxDrawdownContract, type MaxDrawdownEvent, type MaxDrawdownStatisticsModel, type MeasureData, Memory, type MemoryData, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistIntervalAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, ReportWriter, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TDumpInstanceCtor, type TIntervalFn, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestMaxDrawdownPnlCost, getPositionHighestMaxDrawdownPnlPercentage, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitDistancePnlCost, getPositionHighestProfitDistancePnlPercentage, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };