backtest-kit 6.11.0 → 6.13.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.
Files changed (4) hide show
  1. package/build/index.cjs +2081 -183
  2. package/build/index.mjs +2073 -184
  3. package/package.json +2 -2
  4. package/types.d.ts +1136 -85
package/types.d.ts CHANGED
@@ -2144,6 +2144,16 @@ interface ActivateScheduledCommit extends SignalCommitBase {
2144
2144
  */
2145
2145
  type StrategyCommitContract = CancelScheduledCommit | ClosePendingCommit | PartialProfitCommit | PartialLossCommit | TrailingStopCommit | TrailingTakeCommit | BreakevenCommit | AverageBuyCommit | ActivateScheduledCommit;
2146
2146
 
2147
+ /**
2148
+ * Commit payload for strategy commits.
2149
+ * Used in activateScheduled, closePending, cancelScheduled
2150
+ */
2151
+ type CommitPayload = {
2152
+ /** Commit id */
2153
+ id: string;
2154
+ /** Note describing the commit */
2155
+ note: string;
2156
+ };
2147
2157
  /**
2148
2158
  * Signal generation interval for throttling.
2149
2159
  * Enforces minimum time between getSignal calls.
@@ -2445,6 +2455,8 @@ interface IRiskSignalRow extends IPublicSignalRow {
2445
2455
  interface IScheduledSignalCancelRow extends IScheduledSignalRow {
2446
2456
  /** Cancellation ID (only for user-initiated cancellations) */
2447
2457
  cancelId?: string;
2458
+ /** Note from user payload (only for user-initiated cancellations) */
2459
+ cancelNote?: string;
2448
2460
  }
2449
2461
  /**
2450
2462
  * Base interface for queued commit events.
@@ -3052,7 +3064,7 @@ interface IStrategy {
3052
3064
  * // Strategy continues, can generate new signals
3053
3065
  * ```
3054
3066
  */
3055
- cancelScheduled: (symbol: string, backtest: boolean, cancelId?: string) => Promise<void>;
3067
+ cancelScheduled: (symbol: string, backtest: boolean, payload: Partial<CommitPayload>) => Promise<void>;
3056
3068
  /**
3057
3069
  * Activates the scheduled signal without waiting for price to reach priceOpen.
3058
3070
  *
@@ -3074,7 +3086,7 @@ interface IStrategy {
3074
3086
  * // Scheduled signal becomes pending signal immediately
3075
3087
  * ```
3076
3088
  */
3077
- activateScheduled: (symbol: string, backtest: boolean, activateId?: string) => Promise<void>;
3089
+ activateScheduled: (symbol: string, backtest: boolean, payload: Partial<CommitPayload>) => Promise<void>;
3078
3090
  /**
3079
3091
  * Closes the pending signal without stopping the strategy.
3080
3092
  *
@@ -3096,7 +3108,7 @@ interface IStrategy {
3096
3108
  * // Strategy continues, can generate new signals
3097
3109
  * ```
3098
3110
  */
3099
- closePending: (symbol: string, backtest: boolean, closeId?: string) => Promise<void>;
3111
+ closePending: (symbol: string, backtest: boolean, payload: Partial<CommitPayload>) => Promise<void>;
3100
3112
  /**
3101
3113
  * Executes partial close at profit level (moving toward TP).
3102
3114
  *
@@ -3676,6 +3688,26 @@ interface IStrategy {
3676
3688
  * @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
3677
3689
  */
3678
3690
  getPositionHighestMaxDrawdownPnlCost: (symbol: string, currentPrice: number) => Promise<number | null>;
3691
+ /**
3692
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
3693
+ *
3694
+ * Computed as: max(0, peakPnlPercentage - fallPnlPercentage).
3695
+ *
3696
+ * @param symbol - Trading pair symbol
3697
+ * @param currentPrice - Current market price
3698
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
3699
+ */
3700
+ getMaxDrawdownDistancePnlPercentage: (symbol: string, currentPrice: number) => Promise<number | null>;
3701
+ /**
3702
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
3703
+ *
3704
+ * Computed as: max(0, peakPnlCost - fallPnlCost).
3705
+ *
3706
+ * @param symbol - Trading pair symbol
3707
+ * @param currentPrice - Current market price
3708
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
3709
+ */
3710
+ getMaxDrawdownDistancePnlCost: (symbol: string, currentPrice: number) => Promise<number | null>;
3679
3711
  /**
3680
3712
  * Disposes the strategy instance and cleans up resources.
3681
3713
  *
@@ -4727,7 +4759,7 @@ interface IPositionOverlapLadder {
4727
4759
  *
4728
4760
  * @param symbol - Trading pair symbol
4729
4761
  * @param strategyName - Strategy name
4730
- * @param cancelId - Optional cancellation ID for tracking user-initiated cancellations
4762
+ * @param payload - Optional commit payload with id and note
4731
4763
  * @returns Promise that resolves when scheduled signal is cancelled
4732
4764
  *
4733
4765
  * @example
@@ -4735,10 +4767,10 @@ interface IPositionOverlapLadder {
4735
4767
  * import { commitCancelScheduled } from "backtest-kit";
4736
4768
  *
4737
4769
  * // Cancel scheduled signal with custom ID
4738
- * await commitCancelScheduled("BTCUSDT", "manual-cancel-001");
4770
+ * await commitCancelScheduled("BTCUSDT", { id: "manual-cancel-001" });
4739
4771
  * ```
4740
4772
  */
4741
- declare function commitCancelScheduled(symbol: string, cancelId?: string): Promise<void>;
4773
+ declare function commitCancelScheduled(symbol: string, payload?: Partial<CommitPayload>): Promise<void>;
4742
4774
  /**
4743
4775
  * Closes the pending signal without stopping the strategy.
4744
4776
  *
@@ -4749,7 +4781,7 @@ declare function commitCancelScheduled(symbol: string, cancelId?: string): Promi
4749
4781
  * Automatically detects backtest/live mode from execution context.
4750
4782
  *
4751
4783
  * @param symbol - Trading pair symbol
4752
- * @param closeId - Optional close ID for tracking user-initiated closes
4784
+ * @param payload - Optional commit payload with id and note
4753
4785
  * @returns Promise that resolves when pending signal is closed
4754
4786
  *
4755
4787
  * @example
@@ -4757,10 +4789,10 @@ declare function commitCancelScheduled(symbol: string, cancelId?: string): Promi
4757
4789
  * import { commitClosePending } from "backtest-kit";
4758
4790
  *
4759
4791
  * // Close pending signal with custom ID
4760
- * await commitClosePending("BTCUSDT", "manual-close-001");
4792
+ * await commitClosePending("BTCUSDT", { id: "manual-close-001" });
4761
4793
  * ```
4762
4794
  */
4763
- declare function commitClosePending(symbol: string, closeId?: string): Promise<void>;
4795
+ declare function commitClosePending(symbol: string, payload?: Partial<CommitPayload>): Promise<void>;
4764
4796
  /**
4765
4797
  * Executes partial close at profit level (moving toward TP).
4766
4798
  *
@@ -4968,7 +5000,7 @@ declare function commitBreakeven(symbol: string): Promise<boolean>;
4968
5000
  * Automatically detects backtest/live mode from execution context.
4969
5001
  *
4970
5002
  * @param symbol - Trading pair symbol
4971
- * @param activateId - Optional activation ID for tracking user-initiated activations
5003
+ * @param payload - Optional commit payload with id and note
4972
5004
  * @returns Promise that resolves when activation flag is set
4973
5005
  *
4974
5006
  * @example
@@ -4976,10 +5008,10 @@ declare function commitBreakeven(symbol: string): Promise<boolean>;
4976
5008
  * import { commitActivateScheduled } from "backtest-kit";
4977
5009
  *
4978
5010
  * // Activate scheduled signal early with custom ID
4979
- * await commitActivateScheduled("BTCUSDT", "manual-activate-001");
5011
+ * await commitActivateScheduled("BTCUSDT", { id: "manual-activate-001" });
4980
5012
  * ```
4981
5013
  */
4982
- declare function commitActivateScheduled(symbol: string, activateId?: string): Promise<void>;
5014
+ declare function commitActivateScheduled(symbol: string, payload?: Partial<CommitPayload>): Promise<void>;
4983
5015
  /**
4984
5016
  * Adds a new DCA entry to the active pending signal.
4985
5017
  *
@@ -5708,6 +5740,42 @@ declare function getPositionHighestMaxDrawdownPnlPercentage(symbol: string): Pro
5708
5740
  * ```
5709
5741
  */
5710
5742
  declare function getPositionHighestMaxDrawdownPnlCost(symbol: string): Promise<number>;
5743
+ /**
5744
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
5745
+ *
5746
+ * Computed as: max(0, peakPnlPercentage - fallPnlPercentage).
5747
+ * Returns null if no pending signal exists.
5748
+ *
5749
+ * @param symbol - Trading pair symbol
5750
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
5751
+ *
5752
+ * @example
5753
+ * ```typescript
5754
+ * import { getMaxDrawdownDistancePnlPercentage } from "backtest-kit";
5755
+ *
5756
+ * const dist = await getMaxDrawdownDistancePnlPercentage("BTCUSDT");
5757
+ * // e.g. 3.5 (peak was +3.5% above trough)
5758
+ * ```
5759
+ */
5760
+ declare function getMaxDrawdownDistancePnlPercentage(symbol: string): Promise<number>;
5761
+ /**
5762
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
5763
+ *
5764
+ * Computed as: max(0, peakPnlCost - fallPnlCost).
5765
+ * Returns null if no pending signal exists.
5766
+ *
5767
+ * @param symbol - Trading pair symbol
5768
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
5769
+ *
5770
+ * @example
5771
+ * ```typescript
5772
+ * import { getMaxDrawdownDistancePnlCost } from "backtest-kit";
5773
+ *
5774
+ * const dist = await getMaxDrawdownDistancePnlCost("BTCUSDT");
5775
+ * // e.g. 7.2 (peak was $7.2 above trough)
5776
+ * ```
5777
+ */
5778
+ declare function getMaxDrawdownDistancePnlCost(symbol: string): Promise<number>;
5711
5779
  /**
5712
5780
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
5713
5781
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -8823,6 +8891,34 @@ declare function getNextCandles(symbol: string, interval: CandleInterval, limit:
8823
8891
  */
8824
8892
  declare function getAggregatedTrades(symbol: string, limit?: number): Promise<IAggregatedTradeData[]>;
8825
8893
 
8894
+ /**
8895
+ * Returns the latest signal (pending or closed) for the current strategy context.
8896
+ *
8897
+ * Does not distinguish between active and closed signals — returns whichever
8898
+ * was recorded last. Useful for cooldown logic: e.g. skip opening a new position
8899
+ * for 4 hours after a stop-loss by checking the timestamp of the latest signal
8900
+ * regardless of its outcome.
8901
+ *
8902
+ * Searches backtest storage first, then live storage.
8903
+ * Returns null if no signal exists at all.
8904
+ *
8905
+ * Automatically detects backtest/live mode from execution context.
8906
+ *
8907
+ * @param symbol - Trading pair symbol
8908
+ * @returns Promise resolving to the latest signal or null
8909
+ *
8910
+ * @example
8911
+ * ```typescript
8912
+ * import { getLatestSignal } from "backtest-kit";
8913
+ *
8914
+ * const latest = await getLatestSignal("BTCUSDT");
8915
+ * if (latest && Date.now() - latest.closedAt < 4 * 60 * 60 * 1000) {
8916
+ * return; // cooldown after SL — skip new signal for 4 hours
8917
+ * }
8918
+ * ```
8919
+ */
8920
+ declare function getLatestSignal(symbol: string): Promise<IPublicSignalRow | null>;
8921
+
8826
8922
  /**
8827
8923
  * Writes a value to memory scoped to the current signal.
8828
8924
  *
@@ -11176,6 +11272,8 @@ interface StrategyEvent {
11176
11272
  pnl?: IStrategyPnL;
11177
11273
  /** Cost of this entry in USD (average-buy action only) */
11178
11274
  cost?: number;
11275
+ /** Optional note from commit payload */
11276
+ note?: string;
11179
11277
  }
11180
11278
  /**
11181
11279
  * Statistical data calculated from strategy events.
@@ -12449,6 +12547,80 @@ declare class PersistMemoryUtils {
12449
12547
  * ```
12450
12548
  */
12451
12549
  declare const PersistMemoryAdapter: PersistMemoryUtils;
12550
+ /**
12551
+ * Type for persisted recent signal data.
12552
+ * Stores the latest active signal per context key.
12553
+ */
12554
+ type RecentData = IPublicSignalRow | null;
12555
+ /**
12556
+ * Utility class for managing recent signal persistence.
12557
+ *
12558
+ * Features:
12559
+ * - Memoized storage instances per (symbol, strategyName, exchangeName, frameName) context
12560
+ * - Custom adapter support
12561
+ * - Atomic read/write operations
12562
+ * - Crash-safe recent signal state management
12563
+ *
12564
+ * Used by RecentPersistBacktestUtils/RecentPersistLiveUtils for recent signal persistence.
12565
+ */
12566
+ declare class PersistRecentUtils {
12567
+ private PersistRecentFactory;
12568
+ private getStorage;
12569
+ private createKeyParts;
12570
+ /**
12571
+ * Registers a custom persistence adapter.
12572
+ *
12573
+ * @param Ctor - Custom PersistBase constructor
12574
+ */
12575
+ usePersistRecentAdapter(Ctor: TPersistBaseCtor<string, IPublicSignalRow>): void;
12576
+ /**
12577
+ * Reads the latest persisted recent signal for a given context.
12578
+ *
12579
+ * Returns null if no recent signal exists.
12580
+ *
12581
+ * @param symbol - Trading pair symbol
12582
+ * @param strategyName - Strategy identifier
12583
+ * @param exchangeName - Exchange identifier
12584
+ * @param frameName - Frame identifier
12585
+ * @returns Promise resolving to recent signal or null
12586
+ */
12587
+ readRecentData: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<IPublicSignalRow | null>;
12588
+ /**
12589
+ * Writes the latest recent signal to disk with atomic file writes.
12590
+ *
12591
+ * Uses symbol as the entity ID within the per-context storage instance.
12592
+ * Uses atomic writes to prevent corruption on crashes.
12593
+ *
12594
+ * @param signalRow - Recent signal data to persist
12595
+ * @param symbol - Trading pair symbol
12596
+ * @param strategyName - Strategy identifier
12597
+ * @param exchangeName - Exchange identifier
12598
+ * @param frameName - Frame identifier
12599
+ * @returns Promise that resolves when write is complete
12600
+ */
12601
+ writeRecentData: (signalRow: IPublicSignalRow, symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<void>;
12602
+ /**
12603
+ * Clears the memoized storage cache.
12604
+ * Call this when process.cwd() changes between strategy iterations
12605
+ * so new storage instances are created with the updated base path.
12606
+ */
12607
+ clear(): void;
12608
+ /**
12609
+ * Switches to the default JSON persist adapter.
12610
+ * All future persistence writes will use JSON storage.
12611
+ */
12612
+ useJson(): void;
12613
+ /**
12614
+ * Switches to a dummy persist adapter that discards all writes.
12615
+ * All future persistence writes will be no-ops.
12616
+ */
12617
+ useDummy(): void;
12618
+ }
12619
+ /**
12620
+ * Global singleton instance of PersistRecentUtils.
12621
+ * Used by RecentPersistBacktestUtils/RecentPersistLiveUtils for recent signal persistence.
12622
+ */
12623
+ declare const PersistRecentAdapter: PersistRecentUtils;
12452
12624
 
12453
12625
  /**
12454
12626
  * Configuration interface for selective markdown service enablement.
@@ -13268,6 +13440,23 @@ declare class LogAdapter implements ILog {
13268
13440
  */
13269
13441
  declare const Log: LogAdapter;
13270
13442
 
13443
+ /** Callable that restores a previously saved subject snapshot */
13444
+ type RestoreSnapshot = () => void;
13445
+ /**
13446
+ * Manages isolation of global event-bus state between backtest sessions.
13447
+ * Allows temporarily detaching all subject subscriptions so that one session
13448
+ * does not interfere with another, then restoring them afterwards.
13449
+ */
13450
+ declare class SessionUtils {
13451
+ /**
13452
+ * Snapshots the current listener state of every global subject by replacing
13453
+ * their internal `_events` map with an empty object.
13454
+ * @returns A restore function that, when called, puts all original listeners back.
13455
+ */
13456
+ createSnapshot: () => RestoreSnapshot;
13457
+ }
13458
+ declare const Session: SessionUtils;
13459
+
13271
13460
  /**
13272
13461
  * Type alias for column configuration used in backtest markdown reports.
13273
13462
  *
@@ -14109,6 +14298,36 @@ declare class BacktestUtils {
14109
14298
  exchangeName: ExchangeName;
14110
14299
  frameName: FrameName;
14111
14300
  }) => Promise<number>;
14301
+ /**
14302
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
14303
+ *
14304
+ * Computed as: max(0, peakPnlPercentage - fallPnlPercentage).
14305
+ * Returns null if no pending signal exists.
14306
+ *
14307
+ * @param symbol - Trading pair symbol
14308
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14309
+ * @returns peak-to-trough PnL percentage distance (≥ 0) or null if no active position
14310
+ */
14311
+ getMaxDrawdownDistancePnlPercentage: (symbol: string, context: {
14312
+ strategyName: StrategyName;
14313
+ exchangeName: ExchangeName;
14314
+ frameName: FrameName;
14315
+ }) => Promise<number>;
14316
+ /**
14317
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
14318
+ *
14319
+ * Computed as: max(0, peakPnlCost - fallPnlCost).
14320
+ * Returns null if no pending signal exists.
14321
+ *
14322
+ * @param symbol - Trading pair symbol
14323
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14324
+ * @returns peak-to-trough PnL cost distance (≥ 0) or null if no active position
14325
+ */
14326
+ getMaxDrawdownDistancePnlCost: (symbol: string, context: {
14327
+ strategyName: StrategyName;
14328
+ exchangeName: ExchangeName;
14329
+ frameName: FrameName;
14330
+ }) => Promise<number>;
14112
14331
  /**
14113
14332
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
14114
14333
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -14184,7 +14403,7 @@ declare class BacktestUtils {
14184
14403
  * @param symbol - Trading pair symbol
14185
14404
  * @param strategyName - Strategy name
14186
14405
  * @param context - Execution context with exchangeName and frameName
14187
- * @param cancelId - Optional cancellation ID for tracking user-initiated cancellations
14406
+ * @param payload - Optional commit payload with id and note
14188
14407
  * @returns Promise that resolves when scheduled signal is cancelled
14189
14408
  *
14190
14409
  * @example
@@ -14194,14 +14413,14 @@ declare class BacktestUtils {
14194
14413
  * exchangeName: "binance",
14195
14414
  * frameName: "frame1",
14196
14415
  * strategyName: "my-strategy"
14197
- * }, "manual-cancel-001");
14416
+ * }, { id: "manual-cancel-001" });
14198
14417
  * ```
14199
14418
  */
14200
14419
  commitCancelScheduled: (symbol: string, context: {
14201
14420
  strategyName: StrategyName;
14202
14421
  exchangeName: ExchangeName;
14203
14422
  frameName: FrameName;
14204
- }, cancelId?: string) => Promise<void>;
14423
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
14205
14424
  /**
14206
14425
  * Closes the pending signal without stopping the strategy.
14207
14426
  *
@@ -14211,7 +14430,7 @@ declare class BacktestUtils {
14211
14430
  *
14212
14431
  * @param symbol - Trading pair symbol
14213
14432
  * @param context - Execution context with strategyName, exchangeName, and frameName
14214
- * @param closeId - Optional close ID for user-initiated closes
14433
+ * @param payload - Optional commit payload with id and note
14215
14434
  * @returns Promise that resolves when pending signal is closed
14216
14435
  *
14217
14436
  * @example
@@ -14221,14 +14440,14 @@ declare class BacktestUtils {
14221
14440
  * exchangeName: "binance",
14222
14441
  * strategyName: "my-strategy",
14223
14442
  * frameName: "1m"
14224
- * }, "manual-close-001");
14443
+ * }, { id: "manual-close-001" });
14225
14444
  * ```
14226
14445
  */
14227
14446
  commitClosePending: (symbol: string, context: {
14228
14447
  strategyName: StrategyName;
14229
14448
  exchangeName: ExchangeName;
14230
14449
  frameName: FrameName;
14231
- }, closeId?: string) => Promise<void>;
14450
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
14232
14451
  /**
14233
14452
  * Executes partial close at profit level (moving toward TP).
14234
14453
  *
@@ -14533,7 +14752,7 @@ declare class BacktestUtils {
14533
14752
  *
14534
14753
  * @param symbol - Trading pair symbol
14535
14754
  * @param context - Execution context with strategyName, exchangeName, and frameName
14536
- * @param activateId - Optional activation ID for tracking user-initiated activations
14755
+ * @param payload - Optional commit payload with id and note
14537
14756
  * @returns Promise that resolves when activation flag is set
14538
14757
  *
14539
14758
  * @example
@@ -14543,14 +14762,14 @@ declare class BacktestUtils {
14543
14762
  * strategyName: "my-strategy",
14544
14763
  * exchangeName: "binance",
14545
14764
  * frameName: "1h"
14546
- * }, "manual-activate-001");
14765
+ * }, { id: "manual-activate-001" });
14547
14766
  * ```
14548
14767
  */
14549
14768
  commitActivateScheduled: (symbol: string, context: {
14550
14769
  strategyName: StrategyName;
14551
14770
  exchangeName: ExchangeName;
14552
14771
  frameName: FrameName;
14553
- }, activateId?: string) => Promise<void>;
14772
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
14554
14773
  /**
14555
14774
  * Adds a new DCA entry to the active pending signal.
14556
14775
  *
@@ -15523,6 +15742,34 @@ declare class LiveUtils {
15523
15742
  strategyName: StrategyName;
15524
15743
  exchangeName: ExchangeName;
15525
15744
  }) => Promise<number>;
15745
+ /**
15746
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
15747
+ *
15748
+ * Computed as: max(0, peakPnlPercentage - fallPnlPercentage).
15749
+ * Returns null if no pending signal exists.
15750
+ *
15751
+ * @param symbol - Trading pair symbol
15752
+ * @param context - Execution context with strategyName and exchangeName
15753
+ * @returns peak-to-trough PnL percentage distance (≥ 0) or null if no active position
15754
+ */
15755
+ getMaxDrawdownDistancePnlPercentage: (symbol: string, context: {
15756
+ strategyName: StrategyName;
15757
+ exchangeName: ExchangeName;
15758
+ }) => Promise<number>;
15759
+ /**
15760
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
15761
+ *
15762
+ * Computed as: max(0, peakPnlCost - fallPnlCost).
15763
+ * Returns null if no pending signal exists.
15764
+ *
15765
+ * @param symbol - Trading pair symbol
15766
+ * @param context - Execution context with strategyName and exchangeName
15767
+ * @returns peak-to-trough PnL cost distance (≥ 0) or null if no active position
15768
+ */
15769
+ getMaxDrawdownDistancePnlCost: (symbol: string, context: {
15770
+ strategyName: StrategyName;
15771
+ exchangeName: ExchangeName;
15772
+ }) => Promise<number>;
15526
15773
  /**
15527
15774
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
15528
15775
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -15590,7 +15837,7 @@ declare class LiveUtils {
15590
15837
  * @param symbol - Trading pair symbol
15591
15838
  * @param strategyName - Strategy name
15592
15839
  * @param context - Execution context with exchangeName and frameName
15593
- * @param cancelId - Optional cancellation ID for tracking user-initiated cancellations
15840
+ * @param payload - Optional commit payload with id and note
15594
15841
  * @returns Promise that resolves when scheduled signal is cancelled
15595
15842
  *
15596
15843
  * @example
@@ -15600,13 +15847,13 @@ declare class LiveUtils {
15600
15847
  * exchangeName: "binance",
15601
15848
  * frameName: "",
15602
15849
  * strategyName: "my-strategy"
15603
- * }, "manual-cancel-001");
15850
+ * }, { id: "manual-cancel-001" });
15604
15851
  * ```
15605
15852
  */
15606
15853
  commitCancelScheduled: (symbol: string, context: {
15607
15854
  strategyName: StrategyName;
15608
15855
  exchangeName: ExchangeName;
15609
- }, cancelId?: string) => Promise<void>;
15856
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
15610
15857
  /**
15611
15858
  * Closes the pending signal without stopping the strategy.
15612
15859
  *
@@ -15616,7 +15863,7 @@ declare class LiveUtils {
15616
15863
  *
15617
15864
  * @param symbol - Trading pair symbol
15618
15865
  * @param context - Execution context with strategyName and exchangeName
15619
- * @param closeId - Optional close ID for user-initiated closes
15866
+ * @param payload - Optional commit payload with id and note
15620
15867
  * @returns Promise that resolves when pending signal is closed
15621
15868
  *
15622
15869
  * @example
@@ -15625,13 +15872,13 @@ declare class LiveUtils {
15625
15872
  * await Live.commitClose("BTCUSDT", {
15626
15873
  * exchangeName: "binance",
15627
15874
  * strategyName: "my-strategy"
15628
- * }, "manual-close-001");
15875
+ * }, { id: "manual-close-001" });
15629
15876
  * ```
15630
15877
  */
15631
15878
  commitClosePending: (symbol: string, context: {
15632
15879
  strategyName: StrategyName;
15633
15880
  exchangeName: ExchangeName;
15634
- }, closeId?: string) => Promise<void>;
15881
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
15635
15882
  /**
15636
15883
  * Executes partial close at profit level (moving toward TP).
15637
15884
  *
@@ -15921,7 +16168,7 @@ declare class LiveUtils {
15921
16168
  *
15922
16169
  * @param symbol - Trading pair symbol
15923
16170
  * @param context - Execution context with strategyName and exchangeName
15924
- * @param activateId - Optional activation ID for tracking user-initiated activations
16171
+ * @param payload - Optional commit payload with id and note
15925
16172
  * @returns Promise that resolves when activation flag is set
15926
16173
  *
15927
16174
  * @example
@@ -15930,13 +16177,13 @@ declare class LiveUtils {
15930
16177
  * await Live.commitActivateScheduled("BTCUSDT", {
15931
16178
  * strategyName: "my-strategy",
15932
16179
  * exchangeName: "binance"
15933
- * }, "manual-activate-001");
16180
+ * }, { id: "manual-activate-001" });
15934
16181
  * ```
15935
16182
  */
15936
16183
  commitActivateScheduled: (symbol: string, context: {
15937
16184
  strategyName: StrategyName;
15938
16185
  exchangeName: ExchangeName;
15939
- }, activateId?: string) => Promise<void>;
16186
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
15940
16187
  /**
15941
16188
  * Adds a new DCA entry to the active pending signal.
15942
16189
  *
@@ -18291,50 +18538,603 @@ declare class MaxDrawdownUtils {
18291
18538
  declare const MaxDrawdown: MaxDrawdownUtils;
18292
18539
 
18293
18540
  /**
18294
- * Utility class containing predefined trading constants for take-profit and stop-loss levels.
18541
+ * Utility class for real-time position reflection: PNL, peak profit, and drawdown queries.
18295
18542
  *
18296
- * Based on Kelly Criterion with exponential risk decay.
18297
- * Values represent percentage of distance traveled towards final TP/SL target.
18543
+ * Provides unified access to strategyCoreService position state methods with logging
18544
+ * and full validation (strategy, exchange, frame, risk, actions).
18545
+ * Works for both live and backtest modes via the `backtest` parameter.
18546
+ * Exported as singleton instance for convenient usage.
18298
18547
  *
18299
- * Example: If final TP is at +10% profit:
18300
- * - TP_LEVEL1 (30) triggers when price reaches 30% of distance = +3% profit
18301
- * - TP_LEVEL2 (60) triggers when price reaches 60% of distance = +6% profit
18302
- * - TP_LEVEL3 (90) triggers when price reaches 90% of distance = +9% profit
18548
+ * @example
18549
+ * ```typescript
18550
+ * import { Reflect } from "backtest-kit";
18551
+ *
18552
+ * // Get current unrealized PNL percentage
18553
+ * const pnl = await Reflect.getPositionPnlPercent(
18554
+ * "BTCUSDT",
18555
+ * 45000,
18556
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18557
+ * );
18558
+ * console.log(`PNL: ${pnl}%`);
18559
+ *
18560
+ * // Get peak profit reached
18561
+ * const peakPnl = await Reflect.getPositionHighestPnlPercentage(
18562
+ * "BTCUSDT",
18563
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18564
+ * );
18565
+ * console.log(`Peak PNL: ${peakPnl}%`);
18566
+ * ```
18303
18567
  */
18304
- declare class ConstantUtils {
18305
- /**
18306
- * Take Profit Level 1 (Kelly-optimized early partial).
18307
- * Triggers at 30% of distance to final TP target.
18308
- * Lock in profit early, let rest run.
18309
- */
18310
- readonly TP_LEVEL1 = 30;
18568
+ declare class ReflectUtils {
18311
18569
  /**
18312
- * Take Profit Level 2 (Kelly-optimized mid partial).
18313
- * Triggers at 60% of distance to final TP target.
18314
- * Secure majority of position while trend continues.
18570
+ * Returns the unrealized PNL percentage for the current pending signal at currentPrice.
18571
+ *
18572
+ * Accounts for partial closes, DCA entries, slippage and fees.
18573
+ * Returns null if no pending signal exists.
18574
+ *
18575
+ * @param symbol - Trading pair symbol
18576
+ * @param currentPrice - Current market price
18577
+ * @param context - Execution context with strategyName, exchangeName and frameName
18578
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18579
+ * @returns Promise resolving to PNL percentage or null
18580
+ *
18581
+ * @example
18582
+ * ```typescript
18583
+ * const pnl = await Reflect.getPositionPnlPercent(
18584
+ * "BTCUSDT",
18585
+ * 45000,
18586
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18587
+ * );
18588
+ * console.log(`PNL: ${pnl}%`);
18589
+ * ```
18315
18590
  */
18316
- readonly TP_LEVEL2 = 60;
18591
+ getPositionPnlPercent: (symbol: string, currentPrice: number, context: {
18592
+ strategyName: StrategyName;
18593
+ exchangeName: ExchangeName;
18594
+ frameName: FrameName;
18595
+ }, backtest?: boolean) => Promise<number | null>;
18317
18596
  /**
18318
- * Take Profit Level 3 (Kelly-optimized final partial).
18319
- * Triggers at 90% of distance to final TP target.
18320
- * Near-complete exit, minimal exposure remains.
18597
+ * Returns the unrealized PNL in dollars for the current pending signal at currentPrice.
18598
+ *
18599
+ * Calculated as: pnlPercentage / 100 × totalInvestedCost.
18600
+ * Accounts for partial closes, DCA entries, slippage and fees.
18601
+ * Returns null if no pending signal exists.
18602
+ *
18603
+ * @param symbol - Trading pair symbol
18604
+ * @param currentPrice - Current market price
18605
+ * @param context - Execution context with strategyName, exchangeName and frameName
18606
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18607
+ * @returns Promise resolving to PNL in dollars or null
18608
+ *
18609
+ * @example
18610
+ * ```typescript
18611
+ * const pnlCost = await Reflect.getPositionPnlCost(
18612
+ * "BTCUSDT",
18613
+ * 45000,
18614
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18615
+ * );
18616
+ * console.log(`PNL: $${pnlCost}`);
18617
+ * ```
18321
18618
  */
18322
- readonly TP_LEVEL3 = 90;
18619
+ getPositionPnlCost: (symbol: string, currentPrice: number, context: {
18620
+ strategyName: StrategyName;
18621
+ exchangeName: ExchangeName;
18622
+ frameName: FrameName;
18623
+ }, backtest?: boolean) => Promise<number | null>;
18323
18624
  /**
18324
- * Stop Loss Level 1 (Kelly-optimized early warning).
18325
- * Triggers at 40% of distance to final SL target.
18326
- * Reduce exposure when setup weakens.
18625
+ * Returns the best price reached in the profit direction during this position's life.
18626
+ *
18627
+ * Returns null if no pending signal exists.
18628
+ *
18629
+ * @param symbol - Trading pair symbol
18630
+ * @param context - Execution context with strategyName, exchangeName and frameName
18631
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18632
+ * @returns Promise resolving to price or null
18633
+ *
18634
+ * @example
18635
+ * ```typescript
18636
+ * const peakPrice = await Reflect.getPositionHighestProfitPrice(
18637
+ * "BTCUSDT",
18638
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18639
+ * );
18640
+ * console.log(`Peak price: ${peakPrice}`);
18641
+ * ```
18327
18642
  */
18328
- readonly SL_LEVEL1 = 40;
18643
+ getPositionHighestProfitPrice: (symbol: string, context: {
18644
+ strategyName: StrategyName;
18645
+ exchangeName: ExchangeName;
18646
+ frameName: FrameName;
18647
+ }, backtest?: boolean) => Promise<number | null>;
18329
18648
  /**
18330
- * Stop Loss Level 2 (Kelly-optimized final exit).
18331
- * Triggers at 80% of distance to final SL target.
18332
- * Exit remaining position before catastrophic loss.
18333
- */
18334
- readonly SL_LEVEL2 = 80;
18335
- }
18336
- /**
18337
- * Global singleton instance of ConstantUtils.
18649
+ * Returns the timestamp when the best profit price was recorded during this position's life.
18650
+ *
18651
+ * Returns null if no pending signal exists.
18652
+ *
18653
+ * @param symbol - Trading pair symbol
18654
+ * @param context - Execution context with strategyName, exchangeName and frameName
18655
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18656
+ * @returns Promise resolving to timestamp in milliseconds or null
18657
+ *
18658
+ * @example
18659
+ * ```typescript
18660
+ * const ts = await Reflect.getPositionHighestProfitTimestamp(
18661
+ * "BTCUSDT",
18662
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18663
+ * );
18664
+ * console.log(`Peak at: ${new Date(ts).toISOString()}`);
18665
+ * ```
18666
+ */
18667
+ getPositionHighestProfitTimestamp: (symbol: string, context: {
18668
+ strategyName: StrategyName;
18669
+ exchangeName: ExchangeName;
18670
+ frameName: FrameName;
18671
+ }, backtest?: boolean) => Promise<number | null>;
18672
+ /**
18673
+ * Returns the PnL percentage at the moment the best profit price was recorded during this position's life.
18674
+ *
18675
+ * Returns null if no pending signal exists.
18676
+ *
18677
+ * @param symbol - Trading pair symbol
18678
+ * @param context - Execution context with strategyName, exchangeName and frameName
18679
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18680
+ * @returns Promise resolving to PnL percentage or null
18681
+ *
18682
+ * @example
18683
+ * ```typescript
18684
+ * const peakPnl = await Reflect.getPositionHighestPnlPercentage(
18685
+ * "BTCUSDT",
18686
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18687
+ * );
18688
+ * console.log(`Peak PNL: ${peakPnl}%`);
18689
+ * ```
18690
+ */
18691
+ getPositionHighestPnlPercentage: (symbol: string, context: {
18692
+ strategyName: StrategyName;
18693
+ exchangeName: ExchangeName;
18694
+ frameName: FrameName;
18695
+ }, backtest?: boolean) => Promise<number | null>;
18696
+ /**
18697
+ * Returns the PnL cost (in quote currency) at the moment the best profit price was recorded during this position's life.
18698
+ *
18699
+ * Returns null if no pending signal exists.
18700
+ *
18701
+ * @param symbol - Trading pair symbol
18702
+ * @param context - Execution context with strategyName, exchangeName and frameName
18703
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18704
+ * @returns Promise resolving to PnL cost in quote currency or null
18705
+ *
18706
+ * @example
18707
+ * ```typescript
18708
+ * const peakCost = await Reflect.getPositionHighestPnlCost(
18709
+ * "BTCUSDT",
18710
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18711
+ * );
18712
+ * console.log(`Peak PNL: $${peakCost}`);
18713
+ * ```
18714
+ */
18715
+ getPositionHighestPnlCost: (symbol: string, context: {
18716
+ strategyName: StrategyName;
18717
+ exchangeName: ExchangeName;
18718
+ frameName: FrameName;
18719
+ }, backtest?: boolean) => Promise<number | null>;
18720
+ /**
18721
+ * Returns whether breakeven was mathematically reachable at the highest profit price.
18722
+ *
18723
+ * Returns null if no pending signal exists.
18724
+ *
18725
+ * @param symbol - Trading pair symbol
18726
+ * @param context - Execution context with strategyName, exchangeName and frameName
18727
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18728
+ * @returns Promise resolving to true if breakeven was reachable at peak, false otherwise, or null
18729
+ *
18730
+ * @example
18731
+ * ```typescript
18732
+ * const wasReachable = await Reflect.getPositionHighestProfitBreakeven(
18733
+ * "BTCUSDT",
18734
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18735
+ * );
18736
+ * console.log(`Breakeven reachable at peak: ${wasReachable}`);
18737
+ * ```
18738
+ */
18739
+ getPositionHighestProfitBreakeven: (symbol: string, context: {
18740
+ strategyName: StrategyName;
18741
+ exchangeName: ExchangeName;
18742
+ frameName: FrameName;
18743
+ }, backtest?: boolean) => Promise<boolean | null>;
18744
+ /**
18745
+ * Returns the number of minutes elapsed since the highest profit price was recorded.
18746
+ *
18747
+ * Returns null if no pending signal exists.
18748
+ *
18749
+ * @param symbol - Trading pair symbol
18750
+ * @param context - Execution context with strategyName, exchangeName and frameName
18751
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18752
+ * @returns Promise resolving to minutes since highest profit price was recorded, or null
18753
+ *
18754
+ * @example
18755
+ * ```typescript
18756
+ * const minutes = await Reflect.getPositionDrawdownMinutes(
18757
+ * "BTCUSDT",
18758
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18759
+ * );
18760
+ * console.log(`Pulling back from peak for ${minutes} minutes`);
18761
+ * ```
18762
+ */
18763
+ getPositionDrawdownMinutes: (symbol: string, context: {
18764
+ strategyName: StrategyName;
18765
+ exchangeName: ExchangeName;
18766
+ frameName: FrameName;
18767
+ }, backtest?: boolean) => Promise<number | null>;
18768
+ /**
18769
+ * Returns the number of minutes elapsed since the highest profit price was recorded.
18770
+ *
18771
+ * Alias for getPositionDrawdownMinutes — measures how long the position has been
18772
+ * pulling back from its peak profit level.
18773
+ * Returns null if no pending signal exists.
18774
+ *
18775
+ * @param symbol - Trading pair symbol
18776
+ * @param context - Execution context with strategyName, exchangeName and frameName
18777
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18778
+ * @returns Promise resolving to minutes since last profit peak or null
18779
+ *
18780
+ * @example
18781
+ * ```typescript
18782
+ * const minutes = await Reflect.getPositionHighestProfitMinutes(
18783
+ * "BTCUSDT",
18784
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18785
+ * );
18786
+ * console.log(`Pulling back from peak for ${minutes} minutes`);
18787
+ * ```
18788
+ */
18789
+ getPositionHighestProfitMinutes: (symbol: string, context: {
18790
+ strategyName: StrategyName;
18791
+ exchangeName: ExchangeName;
18792
+ frameName: FrameName;
18793
+ }, backtest?: boolean) => Promise<number | null>;
18794
+ /**
18795
+ * Returns the number of minutes elapsed since the worst loss price was recorded.
18796
+ *
18797
+ * Measures how long ago the deepest drawdown point occurred.
18798
+ * Zero when called at the exact moment the trough was set.
18799
+ * Returns null if no pending signal exists.
18800
+ *
18801
+ * @param symbol - Trading pair symbol
18802
+ * @param context - Execution context with strategyName, exchangeName and frameName
18803
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18804
+ * @returns Promise resolving to minutes since last drawdown trough or null
18805
+ *
18806
+ * @example
18807
+ * ```typescript
18808
+ * const minutes = await Reflect.getPositionMaxDrawdownMinutes(
18809
+ * "BTCUSDT",
18810
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18811
+ * );
18812
+ * console.log(`Drawdown trough was ${minutes} minutes ago`);
18813
+ * ```
18814
+ */
18815
+ getPositionMaxDrawdownMinutes: (symbol: string, context: {
18816
+ strategyName: StrategyName;
18817
+ exchangeName: ExchangeName;
18818
+ frameName: FrameName;
18819
+ }, backtest?: boolean) => Promise<number | null>;
18820
+ /**
18821
+ * Returns the worst price reached in the loss direction during this position's life.
18822
+ *
18823
+ * Returns null if no pending signal exists.
18824
+ *
18825
+ * @param symbol - Trading pair symbol
18826
+ * @param context - Execution context with strategyName, exchangeName and frameName
18827
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18828
+ * @returns Promise resolving to price or null
18829
+ *
18830
+ * @example
18831
+ * ```typescript
18832
+ * const troughPrice = await Reflect.getPositionMaxDrawdownPrice(
18833
+ * "BTCUSDT",
18834
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18835
+ * );
18836
+ * console.log(`Worst price: ${troughPrice}`);
18837
+ * ```
18838
+ */
18839
+ getPositionMaxDrawdownPrice: (symbol: string, context: {
18840
+ strategyName: StrategyName;
18841
+ exchangeName: ExchangeName;
18842
+ frameName: FrameName;
18843
+ }, backtest?: boolean) => Promise<number | null>;
18844
+ /**
18845
+ * Returns the timestamp when the worst loss price was recorded during this position's life.
18846
+ *
18847
+ * Returns null if no pending signal exists.
18848
+ *
18849
+ * @param symbol - Trading pair symbol
18850
+ * @param context - Execution context with strategyName, exchangeName and frameName
18851
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18852
+ * @returns Promise resolving to timestamp in milliseconds or null
18853
+ *
18854
+ * @example
18855
+ * ```typescript
18856
+ * const ts = await Reflect.getPositionMaxDrawdownTimestamp(
18857
+ * "BTCUSDT",
18858
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18859
+ * );
18860
+ * console.log(`Worst drawdown at: ${new Date(ts).toISOString()}`);
18861
+ * ```
18862
+ */
18863
+ getPositionMaxDrawdownTimestamp: (symbol: string, context: {
18864
+ strategyName: StrategyName;
18865
+ exchangeName: ExchangeName;
18866
+ frameName: FrameName;
18867
+ }, backtest?: boolean) => Promise<number | null>;
18868
+ /**
18869
+ * Returns the PnL percentage at the moment the worst loss price was recorded during this position's life.
18870
+ *
18871
+ * Returns null if no pending signal exists.
18872
+ *
18873
+ * @param symbol - Trading pair symbol
18874
+ * @param context - Execution context with strategyName, exchangeName and frameName
18875
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18876
+ * @returns Promise resolving to PnL percentage or null
18877
+ *
18878
+ * @example
18879
+ * ```typescript
18880
+ * const worstPnl = await Reflect.getPositionMaxDrawdownPnlPercentage(
18881
+ * "BTCUSDT",
18882
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18883
+ * );
18884
+ * console.log(`Worst PNL: ${worstPnl}%`);
18885
+ * ```
18886
+ */
18887
+ getPositionMaxDrawdownPnlPercentage: (symbol: string, context: {
18888
+ strategyName: StrategyName;
18889
+ exchangeName: ExchangeName;
18890
+ frameName: FrameName;
18891
+ }, backtest?: boolean) => Promise<number | null>;
18892
+ /**
18893
+ * Returns the PnL cost (in quote currency) at the moment the worst loss price was recorded during this position's life.
18894
+ *
18895
+ * Returns null if no pending signal exists.
18896
+ *
18897
+ * @param symbol - Trading pair symbol
18898
+ * @param context - Execution context with strategyName, exchangeName and frameName
18899
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18900
+ * @returns Promise resolving to PnL cost in quote currency or null
18901
+ *
18902
+ * @example
18903
+ * ```typescript
18904
+ * const worstCost = await Reflect.getPositionMaxDrawdownPnlCost(
18905
+ * "BTCUSDT",
18906
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18907
+ * );
18908
+ * console.log(`Worst PNL: $${worstCost}`);
18909
+ * ```
18910
+ */
18911
+ getPositionMaxDrawdownPnlCost: (symbol: string, context: {
18912
+ strategyName: StrategyName;
18913
+ exchangeName: ExchangeName;
18914
+ frameName: FrameName;
18915
+ }, backtest?: boolean) => Promise<number | null>;
18916
+ /**
18917
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
18918
+ *
18919
+ * Result is ≥ 0. Returns null if no pending signal exists.
18920
+ *
18921
+ * @param symbol - Trading pair symbol
18922
+ * @param context - Execution context with strategyName, exchangeName and frameName
18923
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18924
+ * @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
18925
+ *
18926
+ * @example
18927
+ * ```typescript
18928
+ * const distance = await Reflect.getPositionHighestProfitDistancePnlPercentage(
18929
+ * "BTCUSDT",
18930
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18931
+ * );
18932
+ * console.log(`Dropped ${distance}% from peak`);
18933
+ * ```
18934
+ */
18935
+ getPositionHighestProfitDistancePnlPercentage: (symbol: string, context: {
18936
+ strategyName: StrategyName;
18937
+ exchangeName: ExchangeName;
18938
+ frameName: FrameName;
18939
+ }, backtest?: boolean) => Promise<number | null>;
18940
+ /**
18941
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
18942
+ *
18943
+ * Result is ≥ 0. Returns null if no pending signal exists.
18944
+ *
18945
+ * @param symbol - Trading pair symbol
18946
+ * @param context - Execution context with strategyName, exchangeName and frameName
18947
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18948
+ * @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
18949
+ *
18950
+ * @example
18951
+ * ```typescript
18952
+ * const distance = await Reflect.getPositionHighestProfitDistancePnlCost(
18953
+ * "BTCUSDT",
18954
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18955
+ * );
18956
+ * console.log(`Dropped $${distance} from peak`);
18957
+ * ```
18958
+ */
18959
+ getPositionHighestProfitDistancePnlCost: (symbol: string, context: {
18960
+ strategyName: StrategyName;
18961
+ exchangeName: ExchangeName;
18962
+ frameName: FrameName;
18963
+ }, backtest?: boolean) => Promise<number | null>;
18964
+ /**
18965
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
18966
+ *
18967
+ * Result is ≥ 0. Returns null if no pending signal exists.
18968
+ *
18969
+ * @param symbol - Trading pair symbol
18970
+ * @param context - Execution context with strategyName, exchangeName and frameName
18971
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18972
+ * @returns Promise resolving to recovery distance from worst drawdown trough in PnL% (≥ 0) or null
18973
+ *
18974
+ * @example
18975
+ * ```typescript
18976
+ * const distance = await Reflect.getPositionHighestMaxDrawdownPnlPercentage(
18977
+ * "BTCUSDT",
18978
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18979
+ * );
18980
+ * console.log(`${distance}% above worst trough`);
18981
+ * ```
18982
+ */
18983
+ getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, context: {
18984
+ strategyName: StrategyName;
18985
+ exchangeName: ExchangeName;
18986
+ frameName: FrameName;
18987
+ }, backtest?: boolean) => Promise<number | null>;
18988
+ /**
18989
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
18990
+ *
18991
+ * Result is ≥ 0. Returns null if no pending signal exists.
18992
+ *
18993
+ * @param symbol - Trading pair symbol
18994
+ * @param context - Execution context with strategyName, exchangeName and frameName
18995
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18996
+ * @returns Promise resolving to recovery distance from worst drawdown trough in PnL cost (≥ 0) or null
18997
+ *
18998
+ * @example
18999
+ * ```typescript
19000
+ * const distance = await Reflect.getPositionHighestMaxDrawdownPnlCost(
19001
+ * "BTCUSDT",
19002
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
19003
+ * );
19004
+ * console.log(`$${distance} above worst trough`);
19005
+ * ```
19006
+ */
19007
+ getPositionHighestMaxDrawdownPnlCost: (symbol: string, context: {
19008
+ strategyName: StrategyName;
19009
+ exchangeName: ExchangeName;
19010
+ frameName: FrameName;
19011
+ }, backtest?: boolean) => Promise<number | null>;
19012
+ /**
19013
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
19014
+ *
19015
+ * Result is ≥ 0. Returns null if no pending signal exists.
19016
+ *
19017
+ * @param symbol - Trading pair symbol
19018
+ * @param context - Execution context with strategyName, exchangeName and frameName
19019
+ * @param backtest - True if backtest mode, false if live mode (default: false)
19020
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
19021
+ *
19022
+ * @example
19023
+ * ```typescript
19024
+ * const distance = await Reflect.getMaxDrawdownDistancePnlPercentage(
19025
+ * "BTCUSDT",
19026
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
19027
+ * );
19028
+ * console.log(`Peak-to-trough: ${distance}%`);
19029
+ * ```
19030
+ */
19031
+ getMaxDrawdownDistancePnlPercentage: (symbol: string, context: {
19032
+ strategyName: StrategyName;
19033
+ exchangeName: ExchangeName;
19034
+ frameName: FrameName;
19035
+ }, backtest?: boolean) => Promise<number | null>;
19036
+ /**
19037
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
19038
+ *
19039
+ * Result is ≥ 0. Returns null if no pending signal exists.
19040
+ *
19041
+ * @param symbol - Trading pair symbol
19042
+ * @param context - Execution context with strategyName, exchangeName and frameName
19043
+ * @param backtest - True if backtest mode, false if live mode (default: false)
19044
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
19045
+ *
19046
+ * @example
19047
+ * ```typescript
19048
+ * const distance = await Reflect.getMaxDrawdownDistancePnlCost(
19049
+ * "BTCUSDT",
19050
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
19051
+ * );
19052
+ * console.log(`Peak-to-trough: $${distance}`);
19053
+ * ```
19054
+ */
19055
+ getMaxDrawdownDistancePnlCost: (symbol: string, context: {
19056
+ strategyName: StrategyName;
19057
+ exchangeName: ExchangeName;
19058
+ frameName: FrameName;
19059
+ }, backtest?: boolean) => Promise<number | null>;
19060
+ }
19061
+ /**
19062
+ * Singleton instance of ReflectUtils for convenient position state queries.
19063
+ *
19064
+ * @example
19065
+ * ```typescript
19066
+ * import { Reflect } from "backtest-kit";
19067
+ *
19068
+ * // Real-time PNL
19069
+ * const pnl = await Reflect.getPositionPnlPercent(
19070
+ * "BTCUSDT",
19071
+ * 45000,
19072
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
19073
+ * );
19074
+ * console.log(`PNL: ${pnl}%`);
19075
+ *
19076
+ * // Peak profit
19077
+ * const peakPnl = await Reflect.getPositionHighestPnlPercentage(
19078
+ * "BTCUSDT",
19079
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
19080
+ * );
19081
+ * console.log(`Peak PNL: ${peakPnl}%`);
19082
+ *
19083
+ * // Drawdown from peak
19084
+ * const drawdown = await Reflect.getPositionHighestProfitDistancePnlPercentage(
19085
+ * "BTCUSDT",
19086
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
19087
+ * );
19088
+ * console.log(`Dropped ${drawdown}% from peak`);
19089
+ * ```
19090
+ */
19091
+ declare const Reflect: ReflectUtils;
19092
+
19093
+ /**
19094
+ * Utility class containing predefined trading constants for take-profit and stop-loss levels.
19095
+ *
19096
+ * Based on Kelly Criterion with exponential risk decay.
19097
+ * Values represent percentage of distance traveled towards final TP/SL target.
19098
+ *
19099
+ * Example: If final TP is at +10% profit:
19100
+ * - TP_LEVEL1 (30) triggers when price reaches 30% of distance = +3% profit
19101
+ * - TP_LEVEL2 (60) triggers when price reaches 60% of distance = +6% profit
19102
+ * - TP_LEVEL3 (90) triggers when price reaches 90% of distance = +9% profit
19103
+ */
19104
+ declare class ConstantUtils {
19105
+ /**
19106
+ * Take Profit Level 1 (Kelly-optimized early partial).
19107
+ * Triggers at 30% of distance to final TP target.
19108
+ * Lock in profit early, let rest run.
19109
+ */
19110
+ readonly TP_LEVEL1 = 30;
19111
+ /**
19112
+ * Take Profit Level 2 (Kelly-optimized mid partial).
19113
+ * Triggers at 60% of distance to final TP target.
19114
+ * Secure majority of position while trend continues.
19115
+ */
19116
+ readonly TP_LEVEL2 = 60;
19117
+ /**
19118
+ * Take Profit Level 3 (Kelly-optimized final partial).
19119
+ * Triggers at 90% of distance to final TP target.
19120
+ * Near-complete exit, minimal exposure remains.
19121
+ */
19122
+ readonly TP_LEVEL3 = 90;
19123
+ /**
19124
+ * Stop Loss Level 1 (Kelly-optimized early warning).
19125
+ * Triggers at 40% of distance to final SL target.
19126
+ * Reduce exposure when setup weakens.
19127
+ */
19128
+ readonly SL_LEVEL1 = 40;
19129
+ /**
19130
+ * Stop Loss Level 2 (Kelly-optimized final exit).
19131
+ * Triggers at 80% of distance to final SL target.
19132
+ * Exit remaining position before catastrophic loss.
19133
+ */
19134
+ readonly SL_LEVEL2 = 80;
19135
+ }
19136
+ /**
19137
+ * Global singleton instance of ConstantUtils.
18338
19138
  * Provides static-like access to predefined trading level constants.
18339
19139
  *
18340
19140
  * Kelly-optimized scaling strategy:
@@ -19383,6 +20183,184 @@ declare const StorageLive: StorageLiveAdapter;
19383
20183
  */
19384
20184
  declare const StorageBacktest: StorageBacktestAdapter;
19385
20185
 
20186
+ /**
20187
+ * Base interface for recent signal storage adapters.
20188
+ */
20189
+ interface IRecentUtils {
20190
+ /**
20191
+ * Handles active ping event and persists the latest signal.
20192
+ * @param event - Active ping contract with signal data
20193
+ */
20194
+ handleActivePing(event: ActivePingContract): Promise<void>;
20195
+ /**
20196
+ * Retrieves the latest active signal for the given context.
20197
+ * @param symbol - Trading pair symbol
20198
+ * @param strategyName - Strategy identifier
20199
+ * @param exchangeName - Exchange identifier
20200
+ * @param frameName - Frame identifier
20201
+ * @param backtest - Flag indicating if the context is backtest or live
20202
+ * @returns The latest signal or null if not found
20203
+ */
20204
+ getLatestSignal(symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean): Promise<IPublicSignalRow | null>;
20205
+ }
20206
+ /**
20207
+ * Constructor type for recent signal storage adapters.
20208
+ */
20209
+ type TRecentUtilsCtor = new () => IRecentUtils;
20210
+ /**
20211
+ * Backtest recent signal adapter with pluggable storage backend.
20212
+ *
20213
+ * Features:
20214
+ * - Adapter pattern for swappable storage implementations
20215
+ * - Default adapter: RecentMemoryBacktestUtils (in-memory storage)
20216
+ * - Alternative adapter: RecentPersistBacktestUtils
20217
+ * - Convenience methods: usePersist(), useMemory()
20218
+ */
20219
+ declare class RecentBacktestAdapter implements IRecentUtils {
20220
+ /** Internal storage utils instance */
20221
+ private _recentBacktestUtils;
20222
+ /**
20223
+ * Handles active ping event.
20224
+ * Proxies call to the underlying storage adapter.
20225
+ * @param event - Active ping contract with signal data
20226
+ */
20227
+ handleActivePing: (event: ActivePingContract) => Promise<void>;
20228
+ /**
20229
+ * Retrieves the latest signal for the given context.
20230
+ * Proxies call to the underlying storage adapter.
20231
+ * @param symbol - Trading pair symbol
20232
+ * @param strategyName - Strategy identifier
20233
+ * @param exchangeName - Exchange identifier
20234
+ * @param frameName - Frame identifier
20235
+ * @param backtest - Flag indicating if the context is backtest or live
20236
+ * @returns The latest signal or null if not found
20237
+ */
20238
+ getLatestSignal: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<IPublicSignalRow | null>;
20239
+ /**
20240
+ * Sets the storage adapter constructor.
20241
+ * All future storage operations will use this adapter.
20242
+ * @param Ctor - Constructor for recent adapter
20243
+ */
20244
+ useRecentAdapter: (Ctor: TRecentUtilsCtor) => void;
20245
+ /**
20246
+ * Switches to persistent storage adapter.
20247
+ * Signals will be persisted to disk.
20248
+ */
20249
+ usePersist: () => void;
20250
+ /**
20251
+ * Switches to in-memory storage adapter (default).
20252
+ * Signals will be stored in memory only.
20253
+ */
20254
+ useMemory: () => void;
20255
+ /**
20256
+ * Clears the cached utils instance by resetting to the default in-memory adapter.
20257
+ */
20258
+ clear: () => void;
20259
+ }
20260
+ /**
20261
+ * Live recent signal adapter with pluggable storage backend.
20262
+ *
20263
+ * Features:
20264
+ * - Adapter pattern for swappable storage implementations
20265
+ * - Default adapter: RecentPersistLiveUtils (persistent storage)
20266
+ * - Alternative adapter: RecentMemoryLiveUtils
20267
+ * - Convenience methods: usePersist(), useMemory()
20268
+ */
20269
+ declare class RecentLiveAdapter implements IRecentUtils {
20270
+ /** Internal storage utils instance */
20271
+ private _recentLiveUtils;
20272
+ /**
20273
+ * Handles active ping event.
20274
+ * Proxies call to the underlying storage adapter.
20275
+ * @param event - Active ping contract with signal data
20276
+ */
20277
+ handleActivePing: (event: ActivePingContract) => Promise<void>;
20278
+ /**
20279
+ * Retrieves the latest signal for the given context.
20280
+ * Proxies call to the underlying storage adapter.
20281
+ * @param symbol - Trading pair symbol
20282
+ * @param strategyName - Strategy identifier
20283
+ * @param exchangeName - Exchange identifier
20284
+ * @param frameName - Frame identifier
20285
+ * @param backtest - Flag indicating if the context is backtest or live
20286
+ * @returns The latest signal or null if not found
20287
+ */
20288
+ getLatestSignal: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<IPublicSignalRow | null>;
20289
+ /**
20290
+ * Sets the storage adapter constructor.
20291
+ * All future storage operations will use this adapter.
20292
+ * @param Ctor - Constructor for recent adapter
20293
+ */
20294
+ useRecentAdapter: (Ctor: TRecentUtilsCtor) => void;
20295
+ /**
20296
+ * Switches to persistent storage adapter (default).
20297
+ * Signals will be persisted to disk.
20298
+ */
20299
+ usePersist: () => void;
20300
+ /**
20301
+ * Switches to in-memory storage adapter.
20302
+ * Signals will be stored in memory only.
20303
+ */
20304
+ useMemory: () => void;
20305
+ /**
20306
+ * Clears the cached utils instance by resetting to the default persistent adapter.
20307
+ */
20308
+ clear: () => void;
20309
+ }
20310
+ /**
20311
+ * Main recent signal adapter that manages both backtest and live recent signal storage.
20312
+ *
20313
+ * Features:
20314
+ * - Subscribes to activePingSubject for automatic storage updates
20315
+ * - Provides unified access to the latest signal for any context
20316
+ * - Singleshot enable pattern prevents duplicate subscriptions
20317
+ * - Cleanup function for proper unsubscription
20318
+ */
20319
+ declare class RecentAdapter {
20320
+ /**
20321
+ * Enables recent signal storage by subscribing to activePingSubject.
20322
+ * Uses singleshot to ensure one-time subscription.
20323
+ *
20324
+ * @returns Cleanup function that unsubscribes from all emitters
20325
+ */
20326
+ enable: (() => (...args: any[]) => any) & functools_kit.ISingleshotClearable;
20327
+ /**
20328
+ * Disables recent signal storage by unsubscribing from all emitters.
20329
+ * Safe to call multiple times.
20330
+ */
20331
+ disable: () => void;
20332
+ /**
20333
+ * Retrieves the latest active signal for the given symbol and context.
20334
+ * Searches backtest storage first, then live storage.
20335
+ *
20336
+ * @param symbol - Trading pair symbol
20337
+ * @param context - Execution context with strategyName, exchangeName, and frameName
20338
+ * @param backtest - Flag indicating if the context is backtest or live
20339
+ * @returns The latest signal or null if not found
20340
+ * @throws Error if RecentAdapter is not enabled
20341
+ */
20342
+ getLatestSignal: (symbol: string, context: {
20343
+ strategyName: StrategyName;
20344
+ exchangeName: ExchangeName;
20345
+ frameName: FrameName;
20346
+ }) => Promise<IPublicSignalRow | null>;
20347
+ }
20348
+ /**
20349
+ * Global singleton instance of RecentAdapter.
20350
+ * Provides unified recent signal management for backtest and live trading.
20351
+ */
20352
+ declare const Recent: RecentAdapter;
20353
+ /**
20354
+ * Global singleton instance of RecentLiveAdapter.
20355
+ * Provides live trading recent signal storage with pluggable backends.
20356
+ */
20357
+ declare const RecentLive: RecentLiveAdapter;
20358
+ /**
20359
+ * Global singleton instance of RecentBacktestAdapter.
20360
+ * Provides backtest recent signal storage with pluggable backends.
20361
+ */
20362
+ declare const RecentBacktest: RecentBacktestAdapter;
20363
+
19386
20364
  /**
19387
20365
  * Base interface for notification adapters.
19388
20366
  * All notification adapters must implement this interface.
@@ -20345,6 +21323,7 @@ declare class CacheUtils {
20345
21323
  }) => T & {
20346
21324
  clear(): void;
20347
21325
  gc(): number | undefined;
21326
+ hasValue(...args: Parameters<T>): boolean;
20348
21327
  };
20349
21328
  /**
20350
21329
  * Wrap an async function with persistent file-based caching.
@@ -20390,6 +21369,7 @@ declare class CacheUtils {
20390
21369
  key?: (args: CacheFileKeyArgs<T>) => string;
20391
21370
  }) => T & {
20392
21371
  clear(): Promise<void>;
21372
+ hasValue(...args: Parameters<T>): Promise<boolean>;
20393
21373
  };
20394
21374
  /**
20395
21375
  * Dispose (remove) the memoized CacheFnInstance for a specific function.
@@ -20529,6 +21509,7 @@ declare class IntervalUtils {
20529
21509
  }) => F & {
20530
21510
  clear(): void;
20531
21511
  gc(): number | undefined;
21512
+ hasValue(...args: Parameters<F>): boolean;
20532
21513
  };
20533
21514
  /**
20534
21515
  * Wrap an async signal function with persistent file-based once-per-interval firing.
@@ -20565,6 +21546,7 @@ declare class IntervalUtils {
20565
21546
  key?: (args: IntervalFileKeyArgs<F>) => string;
20566
21547
  }) => F & {
20567
21548
  clear(): Promise<void>;
21549
+ hasValue(...args: Parameters<F>): Promise<boolean>;
20568
21550
  };
20569
21551
  /**
20570
21552
  * Dispose (remove) the memoized `IntervalFnInstance` for a specific function.
@@ -21046,12 +22028,13 @@ declare class StrategyMarkdownService {
21046
22028
  * @param context - Strategy context with strategyName, exchangeName, frameName
21047
22029
  * @param timestamp - Timestamp from StrategyCommitContract (execution context time)
21048
22030
  * @param cancelId - Optional identifier for the cancellation reason
22031
+ * @param note - Optional note from commit payload
21049
22032
  */
21050
22033
  cancelScheduled: (symbol: string, isBacktest: boolean, context: {
21051
22034
  strategyName: StrategyName;
21052
22035
  exchangeName: ExchangeName;
21053
22036
  frameName: FrameName;
21054
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, cancelId?: string) => Promise<void>;
22037
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, cancelId?: string, note?: string) => Promise<void>;
21055
22038
  /**
21056
22039
  * Records a close-pending event when a pending signal is closed.
21057
22040
  *
@@ -21060,12 +22043,13 @@ declare class StrategyMarkdownService {
21060
22043
  * @param context - Strategy context with strategyName, exchangeName, frameName
21061
22044
  * @param timestamp - Timestamp from StrategyCommitContract (execution context time)
21062
22045
  * @param closeId - Optional identifier for the close reason
22046
+ * @param note - Optional note from commit payload
21063
22047
  */
21064
22048
  closePending: (symbol: string, isBacktest: boolean, context: {
21065
22049
  strategyName: StrategyName;
21066
22050
  exchangeName: ExchangeName;
21067
22051
  frameName: FrameName;
21068
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, closeId?: string) => Promise<void>;
22052
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, closeId?: string, note?: string) => Promise<void>;
21069
22053
  /**
21070
22054
  * Records a partial-profit event when a portion of the position is closed at profit.
21071
22055
  *
@@ -21197,12 +22181,13 @@ declare class StrategyMarkdownService {
21197
22181
  * @param scheduledAt - Signal creation timestamp in milliseconds
21198
22182
  * @param pendingAt - Pending timestamp in milliseconds
21199
22183
  * @param activateId - Optional identifier for the activation reason
22184
+ * @param note - Optional note from commit payload
21200
22185
  */
21201
22186
  activateScheduled: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
21202
22187
  strategyName: StrategyName;
21203
22188
  exchangeName: ExchangeName;
21204
22189
  frameName: FrameName;
21205
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number, activateId?: string) => Promise<void>;
22190
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number, activateId?: string, note?: string) => Promise<void>;
21206
22191
  /**
21207
22192
  * Records an average-buy (DCA) event when a new averaging entry is added to an open position.
21208
22193
  *
@@ -25442,6 +26427,40 @@ declare class StrategyConnectionService implements TStrategy$1 {
25442
26427
  exchangeName: ExchangeName;
25443
26428
  frameName: FrameName;
25444
26429
  }) => Promise<number | null>;
26430
+ /**
26431
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
26432
+ *
26433
+ * Resolves current price via priceMetaService and delegates to
26434
+ * ClientStrategy.getMaxDrawdownDistancePnlPercentage().
26435
+ * Returns null if no pending signal exists.
26436
+ *
26437
+ * @param backtest - Whether running in backtest mode
26438
+ * @param symbol - Trading pair symbol
26439
+ * @param context - Execution context with strategyName, exchangeName, frameName
26440
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
26441
+ */
26442
+ getMaxDrawdownDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
26443
+ strategyName: StrategyName;
26444
+ exchangeName: ExchangeName;
26445
+ frameName: FrameName;
26446
+ }) => Promise<number | null>;
26447
+ /**
26448
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
26449
+ *
26450
+ * Resolves current price via priceMetaService and delegates to
26451
+ * ClientStrategy.getMaxDrawdownDistancePnlCost().
26452
+ * Returns null if no pending signal exists.
26453
+ *
26454
+ * @param backtest - Whether running in backtest mode
26455
+ * @param symbol - Trading pair symbol
26456
+ * @param context - Execution context with strategyName, exchangeName, frameName
26457
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
26458
+ */
26459
+ getMaxDrawdownDistancePnlCost: (backtest: boolean, symbol: string, context: {
26460
+ strategyName: StrategyName;
26461
+ exchangeName: ExchangeName;
26462
+ frameName: FrameName;
26463
+ }) => Promise<number | null>;
25445
26464
  /**
25446
26465
  * Disposes the ClientStrategy instance for the given context.
25447
26466
  *
@@ -25483,14 +26502,14 @@ declare class StrategyConnectionService implements TStrategy$1 {
25483
26502
  * @param backtest - Whether running in backtest mode
25484
26503
  * @param symbol - Trading pair symbol
25485
26504
  * @param ctx - Context with strategyName, exchangeName, frameName
25486
- * @param cancelId - Optional cancellation ID for user-initiated cancellations
26505
+ * @param payload - Optional commit payload with id and note
25487
26506
  * @returns Promise that resolves when scheduled signal is cancelled
25488
26507
  */
25489
26508
  cancelScheduled: (backtest: boolean, symbol: string, context: {
25490
26509
  strategyName: StrategyName;
25491
26510
  exchangeName: ExchangeName;
25492
26511
  frameName: FrameName;
25493
- }, cancelId?: string) => Promise<void>;
26512
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
25494
26513
  /**
25495
26514
  * Closes the pending signal without stopping the strategy.
25496
26515
  *
@@ -25504,14 +26523,14 @@ declare class StrategyConnectionService implements TStrategy$1 {
25504
26523
  * @param backtest - Whether running in backtest mode
25505
26524
  * @param symbol - Trading pair symbol
25506
26525
  * @param context - Context with strategyName, exchangeName, frameName
25507
- * @param closeId - Optional close ID for user-initiated closes
26526
+ * @param payload - Optional commit payload with id and note
25508
26527
  * @returns Promise that resolves when pending signal is closed
25509
26528
  */
25510
26529
  closePending: (backtest: boolean, symbol: string, context: {
25511
26530
  strategyName: StrategyName;
25512
26531
  exchangeName: ExchangeName;
25513
26532
  frameName: FrameName;
25514
- }, closeId?: string) => Promise<void>;
26533
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
25515
26534
  /**
25516
26535
  * Checks whether `partialProfit` would succeed without executing it.
25517
26536
  * Delegates to `ClientStrategy.validatePartialProfit()` — no throws, pure boolean result.
@@ -25763,7 +26782,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
25763
26782
  * @param backtest - Whether running in backtest mode
25764
26783
  * @param symbol - Trading pair symbol
25765
26784
  * @param context - Execution context with strategyName, exchangeName, frameName
25766
- * @param activateId - Optional identifier for the activation reason
26785
+ * @param payload - Optional commit payload with id and note
25767
26786
  * @returns Promise that resolves when activation flag is set
25768
26787
  *
25769
26788
  * @example
@@ -25773,7 +26792,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
25773
26792
  * false,
25774
26793
  * "BTCUSDT",
25775
26794
  * { strategyName: "my-strategy", exchangeName: "binance", frameName: "" },
25776
- * "manual-activation"
26795
+ * { id: "manual-activation" }
25777
26796
  * );
25778
26797
  * ```
25779
26798
  */
@@ -25781,7 +26800,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
25781
26800
  strategyName: StrategyName;
25782
26801
  exchangeName: ExchangeName;
25783
26802
  frameName: FrameName;
25784
- }, activateId?: string) => Promise<void>;
26803
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
25785
26804
  /**
25786
26805
  * Checks whether `averageBuy` would succeed without executing it.
25787
26806
  * Delegates to `ClientStrategy.validateAverageBuy()` — no throws, pure boolean result.
@@ -27023,14 +28042,14 @@ declare class StrategyCoreService implements TStrategy {
27023
28042
  * @param backtest - Whether running in backtest mode
27024
28043
  * @param symbol - Trading pair symbol
27025
28044
  * @param ctx - Context with strategyName, exchangeName, frameName
27026
- * @param cancelId - Optional cancellation ID for user-initiated cancellations
28045
+ * @param payload - Optional commit payload with id and note
27027
28046
  * @returns Promise that resolves when scheduled signal is cancelled
27028
28047
  */
27029
28048
  cancelScheduled: (backtest: boolean, symbol: string, context: {
27030
28049
  strategyName: StrategyName;
27031
28050
  exchangeName: ExchangeName;
27032
28051
  frameName: FrameName;
27033
- }, cancelId?: string) => Promise<void>;
28052
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
27034
28053
  /**
27035
28054
  * Closes the pending signal without stopping the strategy.
27036
28055
  *
@@ -27045,14 +28064,14 @@ declare class StrategyCoreService implements TStrategy {
27045
28064
  * @param backtest - Whether running in backtest mode
27046
28065
  * @param symbol - Trading pair symbol
27047
28066
  * @param context - Context with strategyName, exchangeName, frameName
27048
- * @param closeId - Optional close ID for user-initiated closes
28067
+ * @param payload - Optional commit payload with id and note
27049
28068
  * @returns Promise that resolves when pending signal is closed
27050
28069
  */
27051
28070
  closePending: (backtest: boolean, symbol: string, context: {
27052
28071
  strategyName: StrategyName;
27053
28072
  exchangeName: ExchangeName;
27054
28073
  frameName: FrameName;
27055
- }, closeId?: string) => Promise<void>;
28074
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
27056
28075
  /**
27057
28076
  * Disposes the ClientStrategy instance for the given context.
27058
28077
  *
@@ -27328,7 +28347,7 @@ declare class StrategyCoreService implements TStrategy {
27328
28347
  * @param backtest - Whether running in backtest mode
27329
28348
  * @param symbol - Trading pair symbol
27330
28349
  * @param context - Execution context with strategyName, exchangeName, frameName
27331
- * @param activateId - Optional identifier for the activation reason
28350
+ * @param payload - Optional commit payload with id and note
27332
28351
  * @returns Promise that resolves when activation flag is set
27333
28352
  *
27334
28353
  * @example
@@ -27338,7 +28357,7 @@ declare class StrategyCoreService implements TStrategy {
27338
28357
  * false,
27339
28358
  * "BTCUSDT",
27340
28359
  * { strategyName: "my-strategy", exchangeName: "binance", frameName: "" },
27341
- * "manual-activation"
28360
+ * { id: "manual-activation" }
27342
28361
  * );
27343
28362
  * ```
27344
28363
  */
@@ -27346,7 +28365,7 @@ declare class StrategyCoreService implements TStrategy {
27346
28365
  strategyName: StrategyName;
27347
28366
  exchangeName: ExchangeName;
27348
28367
  frameName: FrameName;
27349
- }, activateId?: string) => Promise<void>;
28368
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
27350
28369
  /**
27351
28370
  * Checks whether `averageBuy` would succeed without executing it.
27352
28371
  * Validates context, then delegates to StrategyConnectionService.validateAverageBuy().
@@ -27677,6 +28696,38 @@ declare class StrategyCoreService implements TStrategy {
27677
28696
  exchangeName: ExchangeName;
27678
28697
  frameName: FrameName;
27679
28698
  }) => Promise<number | null>;
28699
+ /**
28700
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
28701
+ *
28702
+ * Delegates to StrategyConnectionService.getMaxDrawdownDistancePnlPercentage().
28703
+ * Returns null if no pending signal exists.
28704
+ *
28705
+ * @param backtest - Whether running in backtest mode
28706
+ * @param symbol - Trading pair symbol
28707
+ * @param context - Execution context with strategyName, exchangeName, frameName
28708
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
28709
+ */
28710
+ getMaxDrawdownDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
28711
+ strategyName: StrategyName;
28712
+ exchangeName: ExchangeName;
28713
+ frameName: FrameName;
28714
+ }) => Promise<number | null>;
28715
+ /**
28716
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
28717
+ *
28718
+ * Delegates to StrategyConnectionService.getMaxDrawdownDistancePnlCost().
28719
+ * Returns null if no pending signal exists.
28720
+ *
28721
+ * @param backtest - Whether running in backtest mode
28722
+ * @param symbol - Trading pair symbol
28723
+ * @param context - Execution context with strategyName, exchangeName, frameName
28724
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
28725
+ */
28726
+ getMaxDrawdownDistancePnlCost: (backtest: boolean, symbol: string, context: {
28727
+ strategyName: StrategyName;
28728
+ exchangeName: ExchangeName;
28729
+ frameName: FrameName;
28730
+ }) => Promise<number | null>;
27680
28731
  }
27681
28732
 
27682
28733
  /**
@@ -30072,7 +31123,7 @@ declare class StrategyReportService {
30072
31123
  strategyName: StrategyName;
30073
31124
  exchangeName: ExchangeName;
30074
31125
  frameName: FrameName;
30075
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, cancelId?: string) => Promise<void>;
31126
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, cancelId?: string, note?: string) => Promise<void>;
30076
31127
  /**
30077
31128
  * Logs a close-pending event when a pending signal is closed.
30078
31129
  */
@@ -30080,7 +31131,7 @@ declare class StrategyReportService {
30080
31131
  strategyName: StrategyName;
30081
31132
  exchangeName: ExchangeName;
30082
31133
  frameName: FrameName;
30083
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, closeId?: string) => Promise<void>;
31134
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, closeId?: string, note?: string) => Promise<void>;
30084
31135
  /**
30085
31136
  * Logs a partial-profit event when a portion of the position is closed at profit.
30086
31137
  */
@@ -30128,7 +31179,7 @@ declare class StrategyReportService {
30128
31179
  strategyName: StrategyName;
30129
31180
  exchangeName: ExchangeName;
30130
31181
  frameName: FrameName;
30131
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number, activateId?: string) => Promise<void>;
31182
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number, activateId?: string, note?: string) => Promise<void>;
30132
31183
  /**
30133
31184
  * Logs an average-buy (DCA) event when a new averaging entry is added to an open position.
30134
31185
  */
@@ -30528,4 +31579,4 @@ declare const getTotalClosed: (signal: Signal) => {
30528
31579
  remainingCostBasis: number;
30529
31580
  };
30530
31581
 
30531
- 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 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 };
31582
+ 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 IRecentUtils, 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, PersistRecentAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Recent, RecentBacktest, type RecentData, RecentLive, Reflect, 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, Session, 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 TRecentUtilsCtor, 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, getLatestSignal, getMaxDrawdownDistancePnlCost, getMaxDrawdownDistancePnlPercentage, 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 };