backtest-kit 6.9.0 → 6.11.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/build/index.cjs +835 -111
- package/build/index.mjs +832 -112
- package/package.json +3 -3
- package/types.d.ts +478 -36
package/types.d.ts
CHANGED
|
@@ -1900,6 +1900,8 @@ interface SignalCommitBase {
|
|
|
1900
1900
|
totalPartials: number;
|
|
1901
1901
|
/** Original entry price at signal creation (unchanged by DCA averaging). */
|
|
1902
1902
|
originalPriceOpen: number;
|
|
1903
|
+
/** Optional human-readable description of signal reason */
|
|
1904
|
+
note?: string;
|
|
1903
1905
|
}
|
|
1904
1906
|
/**
|
|
1905
1907
|
* Cancel scheduled signal event.
|
|
@@ -2577,14 +2579,18 @@ interface IStrategySchema {
|
|
|
2577
2579
|
strategyName: StrategyName;
|
|
2578
2580
|
/** Optional developer note for documentation */
|
|
2579
2581
|
note?: string;
|
|
2580
|
-
/**
|
|
2581
|
-
|
|
2582
|
+
/**
|
|
2583
|
+
* Minimum interval between getSignal calls (throttling)
|
|
2584
|
+
*
|
|
2585
|
+
* Default: 1m
|
|
2586
|
+
*/
|
|
2587
|
+
interval?: SignalInterval;
|
|
2582
2588
|
/**
|
|
2583
2589
|
* Signal generation function (returns null if no signal, validated DTO if signal).
|
|
2584
2590
|
* If priceOpen is provided - becomes scheduled signal waiting for price to reach entry point.
|
|
2585
2591
|
* If priceOpen is omitted - opens immediately at current price.
|
|
2586
2592
|
*/
|
|
2587
|
-
getSignal: (symbol: string, when: Date) => Promise<ISignalDto | null>;
|
|
2593
|
+
getSignal: (symbol: string, when: Date, currentPrice: number) => Promise<ISignalDto | null>;
|
|
2588
2594
|
/** Optional lifecycle event callbacks (onOpen, onClose) */
|
|
2589
2595
|
callbacks?: Partial<IStrategyCallbacks>;
|
|
2590
2596
|
/** Optional risk profile identifier for risk management */
|
|
@@ -3630,6 +3636,46 @@ interface IStrategy {
|
|
|
3630
3636
|
* @returns Promise resolving to PnL cost or null
|
|
3631
3637
|
*/
|
|
3632
3638
|
getPositionMaxDrawdownPnlCost: (symbol: string) => Promise<number | null>;
|
|
3639
|
+
/**
|
|
3640
|
+
* Returns the distance in PnL percentage between the current price and the highest profit peak.
|
|
3641
|
+
*
|
|
3642
|
+
* Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
|
|
3643
|
+
*
|
|
3644
|
+
* @param symbol - Trading pair symbol
|
|
3645
|
+
* @param currentPrice - Current market price
|
|
3646
|
+
* @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
|
|
3647
|
+
*/
|
|
3648
|
+
getPositionHighestProfitDistancePnlPercentage: (symbol: string, currentPrice: number) => Promise<number | null>;
|
|
3649
|
+
/**
|
|
3650
|
+
* Returns the distance in PnL cost between the current price and the highest profit peak.
|
|
3651
|
+
*
|
|
3652
|
+
* Computed as: max(0, peakPnlCost - currentPnlCost).
|
|
3653
|
+
*
|
|
3654
|
+
* @param symbol - Trading pair symbol
|
|
3655
|
+
* @param currentPrice - Current market price
|
|
3656
|
+
* @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
|
|
3657
|
+
*/
|
|
3658
|
+
getPositionHighestProfitDistancePnlCost: (symbol: string, currentPrice: number) => Promise<number | null>;
|
|
3659
|
+
/**
|
|
3660
|
+
* Returns the distance in PnL percentage between the current price and the worst drawdown trough.
|
|
3661
|
+
*
|
|
3662
|
+
* Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
|
|
3663
|
+
*
|
|
3664
|
+
* @param symbol - Trading pair symbol
|
|
3665
|
+
* @param currentPrice - Current market price
|
|
3666
|
+
* @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
|
|
3667
|
+
*/
|
|
3668
|
+
getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, currentPrice: number) => Promise<number | null>;
|
|
3669
|
+
/**
|
|
3670
|
+
* Returns the distance in PnL cost between the current price and the worst drawdown trough.
|
|
3671
|
+
*
|
|
3672
|
+
* Computed as: max(0, currentPnlCost - fallPnlCost).
|
|
3673
|
+
*
|
|
3674
|
+
* @param symbol - Trading pair symbol
|
|
3675
|
+
* @param currentPrice - Current market price
|
|
3676
|
+
* @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
|
|
3677
|
+
*/
|
|
3678
|
+
getPositionHighestMaxDrawdownPnlCost: (symbol: string, currentPrice: number) => Promise<number | null>;
|
|
3633
3679
|
/**
|
|
3634
3680
|
* Disposes the strategy instance and cleans up resources.
|
|
3635
3681
|
*
|
|
@@ -5590,6 +5636,78 @@ declare function getPositionMaxDrawdownPnlPercentage(symbol: string): Promise<nu
|
|
|
5590
5636
|
* ```
|
|
5591
5637
|
*/
|
|
5592
5638
|
declare function getPositionMaxDrawdownPnlCost(symbol: string): Promise<number>;
|
|
5639
|
+
/**
|
|
5640
|
+
* Returns the distance in PnL percentage between the current price and the highest profit peak.
|
|
5641
|
+
*
|
|
5642
|
+
* Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
|
|
5643
|
+
* Returns null if no pending signal exists.
|
|
5644
|
+
*
|
|
5645
|
+
* @param symbol - Trading pair symbol
|
|
5646
|
+
* @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
|
|
5647
|
+
*
|
|
5648
|
+
* @example
|
|
5649
|
+
* ```typescript
|
|
5650
|
+
* import { getPositionHighestProfitDistancePnlPercentage } from "backtest-kit";
|
|
5651
|
+
*
|
|
5652
|
+
* const dist = await getPositionHighestProfitDistancePnlPercentage("BTCUSDT");
|
|
5653
|
+
* // e.g. 1.5 (gave back 1.5% from peak)
|
|
5654
|
+
* ```
|
|
5655
|
+
*/
|
|
5656
|
+
declare function getPositionHighestProfitDistancePnlPercentage(symbol: string): Promise<number>;
|
|
5657
|
+
/**
|
|
5658
|
+
* Returns the distance in PnL cost between the current price and the highest profit peak.
|
|
5659
|
+
*
|
|
5660
|
+
* Computed as: max(0, peakPnlCost - currentPnlCost).
|
|
5661
|
+
* Returns null if no pending signal exists.
|
|
5662
|
+
*
|
|
5663
|
+
* @param symbol - Trading pair symbol
|
|
5664
|
+
* @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
|
|
5665
|
+
*
|
|
5666
|
+
* @example
|
|
5667
|
+
* ```typescript
|
|
5668
|
+
* import { getPositionHighestProfitDistancePnlCost } from "backtest-kit";
|
|
5669
|
+
*
|
|
5670
|
+
* const dist = await getPositionHighestProfitDistancePnlCost("BTCUSDT");
|
|
5671
|
+
* // e.g. 3.2 (gave back $3.2 from peak)
|
|
5672
|
+
* ```
|
|
5673
|
+
*/
|
|
5674
|
+
declare function getPositionHighestProfitDistancePnlCost(symbol: string): Promise<number>;
|
|
5675
|
+
/**
|
|
5676
|
+
* Returns the distance in PnL percentage between the current price and the worst drawdown trough.
|
|
5677
|
+
*
|
|
5678
|
+
* Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
|
|
5679
|
+
* Returns null if no pending signal exists.
|
|
5680
|
+
*
|
|
5681
|
+
* @param symbol - Trading pair symbol
|
|
5682
|
+
* @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
|
|
5683
|
+
*
|
|
5684
|
+
* @example
|
|
5685
|
+
* ```typescript
|
|
5686
|
+
* import { getPositionHighestMaxDrawdownPnlPercentage } from "backtest-kit";
|
|
5687
|
+
*
|
|
5688
|
+
* const dist = await getPositionHighestMaxDrawdownPnlPercentage("BTCUSDT");
|
|
5689
|
+
* // e.g. 2.1 (recovered 2.1% from trough)
|
|
5690
|
+
* ```
|
|
5691
|
+
*/
|
|
5692
|
+
declare function getPositionHighestMaxDrawdownPnlPercentage(symbol: string): Promise<number>;
|
|
5693
|
+
/**
|
|
5694
|
+
* Returns the distance in PnL cost between the current price and the worst drawdown trough.
|
|
5695
|
+
*
|
|
5696
|
+
* Computed as: max(0, currentPnlCost - fallPnlCost).
|
|
5697
|
+
* Returns null if no pending signal exists.
|
|
5698
|
+
*
|
|
5699
|
+
* @param symbol - Trading pair symbol
|
|
5700
|
+
* @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
|
|
5701
|
+
*
|
|
5702
|
+
* @example
|
|
5703
|
+
* ```typescript
|
|
5704
|
+
* import { getPositionHighestMaxDrawdownPnlCost } from "backtest-kit";
|
|
5705
|
+
*
|
|
5706
|
+
* const dist = await getPositionHighestMaxDrawdownPnlCost("BTCUSDT");
|
|
5707
|
+
* // e.g. 4.8 (recovered $4.8 from trough)
|
|
5708
|
+
* ```
|
|
5709
|
+
*/
|
|
5710
|
+
declare function getPositionHighestMaxDrawdownPnlCost(symbol: string): Promise<number>;
|
|
5593
5711
|
/**
|
|
5594
5712
|
* Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
|
|
5595
5713
|
* Use this to prevent duplicate DCA entries at the same price area.
|
|
@@ -9061,7 +9179,7 @@ interface IRunContext extends IMethodContext, IExecutionContext {
|
|
|
9061
9179
|
*
|
|
9062
9180
|
* @template T - Return type of the function.
|
|
9063
9181
|
*/
|
|
9064
|
-
type Function$
|
|
9182
|
+
type Function$2<T extends unknown = any> = () => T | Promise<T>;
|
|
9065
9183
|
/**
|
|
9066
9184
|
* Runs a function inside a mock method and execution context.
|
|
9067
9185
|
*
|
|
@@ -9089,7 +9207,7 @@ type Function$1<T extends unknown = any> = () => T | Promise<T>;
|
|
|
9089
9207
|
* );
|
|
9090
9208
|
* ```
|
|
9091
9209
|
*/
|
|
9092
|
-
declare function runInMockContext<T extends unknown = any>(run: Function$
|
|
9210
|
+
declare function runInMockContext<T extends unknown = any>(run: Function$2<T>, { exchangeName, frameName, strategyName, symbol, backtest: isBacktest, when, }: Partial<IRunContext>): Promise<T>;
|
|
9093
9211
|
|
|
9094
9212
|
/**
|
|
9095
9213
|
* Portfolio heatmap statistics for a single symbol.
|
|
@@ -9353,6 +9471,8 @@ interface PartialProfitAvailableNotification {
|
|
|
9353
9471
|
pnlCost: number;
|
|
9354
9472
|
/** Total invested capital in USD */
|
|
9355
9473
|
pnlEntries: number;
|
|
9474
|
+
/** Optional human-readable description of signal reason */
|
|
9475
|
+
note?: string;
|
|
9356
9476
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9357
9477
|
scheduledAt: number;
|
|
9358
9478
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9415,6 +9535,8 @@ interface PartialLossAvailableNotification {
|
|
|
9415
9535
|
pnlCost: number;
|
|
9416
9536
|
/** Total invested capital in USD */
|
|
9417
9537
|
pnlEntries: number;
|
|
9538
|
+
/** Optional human-readable description of signal reason */
|
|
9539
|
+
note?: string;
|
|
9418
9540
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9419
9541
|
scheduledAt: number;
|
|
9420
9542
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9475,6 +9597,8 @@ interface BreakevenAvailableNotification {
|
|
|
9475
9597
|
pnlCost: number;
|
|
9476
9598
|
/** Total invested capital in USD */
|
|
9477
9599
|
pnlEntries: number;
|
|
9600
|
+
/** Optional human-readable description of signal reason */
|
|
9601
|
+
note?: string;
|
|
9478
9602
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9479
9603
|
scheduledAt: number;
|
|
9480
9604
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9537,6 +9661,8 @@ interface PartialProfitCommitNotification {
|
|
|
9537
9661
|
pnlCost: number;
|
|
9538
9662
|
/** Total invested capital in USD */
|
|
9539
9663
|
pnlEntries: number;
|
|
9664
|
+
/** Optional human-readable description of signal reason */
|
|
9665
|
+
note?: string;
|
|
9540
9666
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9541
9667
|
scheduledAt: number;
|
|
9542
9668
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9599,6 +9725,8 @@ interface PartialLossCommitNotification {
|
|
|
9599
9725
|
pnlCost: number;
|
|
9600
9726
|
/** Total invested capital in USD */
|
|
9601
9727
|
pnlEntries: number;
|
|
9728
|
+
/** Optional human-readable description of signal reason */
|
|
9729
|
+
note?: string;
|
|
9602
9730
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9603
9731
|
scheduledAt: number;
|
|
9604
9732
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9659,6 +9787,8 @@ interface BreakevenCommitNotification {
|
|
|
9659
9787
|
pnlCost: number;
|
|
9660
9788
|
/** Total invested capital in USD */
|
|
9661
9789
|
pnlEntries: number;
|
|
9790
|
+
/** Optional human-readable description of signal reason */
|
|
9791
|
+
note?: string;
|
|
9662
9792
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9663
9793
|
scheduledAt: number;
|
|
9664
9794
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9723,6 +9853,8 @@ interface AverageBuyCommitNotification {
|
|
|
9723
9853
|
pnlCost: number;
|
|
9724
9854
|
/** Total invested capital in USD */
|
|
9725
9855
|
pnlEntries: number;
|
|
9856
|
+
/** Optional human-readable description of signal reason */
|
|
9857
|
+
note?: string;
|
|
9726
9858
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9727
9859
|
scheduledAt: number;
|
|
9728
9860
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9789,6 +9921,8 @@ interface ActivateScheduledCommitNotification {
|
|
|
9789
9921
|
pendingAt: number;
|
|
9790
9922
|
/** Current market price when activation was executed */
|
|
9791
9923
|
currentPrice: number;
|
|
9924
|
+
/** Optional human-readable description of signal reason */
|
|
9925
|
+
note?: string;
|
|
9792
9926
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
9793
9927
|
createdAt: number;
|
|
9794
9928
|
}
|
|
@@ -9847,6 +9981,8 @@ interface TrailingStopCommitNotification {
|
|
|
9847
9981
|
pnlCost: number;
|
|
9848
9982
|
/** Total invested capital in USD */
|
|
9849
9983
|
pnlEntries: number;
|
|
9984
|
+
/** Optional human-readable description of signal reason */
|
|
9985
|
+
note?: string;
|
|
9850
9986
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9851
9987
|
scheduledAt: number;
|
|
9852
9988
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9909,6 +10045,8 @@ interface TrailingTakeCommitNotification {
|
|
|
9909
10045
|
pnlCost: number;
|
|
9910
10046
|
/** Total invested capital in USD */
|
|
9911
10047
|
pnlEntries: number;
|
|
10048
|
+
/** Optional human-readable description of signal reason */
|
|
10049
|
+
note?: string;
|
|
9912
10050
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
9913
10051
|
scheduledAt: number;
|
|
9914
10052
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -9975,6 +10113,8 @@ interface SignalSyncOpenNotification {
|
|
|
9975
10113
|
scheduledAt: number;
|
|
9976
10114
|
/** Position activation timestamp in milliseconds */
|
|
9977
10115
|
pendingAt: number;
|
|
10116
|
+
/** Optional human-readable description of signal reason */
|
|
10117
|
+
note?: string;
|
|
9978
10118
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
9979
10119
|
createdAt: number;
|
|
9980
10120
|
}
|
|
@@ -10037,6 +10177,8 @@ interface SignalSyncCloseNotification {
|
|
|
10037
10177
|
pendingAt: number;
|
|
10038
10178
|
/** Why the signal was closed (take_profit | stop_loss | time_expired | closed) */
|
|
10039
10179
|
closeReason: string;
|
|
10180
|
+
/** Optional human-readable description of signal reason */
|
|
10181
|
+
note?: string;
|
|
10040
10182
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
10041
10183
|
createdAt: number;
|
|
10042
10184
|
}
|
|
@@ -10141,6 +10283,8 @@ interface SignalScheduledNotification {
|
|
|
10141
10283
|
scheduledAt: number;
|
|
10142
10284
|
/** Current market price when signal was scheduled */
|
|
10143
10285
|
currentPrice: number;
|
|
10286
|
+
/** Optional human-readable description of signal reason */
|
|
10287
|
+
note?: string;
|
|
10144
10288
|
/** Unix timestamp in milliseconds when the tick result was created (from candle timestamp in backtest or execution context when in live) */
|
|
10145
10289
|
createdAt: number;
|
|
10146
10290
|
}
|
|
@@ -10193,6 +10337,8 @@ interface SignalCancelledNotification {
|
|
|
10193
10337
|
scheduledAt: number;
|
|
10194
10338
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
10195
10339
|
pendingAt: number;
|
|
10340
|
+
/** Optional human-readable description of signal reason */
|
|
10341
|
+
note?: string;
|
|
10196
10342
|
/** Unix timestamp in milliseconds when the tick result was created (from candle timestamp in backtest or execution context when in live) */
|
|
10197
10343
|
createdAt: number;
|
|
10198
10344
|
}
|
|
@@ -10285,6 +10431,8 @@ interface CancelScheduledCommitNotification {
|
|
|
10285
10431
|
pnlCost: number;
|
|
10286
10432
|
/** Total invested capital in USD */
|
|
10287
10433
|
pnlEntries: number;
|
|
10434
|
+
/** Optional human-readable description of signal reason */
|
|
10435
|
+
note?: string;
|
|
10288
10436
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
10289
10437
|
createdAt: number;
|
|
10290
10438
|
}
|
|
@@ -10329,6 +10477,8 @@ interface ClosePendingCommitNotification {
|
|
|
10329
10477
|
pnlCost: number;
|
|
10330
10478
|
/** Total invested capital in USD */
|
|
10331
10479
|
pnlEntries: number;
|
|
10480
|
+
/** Optional human-readable description of signal reason */
|
|
10481
|
+
note?: string;
|
|
10332
10482
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
10333
10483
|
createdAt: number;
|
|
10334
10484
|
}
|
|
@@ -13899,6 +14049,66 @@ declare class BacktestUtils {
|
|
|
13899
14049
|
exchangeName: ExchangeName;
|
|
13900
14050
|
frameName: FrameName;
|
|
13901
14051
|
}) => Promise<number>;
|
|
14052
|
+
/**
|
|
14053
|
+
* Returns the distance in PnL percentage between the current price and the highest profit peak.
|
|
14054
|
+
*
|
|
14055
|
+
* Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
|
|
14056
|
+
* Returns null if no pending signal exists.
|
|
14057
|
+
*
|
|
14058
|
+
* @param symbol - Trading pair symbol
|
|
14059
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
14060
|
+
* @returns drawdown distance in PnL% (≥ 0) or null if no active position
|
|
14061
|
+
*/
|
|
14062
|
+
getPositionHighestProfitDistancePnlPercentage: (symbol: string, context: {
|
|
14063
|
+
strategyName: StrategyName;
|
|
14064
|
+
exchangeName: ExchangeName;
|
|
14065
|
+
frameName: FrameName;
|
|
14066
|
+
}) => Promise<number>;
|
|
14067
|
+
/**
|
|
14068
|
+
* Returns the distance in PnL cost between the current price and the highest profit peak.
|
|
14069
|
+
*
|
|
14070
|
+
* Computed as: max(0, peakPnlCost - currentPnlCost).
|
|
14071
|
+
* Returns null if no pending signal exists.
|
|
14072
|
+
*
|
|
14073
|
+
* @param symbol - Trading pair symbol
|
|
14074
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
14075
|
+
* @returns drawdown distance in PnL cost (≥ 0) or null if no active position
|
|
14076
|
+
*/
|
|
14077
|
+
getPositionHighestProfitDistancePnlCost: (symbol: string, context: {
|
|
14078
|
+
strategyName: StrategyName;
|
|
14079
|
+
exchangeName: ExchangeName;
|
|
14080
|
+
frameName: FrameName;
|
|
14081
|
+
}) => Promise<number>;
|
|
14082
|
+
/**
|
|
14083
|
+
* Returns the distance in PnL percentage between the current price and the worst drawdown trough.
|
|
14084
|
+
*
|
|
14085
|
+
* Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
|
|
14086
|
+
* Returns null if no pending signal exists.
|
|
14087
|
+
*
|
|
14088
|
+
* @param symbol - Trading pair symbol
|
|
14089
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
14090
|
+
* @returns recovery distance in PnL% (≥ 0) or null if no active position
|
|
14091
|
+
*/
|
|
14092
|
+
getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, context: {
|
|
14093
|
+
strategyName: StrategyName;
|
|
14094
|
+
exchangeName: ExchangeName;
|
|
14095
|
+
frameName: FrameName;
|
|
14096
|
+
}) => Promise<number>;
|
|
14097
|
+
/**
|
|
14098
|
+
* Returns the distance in PnL cost between the current price and the worst drawdown trough.
|
|
14099
|
+
*
|
|
14100
|
+
* Computed as: max(0, currentPnlCost - fallPnlCost).
|
|
14101
|
+
* Returns null if no pending signal exists.
|
|
14102
|
+
*
|
|
14103
|
+
* @param symbol - Trading pair symbol
|
|
14104
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
14105
|
+
* @returns recovery distance in PnL cost (≥ 0) or null if no active position
|
|
14106
|
+
*/
|
|
14107
|
+
getPositionHighestMaxDrawdownPnlCost: (symbol: string, context: {
|
|
14108
|
+
strategyName: StrategyName;
|
|
14109
|
+
exchangeName: ExchangeName;
|
|
14110
|
+
frameName: FrameName;
|
|
14111
|
+
}) => Promise<number>;
|
|
13902
14112
|
/**
|
|
13903
14113
|
* Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
|
|
13904
14114
|
* Use this to prevent duplicate DCA entries at the same price area.
|
|
@@ -15257,6 +15467,62 @@ declare class LiveUtils {
|
|
|
15257
15467
|
strategyName: StrategyName;
|
|
15258
15468
|
exchangeName: ExchangeName;
|
|
15259
15469
|
}) => Promise<number>;
|
|
15470
|
+
/**
|
|
15471
|
+
* Returns the distance in PnL percentage between the current price and the highest profit peak.
|
|
15472
|
+
*
|
|
15473
|
+
* Computed as: max(0, peakPnlPercentage - currentPnlPercentage).
|
|
15474
|
+
* Returns null if no pending signal exists.
|
|
15475
|
+
*
|
|
15476
|
+
* @param symbol - Trading pair symbol
|
|
15477
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
15478
|
+
* @returns drawdown distance in PnL% (≥ 0) or null if no active position
|
|
15479
|
+
*/
|
|
15480
|
+
getPositionHighestProfitDistancePnlPercentage: (symbol: string, context: {
|
|
15481
|
+
strategyName: StrategyName;
|
|
15482
|
+
exchangeName: ExchangeName;
|
|
15483
|
+
}) => Promise<number>;
|
|
15484
|
+
/**
|
|
15485
|
+
* Returns the distance in PnL cost between the current price and the highest profit peak.
|
|
15486
|
+
*
|
|
15487
|
+
* Computed as: max(0, peakPnlCost - currentPnlCost).
|
|
15488
|
+
* Returns null if no pending signal exists.
|
|
15489
|
+
*
|
|
15490
|
+
* @param symbol - Trading pair symbol
|
|
15491
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
15492
|
+
* @returns drawdown distance in PnL cost (≥ 0) or null if no active position
|
|
15493
|
+
*/
|
|
15494
|
+
getPositionHighestProfitDistancePnlCost: (symbol: string, context: {
|
|
15495
|
+
strategyName: StrategyName;
|
|
15496
|
+
exchangeName: ExchangeName;
|
|
15497
|
+
}) => Promise<number>;
|
|
15498
|
+
/**
|
|
15499
|
+
* Returns the distance in PnL percentage between the current price and the worst drawdown trough.
|
|
15500
|
+
*
|
|
15501
|
+
* Computed as: max(0, currentPnlPercentage - fallPnlPercentage).
|
|
15502
|
+
* Returns null if no pending signal exists.
|
|
15503
|
+
*
|
|
15504
|
+
* @param symbol - Trading pair symbol
|
|
15505
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
15506
|
+
* @returns recovery distance in PnL% (≥ 0) or null if no active position
|
|
15507
|
+
*/
|
|
15508
|
+
getPositionHighestMaxDrawdownPnlPercentage: (symbol: string, context: {
|
|
15509
|
+
strategyName: StrategyName;
|
|
15510
|
+
exchangeName: ExchangeName;
|
|
15511
|
+
}) => Promise<number>;
|
|
15512
|
+
/**
|
|
15513
|
+
* Returns the distance in PnL cost between the current price and the worst drawdown trough.
|
|
15514
|
+
*
|
|
15515
|
+
* Computed as: max(0, currentPnlCost - fallPnlCost).
|
|
15516
|
+
* Returns null if no pending signal exists.
|
|
15517
|
+
*
|
|
15518
|
+
* @param symbol - Trading pair symbol
|
|
15519
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
15520
|
+
* @returns recovery distance in PnL cost (≥ 0) or null if no active position
|
|
15521
|
+
*/
|
|
15522
|
+
getPositionHighestMaxDrawdownPnlCost: (symbol: string, context: {
|
|
15523
|
+
strategyName: StrategyName;
|
|
15524
|
+
exchangeName: ExchangeName;
|
|
15525
|
+
}) => Promise<number>;
|
|
15260
15526
|
/**
|
|
15261
15527
|
* Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
|
|
15262
15528
|
* Use this to prevent duplicate DCA entries at the same price area.
|
|
@@ -19989,7 +20255,7 @@ declare const Exchange: ExchangeUtils;
|
|
|
19989
20255
|
* Generic function type that accepts any arguments and returns any value.
|
|
19990
20256
|
* Used as a constraint for cached functions.
|
|
19991
20257
|
*/
|
|
19992
|
-
type Function = (...args: any[]) => any;
|
|
20258
|
+
type Function$1 = (...args: any[]) => any;
|
|
19993
20259
|
/**
|
|
19994
20260
|
* Async function type for file-cached functions.
|
|
19995
20261
|
* First argument is always `symbol: string`, followed by optional spread args.
|
|
@@ -20000,7 +20266,7 @@ type CacheFileFunction = (symbol: string, ...args: any[]) => Promise<any>;
|
|
|
20000
20266
|
* For example, for a function type `(symbol: string, arg1: number, arg2: string) => Promise<void>`,
|
|
20001
20267
|
* this type will infer the rest of the arguments as `[arg1: number, arg2: string]`.
|
|
20002
20268
|
*/
|
|
20003
|
-
type DropFirst<T extends (...args: any) => any> = T extends (first: any, ...rest: infer R) => any ? R : never;
|
|
20269
|
+
type DropFirst$1<T extends (...args: any) => any> = T extends (first: any, ...rest: infer R) => any ? R : never;
|
|
20004
20270
|
/**
|
|
20005
20271
|
* Extracts the `key` generator argument tuple from a `CacheFileFunction`.
|
|
20006
20272
|
* The first two arguments are always `symbol: string` and `alignMs: number` (aligned timestamp),
|
|
@@ -20012,7 +20278,7 @@ type DropFirst<T extends (...args: any) => any> = T extends (first: any, ...rest
|
|
|
20012
20278
|
type CacheFileKeyArgs<T extends CacheFileFunction> = [
|
|
20013
20279
|
symbol: string,
|
|
20014
20280
|
alignMs: number,
|
|
20015
|
-
...rest: DropFirst<T>
|
|
20281
|
+
...rest: DropFirst$1<T>
|
|
20016
20282
|
];
|
|
20017
20283
|
/**
|
|
20018
20284
|
* Utility class for function caching with timeframe-based invalidation.
|
|
@@ -20073,7 +20339,7 @@ declare class CacheUtils {
|
|
|
20073
20339
|
* const result3 = cachedCalculate("BTCUSDT", 14); // Cached (same key, same interval)
|
|
20074
20340
|
* ```
|
|
20075
20341
|
*/
|
|
20076
|
-
fn: <T extends Function, K = symbol>(run: T, context: {
|
|
20342
|
+
fn: <T extends Function$1, K = symbol>(run: T, context: {
|
|
20077
20343
|
interval: CandleInterval;
|
|
20078
20344
|
key?: (args: Parameters<T>) => K;
|
|
20079
20345
|
}) => T & {
|
|
@@ -20143,13 +20409,19 @@ declare class CacheUtils {
|
|
|
20143
20409
|
* Cache.dispose(calculateIndicator);
|
|
20144
20410
|
* ```
|
|
20145
20411
|
*/
|
|
20146
|
-
dispose: <T extends Function>(run: T) => void;
|
|
20412
|
+
dispose: <T extends Function$1>(run: T) => void;
|
|
20147
20413
|
/**
|
|
20148
20414
|
* Clears all memoized CacheFnInstance and CacheFileInstance objects.
|
|
20149
20415
|
* Call this when process.cwd() changes between strategy iterations
|
|
20150
20416
|
* so new instances are created with the updated base path.
|
|
20151
20417
|
*/
|
|
20152
20418
|
clear: () => void;
|
|
20419
|
+
/**
|
|
20420
|
+
* Resets the CacheFileInstance index counter to zero.
|
|
20421
|
+
* This is useful when process.cwd() changes between strategy iterations to ensure
|
|
20422
|
+
* that new CacheFileInstance objects start with index 0 and do not collide with old instances.
|
|
20423
|
+
*/
|
|
20424
|
+
resetCounter: () => void;
|
|
20153
20425
|
}
|
|
20154
20426
|
/**
|
|
20155
20427
|
* Singleton instance of CacheUtils for convenient function caching.
|
|
@@ -20168,18 +20440,34 @@ declare class CacheUtils {
|
|
|
20168
20440
|
declare const Cache: CacheUtils;
|
|
20169
20441
|
|
|
20170
20442
|
/**
|
|
20171
|
-
*
|
|
20172
|
-
*
|
|
20173
|
-
* Must return a non-null `ISignalIntervalDto` to start the interval countdown,
|
|
20174
|
-
* or `null` to defer firing until the next call.
|
|
20443
|
+
* Generic function type that accepts any arguments and returns any value.
|
|
20444
|
+
* Used as a constraint for interval functions.
|
|
20175
20445
|
*/
|
|
20176
|
-
type
|
|
20446
|
+
type Function = (...args: any[]) => any;
|
|
20177
20447
|
/**
|
|
20178
|
-
*
|
|
20448
|
+
* Async function type for file-interval functions.
|
|
20179
20449
|
* First argument is always `symbol: string`, followed by optional spread args.
|
|
20180
|
-
* Fired state survives process restarts via `PersistIntervalAdapter`.
|
|
20181
20450
|
*/
|
|
20182
|
-
type
|
|
20451
|
+
type IntervalFileFunction = (symbol: string, ...args: any[]) => Promise<any>;
|
|
20452
|
+
/**
|
|
20453
|
+
* Utility type to drop the first argument from a function type.
|
|
20454
|
+
* For example, for `(symbol: string, arg1: number, arg2: string) => Promise<void>`,
|
|
20455
|
+
* this will infer `[arg1: number, arg2: string]`.
|
|
20456
|
+
*/
|
|
20457
|
+
type DropFirst<T extends (...args: any) => any> = T extends (first: any, ...rest: infer R) => any ? R : never;
|
|
20458
|
+
/**
|
|
20459
|
+
* Extracts the `key` generator argument tuple from an `IntervalFileFunction`.
|
|
20460
|
+
* The first two arguments are always `symbol: string` and `alignMs: number` (aligned timestamp),
|
|
20461
|
+
* followed by the rest of the original function's arguments.
|
|
20462
|
+
*
|
|
20463
|
+
* For example, for `(symbol: string, arg1: number) => Promise<void>`,
|
|
20464
|
+
* this will produce `[symbol: string, alignMs: number, arg1: number]`.
|
|
20465
|
+
*/
|
|
20466
|
+
type IntervalFileKeyArgs<T extends IntervalFileFunction> = [
|
|
20467
|
+
symbol: string,
|
|
20468
|
+
alignMs: number,
|
|
20469
|
+
...rest: DropFirst<T>
|
|
20470
|
+
];
|
|
20183
20471
|
/**
|
|
20184
20472
|
* Utility class for wrapping signal functions with once-per-interval firing.
|
|
20185
20473
|
* Provides two modes: in-memory (`fn`) and persistent file-based (`file`).
|
|
@@ -20190,8 +20478,8 @@ type TIntervalFileFn = (symbol: string, ...args: any[]) => Promise<ISignalInterv
|
|
|
20190
20478
|
* import { Interval } from "./classes/Interval";
|
|
20191
20479
|
*
|
|
20192
20480
|
* const fireOncePerHour = Interval.fn(mySignalFn, { interval: "1h" });
|
|
20193
|
-
* await fireOncePerHour("BTCUSDT"
|
|
20194
|
-
* await fireOncePerHour("BTCUSDT"
|
|
20481
|
+
* await fireOncePerHour("BTCUSDT"); // fn called — returns its result
|
|
20482
|
+
* await fireOncePerHour("BTCUSDT"); // returns null (same interval)
|
|
20195
20483
|
* ```
|
|
20196
20484
|
*/
|
|
20197
20485
|
declare class IntervalUtils {
|
|
@@ -20216,20 +20504,31 @@ declare class IntervalUtils {
|
|
|
20216
20504
|
*
|
|
20217
20505
|
* @param run - Signal function to wrap
|
|
20218
20506
|
* @param context.interval - Candle interval that controls the firing boundary
|
|
20219
|
-
* @
|
|
20507
|
+
* @param context.key - Optional key generator for argument-based state separation
|
|
20508
|
+
* @returns Wrapped function with the same signature as `F`, plus a `clear()` method
|
|
20220
20509
|
*
|
|
20221
20510
|
* @example
|
|
20222
20511
|
* ```typescript
|
|
20512
|
+
* // Without extra args
|
|
20223
20513
|
* const fireOnce = Interval.fn(mySignalFn, { interval: "15m" });
|
|
20514
|
+
* await fireOnce("BTCUSDT"); // → T or null (fn called)
|
|
20515
|
+
* await fireOnce("BTCUSDT"); // → null (same interval, skipped)
|
|
20224
20516
|
*
|
|
20225
|
-
*
|
|
20226
|
-
*
|
|
20517
|
+
* // With extra args and key
|
|
20518
|
+
* const fireOnce = Interval.fn(mySignalFn, {
|
|
20519
|
+
* interval: "15m",
|
|
20520
|
+
* key: ([symbol, period]) => `${symbol}_${period}`,
|
|
20521
|
+
* });
|
|
20522
|
+
* await fireOnce("BTCUSDT", 14); // → T or null
|
|
20523
|
+
* await fireOnce("BTCUSDT", 28); // → T or null (separate state)
|
|
20227
20524
|
* ```
|
|
20228
20525
|
*/
|
|
20229
|
-
fn: (run:
|
|
20526
|
+
fn: <F extends Function>(run: F, context: {
|
|
20230
20527
|
interval: CandleInterval;
|
|
20231
|
-
|
|
20528
|
+
key?: (args: Parameters<F>) => string;
|
|
20529
|
+
}) => F & {
|
|
20232
20530
|
clear(): void;
|
|
20531
|
+
gc(): number | undefined;
|
|
20233
20532
|
};
|
|
20234
20533
|
/**
|
|
20235
20534
|
* Wrap an async signal function with persistent file-based once-per-interval firing.
|
|
@@ -20241,24 +20540,30 @@ declare class IntervalUtils {
|
|
|
20241
20540
|
* The `run` function reference is used as the memoization key for the underlying
|
|
20242
20541
|
* `IntervalFileInstance`, so each unique function reference gets its own isolated instance.
|
|
20243
20542
|
*
|
|
20244
|
-
* @template
|
|
20543
|
+
* @template F - Concrete async function type
|
|
20245
20544
|
* @param run - Async signal function to wrap with persistent once-per-interval firing
|
|
20246
20545
|
* @param context.interval - Candle interval that controls the firing boundary
|
|
20247
20546
|
* @param context.name - Human-readable bucket name; becomes the directory prefix
|
|
20248
|
-
* @
|
|
20249
|
-
*
|
|
20547
|
+
* @param context.key - Optional entity key generator. Receives `[symbol, alignMs, ...rest]`.
|
|
20548
|
+
* Default: `([symbol, alignMs]) => \`${symbol}_${alignMs}\``
|
|
20549
|
+
* @returns Wrapped function with the same signature as `F`, plus an async `clear()` method
|
|
20250
20550
|
*
|
|
20251
20551
|
* @example
|
|
20252
20552
|
* ```typescript
|
|
20253
20553
|
* const fetchSignal = async (symbol: string, period: number) => { ... };
|
|
20254
|
-
* const fireOnce = Interval.file(fetchSignal, {
|
|
20255
|
-
*
|
|
20554
|
+
* const fireOnce = Interval.file(fetchSignal, {
|
|
20555
|
+
* interval: "1h",
|
|
20556
|
+
* name: "fetchSignal",
|
|
20557
|
+
* key: ([symbol, alignMs, period]) => `${symbol}_${alignMs}_${period}`,
|
|
20558
|
+
* });
|
|
20559
|
+
* await fireOnce("BTCUSDT", 14);
|
|
20256
20560
|
* ```
|
|
20257
20561
|
*/
|
|
20258
|
-
file: <
|
|
20562
|
+
file: <F extends IntervalFileFunction>(run: F, context: {
|
|
20259
20563
|
interval: CandleInterval;
|
|
20260
20564
|
name: string;
|
|
20261
|
-
|
|
20565
|
+
key?: (args: IntervalFileKeyArgs<F>) => string;
|
|
20566
|
+
}) => F & {
|
|
20262
20567
|
clear(): Promise<void>;
|
|
20263
20568
|
};
|
|
20264
20569
|
/**
|
|
@@ -20276,14 +20581,19 @@ declare class IntervalUtils {
|
|
|
20276
20581
|
* Interval.dispose(mySignalFn);
|
|
20277
20582
|
* ```
|
|
20278
20583
|
*/
|
|
20279
|
-
dispose: (run:
|
|
20584
|
+
dispose: (run: Function) => void;
|
|
20280
20585
|
/**
|
|
20281
|
-
* Clears all memoized `IntervalFnInstance` and `IntervalFileInstance` objects
|
|
20282
|
-
* resets the `IntervalFileInstance` index counter.
|
|
20586
|
+
* Clears all memoized `IntervalFnInstance` and `IntervalFileInstance` objects.
|
|
20283
20587
|
* Call this when `process.cwd()` changes between strategy iterations
|
|
20284
20588
|
* so new instances are created with the updated base path.
|
|
20285
20589
|
*/
|
|
20286
20590
|
clear: () => void;
|
|
20591
|
+
/**
|
|
20592
|
+
* Resets the IntervalFileInstance index counter to zero.
|
|
20593
|
+
* This is useful when process.cwd() changes between strategy iterations to ensure
|
|
20594
|
+
* that new IntervalFileInstance objects start with index 0 and do not collide with old instances.
|
|
20595
|
+
*/
|
|
20596
|
+
resetCounter: () => void;
|
|
20287
20597
|
}
|
|
20288
20598
|
/**
|
|
20289
20599
|
* Singleton instance of `IntervalUtils` for convenient once-per-interval signal firing.
|
|
@@ -25064,6 +25374,74 @@ declare class StrategyConnectionService implements TStrategy$1 {
|
|
|
25064
25374
|
exchangeName: ExchangeName;
|
|
25065
25375
|
frameName: FrameName;
|
|
25066
25376
|
}) => Promise<number | null>;
|
|
25377
|
+
/**
|
|
25378
|
+
* Returns the distance in PnL percentage between the current price and the highest profit peak.
|
|
25379
|
+
*
|
|
25380
|
+
* Resolves current price via priceMetaService and delegates to
|
|
25381
|
+
* ClientStrategy.getPositionHighestProfitDistancePnlPercentage().
|
|
25382
|
+
* Returns null if no pending signal exists.
|
|
25383
|
+
*
|
|
25384
|
+
* @param backtest - Whether running in backtest mode
|
|
25385
|
+
* @param symbol - Trading pair symbol
|
|
25386
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25387
|
+
* @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
|
|
25388
|
+
*/
|
|
25389
|
+
getPositionHighestProfitDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
|
|
25390
|
+
strategyName: StrategyName;
|
|
25391
|
+
exchangeName: ExchangeName;
|
|
25392
|
+
frameName: FrameName;
|
|
25393
|
+
}) => Promise<number | null>;
|
|
25394
|
+
/**
|
|
25395
|
+
* Returns the distance in PnL cost between the current price and the highest profit peak.
|
|
25396
|
+
*
|
|
25397
|
+
* Resolves current price via priceMetaService and delegates to
|
|
25398
|
+
* ClientStrategy.getPositionHighestProfitDistancePnlCost().
|
|
25399
|
+
* Returns null if no pending signal exists.
|
|
25400
|
+
*
|
|
25401
|
+
* @param backtest - Whether running in backtest mode
|
|
25402
|
+
* @param symbol - Trading pair symbol
|
|
25403
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25404
|
+
* @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
|
|
25405
|
+
*/
|
|
25406
|
+
getPositionHighestProfitDistancePnlCost: (backtest: boolean, symbol: string, context: {
|
|
25407
|
+
strategyName: StrategyName;
|
|
25408
|
+
exchangeName: ExchangeName;
|
|
25409
|
+
frameName: FrameName;
|
|
25410
|
+
}) => Promise<number | null>;
|
|
25411
|
+
/**
|
|
25412
|
+
* Returns the distance in PnL percentage between the current price and the worst drawdown trough.
|
|
25413
|
+
*
|
|
25414
|
+
* Resolves current price via priceMetaService and delegates to
|
|
25415
|
+
* ClientStrategy.getPositionHighestMaxDrawdownPnlPercentage().
|
|
25416
|
+
* Returns null if no pending signal exists.
|
|
25417
|
+
*
|
|
25418
|
+
* @param backtest - Whether running in backtest mode
|
|
25419
|
+
* @param symbol - Trading pair symbol
|
|
25420
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25421
|
+
* @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
|
|
25422
|
+
*/
|
|
25423
|
+
getPositionHighestMaxDrawdownPnlPercentage: (backtest: boolean, symbol: string, context: {
|
|
25424
|
+
strategyName: StrategyName;
|
|
25425
|
+
exchangeName: ExchangeName;
|
|
25426
|
+
frameName: FrameName;
|
|
25427
|
+
}) => Promise<number | null>;
|
|
25428
|
+
/**
|
|
25429
|
+
* Returns the distance in PnL cost between the current price and the worst drawdown trough.
|
|
25430
|
+
*
|
|
25431
|
+
* Resolves current price via priceMetaService and delegates to
|
|
25432
|
+
* ClientStrategy.getPositionHighestMaxDrawdownPnlCost().
|
|
25433
|
+
* Returns null if no pending signal exists.
|
|
25434
|
+
*
|
|
25435
|
+
* @param backtest - Whether running in backtest mode
|
|
25436
|
+
* @param symbol - Trading pair symbol
|
|
25437
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25438
|
+
* @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
|
|
25439
|
+
*/
|
|
25440
|
+
getPositionHighestMaxDrawdownPnlCost: (backtest: boolean, symbol: string, context: {
|
|
25441
|
+
strategyName: StrategyName;
|
|
25442
|
+
exchangeName: ExchangeName;
|
|
25443
|
+
frameName: FrameName;
|
|
25444
|
+
}) => Promise<number | null>;
|
|
25067
25445
|
/**
|
|
25068
25446
|
* Disposes the ClientStrategy instance for the given context.
|
|
25069
25447
|
*
|
|
@@ -27235,6 +27613,70 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
27235
27613
|
exchangeName: ExchangeName;
|
|
27236
27614
|
frameName: FrameName;
|
|
27237
27615
|
}) => Promise<number | null>;
|
|
27616
|
+
/**
|
|
27617
|
+
* Returns the distance in PnL percentage between the current price and the highest profit peak.
|
|
27618
|
+
*
|
|
27619
|
+
* Delegates to StrategyConnectionService.getPositionHighestProfitDistancePnlPercentage().
|
|
27620
|
+
* Returns null if no pending signal exists.
|
|
27621
|
+
*
|
|
27622
|
+
* @param backtest - Whether running in backtest mode
|
|
27623
|
+
* @param symbol - Trading pair symbol
|
|
27624
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
27625
|
+
* @returns Promise resolving to drawdown distance in PnL% (≥ 0) or null
|
|
27626
|
+
*/
|
|
27627
|
+
getPositionHighestProfitDistancePnlPercentage: (backtest: boolean, symbol: string, context: {
|
|
27628
|
+
strategyName: StrategyName;
|
|
27629
|
+
exchangeName: ExchangeName;
|
|
27630
|
+
frameName: FrameName;
|
|
27631
|
+
}) => Promise<number | null>;
|
|
27632
|
+
/**
|
|
27633
|
+
* Returns the distance in PnL cost between the current price and the highest profit peak.
|
|
27634
|
+
*
|
|
27635
|
+
* Delegates to StrategyConnectionService.getPositionHighestProfitDistancePnlCost().
|
|
27636
|
+
* Returns null if no pending signal exists.
|
|
27637
|
+
*
|
|
27638
|
+
* @param backtest - Whether running in backtest mode
|
|
27639
|
+
* @param symbol - Trading pair symbol
|
|
27640
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
27641
|
+
* @returns Promise resolving to drawdown distance in PnL cost (≥ 0) or null
|
|
27642
|
+
*/
|
|
27643
|
+
getPositionHighestProfitDistancePnlCost: (backtest: boolean, symbol: string, context: {
|
|
27644
|
+
strategyName: StrategyName;
|
|
27645
|
+
exchangeName: ExchangeName;
|
|
27646
|
+
frameName: FrameName;
|
|
27647
|
+
}) => Promise<number | null>;
|
|
27648
|
+
/**
|
|
27649
|
+
* Returns the distance in PnL percentage between the current price and the worst drawdown trough.
|
|
27650
|
+
*
|
|
27651
|
+
* Delegates to StrategyConnectionService.getPositionHighestMaxDrawdownPnlPercentage().
|
|
27652
|
+
* Returns null if no pending signal exists.
|
|
27653
|
+
*
|
|
27654
|
+
* @param backtest - Whether running in backtest mode
|
|
27655
|
+
* @param symbol - Trading pair symbol
|
|
27656
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
27657
|
+
* @returns Promise resolving to recovery distance in PnL% (≥ 0) or null
|
|
27658
|
+
*/
|
|
27659
|
+
getPositionHighestMaxDrawdownPnlPercentage: (backtest: boolean, symbol: string, context: {
|
|
27660
|
+
strategyName: StrategyName;
|
|
27661
|
+
exchangeName: ExchangeName;
|
|
27662
|
+
frameName: FrameName;
|
|
27663
|
+
}) => Promise<number | null>;
|
|
27664
|
+
/**
|
|
27665
|
+
* Returns the distance in PnL cost between the current price and the worst drawdown trough.
|
|
27666
|
+
*
|
|
27667
|
+
* Delegates to StrategyConnectionService.getPositionHighestMaxDrawdownPnlCost().
|
|
27668
|
+
* Returns null if no pending signal exists.
|
|
27669
|
+
*
|
|
27670
|
+
* @param backtest - Whether running in backtest mode
|
|
27671
|
+
* @param symbol - Trading pair symbol
|
|
27672
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
27673
|
+
* @returns Promise resolving to recovery distance in PnL cost (≥ 0) or null
|
|
27674
|
+
*/
|
|
27675
|
+
getPositionHighestMaxDrawdownPnlCost: (backtest: boolean, symbol: string, context: {
|
|
27676
|
+
strategyName: StrategyName;
|
|
27677
|
+
exchangeName: ExchangeName;
|
|
27678
|
+
frameName: FrameName;
|
|
27679
|
+
}) => Promise<number | null>;
|
|
27238
27680
|
}
|
|
27239
27681
|
|
|
27240
27682
|
/**
|
|
@@ -30086,4 +30528,4 @@ declare const getTotalClosed: (signal: Signal) => {
|
|
|
30086
30528
|
remainingCostBasis: number;
|
|
30087
30529
|
};
|
|
30088
30530
|
|
|
30089
|
-
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, Dump, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IDumpContext, type IDumpInstance, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type IMemoryInstance, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Interval, type IntervalData, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MarkdownWriter, MaxDrawdown, type MaxDrawdownContract, type MaxDrawdownEvent, type MaxDrawdownStatisticsModel, type MeasureData, Memory, type MemoryData, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistIntervalAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, ReportWriter, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };
|
|
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 };
|