backtest-kit 6.11.0 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.
@@ -11176,6 +11244,8 @@ interface StrategyEvent {
11176
11244
  pnl?: IStrategyPnL;
11177
11245
  /** Cost of this entry in USD (average-buy action only) */
11178
11246
  cost?: number;
11247
+ /** Optional note from commit payload */
11248
+ note?: string;
11179
11249
  }
11180
11250
  /**
11181
11251
  * Statistical data calculated from strategy events.
@@ -14109,6 +14179,36 @@ declare class BacktestUtils {
14109
14179
  exchangeName: ExchangeName;
14110
14180
  frameName: FrameName;
14111
14181
  }) => Promise<number>;
14182
+ /**
14183
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
14184
+ *
14185
+ * Computed as: max(0, peakPnlPercentage - fallPnlPercentage).
14186
+ * Returns null if no pending signal exists.
14187
+ *
14188
+ * @param symbol - Trading pair symbol
14189
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14190
+ * @returns peak-to-trough PnL percentage distance (≥ 0) or null if no active position
14191
+ */
14192
+ getMaxDrawdownDistancePnlPercentage: (symbol: string, context: {
14193
+ strategyName: StrategyName;
14194
+ exchangeName: ExchangeName;
14195
+ frameName: FrameName;
14196
+ }) => Promise<number>;
14197
+ /**
14198
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
14199
+ *
14200
+ * Computed as: max(0, peakPnlCost - fallPnlCost).
14201
+ * Returns null if no pending signal exists.
14202
+ *
14203
+ * @param symbol - Trading pair symbol
14204
+ * @param context - Execution context with strategyName, exchangeName, and frameName
14205
+ * @returns peak-to-trough PnL cost distance (≥ 0) or null if no active position
14206
+ */
14207
+ getMaxDrawdownDistancePnlCost: (symbol: string, context: {
14208
+ strategyName: StrategyName;
14209
+ exchangeName: ExchangeName;
14210
+ frameName: FrameName;
14211
+ }) => Promise<number>;
14112
14212
  /**
14113
14213
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
14114
14214
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -14184,7 +14284,7 @@ declare class BacktestUtils {
14184
14284
  * @param symbol - Trading pair symbol
14185
14285
  * @param strategyName - Strategy name
14186
14286
  * @param context - Execution context with exchangeName and frameName
14187
- * @param cancelId - Optional cancellation ID for tracking user-initiated cancellations
14287
+ * @param payload - Optional commit payload with id and note
14188
14288
  * @returns Promise that resolves when scheduled signal is cancelled
14189
14289
  *
14190
14290
  * @example
@@ -14194,14 +14294,14 @@ declare class BacktestUtils {
14194
14294
  * exchangeName: "binance",
14195
14295
  * frameName: "frame1",
14196
14296
  * strategyName: "my-strategy"
14197
- * }, "manual-cancel-001");
14297
+ * }, { id: "manual-cancel-001" });
14198
14298
  * ```
14199
14299
  */
14200
14300
  commitCancelScheduled: (symbol: string, context: {
14201
14301
  strategyName: StrategyName;
14202
14302
  exchangeName: ExchangeName;
14203
14303
  frameName: FrameName;
14204
- }, cancelId?: string) => Promise<void>;
14304
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
14205
14305
  /**
14206
14306
  * Closes the pending signal without stopping the strategy.
14207
14307
  *
@@ -14211,7 +14311,7 @@ declare class BacktestUtils {
14211
14311
  *
14212
14312
  * @param symbol - Trading pair symbol
14213
14313
  * @param context - Execution context with strategyName, exchangeName, and frameName
14214
- * @param closeId - Optional close ID for user-initiated closes
14314
+ * @param payload - Optional commit payload with id and note
14215
14315
  * @returns Promise that resolves when pending signal is closed
14216
14316
  *
14217
14317
  * @example
@@ -14221,14 +14321,14 @@ declare class BacktestUtils {
14221
14321
  * exchangeName: "binance",
14222
14322
  * strategyName: "my-strategy",
14223
14323
  * frameName: "1m"
14224
- * }, "manual-close-001");
14324
+ * }, { id: "manual-close-001" });
14225
14325
  * ```
14226
14326
  */
14227
14327
  commitClosePending: (symbol: string, context: {
14228
14328
  strategyName: StrategyName;
14229
14329
  exchangeName: ExchangeName;
14230
14330
  frameName: FrameName;
14231
- }, closeId?: string) => Promise<void>;
14331
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
14232
14332
  /**
14233
14333
  * Executes partial close at profit level (moving toward TP).
14234
14334
  *
@@ -14533,7 +14633,7 @@ declare class BacktestUtils {
14533
14633
  *
14534
14634
  * @param symbol - Trading pair symbol
14535
14635
  * @param context - Execution context with strategyName, exchangeName, and frameName
14536
- * @param activateId - Optional activation ID for tracking user-initiated activations
14636
+ * @param payload - Optional commit payload with id and note
14537
14637
  * @returns Promise that resolves when activation flag is set
14538
14638
  *
14539
14639
  * @example
@@ -14543,14 +14643,14 @@ declare class BacktestUtils {
14543
14643
  * strategyName: "my-strategy",
14544
14644
  * exchangeName: "binance",
14545
14645
  * frameName: "1h"
14546
- * }, "manual-activate-001");
14646
+ * }, { id: "manual-activate-001" });
14547
14647
  * ```
14548
14648
  */
14549
14649
  commitActivateScheduled: (symbol: string, context: {
14550
14650
  strategyName: StrategyName;
14551
14651
  exchangeName: ExchangeName;
14552
14652
  frameName: FrameName;
14553
- }, activateId?: string) => Promise<void>;
14653
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
14554
14654
  /**
14555
14655
  * Adds a new DCA entry to the active pending signal.
14556
14656
  *
@@ -15523,6 +15623,34 @@ declare class LiveUtils {
15523
15623
  strategyName: StrategyName;
15524
15624
  exchangeName: ExchangeName;
15525
15625
  }) => Promise<number>;
15626
+ /**
15627
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
15628
+ *
15629
+ * Computed as: max(0, peakPnlPercentage - fallPnlPercentage).
15630
+ * Returns null if no pending signal exists.
15631
+ *
15632
+ * @param symbol - Trading pair symbol
15633
+ * @param context - Execution context with strategyName and exchangeName
15634
+ * @returns peak-to-trough PnL percentage distance (≥ 0) or null if no active position
15635
+ */
15636
+ getMaxDrawdownDistancePnlPercentage: (symbol: string, context: {
15637
+ strategyName: StrategyName;
15638
+ exchangeName: ExchangeName;
15639
+ }) => Promise<number>;
15640
+ /**
15641
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
15642
+ *
15643
+ * Computed as: max(0, peakPnlCost - fallPnlCost).
15644
+ * Returns null if no pending signal exists.
15645
+ *
15646
+ * @param symbol - Trading pair symbol
15647
+ * @param context - Execution context with strategyName and exchangeName
15648
+ * @returns peak-to-trough PnL cost distance (≥ 0) or null if no active position
15649
+ */
15650
+ getMaxDrawdownDistancePnlCost: (symbol: string, context: {
15651
+ strategyName: StrategyName;
15652
+ exchangeName: ExchangeName;
15653
+ }) => Promise<number>;
15526
15654
  /**
15527
15655
  * Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
15528
15656
  * Use this to prevent duplicate DCA entries at the same price area.
@@ -15590,7 +15718,7 @@ declare class LiveUtils {
15590
15718
  * @param symbol - Trading pair symbol
15591
15719
  * @param strategyName - Strategy name
15592
15720
  * @param context - Execution context with exchangeName and frameName
15593
- * @param cancelId - Optional cancellation ID for tracking user-initiated cancellations
15721
+ * @param payload - Optional commit payload with id and note
15594
15722
  * @returns Promise that resolves when scheduled signal is cancelled
15595
15723
  *
15596
15724
  * @example
@@ -15600,13 +15728,13 @@ declare class LiveUtils {
15600
15728
  * exchangeName: "binance",
15601
15729
  * frameName: "",
15602
15730
  * strategyName: "my-strategy"
15603
- * }, "manual-cancel-001");
15731
+ * }, { id: "manual-cancel-001" });
15604
15732
  * ```
15605
15733
  */
15606
15734
  commitCancelScheduled: (symbol: string, context: {
15607
15735
  strategyName: StrategyName;
15608
15736
  exchangeName: ExchangeName;
15609
- }, cancelId?: string) => Promise<void>;
15737
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
15610
15738
  /**
15611
15739
  * Closes the pending signal without stopping the strategy.
15612
15740
  *
@@ -15616,7 +15744,7 @@ declare class LiveUtils {
15616
15744
  *
15617
15745
  * @param symbol - Trading pair symbol
15618
15746
  * @param context - Execution context with strategyName and exchangeName
15619
- * @param closeId - Optional close ID for user-initiated closes
15747
+ * @param payload - Optional commit payload with id and note
15620
15748
  * @returns Promise that resolves when pending signal is closed
15621
15749
  *
15622
15750
  * @example
@@ -15625,13 +15753,13 @@ declare class LiveUtils {
15625
15753
  * await Live.commitClose("BTCUSDT", {
15626
15754
  * exchangeName: "binance",
15627
15755
  * strategyName: "my-strategy"
15628
- * }, "manual-close-001");
15756
+ * }, { id: "manual-close-001" });
15629
15757
  * ```
15630
15758
  */
15631
15759
  commitClosePending: (symbol: string, context: {
15632
15760
  strategyName: StrategyName;
15633
15761
  exchangeName: ExchangeName;
15634
- }, closeId?: string) => Promise<void>;
15762
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
15635
15763
  /**
15636
15764
  * Executes partial close at profit level (moving toward TP).
15637
15765
  *
@@ -15921,7 +16049,7 @@ declare class LiveUtils {
15921
16049
  *
15922
16050
  * @param symbol - Trading pair symbol
15923
16051
  * @param context - Execution context with strategyName and exchangeName
15924
- * @param activateId - Optional activation ID for tracking user-initiated activations
16052
+ * @param payload - Optional commit payload with id and note
15925
16053
  * @returns Promise that resolves when activation flag is set
15926
16054
  *
15927
16055
  * @example
@@ -15930,13 +16058,13 @@ declare class LiveUtils {
15930
16058
  * await Live.commitActivateScheduled("BTCUSDT", {
15931
16059
  * strategyName: "my-strategy",
15932
16060
  * exchangeName: "binance"
15933
- * }, "manual-activate-001");
16061
+ * }, { id: "manual-activate-001" });
15934
16062
  * ```
15935
16063
  */
15936
16064
  commitActivateScheduled: (symbol: string, context: {
15937
16065
  strategyName: StrategyName;
15938
16066
  exchangeName: ExchangeName;
15939
- }, activateId?: string) => Promise<void>;
16067
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
15940
16068
  /**
15941
16069
  * Adds a new DCA entry to the active pending signal.
15942
16070
  *
@@ -18291,167 +18419,720 @@ declare class MaxDrawdownUtils {
18291
18419
  declare const MaxDrawdown: MaxDrawdownUtils;
18292
18420
 
18293
18421
  /**
18294
- * Utility class containing predefined trading constants for take-profit and stop-loss levels.
18295
- *
18296
- * Based on Kelly Criterion with exponential risk decay.
18297
- * Values represent percentage of distance traveled towards final TP/SL target.
18298
- *
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
18303
- */
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;
18311
- /**
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.
18315
- */
18316
- readonly TP_LEVEL2 = 60;
18317
- /**
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.
18321
- */
18322
- readonly TP_LEVEL3 = 90;
18323
- /**
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.
18327
- */
18328
- readonly SL_LEVEL1 = 40;
18329
- /**
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.
18338
- * Provides static-like access to predefined trading level constants.
18339
- *
18340
- * Kelly-optimized scaling strategy:
18341
- * Profit side (pyramiding out):
18342
- * - Close 33% at 30% progress (quick profit lock)
18343
- * - Close 33% at 60% progress (secure gains)
18344
- * - Close 34% at 90% progress (exit near target)
18345
- *
18346
- * Loss side (damage control):
18347
- * - Close 50% at 40% progress (reduce risk early)
18348
- * - Close 50% at 80% progress (exit before full stop)
18349
- *
18350
- * @example
18351
- * ```typescript
18352
- * // Final targets: TP at +10%, SL at -5%
18353
- * listenPartialProfit(async (event) => {
18354
- * // event.level emits: 10, 20, 30, 40, 50...
18355
- * if (event.level === Constant.TP_LEVEL1) { await close(33); } // at +3% profit
18356
- * if (event.level === Constant.TP_LEVEL2) { await close(33); } // at +6% profit
18357
- * if (event.level === Constant.TP_LEVEL3) { await close(34); } // at +9% profit
18358
- * });
18359
- * ```
18360
- *
18361
- * @example
18362
- * ```typescript
18363
- * listenPartialLoss(async (event) => {
18364
- * // event.level emits: 10, 20, 30, 40, 50...
18365
- * if (event.level === Constant.SL_LEVEL1) { await close(50); } // at -2% loss
18366
- * if (event.level === Constant.SL_LEVEL2) { await close(50); } // at -4% loss
18367
- * });
18368
- * ```
18369
- */
18370
- declare const Constant: ConstantUtils;
18371
-
18372
- /**
18373
- * Type alias for column configuration used in risk management markdown reports.
18374
- *
18375
- * Represents a column model specifically designed to format and display
18376
- * risk rejection events in markdown tables.
18377
- *
18378
- * @typeParam RiskEvent - The risk event data type containing
18379
- * risk rejection details, symbol, and rejection reason
18380
- *
18381
- * @example
18382
- * ```typescript
18383
- * // Column to display symbol
18384
- * const symbolColumn: Columns = {
18385
- * key: "symbol",
18386
- * label: "Symbol",
18387
- * format: (event) => event.symbol,
18388
- * isVisible: () => true
18389
- * };
18390
- *
18391
- * // Column to display rejection reason
18392
- * const reasonColumn: Columns = {
18393
- * key: "reason",
18394
- * label: "Rejection Reason",
18395
- * format: (event) => event.reason,
18396
- * isVisible: () => true
18397
- * };
18398
- * ```
18399
- *
18400
- * @see ColumnModel for the base interface
18401
- * @see RiskEvent for the event data structure
18402
- */
18403
- type Columns$3 = ColumnModel<RiskEvent>;
18404
- /**
18405
- * Service for generating and saving risk rejection markdown reports.
18422
+ * Utility class for real-time position reflection: PNL, peak profit, and drawdown queries.
18406
18423
  *
18407
- * Features:
18408
- * - Listens to risk rejection events via riskSubject
18409
- * - Accumulates all rejection events per symbol-strategy pair
18410
- * - Generates markdown tables with detailed rejection information
18411
- * - Provides statistics (total rejections, by symbol, by strategy)
18412
- * - Saves reports to disk in dump/risk/{symbol}_{strategyName}.md
18424
+ * Provides unified access to strategyCoreService position state methods with logging
18425
+ * and full validation (strategy, exchange, frame, risk, actions).
18426
+ * Works for both live and backtest modes via the `backtest` parameter.
18427
+ * Exported as singleton instance for convenient usage.
18413
18428
  *
18414
18429
  * @example
18415
18430
  * ```typescript
18416
- * const service = new RiskMarkdownService();
18431
+ * import { Reflect } from "backtest-kit";
18417
18432
  *
18418
- * // Service automatically subscribes to subjects on init
18419
- * // No manual callback setup needed
18433
+ * // Get current unrealized PNL percentage
18434
+ * const pnl = await Reflect.getPositionPnlPercent(
18435
+ * "BTCUSDT",
18436
+ * 45000,
18437
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18438
+ * );
18439
+ * console.log(`PNL: ${pnl}%`);
18420
18440
  *
18421
- * // Later: generate and save report
18422
- * await service.dump("BTCUSDT", "my-strategy");
18441
+ * // Get peak profit reached
18442
+ * const peakPnl = await Reflect.getPositionHighestPnlPercentage(
18443
+ * "BTCUSDT",
18444
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18445
+ * );
18446
+ * console.log(`Peak PNL: ${peakPnl}%`);
18423
18447
  * ```
18424
18448
  */
18425
- declare class RiskMarkdownService {
18426
- /** Logger service for debug output */
18427
- private readonly loggerService;
18428
- /**
18429
- * Memoized function to get or create ReportStorage for a symbol-strategy-exchange-frame-backtest combination.
18430
- * Each combination gets its own isolated storage instance.
18431
- */
18432
- private getStorage;
18449
+ declare class ReflectUtils {
18433
18450
  /**
18434
- * Subscribes to risk rejection emitter to receive rejection events.
18435
- * Protected against multiple subscriptions.
18436
- * Returns an unsubscribe function to stop receiving events.
18451
+ * Returns the unrealized PNL percentage for the current pending signal at currentPrice.
18452
+ *
18453
+ * Accounts for partial closes, DCA entries, slippage and fees.
18454
+ * Returns null if no pending signal exists.
18455
+ *
18456
+ * @param symbol - Trading pair symbol
18457
+ * @param currentPrice - Current market price
18458
+ * @param context - Execution context with strategyName, exchangeName and frameName
18459
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18460
+ * @returns Promise resolving to PNL percentage or null
18437
18461
  *
18438
18462
  * @example
18439
18463
  * ```typescript
18440
- * const service = new RiskMarkdownService();
18441
- * const unsubscribe = service.subscribe();
18442
- * // ... later
18443
- * unsubscribe();
18464
+ * const pnl = await Reflect.getPositionPnlPercent(
18465
+ * "BTCUSDT",
18466
+ * 45000,
18467
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18468
+ * );
18469
+ * console.log(`PNL: ${pnl}%`);
18444
18470
  * ```
18445
18471
  */
18446
- subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
18472
+ getPositionPnlPercent: (symbol: string, currentPrice: number, context: {
18473
+ strategyName: StrategyName;
18474
+ exchangeName: ExchangeName;
18475
+ frameName: FrameName;
18476
+ }, backtest?: boolean) => Promise<number | null>;
18447
18477
  /**
18448
- * Unsubscribes from risk rejection emitter to stop receiving events.
18449
- * Calls the unsubscribe function returned by subscribe().
18450
- * If not subscribed, does nothing.
18478
+ * Returns the unrealized PNL in dollars for the current pending signal at currentPrice.
18479
+ *
18480
+ * Calculated as: pnlPercentage / 100 × totalInvestedCost.
18481
+ * Accounts for partial closes, DCA entries, slippage and fees.
18482
+ * Returns null if no pending signal exists.
18483
+ *
18484
+ * @param symbol - Trading pair symbol
18485
+ * @param currentPrice - Current market price
18486
+ * @param context - Execution context with strategyName, exchangeName and frameName
18487
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18488
+ * @returns Promise resolving to PNL in dollars or null
18451
18489
  *
18452
18490
  * @example
18453
18491
  * ```typescript
18454
- * const service = new RiskMarkdownService();
18492
+ * const pnlCost = await Reflect.getPositionPnlCost(
18493
+ * "BTCUSDT",
18494
+ * 45000,
18495
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18496
+ * );
18497
+ * console.log(`PNL: $${pnlCost}`);
18498
+ * ```
18499
+ */
18500
+ getPositionPnlCost: (symbol: string, currentPrice: number, context: {
18501
+ strategyName: StrategyName;
18502
+ exchangeName: ExchangeName;
18503
+ frameName: FrameName;
18504
+ }, backtest?: boolean) => Promise<number | null>;
18505
+ /**
18506
+ * Returns the best price reached in the profit direction during this position's life.
18507
+ *
18508
+ * Returns null if no pending signal exists.
18509
+ *
18510
+ * @param symbol - Trading pair symbol
18511
+ * @param context - Execution context with strategyName, exchangeName and frameName
18512
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18513
+ * @returns Promise resolving to price or null
18514
+ *
18515
+ * @example
18516
+ * ```typescript
18517
+ * const peakPrice = await Reflect.getPositionHighestProfitPrice(
18518
+ * "BTCUSDT",
18519
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18520
+ * );
18521
+ * console.log(`Peak price: ${peakPrice}`);
18522
+ * ```
18523
+ */
18524
+ getPositionHighestProfitPrice: (symbol: string, context: {
18525
+ strategyName: StrategyName;
18526
+ exchangeName: ExchangeName;
18527
+ frameName: FrameName;
18528
+ }, backtest?: boolean) => Promise<number | null>;
18529
+ /**
18530
+ * Returns the timestamp when the best profit price was recorded during this position's life.
18531
+ *
18532
+ * Returns null if no pending signal exists.
18533
+ *
18534
+ * @param symbol - Trading pair symbol
18535
+ * @param context - Execution context with strategyName, exchangeName and frameName
18536
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18537
+ * @returns Promise resolving to timestamp in milliseconds or null
18538
+ *
18539
+ * @example
18540
+ * ```typescript
18541
+ * const ts = await Reflect.getPositionHighestProfitTimestamp(
18542
+ * "BTCUSDT",
18543
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18544
+ * );
18545
+ * console.log(`Peak at: ${new Date(ts).toISOString()}`);
18546
+ * ```
18547
+ */
18548
+ getPositionHighestProfitTimestamp: (symbol: string, context: {
18549
+ strategyName: StrategyName;
18550
+ exchangeName: ExchangeName;
18551
+ frameName: FrameName;
18552
+ }, backtest?: boolean) => Promise<number | null>;
18553
+ /**
18554
+ * Returns the PnL percentage at the moment the best profit price was recorded during this position's life.
18555
+ *
18556
+ * Returns null if no pending signal exists.
18557
+ *
18558
+ * @param symbol - Trading pair symbol
18559
+ * @param context - Execution context with strategyName, exchangeName and frameName
18560
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18561
+ * @returns Promise resolving to PnL percentage or null
18562
+ *
18563
+ * @example
18564
+ * ```typescript
18565
+ * const peakPnl = await Reflect.getPositionHighestPnlPercentage(
18566
+ * "BTCUSDT",
18567
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18568
+ * );
18569
+ * console.log(`Peak PNL: ${peakPnl}%`);
18570
+ * ```
18571
+ */
18572
+ getPositionHighestPnlPercentage: (symbol: string, context: {
18573
+ strategyName: StrategyName;
18574
+ exchangeName: ExchangeName;
18575
+ frameName: FrameName;
18576
+ }, backtest?: boolean) => Promise<number | null>;
18577
+ /**
18578
+ * Returns the PnL cost (in quote currency) at the moment the best profit price was recorded during this position's life.
18579
+ *
18580
+ * Returns null if no pending signal exists.
18581
+ *
18582
+ * @param symbol - Trading pair symbol
18583
+ * @param context - Execution context with strategyName, exchangeName and frameName
18584
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18585
+ * @returns Promise resolving to PnL cost in quote currency or null
18586
+ *
18587
+ * @example
18588
+ * ```typescript
18589
+ * const peakCost = await Reflect.getPositionHighestPnlCost(
18590
+ * "BTCUSDT",
18591
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18592
+ * );
18593
+ * console.log(`Peak PNL: $${peakCost}`);
18594
+ * ```
18595
+ */
18596
+ getPositionHighestPnlCost: (symbol: string, context: {
18597
+ strategyName: StrategyName;
18598
+ exchangeName: ExchangeName;
18599
+ frameName: FrameName;
18600
+ }, backtest?: boolean) => Promise<number | null>;
18601
+ /**
18602
+ * Returns whether breakeven was mathematically reachable at the highest profit price.
18603
+ *
18604
+ * Returns null if no pending signal exists.
18605
+ *
18606
+ * @param symbol - Trading pair symbol
18607
+ * @param context - Execution context with strategyName, exchangeName and frameName
18608
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18609
+ * @returns Promise resolving to true if breakeven was reachable at peak, false otherwise, or null
18610
+ *
18611
+ * @example
18612
+ * ```typescript
18613
+ * const wasReachable = await Reflect.getPositionHighestProfitBreakeven(
18614
+ * "BTCUSDT",
18615
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18616
+ * );
18617
+ * console.log(`Breakeven reachable at peak: ${wasReachable}`);
18618
+ * ```
18619
+ */
18620
+ getPositionHighestProfitBreakeven: (symbol: string, context: {
18621
+ strategyName: StrategyName;
18622
+ exchangeName: ExchangeName;
18623
+ frameName: FrameName;
18624
+ }, backtest?: boolean) => Promise<boolean | null>;
18625
+ /**
18626
+ * Returns the number of minutes elapsed since the highest profit price was recorded.
18627
+ *
18628
+ * Returns null if no pending signal exists.
18629
+ *
18630
+ * @param symbol - Trading pair symbol
18631
+ * @param context - Execution context with strategyName, exchangeName and frameName
18632
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18633
+ * @returns Promise resolving to minutes since highest profit price was recorded, or null
18634
+ *
18635
+ * @example
18636
+ * ```typescript
18637
+ * const minutes = await Reflect.getPositionDrawdownMinutes(
18638
+ * "BTCUSDT",
18639
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18640
+ * );
18641
+ * console.log(`Pulling back from peak for ${minutes} minutes`);
18642
+ * ```
18643
+ */
18644
+ getPositionDrawdownMinutes: (symbol: string, context: {
18645
+ strategyName: StrategyName;
18646
+ exchangeName: ExchangeName;
18647
+ frameName: FrameName;
18648
+ }, backtest?: boolean) => Promise<number | null>;
18649
+ /**
18650
+ * Returns the number of minutes elapsed since the highest profit price was recorded.
18651
+ *
18652
+ * Alias for getPositionDrawdownMinutes — measures how long the position has been
18653
+ * pulling back from its peak profit level.
18654
+ * Returns null if no pending signal exists.
18655
+ *
18656
+ * @param symbol - Trading pair symbol
18657
+ * @param context - Execution context with strategyName, exchangeName and frameName
18658
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18659
+ * @returns Promise resolving to minutes since last profit peak or null
18660
+ *
18661
+ * @example
18662
+ * ```typescript
18663
+ * const minutes = await Reflect.getPositionHighestProfitMinutes(
18664
+ * "BTCUSDT",
18665
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18666
+ * );
18667
+ * console.log(`Pulling back from peak for ${minutes} minutes`);
18668
+ * ```
18669
+ */
18670
+ getPositionHighestProfitMinutes: (symbol: string, context: {
18671
+ strategyName: StrategyName;
18672
+ exchangeName: ExchangeName;
18673
+ frameName: FrameName;
18674
+ }, backtest?: boolean) => Promise<number | null>;
18675
+ /**
18676
+ * Returns the number of minutes elapsed since the worst loss price was recorded.
18677
+ *
18678
+ * Measures how long ago the deepest drawdown point occurred.
18679
+ * Zero when called at the exact moment the trough was set.
18680
+ * Returns null if no pending signal exists.
18681
+ *
18682
+ * @param symbol - Trading pair symbol
18683
+ * @param context - Execution context with strategyName, exchangeName and frameName
18684
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18685
+ * @returns Promise resolving to minutes since last drawdown trough or null
18686
+ *
18687
+ * @example
18688
+ * ```typescript
18689
+ * const minutes = await Reflect.getPositionMaxDrawdownMinutes(
18690
+ * "BTCUSDT",
18691
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18692
+ * );
18693
+ * console.log(`Drawdown trough was ${minutes} minutes ago`);
18694
+ * ```
18695
+ */
18696
+ getPositionMaxDrawdownMinutes: (symbol: string, context: {
18697
+ strategyName: StrategyName;
18698
+ exchangeName: ExchangeName;
18699
+ frameName: FrameName;
18700
+ }, backtest?: boolean) => Promise<number | null>;
18701
+ /**
18702
+ * Returns the worst price reached in the loss direction during this position's life.
18703
+ *
18704
+ * Returns null if no pending signal exists.
18705
+ *
18706
+ * @param symbol - Trading pair symbol
18707
+ * @param context - Execution context with strategyName, exchangeName and frameName
18708
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18709
+ * @returns Promise resolving to price or null
18710
+ *
18711
+ * @example
18712
+ * ```typescript
18713
+ * const troughPrice = await Reflect.getPositionMaxDrawdownPrice(
18714
+ * "BTCUSDT",
18715
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18716
+ * );
18717
+ * console.log(`Worst price: ${troughPrice}`);
18718
+ * ```
18719
+ */
18720
+ getPositionMaxDrawdownPrice: (symbol: string, context: {
18721
+ strategyName: StrategyName;
18722
+ exchangeName: ExchangeName;
18723
+ frameName: FrameName;
18724
+ }, backtest?: boolean) => Promise<number | null>;
18725
+ /**
18726
+ * Returns the timestamp when the worst loss price was recorded during this position's life.
18727
+ *
18728
+ * Returns null if no pending signal exists.
18729
+ *
18730
+ * @param symbol - Trading pair symbol
18731
+ * @param context - Execution context with strategyName, exchangeName and frameName
18732
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18733
+ * @returns Promise resolving to timestamp in milliseconds or null
18734
+ *
18735
+ * @example
18736
+ * ```typescript
18737
+ * const ts = await Reflect.getPositionMaxDrawdownTimestamp(
18738
+ * "BTCUSDT",
18739
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18740
+ * );
18741
+ * console.log(`Worst drawdown at: ${new Date(ts).toISOString()}`);
18742
+ * ```
18743
+ */
18744
+ getPositionMaxDrawdownTimestamp: (symbol: string, context: {
18745
+ strategyName: StrategyName;
18746
+ exchangeName: ExchangeName;
18747
+ frameName: FrameName;
18748
+ }, backtest?: boolean) => Promise<number | null>;
18749
+ /**
18750
+ * Returns the PnL percentage at the moment the worst loss price was recorded during this position's life.
18751
+ *
18752
+ * Returns null if no pending signal exists.
18753
+ *
18754
+ * @param symbol - Trading pair symbol
18755
+ * @param context - Execution context with strategyName, exchangeName and frameName
18756
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18757
+ * @returns Promise resolving to PnL percentage or null
18758
+ *
18759
+ * @example
18760
+ * ```typescript
18761
+ * const worstPnl = await Reflect.getPositionMaxDrawdownPnlPercentage(
18762
+ * "BTCUSDT",
18763
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18764
+ * );
18765
+ * console.log(`Worst PNL: ${worstPnl}%`);
18766
+ * ```
18767
+ */
18768
+ getPositionMaxDrawdownPnlPercentage: (symbol: string, context: {
18769
+ strategyName: StrategyName;
18770
+ exchangeName: ExchangeName;
18771
+ frameName: FrameName;
18772
+ }, backtest?: boolean) => Promise<number | null>;
18773
+ /**
18774
+ * Returns the PnL cost (in quote currency) at the moment the worst loss price was recorded during this position's life.
18775
+ *
18776
+ * Returns null if no pending signal exists.
18777
+ *
18778
+ * @param symbol - Trading pair symbol
18779
+ * @param context - Execution context with strategyName, exchangeName and frameName
18780
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18781
+ * @returns Promise resolving to PnL cost in quote currency or null
18782
+ *
18783
+ * @example
18784
+ * ```typescript
18785
+ * const worstCost = await Reflect.getPositionMaxDrawdownPnlCost(
18786
+ * "BTCUSDT",
18787
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18788
+ * );
18789
+ * console.log(`Worst PNL: $${worstCost}`);
18790
+ * ```
18791
+ */
18792
+ getPositionMaxDrawdownPnlCost: (symbol: string, context: {
18793
+ strategyName: StrategyName;
18794
+ exchangeName: ExchangeName;
18795
+ frameName: FrameName;
18796
+ }, backtest?: boolean) => Promise<number | null>;
18797
+ /**
18798
+ * Returns the distance in PnL percentage between the current price and the highest profit peak.
18799
+ *
18800
+ * Result is ≥ 0. Returns null if no pending signal exists.
18801
+ *
18802
+ * @param symbol - Trading pair symbol
18803
+ * @param context - Execution context with strategyName, exchangeName and frameName
18804
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18805
+ * @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
18806
+ *
18807
+ * @example
18808
+ * ```typescript
18809
+ * const distance = await Reflect.getPositionHighestProfitDistancePnlPercentage(
18810
+ * "BTCUSDT",
18811
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18812
+ * );
18813
+ * console.log(`Dropped ${distance}% from peak`);
18814
+ * ```
18815
+ */
18816
+ getPositionHighestProfitDistancePnlPercentage: (symbol: string, context: {
18817
+ strategyName: StrategyName;
18818
+ exchangeName: ExchangeName;
18819
+ frameName: FrameName;
18820
+ }, backtest?: boolean) => Promise<number | null>;
18821
+ /**
18822
+ * Returns the distance in PnL cost between the current price and the highest profit peak.
18823
+ *
18824
+ * Result is ≥ 0. Returns null if no pending signal exists.
18825
+ *
18826
+ * @param symbol - Trading pair symbol
18827
+ * @param context - Execution context with strategyName, exchangeName and frameName
18828
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18829
+ * @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
18830
+ *
18831
+ * @example
18832
+ * ```typescript
18833
+ * const distance = await Reflect.getPositionHighestProfitDistancePnlCost(
18834
+ * "BTCUSDT",
18835
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18836
+ * );
18837
+ * console.log(`Dropped $${distance} from peak`);
18838
+ * ```
18839
+ */
18840
+ getPositionHighestProfitDistancePnlCost: (symbol: string, context: {
18841
+ strategyName: StrategyName;
18842
+ exchangeName: ExchangeName;
18843
+ frameName: FrameName;
18844
+ }, backtest?: boolean) => Promise<number | null>;
18845
+ /**
18846
+ * Returns the distance in PnL percentage between the current price and the worst drawdown trough.
18847
+ *
18848
+ * Result is ≥ 0. Returns null if no pending signal exists.
18849
+ *
18850
+ * @param symbol - Trading pair symbol
18851
+ * @param context - Execution context with strategyName, exchangeName and frameName
18852
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18853
+ * @returns Promise resolving to recovery distance from worst drawdown trough in PnL% (≥ 0) or null
18854
+ *
18855
+ * @example
18856
+ * ```typescript
18857
+ * const distance = await Reflect.getPositionHighestMaxDrawdownPnlPercentage(
18858
+ * "BTCUSDT",
18859
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18860
+ * );
18861
+ * console.log(`${distance}% above worst trough`);
18862
+ * ```
18863
+ */
18864
+ getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, context: {
18865
+ strategyName: StrategyName;
18866
+ exchangeName: ExchangeName;
18867
+ frameName: FrameName;
18868
+ }, backtest?: boolean) => Promise<number | null>;
18869
+ /**
18870
+ * Returns the distance in PnL cost between the current price and the worst drawdown trough.
18871
+ *
18872
+ * Result is ≥ 0. Returns null if no pending signal exists.
18873
+ *
18874
+ * @param symbol - Trading pair symbol
18875
+ * @param context - Execution context with strategyName, exchangeName and frameName
18876
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18877
+ * @returns Promise resolving to recovery distance from worst drawdown trough in PnL cost (≥ 0) or null
18878
+ *
18879
+ * @example
18880
+ * ```typescript
18881
+ * const distance = await Reflect.getPositionHighestMaxDrawdownPnlCost(
18882
+ * "BTCUSDT",
18883
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18884
+ * );
18885
+ * console.log(`$${distance} above worst trough`);
18886
+ * ```
18887
+ */
18888
+ getPositionHighestMaxDrawdownPnlCost: (symbol: string, context: {
18889
+ strategyName: StrategyName;
18890
+ exchangeName: ExchangeName;
18891
+ frameName: FrameName;
18892
+ }, backtest?: boolean) => Promise<number | null>;
18893
+ /**
18894
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
18895
+ *
18896
+ * Result is ≥ 0. Returns null if no pending signal exists.
18897
+ *
18898
+ * @param symbol - Trading pair symbol
18899
+ * @param context - Execution context with strategyName, exchangeName and frameName
18900
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18901
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
18902
+ *
18903
+ * @example
18904
+ * ```typescript
18905
+ * const distance = await Reflect.getMaxDrawdownDistancePnlPercentage(
18906
+ * "BTCUSDT",
18907
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18908
+ * );
18909
+ * console.log(`Peak-to-trough: ${distance}%`);
18910
+ * ```
18911
+ */
18912
+ getMaxDrawdownDistancePnlPercentage: (symbol: string, context: {
18913
+ strategyName: StrategyName;
18914
+ exchangeName: ExchangeName;
18915
+ frameName: FrameName;
18916
+ }, backtest?: boolean) => Promise<number | null>;
18917
+ /**
18918
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
18919
+ *
18920
+ * Result is ≥ 0. Returns null if no pending signal exists.
18921
+ *
18922
+ * @param symbol - Trading pair symbol
18923
+ * @param context - Execution context with strategyName, exchangeName and frameName
18924
+ * @param backtest - True if backtest mode, false if live mode (default: false)
18925
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
18926
+ *
18927
+ * @example
18928
+ * ```typescript
18929
+ * const distance = await Reflect.getMaxDrawdownDistancePnlCost(
18930
+ * "BTCUSDT",
18931
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18932
+ * );
18933
+ * console.log(`Peak-to-trough: $${distance}`);
18934
+ * ```
18935
+ */
18936
+ getMaxDrawdownDistancePnlCost: (symbol: string, context: {
18937
+ strategyName: StrategyName;
18938
+ exchangeName: ExchangeName;
18939
+ frameName: FrameName;
18940
+ }, backtest?: boolean) => Promise<number | null>;
18941
+ }
18942
+ /**
18943
+ * Singleton instance of ReflectUtils for convenient position state queries.
18944
+ *
18945
+ * @example
18946
+ * ```typescript
18947
+ * import { Reflect } from "backtest-kit";
18948
+ *
18949
+ * // Real-time PNL
18950
+ * const pnl = await Reflect.getPositionPnlPercent(
18951
+ * "BTCUSDT",
18952
+ * 45000,
18953
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18954
+ * );
18955
+ * console.log(`PNL: ${pnl}%`);
18956
+ *
18957
+ * // Peak profit
18958
+ * const peakPnl = await Reflect.getPositionHighestPnlPercentage(
18959
+ * "BTCUSDT",
18960
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18961
+ * );
18962
+ * console.log(`Peak PNL: ${peakPnl}%`);
18963
+ *
18964
+ * // Drawdown from peak
18965
+ * const drawdown = await Reflect.getPositionHighestProfitDistancePnlPercentage(
18966
+ * "BTCUSDT",
18967
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "frame1" }
18968
+ * );
18969
+ * console.log(`Dropped ${drawdown}% from peak`);
18970
+ * ```
18971
+ */
18972
+ declare const Reflect: ReflectUtils;
18973
+
18974
+ /**
18975
+ * Utility class containing predefined trading constants for take-profit and stop-loss levels.
18976
+ *
18977
+ * Based on Kelly Criterion with exponential risk decay.
18978
+ * Values represent percentage of distance traveled towards final TP/SL target.
18979
+ *
18980
+ * Example: If final TP is at +10% profit:
18981
+ * - TP_LEVEL1 (30) triggers when price reaches 30% of distance = +3% profit
18982
+ * - TP_LEVEL2 (60) triggers when price reaches 60% of distance = +6% profit
18983
+ * - TP_LEVEL3 (90) triggers when price reaches 90% of distance = +9% profit
18984
+ */
18985
+ declare class ConstantUtils {
18986
+ /**
18987
+ * Take Profit Level 1 (Kelly-optimized early partial).
18988
+ * Triggers at 30% of distance to final TP target.
18989
+ * Lock in profit early, let rest run.
18990
+ */
18991
+ readonly TP_LEVEL1 = 30;
18992
+ /**
18993
+ * Take Profit Level 2 (Kelly-optimized mid partial).
18994
+ * Triggers at 60% of distance to final TP target.
18995
+ * Secure majority of position while trend continues.
18996
+ */
18997
+ readonly TP_LEVEL2 = 60;
18998
+ /**
18999
+ * Take Profit Level 3 (Kelly-optimized final partial).
19000
+ * Triggers at 90% of distance to final TP target.
19001
+ * Near-complete exit, minimal exposure remains.
19002
+ */
19003
+ readonly TP_LEVEL3 = 90;
19004
+ /**
19005
+ * Stop Loss Level 1 (Kelly-optimized early warning).
19006
+ * Triggers at 40% of distance to final SL target.
19007
+ * Reduce exposure when setup weakens.
19008
+ */
19009
+ readonly SL_LEVEL1 = 40;
19010
+ /**
19011
+ * Stop Loss Level 2 (Kelly-optimized final exit).
19012
+ * Triggers at 80% of distance to final SL target.
19013
+ * Exit remaining position before catastrophic loss.
19014
+ */
19015
+ readonly SL_LEVEL2 = 80;
19016
+ }
19017
+ /**
19018
+ * Global singleton instance of ConstantUtils.
19019
+ * Provides static-like access to predefined trading level constants.
19020
+ *
19021
+ * Kelly-optimized scaling strategy:
19022
+ * Profit side (pyramiding out):
19023
+ * - Close 33% at 30% progress (quick profit lock)
19024
+ * - Close 33% at 60% progress (secure gains)
19025
+ * - Close 34% at 90% progress (exit near target)
19026
+ *
19027
+ * Loss side (damage control):
19028
+ * - Close 50% at 40% progress (reduce risk early)
19029
+ * - Close 50% at 80% progress (exit before full stop)
19030
+ *
19031
+ * @example
19032
+ * ```typescript
19033
+ * // Final targets: TP at +10%, SL at -5%
19034
+ * listenPartialProfit(async (event) => {
19035
+ * // event.level emits: 10, 20, 30, 40, 50...
19036
+ * if (event.level === Constant.TP_LEVEL1) { await close(33); } // at +3% profit
19037
+ * if (event.level === Constant.TP_LEVEL2) { await close(33); } // at +6% profit
19038
+ * if (event.level === Constant.TP_LEVEL3) { await close(34); } // at +9% profit
19039
+ * });
19040
+ * ```
19041
+ *
19042
+ * @example
19043
+ * ```typescript
19044
+ * listenPartialLoss(async (event) => {
19045
+ * // event.level emits: 10, 20, 30, 40, 50...
19046
+ * if (event.level === Constant.SL_LEVEL1) { await close(50); } // at -2% loss
19047
+ * if (event.level === Constant.SL_LEVEL2) { await close(50); } // at -4% loss
19048
+ * });
19049
+ * ```
19050
+ */
19051
+ declare const Constant: ConstantUtils;
19052
+
19053
+ /**
19054
+ * Type alias for column configuration used in risk management markdown reports.
19055
+ *
19056
+ * Represents a column model specifically designed to format and display
19057
+ * risk rejection events in markdown tables.
19058
+ *
19059
+ * @typeParam RiskEvent - The risk event data type containing
19060
+ * risk rejection details, symbol, and rejection reason
19061
+ *
19062
+ * @example
19063
+ * ```typescript
19064
+ * // Column to display symbol
19065
+ * const symbolColumn: Columns = {
19066
+ * key: "symbol",
19067
+ * label: "Symbol",
19068
+ * format: (event) => event.symbol,
19069
+ * isVisible: () => true
19070
+ * };
19071
+ *
19072
+ * // Column to display rejection reason
19073
+ * const reasonColumn: Columns = {
19074
+ * key: "reason",
19075
+ * label: "Rejection Reason",
19076
+ * format: (event) => event.reason,
19077
+ * isVisible: () => true
19078
+ * };
19079
+ * ```
19080
+ *
19081
+ * @see ColumnModel for the base interface
19082
+ * @see RiskEvent for the event data structure
19083
+ */
19084
+ type Columns$3 = ColumnModel<RiskEvent>;
19085
+ /**
19086
+ * Service for generating and saving risk rejection markdown reports.
19087
+ *
19088
+ * Features:
19089
+ * - Listens to risk rejection events via riskSubject
19090
+ * - Accumulates all rejection events per symbol-strategy pair
19091
+ * - Generates markdown tables with detailed rejection information
19092
+ * - Provides statistics (total rejections, by symbol, by strategy)
19093
+ * - Saves reports to disk in dump/risk/{symbol}_{strategyName}.md
19094
+ *
19095
+ * @example
19096
+ * ```typescript
19097
+ * const service = new RiskMarkdownService();
19098
+ *
19099
+ * // Service automatically subscribes to subjects on init
19100
+ * // No manual callback setup needed
19101
+ *
19102
+ * // Later: generate and save report
19103
+ * await service.dump("BTCUSDT", "my-strategy");
19104
+ * ```
19105
+ */
19106
+ declare class RiskMarkdownService {
19107
+ /** Logger service for debug output */
19108
+ private readonly loggerService;
19109
+ /**
19110
+ * Memoized function to get or create ReportStorage for a symbol-strategy-exchange-frame-backtest combination.
19111
+ * Each combination gets its own isolated storage instance.
19112
+ */
19113
+ private getStorage;
19114
+ /**
19115
+ * Subscribes to risk rejection emitter to receive rejection events.
19116
+ * Protected against multiple subscriptions.
19117
+ * Returns an unsubscribe function to stop receiving events.
19118
+ *
19119
+ * @example
19120
+ * ```typescript
19121
+ * const service = new RiskMarkdownService();
19122
+ * const unsubscribe = service.subscribe();
19123
+ * // ... later
19124
+ * unsubscribe();
19125
+ * ```
19126
+ */
19127
+ subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
19128
+ /**
19129
+ * Unsubscribes from risk rejection emitter to stop receiving events.
19130
+ * Calls the unsubscribe function returned by subscribe().
19131
+ * If not subscribed, does nothing.
19132
+ *
19133
+ * @example
19134
+ * ```typescript
19135
+ * const service = new RiskMarkdownService();
18455
19136
  * service.subscribe();
18456
19137
  * // ... later
18457
19138
  * service.unsubscribe();
@@ -21046,12 +21727,13 @@ declare class StrategyMarkdownService {
21046
21727
  * @param context - Strategy context with strategyName, exchangeName, frameName
21047
21728
  * @param timestamp - Timestamp from StrategyCommitContract (execution context time)
21048
21729
  * @param cancelId - Optional identifier for the cancellation reason
21730
+ * @param note - Optional note from commit payload
21049
21731
  */
21050
21732
  cancelScheduled: (symbol: string, isBacktest: boolean, context: {
21051
21733
  strategyName: StrategyName;
21052
21734
  exchangeName: ExchangeName;
21053
21735
  frameName: FrameName;
21054
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, cancelId?: string) => Promise<void>;
21736
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, cancelId?: string, note?: string) => Promise<void>;
21055
21737
  /**
21056
21738
  * Records a close-pending event when a pending signal is closed.
21057
21739
  *
@@ -21060,12 +21742,13 @@ declare class StrategyMarkdownService {
21060
21742
  * @param context - Strategy context with strategyName, exchangeName, frameName
21061
21743
  * @param timestamp - Timestamp from StrategyCommitContract (execution context time)
21062
21744
  * @param closeId - Optional identifier for the close reason
21745
+ * @param note - Optional note from commit payload
21063
21746
  */
21064
21747
  closePending: (symbol: string, isBacktest: boolean, context: {
21065
21748
  strategyName: StrategyName;
21066
21749
  exchangeName: ExchangeName;
21067
21750
  frameName: FrameName;
21068
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, closeId?: string) => Promise<void>;
21751
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, closeId?: string, note?: string) => Promise<void>;
21069
21752
  /**
21070
21753
  * Records a partial-profit event when a portion of the position is closed at profit.
21071
21754
  *
@@ -21197,12 +21880,13 @@ declare class StrategyMarkdownService {
21197
21880
  * @param scheduledAt - Signal creation timestamp in milliseconds
21198
21881
  * @param pendingAt - Pending timestamp in milliseconds
21199
21882
  * @param activateId - Optional identifier for the activation reason
21883
+ * @param note - Optional note from commit payload
21200
21884
  */
21201
21885
  activateScheduled: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
21202
21886
  strategyName: StrategyName;
21203
21887
  exchangeName: ExchangeName;
21204
21888
  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>;
21889
+ }, 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
21890
  /**
21207
21891
  * Records an average-buy (DCA) event when a new averaging entry is added to an open position.
21208
21892
  *
@@ -25442,6 +26126,40 @@ declare class StrategyConnectionService implements TStrategy$1 {
25442
26126
  exchangeName: ExchangeName;
25443
26127
  frameName: FrameName;
25444
26128
  }) => Promise<number | null>;
26129
+ /**
26130
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
26131
+ *
26132
+ * Resolves current price via priceMetaService and delegates to
26133
+ * ClientStrategy.getMaxDrawdownDistancePnlPercentage().
26134
+ * Returns null if no pending signal exists.
26135
+ *
26136
+ * @param backtest - Whether running in backtest mode
26137
+ * @param symbol - Trading pair symbol
26138
+ * @param context - Execution context with strategyName, exchangeName, frameName
26139
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
26140
+ */
26141
+ getMaxDrawdownDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
26142
+ strategyName: StrategyName;
26143
+ exchangeName: ExchangeName;
26144
+ frameName: FrameName;
26145
+ }) => Promise<number | null>;
26146
+ /**
26147
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
26148
+ *
26149
+ * Resolves current price via priceMetaService and delegates to
26150
+ * ClientStrategy.getMaxDrawdownDistancePnlCost().
26151
+ * Returns null if no pending signal exists.
26152
+ *
26153
+ * @param backtest - Whether running in backtest mode
26154
+ * @param symbol - Trading pair symbol
26155
+ * @param context - Execution context with strategyName, exchangeName, frameName
26156
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
26157
+ */
26158
+ getMaxDrawdownDistancePnlCost: (backtest: boolean, symbol: string, context: {
26159
+ strategyName: StrategyName;
26160
+ exchangeName: ExchangeName;
26161
+ frameName: FrameName;
26162
+ }) => Promise<number | null>;
25445
26163
  /**
25446
26164
  * Disposes the ClientStrategy instance for the given context.
25447
26165
  *
@@ -25483,14 +26201,14 @@ declare class StrategyConnectionService implements TStrategy$1 {
25483
26201
  * @param backtest - Whether running in backtest mode
25484
26202
  * @param symbol - Trading pair symbol
25485
26203
  * @param ctx - Context with strategyName, exchangeName, frameName
25486
- * @param cancelId - Optional cancellation ID for user-initiated cancellations
26204
+ * @param payload - Optional commit payload with id and note
25487
26205
  * @returns Promise that resolves when scheduled signal is cancelled
25488
26206
  */
25489
26207
  cancelScheduled: (backtest: boolean, symbol: string, context: {
25490
26208
  strategyName: StrategyName;
25491
26209
  exchangeName: ExchangeName;
25492
26210
  frameName: FrameName;
25493
- }, cancelId?: string) => Promise<void>;
26211
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
25494
26212
  /**
25495
26213
  * Closes the pending signal without stopping the strategy.
25496
26214
  *
@@ -25504,14 +26222,14 @@ declare class StrategyConnectionService implements TStrategy$1 {
25504
26222
  * @param backtest - Whether running in backtest mode
25505
26223
  * @param symbol - Trading pair symbol
25506
26224
  * @param context - Context with strategyName, exchangeName, frameName
25507
- * @param closeId - Optional close ID for user-initiated closes
26225
+ * @param payload - Optional commit payload with id and note
25508
26226
  * @returns Promise that resolves when pending signal is closed
25509
26227
  */
25510
26228
  closePending: (backtest: boolean, symbol: string, context: {
25511
26229
  strategyName: StrategyName;
25512
26230
  exchangeName: ExchangeName;
25513
26231
  frameName: FrameName;
25514
- }, closeId?: string) => Promise<void>;
26232
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
25515
26233
  /**
25516
26234
  * Checks whether `partialProfit` would succeed without executing it.
25517
26235
  * Delegates to `ClientStrategy.validatePartialProfit()` — no throws, pure boolean result.
@@ -25763,7 +26481,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
25763
26481
  * @param backtest - Whether running in backtest mode
25764
26482
  * @param symbol - Trading pair symbol
25765
26483
  * @param context - Execution context with strategyName, exchangeName, frameName
25766
- * @param activateId - Optional identifier for the activation reason
26484
+ * @param payload - Optional commit payload with id and note
25767
26485
  * @returns Promise that resolves when activation flag is set
25768
26486
  *
25769
26487
  * @example
@@ -25773,7 +26491,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
25773
26491
  * false,
25774
26492
  * "BTCUSDT",
25775
26493
  * { strategyName: "my-strategy", exchangeName: "binance", frameName: "" },
25776
- * "manual-activation"
26494
+ * { id: "manual-activation" }
25777
26495
  * );
25778
26496
  * ```
25779
26497
  */
@@ -25781,7 +26499,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
25781
26499
  strategyName: StrategyName;
25782
26500
  exchangeName: ExchangeName;
25783
26501
  frameName: FrameName;
25784
- }, activateId?: string) => Promise<void>;
26502
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
25785
26503
  /**
25786
26504
  * Checks whether `averageBuy` would succeed without executing it.
25787
26505
  * Delegates to `ClientStrategy.validateAverageBuy()` — no throws, pure boolean result.
@@ -27023,14 +27741,14 @@ declare class StrategyCoreService implements TStrategy {
27023
27741
  * @param backtest - Whether running in backtest mode
27024
27742
  * @param symbol - Trading pair symbol
27025
27743
  * @param ctx - Context with strategyName, exchangeName, frameName
27026
- * @param cancelId - Optional cancellation ID for user-initiated cancellations
27744
+ * @param payload - Optional commit payload with id and note
27027
27745
  * @returns Promise that resolves when scheduled signal is cancelled
27028
27746
  */
27029
27747
  cancelScheduled: (backtest: boolean, symbol: string, context: {
27030
27748
  strategyName: StrategyName;
27031
27749
  exchangeName: ExchangeName;
27032
27750
  frameName: FrameName;
27033
- }, cancelId?: string) => Promise<void>;
27751
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
27034
27752
  /**
27035
27753
  * Closes the pending signal without stopping the strategy.
27036
27754
  *
@@ -27045,14 +27763,14 @@ declare class StrategyCoreService implements TStrategy {
27045
27763
  * @param backtest - Whether running in backtest mode
27046
27764
  * @param symbol - Trading pair symbol
27047
27765
  * @param context - Context with strategyName, exchangeName, frameName
27048
- * @param closeId - Optional close ID for user-initiated closes
27766
+ * @param payload - Optional commit payload with id and note
27049
27767
  * @returns Promise that resolves when pending signal is closed
27050
27768
  */
27051
27769
  closePending: (backtest: boolean, symbol: string, context: {
27052
27770
  strategyName: StrategyName;
27053
27771
  exchangeName: ExchangeName;
27054
27772
  frameName: FrameName;
27055
- }, closeId?: string) => Promise<void>;
27773
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
27056
27774
  /**
27057
27775
  * Disposes the ClientStrategy instance for the given context.
27058
27776
  *
@@ -27328,7 +28046,7 @@ declare class StrategyCoreService implements TStrategy {
27328
28046
  * @param backtest - Whether running in backtest mode
27329
28047
  * @param symbol - Trading pair symbol
27330
28048
  * @param context - Execution context with strategyName, exchangeName, frameName
27331
- * @param activateId - Optional identifier for the activation reason
28049
+ * @param payload - Optional commit payload with id and note
27332
28050
  * @returns Promise that resolves when activation flag is set
27333
28051
  *
27334
28052
  * @example
@@ -27338,7 +28056,7 @@ declare class StrategyCoreService implements TStrategy {
27338
28056
  * false,
27339
28057
  * "BTCUSDT",
27340
28058
  * { strategyName: "my-strategy", exchangeName: "binance", frameName: "" },
27341
- * "manual-activation"
28059
+ * { id: "manual-activation" }
27342
28060
  * );
27343
28061
  * ```
27344
28062
  */
@@ -27346,7 +28064,7 @@ declare class StrategyCoreService implements TStrategy {
27346
28064
  strategyName: StrategyName;
27347
28065
  exchangeName: ExchangeName;
27348
28066
  frameName: FrameName;
27349
- }, activateId?: string) => Promise<void>;
28067
+ }, payload?: Partial<CommitPayload>) => Promise<void>;
27350
28068
  /**
27351
28069
  * Checks whether `averageBuy` would succeed without executing it.
27352
28070
  * Validates context, then delegates to StrategyConnectionService.validateAverageBuy().
@@ -27677,6 +28395,38 @@ declare class StrategyCoreService implements TStrategy {
27677
28395
  exchangeName: ExchangeName;
27678
28396
  frameName: FrameName;
27679
28397
  }) => Promise<number | null>;
28398
+ /**
28399
+ * Returns the peak-to-trough PnL percentage distance between the position's highest profit and deepest drawdown.
28400
+ *
28401
+ * Delegates to StrategyConnectionService.getMaxDrawdownDistancePnlPercentage().
28402
+ * Returns null if no pending signal exists.
28403
+ *
28404
+ * @param backtest - Whether running in backtest mode
28405
+ * @param symbol - Trading pair symbol
28406
+ * @param context - Execution context with strategyName, exchangeName, frameName
28407
+ * @returns Promise resolving to peak-to-trough PnL percentage distance (≥ 0) or null
28408
+ */
28409
+ getMaxDrawdownDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
28410
+ strategyName: StrategyName;
28411
+ exchangeName: ExchangeName;
28412
+ frameName: FrameName;
28413
+ }) => Promise<number | null>;
28414
+ /**
28415
+ * Returns the peak-to-trough PnL cost distance between the position's highest profit and deepest drawdown.
28416
+ *
28417
+ * Delegates to StrategyConnectionService.getMaxDrawdownDistancePnlCost().
28418
+ * Returns null if no pending signal exists.
28419
+ *
28420
+ * @param backtest - Whether running in backtest mode
28421
+ * @param symbol - Trading pair symbol
28422
+ * @param context - Execution context with strategyName, exchangeName, frameName
28423
+ * @returns Promise resolving to peak-to-trough PnL cost distance (≥ 0) or null
28424
+ */
28425
+ getMaxDrawdownDistancePnlCost: (backtest: boolean, symbol: string, context: {
28426
+ strategyName: StrategyName;
28427
+ exchangeName: ExchangeName;
28428
+ frameName: FrameName;
28429
+ }) => Promise<number | null>;
27680
28430
  }
27681
28431
 
27682
28432
  /**
@@ -30072,7 +30822,7 @@ declare class StrategyReportService {
30072
30822
  strategyName: StrategyName;
30073
30823
  exchangeName: ExchangeName;
30074
30824
  frameName: FrameName;
30075
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, cancelId?: string) => Promise<void>;
30825
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, cancelId?: string, note?: string) => Promise<void>;
30076
30826
  /**
30077
30827
  * Logs a close-pending event when a pending signal is closed.
30078
30828
  */
@@ -30080,7 +30830,7 @@ declare class StrategyReportService {
30080
30830
  strategyName: StrategyName;
30081
30831
  exchangeName: ExchangeName;
30082
30832
  frameName: FrameName;
30083
- }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, closeId?: string) => Promise<void>;
30833
+ }, timestamp: number, signalId: string, pnl: IStrategyPnL, totalPartials: number, closeId?: string, note?: string) => Promise<void>;
30084
30834
  /**
30085
30835
  * Logs a partial-profit event when a portion of the position is closed at profit.
30086
30836
  */
@@ -30128,7 +30878,7 @@ declare class StrategyReportService {
30128
30878
  strategyName: StrategyName;
30129
30879
  exchangeName: ExchangeName;
30130
30880
  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>;
30881
+ }, 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
30882
  /**
30133
30883
  * Logs an average-buy (DCA) event when a new averaging entry is added to an open position.
30134
30884
  */
@@ -30528,4 +31278,4 @@ declare const getTotalClosed: (signal: Signal) => {
30528
31278
  remainingCostBasis: number;
30529
31279
  };
30530
31280
 
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 };
31281
+ 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, 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, 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, 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 };