backtest-kit 2.2.14 → 2.2.15
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 +326 -259
- package/build/index.mjs +326 -259
- package/package.json +1 -1
- package/types.d.ts +126 -151
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1003,6 +1003,86 @@ interface IBreakeven {
|
|
|
1003
1003
|
clear(symbol: string, data: IPublicSignalRow, priceClose: number, backtest: boolean): Promise<void>;
|
|
1004
1004
|
}
|
|
1005
1005
|
|
|
1006
|
+
/**
|
|
1007
|
+
* Base fields for all signal commit events.
|
|
1008
|
+
*/
|
|
1009
|
+
interface SignalCommitBase {
|
|
1010
|
+
symbol: string;
|
|
1011
|
+
strategyName: StrategyName;
|
|
1012
|
+
exchangeName: ExchangeName;
|
|
1013
|
+
frameName: FrameName;
|
|
1014
|
+
backtest: boolean;
|
|
1015
|
+
/** Timestamp from execution context (tick's when or backtest candle timestamp) */
|
|
1016
|
+
timestamp: number;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Cancel scheduled signal event.
|
|
1020
|
+
*/
|
|
1021
|
+
interface CancelScheduledCommit extends SignalCommitBase {
|
|
1022
|
+
action: "cancel-scheduled";
|
|
1023
|
+
cancelId?: string;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Close pending signal event.
|
|
1027
|
+
*/
|
|
1028
|
+
interface ClosePendingCommit extends SignalCommitBase {
|
|
1029
|
+
action: "close-pending";
|
|
1030
|
+
closeId?: string;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Partial profit event.
|
|
1034
|
+
*/
|
|
1035
|
+
interface PartialProfitCommit extends SignalCommitBase {
|
|
1036
|
+
action: "partial-profit";
|
|
1037
|
+
percentToClose: number;
|
|
1038
|
+
currentPrice: number;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Partial loss event.
|
|
1042
|
+
*/
|
|
1043
|
+
interface PartialLossCommit extends SignalCommitBase {
|
|
1044
|
+
action: "partial-loss";
|
|
1045
|
+
percentToClose: number;
|
|
1046
|
+
currentPrice: number;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Trailing stop event.
|
|
1050
|
+
*/
|
|
1051
|
+
interface TrailingStopCommit extends SignalCommitBase {
|
|
1052
|
+
action: "trailing-stop";
|
|
1053
|
+
percentShift: number;
|
|
1054
|
+
currentPrice: number;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Trailing take event.
|
|
1058
|
+
*/
|
|
1059
|
+
interface TrailingTakeCommit extends SignalCommitBase {
|
|
1060
|
+
action: "trailing-take";
|
|
1061
|
+
percentShift: number;
|
|
1062
|
+
currentPrice: number;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Breakeven event.
|
|
1066
|
+
*/
|
|
1067
|
+
interface BreakevenCommit extends SignalCommitBase {
|
|
1068
|
+
action: "breakeven";
|
|
1069
|
+
currentPrice: number;
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Discriminated union for strategy management signal events.
|
|
1073
|
+
*
|
|
1074
|
+
* Emitted by strategyCommitSubject when strategy management actions are executed.
|
|
1075
|
+
*
|
|
1076
|
+
* Consumers:
|
|
1077
|
+
* - StrategyReportService: Persists events to JSON files
|
|
1078
|
+
* - StrategyMarkdownService: Accumulates events for markdown reports
|
|
1079
|
+
*
|
|
1080
|
+
* Note: Signal data (IPublicSignalRow) is NOT included in this contract.
|
|
1081
|
+
* Consumers must retrieve signal data from StrategyCoreService using
|
|
1082
|
+
* getPendingSignal() or getScheduledSignal() methods.
|
|
1083
|
+
*/
|
|
1084
|
+
type StrategyCommitContract = CancelScheduledCommit | ClosePendingCommit | PartialProfitCommit | PartialLossCommit | TrailingStopCommit | TrailingTakeCommit | BreakevenCommit;
|
|
1085
|
+
|
|
1006
1086
|
/**
|
|
1007
1087
|
* Signal generation interval for throttling.
|
|
1008
1088
|
* Enforces minimum time between getSignal calls.
|
|
@@ -5103,84 +5183,6 @@ interface WalkerContract {
|
|
|
5103
5183
|
totalStrategies: number;
|
|
5104
5184
|
}
|
|
5105
5185
|
|
|
5106
|
-
/**
|
|
5107
|
-
* Base fields for all signal commit events.
|
|
5108
|
-
*/
|
|
5109
|
-
interface SignalCommitBase {
|
|
5110
|
-
symbol: string;
|
|
5111
|
-
strategyName: StrategyName;
|
|
5112
|
-
exchangeName: ExchangeName;
|
|
5113
|
-
frameName: FrameName;
|
|
5114
|
-
backtest: boolean;
|
|
5115
|
-
}
|
|
5116
|
-
/**
|
|
5117
|
-
* Cancel scheduled signal event.
|
|
5118
|
-
*/
|
|
5119
|
-
interface CancelScheduledCommit extends SignalCommitBase {
|
|
5120
|
-
action: "cancel-scheduled";
|
|
5121
|
-
cancelId?: string;
|
|
5122
|
-
}
|
|
5123
|
-
/**
|
|
5124
|
-
* Close pending signal event.
|
|
5125
|
-
*/
|
|
5126
|
-
interface ClosePendingCommit extends SignalCommitBase {
|
|
5127
|
-
action: "close-pending";
|
|
5128
|
-
closeId?: string;
|
|
5129
|
-
}
|
|
5130
|
-
/**
|
|
5131
|
-
* Partial profit event.
|
|
5132
|
-
*/
|
|
5133
|
-
interface PartialProfitCommit extends SignalCommitBase {
|
|
5134
|
-
action: "partial-profit";
|
|
5135
|
-
percentToClose: number;
|
|
5136
|
-
currentPrice: number;
|
|
5137
|
-
}
|
|
5138
|
-
/**
|
|
5139
|
-
* Partial loss event.
|
|
5140
|
-
*/
|
|
5141
|
-
interface PartialLossCommit extends SignalCommitBase {
|
|
5142
|
-
action: "partial-loss";
|
|
5143
|
-
percentToClose: number;
|
|
5144
|
-
currentPrice: number;
|
|
5145
|
-
}
|
|
5146
|
-
/**
|
|
5147
|
-
* Trailing stop event.
|
|
5148
|
-
*/
|
|
5149
|
-
interface TrailingStopCommit extends SignalCommitBase {
|
|
5150
|
-
action: "trailing-stop";
|
|
5151
|
-
percentShift: number;
|
|
5152
|
-
currentPrice: number;
|
|
5153
|
-
}
|
|
5154
|
-
/**
|
|
5155
|
-
* Trailing take event.
|
|
5156
|
-
*/
|
|
5157
|
-
interface TrailingTakeCommit extends SignalCommitBase {
|
|
5158
|
-
action: "trailing-take";
|
|
5159
|
-
percentShift: number;
|
|
5160
|
-
currentPrice: number;
|
|
5161
|
-
}
|
|
5162
|
-
/**
|
|
5163
|
-
* Breakeven event.
|
|
5164
|
-
*/
|
|
5165
|
-
interface BreakevenCommit extends SignalCommitBase {
|
|
5166
|
-
action: "breakeven";
|
|
5167
|
-
currentPrice: number;
|
|
5168
|
-
}
|
|
5169
|
-
/**
|
|
5170
|
-
* Discriminated union for strategy management signal events.
|
|
5171
|
-
*
|
|
5172
|
-
* Emitted by strategyCommitSubject when strategy management actions are executed.
|
|
5173
|
-
*
|
|
5174
|
-
* Consumers:
|
|
5175
|
-
* - StrategyReportService: Persists events to JSON files
|
|
5176
|
-
* - StrategyMarkdownService: Accumulates events for markdown reports
|
|
5177
|
-
*
|
|
5178
|
-
* Note: Signal data (IPublicSignalRow) is NOT included in this contract.
|
|
5179
|
-
* Consumers must retrieve signal data from StrategyCoreService using
|
|
5180
|
-
* getPendingSignal() or getScheduledSignal() methods.
|
|
5181
|
-
*/
|
|
5182
|
-
type StrategyCommitContract = CancelScheduledCommit | ClosePendingCommit | PartialProfitCommit | PartialLossCommit | TrailingStopCommit | TrailingTakeCommit | BreakevenCommit;
|
|
5183
|
-
|
|
5184
5186
|
/**
|
|
5185
5187
|
* Subscribes to all signal events with queued async processing.
|
|
5186
5188
|
*
|
|
@@ -6560,6 +6562,8 @@ interface PartialProfitAvailableNotification {
|
|
|
6560
6562
|
priceOpen: number;
|
|
6561
6563
|
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6562
6564
|
position: "long" | "short";
|
|
6565
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6566
|
+
createdAt: number;
|
|
6563
6567
|
}
|
|
6564
6568
|
/**
|
|
6565
6569
|
* Partial loss notification.
|
|
@@ -6590,6 +6594,8 @@ interface PartialLossAvailableNotification {
|
|
|
6590
6594
|
priceOpen: number;
|
|
6591
6595
|
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6592
6596
|
position: "long" | "short";
|
|
6597
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6598
|
+
createdAt: number;
|
|
6593
6599
|
}
|
|
6594
6600
|
/**
|
|
6595
6601
|
* Breakeven available notification.
|
|
@@ -6618,6 +6624,8 @@ interface BreakevenAvailableNotification {
|
|
|
6618
6624
|
priceOpen: number;
|
|
6619
6625
|
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6620
6626
|
position: "long" | "short";
|
|
6627
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6628
|
+
createdAt: number;
|
|
6621
6629
|
}
|
|
6622
6630
|
/**
|
|
6623
6631
|
* Partial profit commit notification.
|
|
@@ -6642,6 +6650,8 @@ interface PartialProfitCommitNotification {
|
|
|
6642
6650
|
percentToClose: number;
|
|
6643
6651
|
/** Current market price when partial was executed */
|
|
6644
6652
|
currentPrice: number;
|
|
6653
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6654
|
+
createdAt: number;
|
|
6645
6655
|
}
|
|
6646
6656
|
/**
|
|
6647
6657
|
* Partial loss commit notification.
|
|
@@ -6666,6 +6676,8 @@ interface PartialLossCommitNotification {
|
|
|
6666
6676
|
percentToClose: number;
|
|
6667
6677
|
/** Current market price when partial was executed */
|
|
6668
6678
|
currentPrice: number;
|
|
6679
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6680
|
+
createdAt: number;
|
|
6669
6681
|
}
|
|
6670
6682
|
/**
|
|
6671
6683
|
* Breakeven commit notification.
|
|
@@ -6688,6 +6700,8 @@ interface BreakevenCommitNotification {
|
|
|
6688
6700
|
exchangeName: ExchangeName;
|
|
6689
6701
|
/** Current market price when breakeven was executed */
|
|
6690
6702
|
currentPrice: number;
|
|
6703
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6704
|
+
createdAt: number;
|
|
6691
6705
|
}
|
|
6692
6706
|
/**
|
|
6693
6707
|
* Trailing stop commit notification.
|
|
@@ -6712,6 +6726,8 @@ interface TrailingStopCommitNotification {
|
|
|
6712
6726
|
percentShift: number;
|
|
6713
6727
|
/** Current market price when trailing stop was executed */
|
|
6714
6728
|
currentPrice: number;
|
|
6729
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6730
|
+
createdAt: number;
|
|
6715
6731
|
}
|
|
6716
6732
|
/**
|
|
6717
6733
|
* Trailing take commit notification.
|
|
@@ -6736,6 +6752,8 @@ interface TrailingTakeCommitNotification {
|
|
|
6736
6752
|
percentShift: number;
|
|
6737
6753
|
/** Current market price when trailing take was executed */
|
|
6738
6754
|
currentPrice: number;
|
|
6755
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6756
|
+
createdAt: number;
|
|
6739
6757
|
}
|
|
6740
6758
|
/**
|
|
6741
6759
|
* Risk rejection notification.
|
|
@@ -6766,6 +6784,8 @@ interface RiskRejectionNotification {
|
|
|
6766
6784
|
currentPrice: number;
|
|
6767
6785
|
/** The signal that was rejected */
|
|
6768
6786
|
pendingSignal: ISignalDto;
|
|
6787
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
6788
|
+
createdAt: number;
|
|
6769
6789
|
}
|
|
6770
6790
|
/**
|
|
6771
6791
|
* Scheduled signal notification.
|
|
@@ -6844,8 +6864,6 @@ interface InfoErrorNotification {
|
|
|
6844
6864
|
error: object;
|
|
6845
6865
|
/** Human-readable error message */
|
|
6846
6866
|
message: string;
|
|
6847
|
-
/** Unix timestamp in milliseconds when error occurred */
|
|
6848
|
-
timestamp: number;
|
|
6849
6867
|
/** Always false for error notifications (errors are from live context) */
|
|
6850
6868
|
backtest: boolean;
|
|
6851
6869
|
}
|
|
@@ -6862,8 +6880,6 @@ interface CriticalErrorNotification {
|
|
|
6862
6880
|
error: object;
|
|
6863
6881
|
/** Human-readable error message */
|
|
6864
6882
|
message: string;
|
|
6865
|
-
/** Unix timestamp in milliseconds when critical error occurred */
|
|
6866
|
-
timestamp: number;
|
|
6867
6883
|
/** Always false for error notifications (errors are from live context) */
|
|
6868
6884
|
backtest: boolean;
|
|
6869
6885
|
}
|
|
@@ -6880,8 +6896,6 @@ interface ValidationErrorNotification {
|
|
|
6880
6896
|
error: object;
|
|
6881
6897
|
/** Human-readable validation error message */
|
|
6882
6898
|
message: string;
|
|
6883
|
-
/** Unix timestamp in milliseconds when validation error occurred */
|
|
6884
|
-
timestamp: number;
|
|
6885
6899
|
/** Always false for error notifications (errors are from live context) */
|
|
6886
6900
|
backtest: boolean;
|
|
6887
6901
|
}
|
|
@@ -13899,9 +13913,6 @@ type Columns = ColumnModel<StrategyEvent>;
|
|
|
13899
13913
|
*/
|
|
13900
13914
|
declare class StrategyMarkdownService {
|
|
13901
13915
|
readonly loggerService: LoggerService;
|
|
13902
|
-
readonly executionContextService: {
|
|
13903
|
-
readonly context: IExecutionContext;
|
|
13904
|
-
};
|
|
13905
13916
|
readonly strategyCoreService: StrategyCoreService;
|
|
13906
13917
|
/**
|
|
13907
13918
|
* Memoized factory for ReportStorage instances.
|
|
@@ -13915,114 +13926,105 @@ declare class StrategyMarkdownService {
|
|
|
13915
13926
|
/**
|
|
13916
13927
|
* Records a cancel-scheduled event when a scheduled signal is cancelled.
|
|
13917
13928
|
*
|
|
13918
|
-
* Retrieves the scheduled signal from StrategyCoreService and stores
|
|
13919
|
-
* the cancellation event in the appropriate ReportStorage.
|
|
13920
|
-
*
|
|
13921
13929
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
13922
13930
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
13923
13931
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
13932
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
13924
13933
|
* @param cancelId - Optional identifier for the cancellation reason
|
|
13925
13934
|
*/
|
|
13926
13935
|
cancelScheduled: (symbol: string, isBacktest: boolean, context: {
|
|
13927
13936
|
strategyName: StrategyName;
|
|
13928
13937
|
exchangeName: ExchangeName;
|
|
13929
13938
|
frameName: FrameName;
|
|
13930
|
-
}, cancelId?: string) => Promise<void>;
|
|
13939
|
+
}, timestamp: number, cancelId?: string) => Promise<void>;
|
|
13931
13940
|
/**
|
|
13932
13941
|
* Records a close-pending event when a pending signal is closed.
|
|
13933
13942
|
*
|
|
13934
|
-
* Retrieves the pending signal from StrategyCoreService and stores
|
|
13935
|
-
* the close event in the appropriate ReportStorage.
|
|
13936
|
-
*
|
|
13937
13943
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
13938
13944
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
13939
13945
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
13946
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
13940
13947
|
* @param closeId - Optional identifier for the close reason
|
|
13941
13948
|
*/
|
|
13942
13949
|
closePending: (symbol: string, isBacktest: boolean, context: {
|
|
13943
13950
|
strategyName: StrategyName;
|
|
13944
13951
|
exchangeName: ExchangeName;
|
|
13945
13952
|
frameName: FrameName;
|
|
13946
|
-
}, closeId?: string) => Promise<void>;
|
|
13953
|
+
}, timestamp: number, closeId?: string) => Promise<void>;
|
|
13947
13954
|
/**
|
|
13948
13955
|
* Records a partial-profit event when a portion of the position is closed at profit.
|
|
13949
13956
|
*
|
|
13950
|
-
* Stores the percentage closed and current price when partial profit-taking occurs.
|
|
13951
|
-
*
|
|
13952
13957
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
13953
13958
|
* @param percentToClose - Percentage of position to close (0-100)
|
|
13954
13959
|
* @param currentPrice - Current market price at time of partial close
|
|
13955
13960
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
13956
13961
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
13962
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
13957
13963
|
*/
|
|
13958
13964
|
partialProfit: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
13959
13965
|
strategyName: StrategyName;
|
|
13960
13966
|
exchangeName: ExchangeName;
|
|
13961
13967
|
frameName: FrameName;
|
|
13962
|
-
}) => Promise<void>;
|
|
13968
|
+
}, timestamp: number) => Promise<void>;
|
|
13963
13969
|
/**
|
|
13964
13970
|
* Records a partial-loss event when a portion of the position is closed at loss.
|
|
13965
13971
|
*
|
|
13966
|
-
* Stores the percentage closed and current price when partial loss-cutting occurs.
|
|
13967
|
-
*
|
|
13968
13972
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
13969
13973
|
* @param percentToClose - Percentage of position to close (0-100)
|
|
13970
13974
|
* @param currentPrice - Current market price at time of partial close
|
|
13971
13975
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
13972
13976
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
13977
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
13973
13978
|
*/
|
|
13974
13979
|
partialLoss: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
13975
13980
|
strategyName: StrategyName;
|
|
13976
13981
|
exchangeName: ExchangeName;
|
|
13977
13982
|
frameName: FrameName;
|
|
13978
|
-
}) => Promise<void>;
|
|
13983
|
+
}, timestamp: number) => Promise<void>;
|
|
13979
13984
|
/**
|
|
13980
13985
|
* Records a trailing-stop event when the stop-loss is adjusted.
|
|
13981
13986
|
*
|
|
13982
|
-
* Stores the percentage shift and current price when trailing stop moves.
|
|
13983
|
-
*
|
|
13984
13987
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
13985
13988
|
* @param percentShift - Percentage the stop-loss was shifted
|
|
13986
13989
|
* @param currentPrice - Current market price at time of adjustment
|
|
13987
13990
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
13988
13991
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
13992
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
13989
13993
|
*/
|
|
13990
13994
|
trailingStop: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
13991
13995
|
strategyName: StrategyName;
|
|
13992
13996
|
exchangeName: ExchangeName;
|
|
13993
13997
|
frameName: FrameName;
|
|
13994
|
-
}) => Promise<void>;
|
|
13998
|
+
}, timestamp: number) => Promise<void>;
|
|
13995
13999
|
/**
|
|
13996
14000
|
* Records a trailing-take event when the take-profit is adjusted.
|
|
13997
14001
|
*
|
|
13998
|
-
* Stores the percentage shift and current price when trailing take-profit moves.
|
|
13999
|
-
*
|
|
14000
14002
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
14001
14003
|
* @param percentShift - Percentage the take-profit was shifted
|
|
14002
14004
|
* @param currentPrice - Current market price at time of adjustment
|
|
14003
14005
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14004
14006
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14007
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14005
14008
|
*/
|
|
14006
14009
|
trailingTake: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14007
14010
|
strategyName: StrategyName;
|
|
14008
14011
|
exchangeName: ExchangeName;
|
|
14009
14012
|
frameName: FrameName;
|
|
14010
|
-
}) => Promise<void>;
|
|
14013
|
+
}, timestamp: number) => Promise<void>;
|
|
14011
14014
|
/**
|
|
14012
14015
|
* Records a breakeven event when the stop-loss is moved to entry price.
|
|
14013
14016
|
*
|
|
14014
|
-
* Stores the current price when breakeven protection is activated.
|
|
14015
|
-
*
|
|
14016
14017
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
14017
14018
|
* @param currentPrice - Current market price at time of breakeven activation
|
|
14018
14019
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14019
14020
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14021
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14020
14022
|
*/
|
|
14021
14023
|
breakeven: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
|
|
14022
14024
|
strategyName: StrategyName;
|
|
14023
14025
|
exchangeName: ExchangeName;
|
|
14024
14026
|
frameName: FrameName;
|
|
14025
|
-
}) => Promise<void>;
|
|
14027
|
+
}, timestamp: number) => Promise<void>;
|
|
14026
14028
|
/**
|
|
14027
14029
|
* Retrieves aggregated statistics from accumulated strategy events.
|
|
14028
14030
|
*
|
|
@@ -19397,141 +19399,114 @@ declare class RiskReportService {
|
|
|
19397
19399
|
* - Events are written via Report.writeData() with "strategy" category
|
|
19398
19400
|
* - Call unsubscribe() to disable event logging
|
|
19399
19401
|
*
|
|
19400
|
-
* @example
|
|
19401
|
-
* ```typescript
|
|
19402
|
-
* // Service is typically used internally by strategy management classes
|
|
19403
|
-
* strategyReportService.subscribe();
|
|
19404
|
-
*
|
|
19405
|
-
* // Events are logged automatically when strategy actions occur
|
|
19406
|
-
* await strategyReportService.partialProfit("BTCUSDT", 50, 50100, false, {
|
|
19407
|
-
* strategyName: "my-strategy",
|
|
19408
|
-
* exchangeName: "binance",
|
|
19409
|
-
* frameName: "1h"
|
|
19410
|
-
* });
|
|
19411
|
-
*
|
|
19412
|
-
* strategyReportService.unsubscribe();
|
|
19413
|
-
* ```
|
|
19414
|
-
*
|
|
19415
19402
|
* @see StrategyMarkdownService for in-memory event accumulation and markdown report generation
|
|
19416
19403
|
* @see Report for the underlying persistence mechanism
|
|
19417
19404
|
*/
|
|
19418
19405
|
declare class StrategyReportService {
|
|
19419
19406
|
readonly loggerService: LoggerService;
|
|
19420
|
-
readonly executionContextService: {
|
|
19421
|
-
readonly context: IExecutionContext;
|
|
19422
|
-
};
|
|
19423
19407
|
readonly strategyCoreService: StrategyCoreService;
|
|
19424
19408
|
/**
|
|
19425
19409
|
* Logs a cancel-scheduled event when a scheduled signal is cancelled.
|
|
19426
19410
|
*
|
|
19427
|
-
* Retrieves the scheduled signal from StrategyCoreService and writes
|
|
19428
|
-
* the cancellation event to the report file.
|
|
19429
|
-
*
|
|
19430
19411
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
19431
19412
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19432
19413
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19414
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19433
19415
|
* @param cancelId - Optional identifier for the cancellation reason
|
|
19434
19416
|
*/
|
|
19435
19417
|
cancelScheduled: (symbol: string, isBacktest: boolean, context: {
|
|
19436
19418
|
strategyName: StrategyName;
|
|
19437
19419
|
exchangeName: ExchangeName;
|
|
19438
19420
|
frameName: FrameName;
|
|
19439
|
-
}, cancelId?: string) => Promise<void>;
|
|
19421
|
+
}, timestamp: number, cancelId?: string) => Promise<void>;
|
|
19440
19422
|
/**
|
|
19441
19423
|
* Logs a close-pending event when a pending signal is closed.
|
|
19442
19424
|
*
|
|
19443
|
-
* Retrieves the pending signal from StrategyCoreService and writes
|
|
19444
|
-
* the close event to the report file.
|
|
19445
|
-
*
|
|
19446
19425
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
19447
19426
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19448
19427
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19428
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19449
19429
|
* @param closeId - Optional identifier for the close reason
|
|
19450
19430
|
*/
|
|
19451
19431
|
closePending: (symbol: string, isBacktest: boolean, context: {
|
|
19452
19432
|
strategyName: StrategyName;
|
|
19453
19433
|
exchangeName: ExchangeName;
|
|
19454
19434
|
frameName: FrameName;
|
|
19455
|
-
}, closeId?: string) => Promise<void>;
|
|
19435
|
+
}, timestamp: number, closeId?: string) => Promise<void>;
|
|
19456
19436
|
/**
|
|
19457
19437
|
* Logs a partial-profit event when a portion of the position is closed at profit.
|
|
19458
19438
|
*
|
|
19459
|
-
* Records the percentage closed and current price when partial profit-taking occurs.
|
|
19460
|
-
*
|
|
19461
19439
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
19462
19440
|
* @param percentToClose - Percentage of position to close (0-100)
|
|
19463
19441
|
* @param currentPrice - Current market price at time of partial close
|
|
19464
19442
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19465
19443
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19444
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19466
19445
|
*/
|
|
19467
19446
|
partialProfit: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19468
19447
|
strategyName: StrategyName;
|
|
19469
19448
|
exchangeName: ExchangeName;
|
|
19470
19449
|
frameName: FrameName;
|
|
19471
|
-
}) => Promise<void>;
|
|
19450
|
+
}, timestamp: number) => Promise<void>;
|
|
19472
19451
|
/**
|
|
19473
19452
|
* Logs a partial-loss event when a portion of the position is closed at loss.
|
|
19474
19453
|
*
|
|
19475
|
-
* Records the percentage closed and current price when partial loss-cutting occurs.
|
|
19476
|
-
*
|
|
19477
19454
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
19478
19455
|
* @param percentToClose - Percentage of position to close (0-100)
|
|
19479
19456
|
* @param currentPrice - Current market price at time of partial close
|
|
19480
19457
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19481
19458
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19459
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19482
19460
|
*/
|
|
19483
19461
|
partialLoss: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19484
19462
|
strategyName: StrategyName;
|
|
19485
19463
|
exchangeName: ExchangeName;
|
|
19486
19464
|
frameName: FrameName;
|
|
19487
|
-
}) => Promise<void>;
|
|
19465
|
+
}, timestamp: number) => Promise<void>;
|
|
19488
19466
|
/**
|
|
19489
19467
|
* Logs a trailing-stop event when the stop-loss is adjusted.
|
|
19490
19468
|
*
|
|
19491
|
-
* Records the percentage shift and current price when trailing stop moves.
|
|
19492
|
-
*
|
|
19493
19469
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
19494
19470
|
* @param percentShift - Percentage the stop-loss was shifted
|
|
19495
19471
|
* @param currentPrice - Current market price at time of adjustment
|
|
19496
19472
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19497
19473
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19474
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19498
19475
|
*/
|
|
19499
19476
|
trailingStop: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19500
19477
|
strategyName: StrategyName;
|
|
19501
19478
|
exchangeName: ExchangeName;
|
|
19502
19479
|
frameName: FrameName;
|
|
19503
|
-
}) => Promise<void>;
|
|
19480
|
+
}, timestamp: number) => Promise<void>;
|
|
19504
19481
|
/**
|
|
19505
19482
|
* Logs a trailing-take event when the take-profit is adjusted.
|
|
19506
19483
|
*
|
|
19507
|
-
* Records the percentage shift and current price when trailing take-profit moves.
|
|
19508
|
-
*
|
|
19509
19484
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
19510
19485
|
* @param percentShift - Percentage the take-profit was shifted
|
|
19511
19486
|
* @param currentPrice - Current market price at time of adjustment
|
|
19512
19487
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19513
19488
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19489
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19514
19490
|
*/
|
|
19515
19491
|
trailingTake: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19516
19492
|
strategyName: StrategyName;
|
|
19517
19493
|
exchangeName: ExchangeName;
|
|
19518
19494
|
frameName: FrameName;
|
|
19519
|
-
}) => Promise<void>;
|
|
19495
|
+
}, timestamp: number) => Promise<void>;
|
|
19520
19496
|
/**
|
|
19521
19497
|
* Logs a breakeven event when the stop-loss is moved to entry price.
|
|
19522
19498
|
*
|
|
19523
|
-
* Records the current price when breakeven protection is activated.
|
|
19524
|
-
*
|
|
19525
19499
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
19526
19500
|
* @param currentPrice - Current market price at time of breakeven activation
|
|
19527
19501
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19528
19502
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19503
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19529
19504
|
*/
|
|
19530
19505
|
breakeven: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
|
|
19531
19506
|
strategyName: StrategyName;
|
|
19532
19507
|
exchangeName: ExchangeName;
|
|
19533
19508
|
frameName: FrameName;
|
|
19534
|
-
}) => Promise<void>;
|
|
19509
|
+
}, timestamp: number) => Promise<void>;
|
|
19535
19510
|
/**
|
|
19536
19511
|
* Initializes the service for event logging.
|
|
19537
19512
|
*
|