backtest-kit 1.4.6 → 1.4.8
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 +345 -245
- package/build/index.mjs +345 -245
- package/package.json +1 -1
- package/types.d.ts +175 -196
package/types.d.ts
CHANGED
|
@@ -972,61 +972,6 @@ type IStrategyTickResult = IStrategyTickResultIdle | IStrategyTickResultSchedule
|
|
|
972
972
|
* Backtest returns closed result (TP/SL or time_expired) or cancelled result (scheduled signal never activated).
|
|
973
973
|
*/
|
|
974
974
|
type IStrategyBacktestResult = IStrategyTickResultClosed | IStrategyTickResultCancelled;
|
|
975
|
-
/**
|
|
976
|
-
* Strategy interface implemented by ClientStrategy.
|
|
977
|
-
* Defines core strategy execution methods.
|
|
978
|
-
*/
|
|
979
|
-
interface IStrategy {
|
|
980
|
-
/**
|
|
981
|
-
* Single tick of strategy execution with VWAP monitoring.
|
|
982
|
-
* Checks for signal generation (throttled) and TP/SL conditions.
|
|
983
|
-
*
|
|
984
|
-
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
985
|
-
* @returns Promise resolving to tick result (idle | opened | active | closed)
|
|
986
|
-
*/
|
|
987
|
-
tick: (symbol: string) => Promise<IStrategyTickResult>;
|
|
988
|
-
/**
|
|
989
|
-
* Retrieves the currently active pending signal for the symbol.
|
|
990
|
-
* If no active signal exists, returns null.
|
|
991
|
-
* Used internally for monitoring TP/SL and time expiration.
|
|
992
|
-
*
|
|
993
|
-
* @param symbol
|
|
994
|
-
* @returns
|
|
995
|
-
*/
|
|
996
|
-
getPendingSignal: (symbol: string) => Promise<ISignalRow | null>;
|
|
997
|
-
/**
|
|
998
|
-
* Fast backtest using historical candles.
|
|
999
|
-
* Iterates through candles, calculates VWAP, checks TP/SL on each candle.
|
|
1000
|
-
*
|
|
1001
|
-
* For scheduled signals: first monitors activation/cancellation,
|
|
1002
|
-
* then if activated continues with TP/SL monitoring.
|
|
1003
|
-
*
|
|
1004
|
-
* @param candles - Array of historical candle data
|
|
1005
|
-
* @returns Promise resolving to closed result (always completes signal)
|
|
1006
|
-
*/
|
|
1007
|
-
backtest: (candles: ICandleData[]) => Promise<IStrategyBacktestResult>;
|
|
1008
|
-
/**
|
|
1009
|
-
* Stops the strategy from generating new signals.
|
|
1010
|
-
*
|
|
1011
|
-
* Sets internal flag to prevent getSignal from being called on subsequent ticks.
|
|
1012
|
-
* Does NOT force-close active pending signals - they continue monitoring until natural closure (TP/SL/time_expired).
|
|
1013
|
-
*
|
|
1014
|
-
* Use case: Graceful shutdown in live trading mode without abandoning open positions.
|
|
1015
|
-
*
|
|
1016
|
-
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
1017
|
-
* @returns Promise that resolves immediately when stop flag is set
|
|
1018
|
-
*
|
|
1019
|
-
* @example
|
|
1020
|
-
* ```typescript
|
|
1021
|
-
* // Graceful shutdown in Live.background() cancellation
|
|
1022
|
-
* const cancel = await Live.background("BTCUSDT", { ... });
|
|
1023
|
-
*
|
|
1024
|
-
* // Later: stop new signals, let existing ones close naturally
|
|
1025
|
-
* await cancel();
|
|
1026
|
-
* ```
|
|
1027
|
-
*/
|
|
1028
|
-
stop: (symbol: string) => Promise<void>;
|
|
1029
|
-
}
|
|
1030
975
|
/**
|
|
1031
976
|
* Unique strategy identifier.
|
|
1032
977
|
*/
|
|
@@ -1109,8 +1054,8 @@ declare class BacktestMarkdownService {
|
|
|
1109
1054
|
/** Logger service for debug output */
|
|
1110
1055
|
private readonly loggerService;
|
|
1111
1056
|
/**
|
|
1112
|
-
* Memoized function to get or create ReportStorage for a strategy.
|
|
1113
|
-
* Each strategy gets its own isolated storage instance.
|
|
1057
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy pair.
|
|
1058
|
+
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
1114
1059
|
*/
|
|
1115
1060
|
private getStorage;
|
|
1116
1061
|
/**
|
|
@@ -1134,40 +1079,43 @@ declare class BacktestMarkdownService {
|
|
|
1134
1079
|
*/
|
|
1135
1080
|
private tick;
|
|
1136
1081
|
/**
|
|
1137
|
-
* Gets statistical data from all closed signals for a strategy.
|
|
1082
|
+
* Gets statistical data from all closed signals for a symbol-strategy pair.
|
|
1138
1083
|
* Delegates to ReportStorage.getData().
|
|
1139
1084
|
*
|
|
1085
|
+
* @param symbol - Trading pair symbol
|
|
1140
1086
|
* @param strategyName - Strategy name to get data for
|
|
1141
1087
|
* @returns Statistical data object with all metrics
|
|
1142
1088
|
*
|
|
1143
1089
|
* @example
|
|
1144
1090
|
* ```typescript
|
|
1145
1091
|
* const service = new BacktestMarkdownService();
|
|
1146
|
-
* const stats = await service.getData("my-strategy");
|
|
1092
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
1147
1093
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
1148
1094
|
* ```
|
|
1149
1095
|
*/
|
|
1150
|
-
getData: (strategyName: StrategyName) => Promise<BacktestStatistics>;
|
|
1096
|
+
getData: (symbol: string, strategyName: StrategyName) => Promise<BacktestStatistics>;
|
|
1151
1097
|
/**
|
|
1152
|
-
* Generates markdown report with all closed signals for a strategy.
|
|
1098
|
+
* Generates markdown report with all closed signals for a symbol-strategy pair.
|
|
1153
1099
|
* Delegates to ReportStorage.generateReport().
|
|
1154
1100
|
*
|
|
1101
|
+
* @param symbol - Trading pair symbol
|
|
1155
1102
|
* @param strategyName - Strategy name to generate report for
|
|
1156
1103
|
* @returns Markdown formatted report string with table of all closed signals
|
|
1157
1104
|
*
|
|
1158
1105
|
* @example
|
|
1159
1106
|
* ```typescript
|
|
1160
1107
|
* const service = new BacktestMarkdownService();
|
|
1161
|
-
* const markdown = await service.getReport("my-strategy");
|
|
1108
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
1162
1109
|
* console.log(markdown);
|
|
1163
1110
|
* ```
|
|
1164
1111
|
*/
|
|
1165
|
-
getReport: (strategyName: StrategyName) => Promise<string>;
|
|
1112
|
+
getReport: (symbol: string, strategyName: StrategyName) => Promise<string>;
|
|
1166
1113
|
/**
|
|
1167
|
-
* Saves strategy report to disk.
|
|
1114
|
+
* Saves symbol-strategy report to disk.
|
|
1168
1115
|
* Creates directory if it doesn't exist.
|
|
1169
1116
|
* Delegates to ReportStorage.dump().
|
|
1170
1117
|
*
|
|
1118
|
+
* @param symbol - Trading pair symbol
|
|
1171
1119
|
* @param strategyName - Strategy name to save report for
|
|
1172
1120
|
* @param path - Directory path to save report (default: "./dump/backtest")
|
|
1173
1121
|
*
|
|
@@ -1176,32 +1124,35 @@ declare class BacktestMarkdownService {
|
|
|
1176
1124
|
* const service = new BacktestMarkdownService();
|
|
1177
1125
|
*
|
|
1178
1126
|
* // Save to default path: ./dump/backtest/my-strategy.md
|
|
1179
|
-
* await service.dump("my-strategy");
|
|
1127
|
+
* await service.dump("BTCUSDT", "my-strategy");
|
|
1180
1128
|
*
|
|
1181
1129
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
1182
|
-
* await service.dump("my-strategy", "./custom/path");
|
|
1130
|
+
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
1183
1131
|
* ```
|
|
1184
1132
|
*/
|
|
1185
|
-
dump: (strategyName: StrategyName, path?: string) => Promise<void>;
|
|
1133
|
+
dump: (symbol: string, strategyName: StrategyName, path?: string) => Promise<void>;
|
|
1186
1134
|
/**
|
|
1187
1135
|
* Clears accumulated signal data from storage.
|
|
1188
|
-
* If
|
|
1189
|
-
* If
|
|
1136
|
+
* If ctx is provided, clears only that specific symbol-strategy pair's data.
|
|
1137
|
+
* If nothing is provided, clears all data.
|
|
1190
1138
|
*
|
|
1191
|
-
* @param
|
|
1139
|
+
* @param ctx - Optional context with symbol and strategyName
|
|
1192
1140
|
*
|
|
1193
1141
|
* @example
|
|
1194
1142
|
* ```typescript
|
|
1195
1143
|
* const service = new BacktestMarkdownService();
|
|
1196
1144
|
*
|
|
1197
|
-
* // Clear specific strategy
|
|
1198
|
-
* await service.clear("my-strategy");
|
|
1145
|
+
* // Clear specific symbol-strategy pair
|
|
1146
|
+
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
1199
1147
|
*
|
|
1200
|
-
* // Clear all
|
|
1148
|
+
* // Clear all data
|
|
1201
1149
|
* await service.clear();
|
|
1202
1150
|
* ```
|
|
1203
1151
|
*/
|
|
1204
|
-
clear: (
|
|
1152
|
+
clear: (ctx?: {
|
|
1153
|
+
symbol: string;
|
|
1154
|
+
strategyName: StrategyName;
|
|
1155
|
+
}) => Promise<void>;
|
|
1205
1156
|
/**
|
|
1206
1157
|
* Initializes the service by subscribing to backtest signal events.
|
|
1207
1158
|
* Uses singleshot to ensure initialization happens only once.
|
|
@@ -3809,8 +3760,8 @@ declare class LiveMarkdownService {
|
|
|
3809
3760
|
/** Logger service for debug output */
|
|
3810
3761
|
private readonly loggerService;
|
|
3811
3762
|
/**
|
|
3812
|
-
* Memoized function to get or create ReportStorage for a strategy.
|
|
3813
|
-
* Each strategy gets its own isolated storage instance.
|
|
3763
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy pair.
|
|
3764
|
+
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
3814
3765
|
*/
|
|
3815
3766
|
private getStorage;
|
|
3816
3767
|
/**
|
|
@@ -3836,40 +3787,43 @@ declare class LiveMarkdownService {
|
|
|
3836
3787
|
*/
|
|
3837
3788
|
private tick;
|
|
3838
3789
|
/**
|
|
3839
|
-
* Gets statistical data from all live trading events for a strategy.
|
|
3790
|
+
* Gets statistical data from all live trading events for a symbol-strategy pair.
|
|
3840
3791
|
* Delegates to ReportStorage.getData().
|
|
3841
3792
|
*
|
|
3793
|
+
* @param symbol - Trading pair symbol
|
|
3842
3794
|
* @param strategyName - Strategy name to get data for
|
|
3843
3795
|
* @returns Statistical data object with all metrics
|
|
3844
3796
|
*
|
|
3845
3797
|
* @example
|
|
3846
3798
|
* ```typescript
|
|
3847
3799
|
* const service = new LiveMarkdownService();
|
|
3848
|
-
* const stats = await service.getData("my-strategy");
|
|
3800
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
3849
3801
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
3850
3802
|
* ```
|
|
3851
3803
|
*/
|
|
3852
|
-
getData: (strategyName: StrategyName) => Promise<LiveStatistics>;
|
|
3804
|
+
getData: (symbol: string, strategyName: StrategyName) => Promise<LiveStatistics>;
|
|
3853
3805
|
/**
|
|
3854
|
-
* Generates markdown report with all events for a strategy.
|
|
3806
|
+
* Generates markdown report with all events for a symbol-strategy pair.
|
|
3855
3807
|
* Delegates to ReportStorage.getReport().
|
|
3856
3808
|
*
|
|
3809
|
+
* @param symbol - Trading pair symbol
|
|
3857
3810
|
* @param strategyName - Strategy name to generate report for
|
|
3858
3811
|
* @returns Markdown formatted report string with table of all events
|
|
3859
3812
|
*
|
|
3860
3813
|
* @example
|
|
3861
3814
|
* ```typescript
|
|
3862
3815
|
* const service = new LiveMarkdownService();
|
|
3863
|
-
* const markdown = await service.getReport("my-strategy");
|
|
3816
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
3864
3817
|
* console.log(markdown);
|
|
3865
3818
|
* ```
|
|
3866
3819
|
*/
|
|
3867
|
-
getReport: (strategyName: StrategyName) => Promise<string>;
|
|
3820
|
+
getReport: (symbol: string, strategyName: StrategyName) => Promise<string>;
|
|
3868
3821
|
/**
|
|
3869
|
-
* Saves strategy report to disk.
|
|
3822
|
+
* Saves symbol-strategy report to disk.
|
|
3870
3823
|
* Creates directory if it doesn't exist.
|
|
3871
3824
|
* Delegates to ReportStorage.dump().
|
|
3872
3825
|
*
|
|
3826
|
+
* @param symbol - Trading pair symbol
|
|
3873
3827
|
* @param strategyName - Strategy name to save report for
|
|
3874
3828
|
* @param path - Directory path to save report (default: "./dump/live")
|
|
3875
3829
|
*
|
|
@@ -3878,32 +3832,35 @@ declare class LiveMarkdownService {
|
|
|
3878
3832
|
* const service = new LiveMarkdownService();
|
|
3879
3833
|
*
|
|
3880
3834
|
* // Save to default path: ./dump/live/my-strategy.md
|
|
3881
|
-
* await service.dump("my-strategy");
|
|
3835
|
+
* await service.dump("BTCUSDT", "my-strategy");
|
|
3882
3836
|
*
|
|
3883
3837
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
3884
|
-
* await service.dump("my-strategy", "./custom/path");
|
|
3838
|
+
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
3885
3839
|
* ```
|
|
3886
3840
|
*/
|
|
3887
|
-
dump: (strategyName: StrategyName, path?: string) => Promise<void>;
|
|
3841
|
+
dump: (symbol: string, strategyName: StrategyName, path?: string) => Promise<void>;
|
|
3888
3842
|
/**
|
|
3889
3843
|
* Clears accumulated event data from storage.
|
|
3890
|
-
* If
|
|
3891
|
-
* If
|
|
3844
|
+
* If ctx is provided, clears only that specific symbol-strategy pair's data.
|
|
3845
|
+
* If nothing is provided, clears all data.
|
|
3892
3846
|
*
|
|
3893
|
-
* @param
|
|
3847
|
+
* @param ctx - Optional context with symbol and strategyName
|
|
3894
3848
|
*
|
|
3895
3849
|
* @example
|
|
3896
3850
|
* ```typescript
|
|
3897
3851
|
* const service = new LiveMarkdownService();
|
|
3898
3852
|
*
|
|
3899
|
-
* // Clear specific strategy
|
|
3900
|
-
* await service.clear("my-strategy");
|
|
3853
|
+
* // Clear specific symbol-strategy pair
|
|
3854
|
+
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
3901
3855
|
*
|
|
3902
|
-
* // Clear all
|
|
3856
|
+
* // Clear all data
|
|
3903
3857
|
* await service.clear();
|
|
3904
3858
|
* ```
|
|
3905
3859
|
*/
|
|
3906
|
-
clear: (
|
|
3860
|
+
clear: (ctx?: {
|
|
3861
|
+
symbol: string;
|
|
3862
|
+
strategyName: StrategyName;
|
|
3863
|
+
}) => Promise<void>;
|
|
3907
3864
|
/**
|
|
3908
3865
|
* Initializes the service by subscribing to live signal events.
|
|
3909
3866
|
* Uses singleshot to ensure initialization happens only once.
|
|
@@ -4009,8 +3966,8 @@ declare class ScheduleMarkdownService {
|
|
|
4009
3966
|
/** Logger service for debug output */
|
|
4010
3967
|
private readonly loggerService;
|
|
4011
3968
|
/**
|
|
4012
|
-
* Memoized function to get or create ReportStorage for a strategy.
|
|
4013
|
-
* Each strategy gets its own isolated storage instance.
|
|
3969
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy pair.
|
|
3970
|
+
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
4014
3971
|
*/
|
|
4015
3972
|
private getStorage;
|
|
4016
3973
|
/**
|
|
@@ -4029,40 +3986,43 @@ declare class ScheduleMarkdownService {
|
|
|
4029
3986
|
*/
|
|
4030
3987
|
private tick;
|
|
4031
3988
|
/**
|
|
4032
|
-
* Gets statistical data from all scheduled signal events for a strategy.
|
|
3989
|
+
* Gets statistical data from all scheduled signal events for a symbol-strategy pair.
|
|
4033
3990
|
* Delegates to ReportStorage.getData().
|
|
4034
3991
|
*
|
|
3992
|
+
* @param symbol - Trading pair symbol
|
|
4035
3993
|
* @param strategyName - Strategy name to get data for
|
|
4036
3994
|
* @returns Statistical data object with all metrics
|
|
4037
3995
|
*
|
|
4038
3996
|
* @example
|
|
4039
3997
|
* ```typescript
|
|
4040
3998
|
* const service = new ScheduleMarkdownService();
|
|
4041
|
-
* const stats = await service.getData("my-strategy");
|
|
3999
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
4042
4000
|
* console.log(stats.cancellationRate, stats.avgWaitTime);
|
|
4043
4001
|
* ```
|
|
4044
4002
|
*/
|
|
4045
|
-
getData: (strategyName: StrategyName) => Promise<ScheduleStatistics>;
|
|
4003
|
+
getData: (symbol: string, strategyName: StrategyName) => Promise<ScheduleStatistics>;
|
|
4046
4004
|
/**
|
|
4047
|
-
* Generates markdown report with all scheduled events for a strategy.
|
|
4005
|
+
* Generates markdown report with all scheduled events for a symbol-strategy pair.
|
|
4048
4006
|
* Delegates to ReportStorage.getReport().
|
|
4049
4007
|
*
|
|
4008
|
+
* @param symbol - Trading pair symbol
|
|
4050
4009
|
* @param strategyName - Strategy name to generate report for
|
|
4051
4010
|
* @returns Markdown formatted report string with table of all events
|
|
4052
4011
|
*
|
|
4053
4012
|
* @example
|
|
4054
4013
|
* ```typescript
|
|
4055
4014
|
* const service = new ScheduleMarkdownService();
|
|
4056
|
-
* const markdown = await service.getReport("my-strategy");
|
|
4015
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
4057
4016
|
* console.log(markdown);
|
|
4058
4017
|
* ```
|
|
4059
4018
|
*/
|
|
4060
|
-
getReport: (strategyName: StrategyName) => Promise<string>;
|
|
4019
|
+
getReport: (symbol: string, strategyName: StrategyName) => Promise<string>;
|
|
4061
4020
|
/**
|
|
4062
|
-
* Saves strategy report to disk.
|
|
4021
|
+
* Saves symbol-strategy report to disk.
|
|
4063
4022
|
* Creates directory if it doesn't exist.
|
|
4064
4023
|
* Delegates to ReportStorage.dump().
|
|
4065
4024
|
*
|
|
4025
|
+
* @param symbol - Trading pair symbol
|
|
4066
4026
|
* @param strategyName - Strategy name to save report for
|
|
4067
4027
|
* @param path - Directory path to save report (default: "./dump/schedule")
|
|
4068
4028
|
*
|
|
@@ -4071,32 +4031,35 @@ declare class ScheduleMarkdownService {
|
|
|
4071
4031
|
* const service = new ScheduleMarkdownService();
|
|
4072
4032
|
*
|
|
4073
4033
|
* // Save to default path: ./dump/schedule/my-strategy.md
|
|
4074
|
-
* await service.dump("my-strategy");
|
|
4034
|
+
* await service.dump("BTCUSDT", "my-strategy");
|
|
4075
4035
|
*
|
|
4076
4036
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
4077
|
-
* await service.dump("my-strategy", "./custom/path");
|
|
4037
|
+
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
4078
4038
|
* ```
|
|
4079
4039
|
*/
|
|
4080
|
-
dump: (strategyName: StrategyName, path?: string) => Promise<void>;
|
|
4040
|
+
dump: (symbol: string, strategyName: StrategyName, path?: string) => Promise<void>;
|
|
4081
4041
|
/**
|
|
4082
4042
|
* Clears accumulated event data from storage.
|
|
4083
|
-
* If
|
|
4084
|
-
* If
|
|
4043
|
+
* If ctx is provided, clears only that specific symbol-strategy pair's data.
|
|
4044
|
+
* If nothing is provided, clears all data.
|
|
4085
4045
|
*
|
|
4086
|
-
* @param
|
|
4046
|
+
* @param ctx - Optional context with symbol and strategyName
|
|
4087
4047
|
*
|
|
4088
4048
|
* @example
|
|
4089
4049
|
* ```typescript
|
|
4090
4050
|
* const service = new ScheduleMarkdownService();
|
|
4091
4051
|
*
|
|
4092
|
-
* // Clear specific strategy
|
|
4093
|
-
* await service.clear("my-strategy");
|
|
4052
|
+
* // Clear specific symbol-strategy pair
|
|
4053
|
+
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
4094
4054
|
*
|
|
4095
|
-
* // Clear all
|
|
4055
|
+
* // Clear all data
|
|
4096
4056
|
* await service.clear();
|
|
4097
4057
|
* ```
|
|
4098
4058
|
*/
|
|
4099
|
-
clear: (
|
|
4059
|
+
clear: (ctx?: {
|
|
4060
|
+
symbol: string;
|
|
4061
|
+
strategyName: StrategyName;
|
|
4062
|
+
}) => Promise<void>;
|
|
4100
4063
|
/**
|
|
4101
4064
|
* Initializes the service by subscribing to live signal events.
|
|
4102
4065
|
* Uses singleshot to ensure initialization happens only once.
|
|
@@ -4188,8 +4151,8 @@ declare class PerformanceMarkdownService {
|
|
|
4188
4151
|
/** Logger service for debug output */
|
|
4189
4152
|
private readonly loggerService;
|
|
4190
4153
|
/**
|
|
4191
|
-
* Memoized function to get or create PerformanceStorage for a strategy.
|
|
4192
|
-
* Each strategy gets its own isolated storage instance.
|
|
4154
|
+
* Memoized function to get or create PerformanceStorage for a symbol-strategy pair.
|
|
4155
|
+
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
4193
4156
|
*/
|
|
4194
4157
|
private getStorage;
|
|
4195
4158
|
/**
|
|
@@ -4200,55 +4163,62 @@ declare class PerformanceMarkdownService {
|
|
|
4200
4163
|
*/
|
|
4201
4164
|
private track;
|
|
4202
4165
|
/**
|
|
4203
|
-
* Gets aggregated performance statistics for a strategy.
|
|
4166
|
+
* Gets aggregated performance statistics for a symbol-strategy pair.
|
|
4204
4167
|
*
|
|
4168
|
+
* @param symbol - Trading pair symbol
|
|
4205
4169
|
* @param strategyName - Strategy name to get data for
|
|
4206
4170
|
* @returns Performance statistics with aggregated metrics
|
|
4207
4171
|
*
|
|
4208
4172
|
* @example
|
|
4209
4173
|
* ```typescript
|
|
4210
|
-
* const stats = await performanceService.getData("my-strategy");
|
|
4174
|
+
* const stats = await performanceService.getData("BTCUSDT", "my-strategy");
|
|
4211
4175
|
* console.log("Total time:", stats.totalDuration);
|
|
4212
4176
|
* console.log("Slowest operation:", Object.values(stats.metricStats)
|
|
4213
4177
|
* .sort((a, b) => b.avgDuration - a.avgDuration)[0]);
|
|
4214
4178
|
* ```
|
|
4215
4179
|
*/
|
|
4216
|
-
getData: (strategyName: string) => Promise<PerformanceStatistics>;
|
|
4180
|
+
getData: (symbol: string, strategyName: string) => Promise<PerformanceStatistics>;
|
|
4217
4181
|
/**
|
|
4218
4182
|
* Generates markdown report with performance analysis.
|
|
4219
4183
|
*
|
|
4184
|
+
* @param symbol - Trading pair symbol
|
|
4220
4185
|
* @param strategyName - Strategy name to generate report for
|
|
4221
4186
|
* @returns Markdown formatted report string
|
|
4222
4187
|
*
|
|
4223
4188
|
* @example
|
|
4224
4189
|
* ```typescript
|
|
4225
|
-
* const markdown = await performanceService.getReport("my-strategy");
|
|
4190
|
+
* const markdown = await performanceService.getReport("BTCUSDT", "my-strategy");
|
|
4226
4191
|
* console.log(markdown);
|
|
4227
4192
|
* ```
|
|
4228
4193
|
*/
|
|
4229
|
-
getReport: (strategyName: string) => Promise<string>;
|
|
4194
|
+
getReport: (symbol: string, strategyName: string) => Promise<string>;
|
|
4230
4195
|
/**
|
|
4231
4196
|
* Saves performance report to disk.
|
|
4232
4197
|
*
|
|
4198
|
+
* @param symbol - Trading pair symbol
|
|
4233
4199
|
* @param strategyName - Strategy name to save report for
|
|
4234
4200
|
* @param path - Directory path to save report
|
|
4235
4201
|
*
|
|
4236
4202
|
* @example
|
|
4237
4203
|
* ```typescript
|
|
4238
4204
|
* // Save to default path: ./dump/performance/my-strategy.md
|
|
4239
|
-
* await performanceService.dump("my-strategy");
|
|
4205
|
+
* await performanceService.dump("BTCUSDT", "my-strategy");
|
|
4240
4206
|
*
|
|
4241
4207
|
* // Save to custom path
|
|
4242
|
-
* await performanceService.dump("my-strategy", "./custom/path");
|
|
4208
|
+
* await performanceService.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
4243
4209
|
* ```
|
|
4244
4210
|
*/
|
|
4245
|
-
dump: (strategyName: string, path?: string) => Promise<void>;
|
|
4211
|
+
dump: (symbol: string, strategyName: string, path?: string) => Promise<void>;
|
|
4246
4212
|
/**
|
|
4247
4213
|
* Clears accumulated performance data from storage.
|
|
4248
4214
|
*
|
|
4249
|
-
* @param
|
|
4215
|
+
* @param symbol - Optional trading pair symbol
|
|
4216
|
+
* @param strategyName - Optional strategy name
|
|
4250
4217
|
*/
|
|
4251
|
-
clear: (
|
|
4218
|
+
clear: (ctx?: {
|
|
4219
|
+
symbol: string;
|
|
4220
|
+
strategyName: string;
|
|
4221
|
+
}) => Promise<void>;
|
|
4252
4222
|
/**
|
|
4253
4223
|
* Initializes the service by subscribing to performance events.
|
|
4254
4224
|
* Uses singleshot to ensure initialization happens only once.
|
|
@@ -4772,16 +4742,16 @@ declare class PersistSignalUtils {
|
|
|
4772
4742
|
*/
|
|
4773
4743
|
usePersistSignalAdapter(Ctor: TPersistBaseCtor<StrategyName, SignalData>): void;
|
|
4774
4744
|
/**
|
|
4775
|
-
* Reads persisted signal data for a
|
|
4745
|
+
* Reads persisted signal data for a symbol and strategy.
|
|
4776
4746
|
*
|
|
4777
4747
|
* Called by ClientStrategy.waitForInit() to restore state.
|
|
4778
4748
|
* Returns null if no signal exists.
|
|
4779
4749
|
*
|
|
4780
|
-
* @param strategyName - Strategy identifier
|
|
4781
4750
|
* @param symbol - Trading pair symbol
|
|
4751
|
+
* @param strategyName - Strategy identifier
|
|
4782
4752
|
* @returns Promise resolving to signal or null
|
|
4783
4753
|
*/
|
|
4784
|
-
readSignalData: (
|
|
4754
|
+
readSignalData: (symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
4785
4755
|
/**
|
|
4786
4756
|
* Writes signal data to disk with atomic file writes.
|
|
4787
4757
|
*
|
|
@@ -4789,11 +4759,11 @@ declare class PersistSignalUtils {
|
|
|
4789
4759
|
* Uses atomic writes to prevent corruption on crashes.
|
|
4790
4760
|
*
|
|
4791
4761
|
* @param signalRow - Signal data (null to clear)
|
|
4792
|
-
* @param strategyName - Strategy identifier
|
|
4793
4762
|
* @param symbol - Trading pair symbol
|
|
4763
|
+
* @param strategyName - Strategy identifier
|
|
4794
4764
|
* @returns Promise that resolves when write is complete
|
|
4795
4765
|
*/
|
|
4796
|
-
writeSignalData: (signalRow: ISignalRow | null,
|
|
4766
|
+
writeSignalData: (signalRow: ISignalRow | null, symbol: string, strategyName: StrategyName) => Promise<void>;
|
|
4797
4767
|
}
|
|
4798
4768
|
/**
|
|
4799
4769
|
* Global singleton instance of PersistSignalUtils.
|
|
@@ -4920,16 +4890,16 @@ declare class PersistScheduleUtils {
|
|
|
4920
4890
|
*/
|
|
4921
4891
|
usePersistScheduleAdapter(Ctor: TPersistBaseCtor<StrategyName, ScheduleData>): void;
|
|
4922
4892
|
/**
|
|
4923
|
-
* Reads persisted scheduled signal data for a
|
|
4893
|
+
* Reads persisted scheduled signal data for a symbol and strategy.
|
|
4924
4894
|
*
|
|
4925
4895
|
* Called by ClientStrategy.waitForInit() to restore scheduled signal state.
|
|
4926
4896
|
* Returns null if no scheduled signal exists.
|
|
4927
4897
|
*
|
|
4928
|
-
* @param strategyName - Strategy identifier
|
|
4929
4898
|
* @param symbol - Trading pair symbol
|
|
4899
|
+
* @param strategyName - Strategy identifier
|
|
4930
4900
|
* @returns Promise resolving to scheduled signal or null
|
|
4931
4901
|
*/
|
|
4932
|
-
readScheduleData: (
|
|
4902
|
+
readScheduleData: (symbol: string, strategyName: StrategyName) => Promise<IScheduledSignalRow | null>;
|
|
4933
4903
|
/**
|
|
4934
4904
|
* Writes scheduled signal data to disk with atomic file writes.
|
|
4935
4905
|
*
|
|
@@ -4937,11 +4907,11 @@ declare class PersistScheduleUtils {
|
|
|
4937
4907
|
* Uses atomic writes to prevent corruption on crashes.
|
|
4938
4908
|
*
|
|
4939
4909
|
* @param scheduledSignalRow - Scheduled signal data (null to clear)
|
|
4940
|
-
* @param strategyName - Strategy identifier
|
|
4941
4910
|
* @param symbol - Trading pair symbol
|
|
4911
|
+
* @param strategyName - Strategy identifier
|
|
4942
4912
|
* @returns Promise that resolves when write is complete
|
|
4943
4913
|
*/
|
|
4944
|
-
writeScheduleData: (scheduledSignalRow: IScheduledSignalRow | null,
|
|
4914
|
+
writeScheduleData: (scheduledSignalRow: IScheduledSignalRow | null, symbol: string, strategyName: StrategyName) => Promise<void>;
|
|
4945
4915
|
}
|
|
4946
4916
|
/**
|
|
4947
4917
|
* Global singleton instance of PersistScheduleUtils.
|
|
@@ -5093,31 +5063,33 @@ declare class BacktestUtils {
|
|
|
5093
5063
|
frameName: string;
|
|
5094
5064
|
}) => () => void;
|
|
5095
5065
|
/**
|
|
5096
|
-
* Gets statistical data from all closed signals for a strategy.
|
|
5066
|
+
* Gets statistical data from all closed signals for a symbol-strategy pair.
|
|
5097
5067
|
*
|
|
5068
|
+
* @param symbol - Trading pair symbol
|
|
5098
5069
|
* @param strategyName - Strategy name to get data for
|
|
5099
5070
|
* @returns Promise resolving to statistical data object
|
|
5100
5071
|
*
|
|
5101
5072
|
* @example
|
|
5102
5073
|
* ```typescript
|
|
5103
|
-
* const stats = await Backtest.getData("my-strategy");
|
|
5074
|
+
* const stats = await Backtest.getData("BTCUSDT", "my-strategy");
|
|
5104
5075
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
5105
5076
|
* ```
|
|
5106
5077
|
*/
|
|
5107
|
-
getData: (strategyName: StrategyName) => Promise<BacktestStatistics>;
|
|
5078
|
+
getData: (symbol: string, strategyName: StrategyName) => Promise<BacktestStatistics>;
|
|
5108
5079
|
/**
|
|
5109
|
-
* Generates markdown report with all closed signals for a strategy.
|
|
5080
|
+
* Generates markdown report with all closed signals for a symbol-strategy pair.
|
|
5110
5081
|
*
|
|
5082
|
+
* @param symbol - Trading pair symbol
|
|
5111
5083
|
* @param strategyName - Strategy name to generate report for
|
|
5112
5084
|
* @returns Promise resolving to markdown formatted report string
|
|
5113
5085
|
*
|
|
5114
5086
|
* @example
|
|
5115
5087
|
* ```typescript
|
|
5116
|
-
* const markdown = await Backtest.getReport("my-strategy");
|
|
5088
|
+
* const markdown = await Backtest.getReport("BTCUSDT", "my-strategy");
|
|
5117
5089
|
* console.log(markdown);
|
|
5118
5090
|
* ```
|
|
5119
5091
|
*/
|
|
5120
|
-
getReport: (strategyName: StrategyName) => Promise<string>;
|
|
5092
|
+
getReport: (symbol: string, strategyName: StrategyName) => Promise<string>;
|
|
5121
5093
|
/**
|
|
5122
5094
|
* Saves strategy report to disk.
|
|
5123
5095
|
*
|
|
@@ -5225,31 +5197,33 @@ declare class LiveUtils {
|
|
|
5225
5197
|
exchangeName: string;
|
|
5226
5198
|
}) => () => void;
|
|
5227
5199
|
/**
|
|
5228
|
-
* Gets statistical data from all live trading events for a strategy.
|
|
5200
|
+
* Gets statistical data from all live trading events for a symbol-strategy pair.
|
|
5229
5201
|
*
|
|
5202
|
+
* @param symbol - Trading pair symbol
|
|
5230
5203
|
* @param strategyName - Strategy name to get data for
|
|
5231
5204
|
* @returns Promise resolving to statistical data object
|
|
5232
5205
|
*
|
|
5233
5206
|
* @example
|
|
5234
5207
|
* ```typescript
|
|
5235
|
-
* const stats = await Live.getData("my-strategy");
|
|
5208
|
+
* const stats = await Live.getData("BTCUSDT", "my-strategy");
|
|
5236
5209
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
5237
5210
|
* ```
|
|
5238
5211
|
*/
|
|
5239
|
-
getData: (strategyName: StrategyName) => Promise<LiveStatistics>;
|
|
5212
|
+
getData: (symbol: string, strategyName: StrategyName) => Promise<LiveStatistics>;
|
|
5240
5213
|
/**
|
|
5241
|
-
* Generates markdown report with all events for a strategy.
|
|
5214
|
+
* Generates markdown report with all events for a symbol-strategy pair.
|
|
5242
5215
|
*
|
|
5216
|
+
* @param symbol - Trading pair symbol
|
|
5243
5217
|
* @param strategyName - Strategy name to generate report for
|
|
5244
5218
|
* @returns Promise resolving to markdown formatted report string
|
|
5245
5219
|
*
|
|
5246
5220
|
* @example
|
|
5247
5221
|
* ```typescript
|
|
5248
|
-
* const markdown = await Live.getReport("my-strategy");
|
|
5222
|
+
* const markdown = await Live.getReport("BTCUSDT", "my-strategy");
|
|
5249
5223
|
* console.log(markdown);
|
|
5250
5224
|
* ```
|
|
5251
5225
|
*/
|
|
5252
|
-
getReport: (strategyName: StrategyName) => Promise<string>;
|
|
5226
|
+
getReport: (symbol: string, strategyName: StrategyName) => Promise<string>;
|
|
5253
5227
|
/**
|
|
5254
5228
|
* Saves strategy report to disk.
|
|
5255
5229
|
*
|
|
@@ -5311,31 +5285,33 @@ declare const Live: LiveUtils;
|
|
|
5311
5285
|
*/
|
|
5312
5286
|
declare class ScheduleUtils {
|
|
5313
5287
|
/**
|
|
5314
|
-
* Gets statistical data from all scheduled signal events for a strategy.
|
|
5288
|
+
* Gets statistical data from all scheduled signal events for a symbol-strategy pair.
|
|
5315
5289
|
*
|
|
5290
|
+
* @param symbol - Trading pair symbol
|
|
5316
5291
|
* @param strategyName - Strategy name to get data for
|
|
5317
5292
|
* @returns Promise resolving to statistical data object
|
|
5318
5293
|
*
|
|
5319
5294
|
* @example
|
|
5320
5295
|
* ```typescript
|
|
5321
|
-
* const stats = await Schedule.getData("my-strategy");
|
|
5296
|
+
* const stats = await Schedule.getData("BTCUSDT", "my-strategy");
|
|
5322
5297
|
* console.log(stats.cancellationRate, stats.avgWaitTime);
|
|
5323
5298
|
* ```
|
|
5324
5299
|
*/
|
|
5325
|
-
getData: (strategyName: StrategyName) => Promise<ScheduleStatistics>;
|
|
5300
|
+
getData: (symbol: string, strategyName: StrategyName) => Promise<ScheduleStatistics>;
|
|
5326
5301
|
/**
|
|
5327
|
-
* Generates markdown report with all scheduled events for a strategy.
|
|
5302
|
+
* Generates markdown report with all scheduled events for a symbol-strategy pair.
|
|
5328
5303
|
*
|
|
5304
|
+
* @param symbol - Trading pair symbol
|
|
5329
5305
|
* @param strategyName - Strategy name to generate report for
|
|
5330
5306
|
* @returns Promise resolving to markdown formatted report string
|
|
5331
5307
|
*
|
|
5332
5308
|
* @example
|
|
5333
5309
|
* ```typescript
|
|
5334
|
-
* const markdown = await Schedule.getReport("my-strategy");
|
|
5310
|
+
* const markdown = await Schedule.getReport("BTCUSDT", "my-strategy");
|
|
5335
5311
|
* console.log(markdown);
|
|
5336
5312
|
* ```
|
|
5337
5313
|
*/
|
|
5338
|
-
getReport: (strategyName: StrategyName) => Promise<string>;
|
|
5314
|
+
getReport: (symbol: string, strategyName: StrategyName) => Promise<string>;
|
|
5339
5315
|
/**
|
|
5340
5316
|
* Saves strategy report to disk.
|
|
5341
5317
|
*
|
|
@@ -5399,19 +5375,20 @@ declare const Schedule: ScheduleUtils;
|
|
|
5399
5375
|
*/
|
|
5400
5376
|
declare class Performance {
|
|
5401
5377
|
/**
|
|
5402
|
-
* Gets aggregated performance statistics for a strategy.
|
|
5378
|
+
* Gets aggregated performance statistics for a symbol-strategy pair.
|
|
5403
5379
|
*
|
|
5404
5380
|
* Returns detailed metrics grouped by operation type:
|
|
5405
5381
|
* - Count, total duration, average, min, max
|
|
5406
5382
|
* - Standard deviation for volatility
|
|
5407
5383
|
* - Percentiles (median, P95, P99) for outlier detection
|
|
5408
5384
|
*
|
|
5385
|
+
* @param symbol - Trading pair symbol
|
|
5409
5386
|
* @param strategyName - Strategy name to analyze
|
|
5410
5387
|
* @returns Performance statistics with aggregated metrics
|
|
5411
5388
|
*
|
|
5412
5389
|
* @example
|
|
5413
5390
|
* ```typescript
|
|
5414
|
-
* const stats = await Performance.getData("my-strategy");
|
|
5391
|
+
* const stats = await Performance.getData("BTCUSDT", "my-strategy");
|
|
5415
5392
|
*
|
|
5416
5393
|
* // Find slowest operation type
|
|
5417
5394
|
* const slowest = Object.values(stats.metricStats)
|
|
@@ -5426,7 +5403,7 @@ declare class Performance {
|
|
|
5426
5403
|
* }
|
|
5427
5404
|
* ```
|
|
5428
5405
|
*/
|
|
5429
|
-
static getData(strategyName: string): Promise<PerformanceStatistics>;
|
|
5406
|
+
static getData(symbol: string, strategyName: string): Promise<PerformanceStatistics>;
|
|
5430
5407
|
/**
|
|
5431
5408
|
* Generates markdown report with performance analysis.
|
|
5432
5409
|
*
|
|
@@ -5435,12 +5412,13 @@ declare class Performance {
|
|
|
5435
5412
|
* - Detailed metrics table with statistics
|
|
5436
5413
|
* - Percentile analysis for bottleneck detection
|
|
5437
5414
|
*
|
|
5415
|
+
* @param symbol - Trading pair symbol
|
|
5438
5416
|
* @param strategyName - Strategy name to generate report for
|
|
5439
5417
|
* @returns Markdown formatted report string
|
|
5440
5418
|
*
|
|
5441
5419
|
* @example
|
|
5442
5420
|
* ```typescript
|
|
5443
|
-
* const markdown = await Performance.getReport("my-strategy");
|
|
5421
|
+
* const markdown = await Performance.getReport("BTCUSDT", "my-strategy");
|
|
5444
5422
|
* console.log(markdown);
|
|
5445
5423
|
*
|
|
5446
5424
|
* // Or save to file
|
|
@@ -5448,7 +5426,7 @@ declare class Performance {
|
|
|
5448
5426
|
* await fs.writeFile("performance-report.md", markdown);
|
|
5449
5427
|
* ```
|
|
5450
5428
|
*/
|
|
5451
|
-
static getReport(strategyName: string): Promise<string>;
|
|
5429
|
+
static getReport(symbol: string, strategyName: string): Promise<string>;
|
|
5452
5430
|
/**
|
|
5453
5431
|
* Saves performance report to disk.
|
|
5454
5432
|
*
|
|
@@ -5468,21 +5446,6 @@ declare class Performance {
|
|
|
5468
5446
|
* ```
|
|
5469
5447
|
*/
|
|
5470
5448
|
static dump(strategyName: string, path?: string): Promise<void>;
|
|
5471
|
-
/**
|
|
5472
|
-
* Clears accumulated performance metrics from memory.
|
|
5473
|
-
*
|
|
5474
|
-
* @param strategyName - Optional strategy name to clear specific strategy's metrics
|
|
5475
|
-
*
|
|
5476
|
-
* @example
|
|
5477
|
-
* ```typescript
|
|
5478
|
-
* // Clear specific strategy metrics
|
|
5479
|
-
* await Performance.clear("my-strategy");
|
|
5480
|
-
*
|
|
5481
|
-
* // Clear all metrics for all strategies
|
|
5482
|
-
* await Performance.clear();
|
|
5483
|
-
* ```
|
|
5484
|
-
*/
|
|
5485
|
-
static clear(strategyName?: string): Promise<void>;
|
|
5486
5449
|
}
|
|
5487
5450
|
|
|
5488
5451
|
/**
|
|
@@ -6177,7 +6140,10 @@ declare const walkerCompleteSubject: Subject<IWalkerResults>;
|
|
|
6177
6140
|
* Walker stop emitter for walker cancellation events.
|
|
6178
6141
|
* Emits when a walker comparison is stopped/cancelled.
|
|
6179
6142
|
*/
|
|
6180
|
-
declare const walkerStopSubject: Subject<
|
|
6143
|
+
declare const walkerStopSubject: Subject<{
|
|
6144
|
+
symbol: string;
|
|
6145
|
+
strategyName: StrategyName;
|
|
6146
|
+
}>;
|
|
6181
6147
|
/**
|
|
6182
6148
|
* Validation emitter for risk validation errors.
|
|
6183
6149
|
* Emits when risk validation functions throw errors during signal checking.
|
|
@@ -6440,24 +6406,23 @@ declare class ExchangeConnectionService implements IExchange {
|
|
|
6440
6406
|
* Connection service routing strategy operations to correct ClientStrategy instance.
|
|
6441
6407
|
*
|
|
6442
6408
|
* Routes all IStrategy method calls to the appropriate strategy implementation
|
|
6443
|
-
* based on
|
|
6409
|
+
* based on symbol-strategy pairs. Uses memoization to cache
|
|
6444
6410
|
* ClientStrategy instances for performance.
|
|
6445
6411
|
*
|
|
6446
6412
|
* Key features:
|
|
6447
|
-
* - Automatic strategy routing via
|
|
6448
|
-
* - Memoized ClientStrategy instances by strategyName
|
|
6449
|
-
* - Implements IStrategy interface
|
|
6413
|
+
* - Automatic strategy routing via symbol-strategy pairs
|
|
6414
|
+
* - Memoized ClientStrategy instances by symbol:strategyName
|
|
6450
6415
|
* - Ensures initialization with waitForInit() before operations
|
|
6451
6416
|
* - Handles both tick() (live) and backtest() operations
|
|
6452
6417
|
*
|
|
6453
6418
|
* @example
|
|
6454
6419
|
* ```typescript
|
|
6455
6420
|
* // Used internally by framework
|
|
6456
|
-
* const result = await strategyConnectionService.tick();
|
|
6457
|
-
* //
|
|
6421
|
+
* const result = await strategyConnectionService.tick(symbol, strategyName);
|
|
6422
|
+
* // Routes to correct strategy instance for symbol-strategy pair
|
|
6458
6423
|
* ```
|
|
6459
6424
|
*/
|
|
6460
|
-
declare class StrategyConnectionService
|
|
6425
|
+
declare class StrategyConnectionService {
|
|
6461
6426
|
private readonly loggerService;
|
|
6462
6427
|
private readonly executionContextService;
|
|
6463
6428
|
private readonly strategySchemaService;
|
|
@@ -6466,11 +6431,12 @@ declare class StrategyConnectionService implements IStrategy {
|
|
|
6466
6431
|
private readonly methodContextService;
|
|
6467
6432
|
private readonly partialConnectionService;
|
|
6468
6433
|
/**
|
|
6469
|
-
* Retrieves memoized ClientStrategy instance for given strategy
|
|
6434
|
+
* Retrieves memoized ClientStrategy instance for given symbol-strategy pair.
|
|
6470
6435
|
*
|
|
6471
6436
|
* Creates ClientStrategy on first call, returns cached instance on subsequent calls.
|
|
6472
|
-
* Cache key is strategyName string.
|
|
6437
|
+
* Cache key is symbol:strategyName string.
|
|
6473
6438
|
*
|
|
6439
|
+
* @param symbol - Trading pair symbol
|
|
6474
6440
|
* @param strategyName - Name of registered strategy schema
|
|
6475
6441
|
* @returns Configured ClientStrategy instance
|
|
6476
6442
|
*/
|
|
@@ -6480,49 +6446,58 @@ declare class StrategyConnectionService implements IStrategy {
|
|
|
6480
6446
|
* If no active signal exists, returns null.
|
|
6481
6447
|
* Used internally for monitoring TP/SL and time expiration.
|
|
6482
6448
|
*
|
|
6449
|
+
* @param symbol - Trading pair symbol
|
|
6483
6450
|
* @param strategyName - Name of strategy to get pending signal for
|
|
6484
6451
|
*
|
|
6485
6452
|
* @returns Promise resolving to pending signal or null
|
|
6486
6453
|
*/
|
|
6487
|
-
getPendingSignal: (strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
6454
|
+
getPendingSignal: (symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
6488
6455
|
/**
|
|
6489
6456
|
* Executes live trading tick for current strategy.
|
|
6490
6457
|
*
|
|
6491
6458
|
* Waits for strategy initialization before processing tick.
|
|
6492
6459
|
* Evaluates current market conditions and returns signal state.
|
|
6493
6460
|
*
|
|
6461
|
+
* @param symbol - Trading pair symbol
|
|
6462
|
+
* @param strategyName - Name of strategy to tick
|
|
6494
6463
|
* @returns Promise resolving to tick result (idle, opened, active, closed)
|
|
6495
6464
|
*/
|
|
6496
|
-
tick: () => Promise<IStrategyTickResult>;
|
|
6465
|
+
tick: (symbol: string, strategyName: StrategyName) => Promise<IStrategyTickResult>;
|
|
6497
6466
|
/**
|
|
6498
6467
|
* Executes backtest for current strategy with provided candles.
|
|
6499
6468
|
*
|
|
6500
6469
|
* Waits for strategy initialization before processing candles.
|
|
6501
6470
|
* Evaluates strategy signals against historical data.
|
|
6502
6471
|
*
|
|
6472
|
+
* @param symbol - Trading pair symbol
|
|
6473
|
+
* @param strategyName - Name of strategy to backtest
|
|
6503
6474
|
* @param candles - Array of historical candle data to backtest
|
|
6504
6475
|
* @returns Promise resolving to backtest result (signal or idle)
|
|
6505
6476
|
*/
|
|
6506
|
-
backtest: (candles: ICandleData[]) => Promise<IStrategyBacktestResult>;
|
|
6477
|
+
backtest: (symbol: string, strategyName: StrategyName, candles: ICandleData[]) => Promise<IStrategyBacktestResult>;
|
|
6507
6478
|
/**
|
|
6508
6479
|
* Stops the specified strategy from generating new signals.
|
|
6509
6480
|
*
|
|
6510
6481
|
* Delegates to ClientStrategy.stop() which sets internal flag to prevent
|
|
6511
6482
|
* getSignal from being called on subsequent ticks.
|
|
6512
6483
|
*
|
|
6484
|
+
* @param symbol - Trading pair symbol
|
|
6513
6485
|
* @param strategyName - Name of strategy to stop
|
|
6514
6486
|
* @returns Promise that resolves when stop flag is set
|
|
6515
6487
|
*/
|
|
6516
|
-
stop: (strategyName: StrategyName) => Promise<void>;
|
|
6488
|
+
stop: (symbol: string, strategyName: StrategyName) => Promise<void>;
|
|
6517
6489
|
/**
|
|
6518
6490
|
* Clears the memoized ClientStrategy instance from cache.
|
|
6519
6491
|
*
|
|
6520
6492
|
* Forces re-initialization of strategy on next getStrategy call.
|
|
6521
6493
|
* Useful for resetting strategy state or releasing resources.
|
|
6522
6494
|
*
|
|
6523
|
-
* @param
|
|
6495
|
+
* @param ctx - Optional context with symbol and strategyName (clears all if not provided)
|
|
6524
6496
|
*/
|
|
6525
|
-
clear: (
|
|
6497
|
+
clear: (ctx?: {
|
|
6498
|
+
symbol: string;
|
|
6499
|
+
strategyName: StrategyName;
|
|
6500
|
+
}) => Promise<void>;
|
|
6526
6501
|
}
|
|
6527
6502
|
|
|
6528
6503
|
/**
|
|
@@ -6926,8 +6901,9 @@ declare class StrategyGlobalService {
|
|
|
6926
6901
|
/**
|
|
6927
6902
|
* Validates strategy and associated risk configuration.
|
|
6928
6903
|
*
|
|
6929
|
-
* Memoized to avoid redundant validations for the same strategy.
|
|
6904
|
+
* Memoized to avoid redundant validations for the same symbol-strategy pair.
|
|
6930
6905
|
* Logs validation activity.
|
|
6906
|
+
* @param symbol - Trading pair symbol
|
|
6931
6907
|
* @param strategyName - Name of the strategy to validate
|
|
6932
6908
|
* @returns Promise that resolves when validation is complete
|
|
6933
6909
|
*/
|
|
@@ -6938,11 +6914,10 @@ declare class StrategyGlobalService {
|
|
|
6938
6914
|
* Used internally for monitoring TP/SL and time expiration.
|
|
6939
6915
|
*
|
|
6940
6916
|
* @param symbol - Trading pair symbol
|
|
6941
|
-
* @param
|
|
6942
|
-
* @param backtest - Whether running in backtest mode
|
|
6917
|
+
* @param strategyName - Name of the strategy
|
|
6943
6918
|
* @returns Promise resolving to pending signal or null
|
|
6944
6919
|
*/
|
|
6945
|
-
getPendingSignal: (strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
6920
|
+
getPendingSignal: (symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
6946
6921
|
/**
|
|
6947
6922
|
* Checks signal status at a specific timestamp.
|
|
6948
6923
|
*
|
|
@@ -6974,19 +6949,23 @@ declare class StrategyGlobalService {
|
|
|
6974
6949
|
* Delegates to StrategyConnectionService.stop() to set internal flag.
|
|
6975
6950
|
* Does not require execution context.
|
|
6976
6951
|
*
|
|
6952
|
+
* @param symbol - Trading pair symbol
|
|
6977
6953
|
* @param strategyName - Name of strategy to stop
|
|
6978
6954
|
* @returns Promise that resolves when stop flag is set
|
|
6979
6955
|
*/
|
|
6980
|
-
stop: (strategyName: StrategyName) => Promise<void>;
|
|
6956
|
+
stop: (symbol: string, strategyName: StrategyName) => Promise<void>;
|
|
6981
6957
|
/**
|
|
6982
6958
|
* Clears the memoized ClientStrategy instance from cache.
|
|
6983
6959
|
*
|
|
6984
6960
|
* Delegates to StrategyConnectionService.clear() to remove strategy from cache.
|
|
6985
6961
|
* Forces re-initialization of strategy on next operation.
|
|
6986
6962
|
*
|
|
6987
|
-
* @param
|
|
6963
|
+
* @param ctx - Optional context with symbol and strategyName (clears all if not provided)
|
|
6988
6964
|
*/
|
|
6989
|
-
clear: (
|
|
6965
|
+
clear: (ctx?: {
|
|
6966
|
+
symbol: string;
|
|
6967
|
+
strategyName: StrategyName;
|
|
6968
|
+
}) => Promise<void>;
|
|
6990
6969
|
}
|
|
6991
6970
|
|
|
6992
6971
|
/**
|
|
@@ -8199,7 +8178,7 @@ declare class OptimizerTemplateService implements IOptimizerTemplate {
|
|
|
8199
8178
|
getJsonDumpTemplate: (symbol: string) => Promise<string>;
|
|
8200
8179
|
/**
|
|
8201
8180
|
* Generates text() helper for LLM text generation.
|
|
8202
|
-
* Uses Ollama
|
|
8181
|
+
* Uses Ollama deepseek-v3.1:671b model for market analysis.
|
|
8203
8182
|
*
|
|
8204
8183
|
* @param symbol - Trading pair symbol (used in prompt)
|
|
8205
8184
|
* @returns Generated async text() function
|