backtest-kit 5.6.5 → 5.6.6
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 +149 -19
- package/build/index.mjs +149 -19
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -35079,7 +35079,14 @@ function listenSignal(fn) {
|
|
|
35079
35079
|
*/
|
|
35080
35080
|
function listenSignalOnce(filterFn, fn) {
|
|
35081
35081
|
bt.loggerService.log(LISTEN_SIGNAL_ONCE_METHOD_NAME);
|
|
35082
|
-
|
|
35082
|
+
let disposeFn;
|
|
35083
|
+
const wrappedFn = async (event) => {
|
|
35084
|
+
if (filterFn(event)) {
|
|
35085
|
+
await fn(event);
|
|
35086
|
+
disposeFn && disposeFn();
|
|
35087
|
+
}
|
|
35088
|
+
};
|
|
35089
|
+
return disposeFn = listenSignal(wrappedFn);
|
|
35083
35090
|
}
|
|
35084
35091
|
/**
|
|
35085
35092
|
* Subscribes to live trading signal events with queued async processing.
|
|
@@ -35128,7 +35135,14 @@ function listenSignalLive(fn) {
|
|
|
35128
35135
|
*/
|
|
35129
35136
|
function listenSignalLiveOnce(filterFn, fn) {
|
|
35130
35137
|
bt.loggerService.log(LISTEN_SIGNAL_LIVE_ONCE_METHOD_NAME);
|
|
35131
|
-
|
|
35138
|
+
let disposeFn;
|
|
35139
|
+
const wrappedFn = async (event) => {
|
|
35140
|
+
if (filterFn(event)) {
|
|
35141
|
+
await fn(event);
|
|
35142
|
+
disposeFn && disposeFn();
|
|
35143
|
+
}
|
|
35144
|
+
};
|
|
35145
|
+
return disposeFn = listenSignalLive(wrappedFn);
|
|
35132
35146
|
}
|
|
35133
35147
|
/**
|
|
35134
35148
|
* Subscribes to backtest signal events with queued async processing.
|
|
@@ -35177,7 +35191,14 @@ function listenSignalBacktest(fn) {
|
|
|
35177
35191
|
*/
|
|
35178
35192
|
function listenSignalBacktestOnce(filterFn, fn) {
|
|
35179
35193
|
bt.loggerService.log(LISTEN_SIGNAL_BACKTEST_ONCE_METHOD_NAME);
|
|
35180
|
-
|
|
35194
|
+
let disposeFn;
|
|
35195
|
+
const wrappedFn = async (event) => {
|
|
35196
|
+
if (filterFn(event)) {
|
|
35197
|
+
await fn(event);
|
|
35198
|
+
disposeFn && disposeFn();
|
|
35199
|
+
}
|
|
35200
|
+
};
|
|
35201
|
+
return disposeFn = listenSignalBacktest(wrappedFn);
|
|
35181
35202
|
}
|
|
35182
35203
|
/**
|
|
35183
35204
|
* Subscribes to recoverable execution errors with queued async processing.
|
|
@@ -35294,7 +35315,14 @@ function listenDoneLive(fn) {
|
|
|
35294
35315
|
*/
|
|
35295
35316
|
function listenDoneLiveOnce(filterFn, fn) {
|
|
35296
35317
|
bt.loggerService.log(LISTEN_DONE_LIVE_ONCE_METHOD_NAME);
|
|
35297
|
-
|
|
35318
|
+
let disposeFn;
|
|
35319
|
+
const wrappedFn = async (event) => {
|
|
35320
|
+
if (filterFn(event)) {
|
|
35321
|
+
await fn(event);
|
|
35322
|
+
disposeFn && disposeFn();
|
|
35323
|
+
}
|
|
35324
|
+
};
|
|
35325
|
+
return disposeFn = listenDoneLive(wrappedFn);
|
|
35298
35326
|
}
|
|
35299
35327
|
/**
|
|
35300
35328
|
* Subscribes to backtest background execution completion events with queued async processing.
|
|
@@ -35357,7 +35385,14 @@ function listenDoneBacktest(fn) {
|
|
|
35357
35385
|
*/
|
|
35358
35386
|
function listenDoneBacktestOnce(filterFn, fn) {
|
|
35359
35387
|
bt.loggerService.log(LISTEN_DONE_BACKTEST_ONCE_METHOD_NAME);
|
|
35360
|
-
|
|
35388
|
+
let disposeFn;
|
|
35389
|
+
const wrappedFn = async (event) => {
|
|
35390
|
+
if (filterFn(event)) {
|
|
35391
|
+
await fn(event);
|
|
35392
|
+
disposeFn && disposeFn();
|
|
35393
|
+
}
|
|
35394
|
+
};
|
|
35395
|
+
return disposeFn = listenDoneBacktest(wrappedFn);
|
|
35361
35396
|
}
|
|
35362
35397
|
/**
|
|
35363
35398
|
* Subscribes to walker background execution completion events with queued async processing.
|
|
@@ -35416,7 +35451,14 @@ function listenDoneWalker(fn) {
|
|
|
35416
35451
|
*/
|
|
35417
35452
|
function listenDoneWalkerOnce(filterFn, fn) {
|
|
35418
35453
|
bt.loggerService.log(LISTEN_DONE_WALKER_ONCE_METHOD_NAME);
|
|
35419
|
-
|
|
35454
|
+
let disposeFn;
|
|
35455
|
+
const wrappedFn = async (event) => {
|
|
35456
|
+
if (filterFn(event)) {
|
|
35457
|
+
await fn(event);
|
|
35458
|
+
disposeFn && disposeFn();
|
|
35459
|
+
}
|
|
35460
|
+
};
|
|
35461
|
+
return disposeFn = listenDoneWalker(wrappedFn);
|
|
35420
35462
|
}
|
|
35421
35463
|
/**
|
|
35422
35464
|
* Subscribes to backtest progress events with queued async processing.
|
|
@@ -35597,7 +35639,14 @@ function listenWalker(fn) {
|
|
|
35597
35639
|
*/
|
|
35598
35640
|
function listenWalkerOnce(filterFn, fn) {
|
|
35599
35641
|
bt.loggerService.log(LISTEN_WALKER_ONCE_METHOD_NAME);
|
|
35600
|
-
|
|
35642
|
+
let disposeFn;
|
|
35643
|
+
const wrappedFn = async (event) => {
|
|
35644
|
+
if (filterFn(event)) {
|
|
35645
|
+
await fn(event);
|
|
35646
|
+
disposeFn && disposeFn();
|
|
35647
|
+
}
|
|
35648
|
+
};
|
|
35649
|
+
return disposeFn = listenWalker(wrappedFn);
|
|
35601
35650
|
}
|
|
35602
35651
|
/**
|
|
35603
35652
|
* Subscribes to walker completion events with queued async processing.
|
|
@@ -35722,7 +35771,14 @@ function listenPartialProfitAvailable(fn) {
|
|
|
35722
35771
|
*/
|
|
35723
35772
|
function listenPartialProfitAvailableOnce(filterFn, fn) {
|
|
35724
35773
|
bt.loggerService.log(LISTEN_PARTIAL_PROFIT_ONCE_METHOD_NAME);
|
|
35725
|
-
|
|
35774
|
+
let disposeFn;
|
|
35775
|
+
const wrappedFn = async (event) => {
|
|
35776
|
+
if (filterFn(event)) {
|
|
35777
|
+
await fn(event);
|
|
35778
|
+
disposeFn && disposeFn();
|
|
35779
|
+
}
|
|
35780
|
+
};
|
|
35781
|
+
return disposeFn = listenPartialProfitAvailable(wrappedFn);
|
|
35726
35782
|
}
|
|
35727
35783
|
/**
|
|
35728
35784
|
* Subscribes to partial loss level events with queued async processing.
|
|
@@ -35784,7 +35840,14 @@ function listenPartialLossAvailable(fn) {
|
|
|
35784
35840
|
*/
|
|
35785
35841
|
function listenPartialLossAvailableOnce(filterFn, fn) {
|
|
35786
35842
|
bt.loggerService.log(LISTEN_PARTIAL_LOSS_ONCE_METHOD_NAME);
|
|
35787
|
-
|
|
35843
|
+
let disposeFn;
|
|
35844
|
+
const wrappedFn = async (event) => {
|
|
35845
|
+
if (filterFn(event)) {
|
|
35846
|
+
await fn(event);
|
|
35847
|
+
disposeFn && disposeFn();
|
|
35848
|
+
}
|
|
35849
|
+
};
|
|
35850
|
+
return disposeFn = listenPartialLossAvailable(wrappedFn);
|
|
35788
35851
|
}
|
|
35789
35852
|
/**
|
|
35790
35853
|
* Subscribes to breakeven protection events with queued async processing.
|
|
@@ -35848,7 +35911,14 @@ function listenBreakevenAvailable(fn) {
|
|
|
35848
35911
|
*/
|
|
35849
35912
|
function listenBreakevenAvailableOnce(filterFn, fn) {
|
|
35850
35913
|
bt.loggerService.log(LISTEN_BREAKEVEN_ONCE_METHOD_NAME);
|
|
35851
|
-
|
|
35914
|
+
let disposeFn;
|
|
35915
|
+
const wrappedFn = async (event) => {
|
|
35916
|
+
if (filterFn(event)) {
|
|
35917
|
+
await fn(event);
|
|
35918
|
+
disposeFn && disposeFn();
|
|
35919
|
+
}
|
|
35920
|
+
};
|
|
35921
|
+
return disposeFn = listenBreakevenAvailable(wrappedFn);
|
|
35852
35922
|
}
|
|
35853
35923
|
/**
|
|
35854
35924
|
* Subscribes to risk rejection events with queued async processing.
|
|
@@ -35917,7 +35987,14 @@ function listenRisk(fn) {
|
|
|
35917
35987
|
*/
|
|
35918
35988
|
function listenRiskOnce(filterFn, fn) {
|
|
35919
35989
|
bt.loggerService.log(LISTEN_RISK_ONCE_METHOD_NAME);
|
|
35920
|
-
|
|
35990
|
+
let disposeFn;
|
|
35991
|
+
const wrappedFn = async (event) => {
|
|
35992
|
+
if (filterFn(event)) {
|
|
35993
|
+
await fn(event);
|
|
35994
|
+
disposeFn && disposeFn();
|
|
35995
|
+
}
|
|
35996
|
+
};
|
|
35997
|
+
return disposeFn = listenRisk(wrappedFn);
|
|
35921
35998
|
}
|
|
35922
35999
|
/**
|
|
35923
36000
|
* Subscribes to ping events during scheduled signal monitoring with queued async processing.
|
|
@@ -35944,7 +36021,16 @@ function listenRiskOnce(filterFn, fn) {
|
|
|
35944
36021
|
*/
|
|
35945
36022
|
function listenSchedulePing(fn) {
|
|
35946
36023
|
bt.loggerService.log(LISTEN_SCHEDULE_PING_METHOD_NAME);
|
|
35947
|
-
|
|
36024
|
+
const wrappedFn = async (event) => {
|
|
36025
|
+
if (await bt.strategyCoreService.hasScheduledSignal(event.backtest, event.symbol, {
|
|
36026
|
+
strategyName: event.data.strategyName,
|
|
36027
|
+
exchangeName: event.data.exchangeName,
|
|
36028
|
+
frameName: event.data.frameName,
|
|
36029
|
+
})) {
|
|
36030
|
+
await fn(event);
|
|
36031
|
+
}
|
|
36032
|
+
};
|
|
36033
|
+
return schedulePingSubject.subscribe(functoolsKit.queued(wrappedFn));
|
|
35948
36034
|
}
|
|
35949
36035
|
/**
|
|
35950
36036
|
* Subscribes to filtered ping events with one-time execution.
|
|
@@ -35978,7 +36064,14 @@ function listenSchedulePing(fn) {
|
|
|
35978
36064
|
*/
|
|
35979
36065
|
function listenSchedulePingOnce(filterFn, fn) {
|
|
35980
36066
|
bt.loggerService.log(LISTEN_SCHEDULE_PING_ONCE_METHOD_NAME);
|
|
35981
|
-
|
|
36067
|
+
let disposeFn;
|
|
36068
|
+
const wrappedFn = async (event) => {
|
|
36069
|
+
if (filterFn(event)) {
|
|
36070
|
+
await fn(event);
|
|
36071
|
+
disposeFn && disposeFn();
|
|
36072
|
+
}
|
|
36073
|
+
};
|
|
36074
|
+
return disposeFn = listenSchedulePing(wrappedFn);
|
|
35982
36075
|
}
|
|
35983
36076
|
/**
|
|
35984
36077
|
* Subscribes to active ping events with queued async processing.
|
|
@@ -36009,7 +36102,16 @@ function listenSchedulePingOnce(filterFn, fn) {
|
|
|
36009
36102
|
*/
|
|
36010
36103
|
function listenActivePing(fn) {
|
|
36011
36104
|
bt.loggerService.log(LISTEN_ACTIVE_PING_METHOD_NAME);
|
|
36012
|
-
|
|
36105
|
+
const wrappedFn = async (event) => {
|
|
36106
|
+
if (await bt.strategyCoreService.hasPendingSignal(event.backtest, event.symbol, {
|
|
36107
|
+
strategyName: event.data.strategyName,
|
|
36108
|
+
exchangeName: event.data.exchangeName,
|
|
36109
|
+
frameName: event.data.frameName,
|
|
36110
|
+
})) {
|
|
36111
|
+
await fn(event);
|
|
36112
|
+
}
|
|
36113
|
+
};
|
|
36114
|
+
return activePingSubject.subscribe(functoolsKit.queued(wrappedFn));
|
|
36013
36115
|
}
|
|
36014
36116
|
/**
|
|
36015
36117
|
* Subscribes to filtered active ping events with one-time execution.
|
|
@@ -36043,7 +36145,14 @@ function listenActivePing(fn) {
|
|
|
36043
36145
|
*/
|
|
36044
36146
|
function listenActivePingOnce(filterFn, fn) {
|
|
36045
36147
|
bt.loggerService.log(LISTEN_ACTIVE_PING_ONCE_METHOD_NAME);
|
|
36046
|
-
|
|
36148
|
+
let disposeFn;
|
|
36149
|
+
const wrappedFn = async (event) => {
|
|
36150
|
+
if (filterFn(event)) {
|
|
36151
|
+
await fn(event);
|
|
36152
|
+
disposeFn && disposeFn();
|
|
36153
|
+
}
|
|
36154
|
+
};
|
|
36155
|
+
return disposeFn = listenActivePing(wrappedFn);
|
|
36047
36156
|
}
|
|
36048
36157
|
/**
|
|
36049
36158
|
* Subscribes to strategy management events with queued async processing.
|
|
@@ -36115,7 +36224,14 @@ function listenStrategyCommit(fn) {
|
|
|
36115
36224
|
*/
|
|
36116
36225
|
function listenStrategyCommitOnce(filterFn, fn) {
|
|
36117
36226
|
bt.loggerService.log(LISTEN_STRATEGY_COMMIT_ONCE_METHOD_NAME);
|
|
36118
|
-
|
|
36227
|
+
let disposeFn;
|
|
36228
|
+
const wrappedFn = async (event) => {
|
|
36229
|
+
if (filterFn(event)) {
|
|
36230
|
+
await fn(event);
|
|
36231
|
+
disposeFn && disposeFn();
|
|
36232
|
+
}
|
|
36233
|
+
};
|
|
36234
|
+
return disposeFn = listenStrategyCommit(wrappedFn);
|
|
36119
36235
|
}
|
|
36120
36236
|
/**
|
|
36121
36237
|
* Subscribes to signal synchronization events with queued async processing.
|
|
@@ -36150,11 +36266,18 @@ function listenSyncOnce(filterFn, fn) {
|
|
|
36150
36266
|
{
|
|
36151
36267
|
console.error("listenSyncOnce is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
|
|
36152
36268
|
console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
|
|
36153
|
-
console.error("If listenSyncOnce throws the exchange
|
|
36269
|
+
console.error("If listenSyncOnce throws the exchange will not execute the order!");
|
|
36154
36270
|
console.error("");
|
|
36155
36271
|
console.error("You have been warned!");
|
|
36156
36272
|
}
|
|
36157
|
-
|
|
36273
|
+
let disposeFn;
|
|
36274
|
+
const wrappedFn = async (event) => {
|
|
36275
|
+
if (filterFn(event)) {
|
|
36276
|
+
await fn(event);
|
|
36277
|
+
disposeFn && disposeFn();
|
|
36278
|
+
}
|
|
36279
|
+
};
|
|
36280
|
+
return disposeFn = listenSync(wrappedFn);
|
|
36158
36281
|
}
|
|
36159
36282
|
/**
|
|
36160
36283
|
* Subscribes to highest profit events with queued async processing.
|
|
@@ -36181,7 +36304,14 @@ function listenHighestProfit(fn) {
|
|
|
36181
36304
|
*/
|
|
36182
36305
|
function listenHighestProfitOnce(filterFn, fn) {
|
|
36183
36306
|
bt.loggerService.log(LISTEN_HIGHEST_PROFIT_ONCE_METHOD_NAME);
|
|
36184
|
-
|
|
36307
|
+
let disposeFn;
|
|
36308
|
+
const wrappedFn = async (event) => {
|
|
36309
|
+
if (filterFn(event)) {
|
|
36310
|
+
await fn(event);
|
|
36311
|
+
disposeFn && disposeFn();
|
|
36312
|
+
}
|
|
36313
|
+
};
|
|
36314
|
+
return disposeFn = listenHighestProfit(wrappedFn);
|
|
36185
36315
|
}
|
|
36186
36316
|
|
|
36187
36317
|
const BACKTEST_METHOD_NAME_RUN = "BacktestUtils.run";
|
package/build/index.mjs
CHANGED
|
@@ -35059,7 +35059,14 @@ function listenSignal(fn) {
|
|
|
35059
35059
|
*/
|
|
35060
35060
|
function listenSignalOnce(filterFn, fn) {
|
|
35061
35061
|
bt.loggerService.log(LISTEN_SIGNAL_ONCE_METHOD_NAME);
|
|
35062
|
-
|
|
35062
|
+
let disposeFn;
|
|
35063
|
+
const wrappedFn = async (event) => {
|
|
35064
|
+
if (filterFn(event)) {
|
|
35065
|
+
await fn(event);
|
|
35066
|
+
disposeFn && disposeFn();
|
|
35067
|
+
}
|
|
35068
|
+
};
|
|
35069
|
+
return disposeFn = listenSignal(wrappedFn);
|
|
35063
35070
|
}
|
|
35064
35071
|
/**
|
|
35065
35072
|
* Subscribes to live trading signal events with queued async processing.
|
|
@@ -35108,7 +35115,14 @@ function listenSignalLive(fn) {
|
|
|
35108
35115
|
*/
|
|
35109
35116
|
function listenSignalLiveOnce(filterFn, fn) {
|
|
35110
35117
|
bt.loggerService.log(LISTEN_SIGNAL_LIVE_ONCE_METHOD_NAME);
|
|
35111
|
-
|
|
35118
|
+
let disposeFn;
|
|
35119
|
+
const wrappedFn = async (event) => {
|
|
35120
|
+
if (filterFn(event)) {
|
|
35121
|
+
await fn(event);
|
|
35122
|
+
disposeFn && disposeFn();
|
|
35123
|
+
}
|
|
35124
|
+
};
|
|
35125
|
+
return disposeFn = listenSignalLive(wrappedFn);
|
|
35112
35126
|
}
|
|
35113
35127
|
/**
|
|
35114
35128
|
* Subscribes to backtest signal events with queued async processing.
|
|
@@ -35157,7 +35171,14 @@ function listenSignalBacktest(fn) {
|
|
|
35157
35171
|
*/
|
|
35158
35172
|
function listenSignalBacktestOnce(filterFn, fn) {
|
|
35159
35173
|
bt.loggerService.log(LISTEN_SIGNAL_BACKTEST_ONCE_METHOD_NAME);
|
|
35160
|
-
|
|
35174
|
+
let disposeFn;
|
|
35175
|
+
const wrappedFn = async (event) => {
|
|
35176
|
+
if (filterFn(event)) {
|
|
35177
|
+
await fn(event);
|
|
35178
|
+
disposeFn && disposeFn();
|
|
35179
|
+
}
|
|
35180
|
+
};
|
|
35181
|
+
return disposeFn = listenSignalBacktest(wrappedFn);
|
|
35161
35182
|
}
|
|
35162
35183
|
/**
|
|
35163
35184
|
* Subscribes to recoverable execution errors with queued async processing.
|
|
@@ -35274,7 +35295,14 @@ function listenDoneLive(fn) {
|
|
|
35274
35295
|
*/
|
|
35275
35296
|
function listenDoneLiveOnce(filterFn, fn) {
|
|
35276
35297
|
bt.loggerService.log(LISTEN_DONE_LIVE_ONCE_METHOD_NAME);
|
|
35277
|
-
|
|
35298
|
+
let disposeFn;
|
|
35299
|
+
const wrappedFn = async (event) => {
|
|
35300
|
+
if (filterFn(event)) {
|
|
35301
|
+
await fn(event);
|
|
35302
|
+
disposeFn && disposeFn();
|
|
35303
|
+
}
|
|
35304
|
+
};
|
|
35305
|
+
return disposeFn = listenDoneLive(wrappedFn);
|
|
35278
35306
|
}
|
|
35279
35307
|
/**
|
|
35280
35308
|
* Subscribes to backtest background execution completion events with queued async processing.
|
|
@@ -35337,7 +35365,14 @@ function listenDoneBacktest(fn) {
|
|
|
35337
35365
|
*/
|
|
35338
35366
|
function listenDoneBacktestOnce(filterFn, fn) {
|
|
35339
35367
|
bt.loggerService.log(LISTEN_DONE_BACKTEST_ONCE_METHOD_NAME);
|
|
35340
|
-
|
|
35368
|
+
let disposeFn;
|
|
35369
|
+
const wrappedFn = async (event) => {
|
|
35370
|
+
if (filterFn(event)) {
|
|
35371
|
+
await fn(event);
|
|
35372
|
+
disposeFn && disposeFn();
|
|
35373
|
+
}
|
|
35374
|
+
};
|
|
35375
|
+
return disposeFn = listenDoneBacktest(wrappedFn);
|
|
35341
35376
|
}
|
|
35342
35377
|
/**
|
|
35343
35378
|
* Subscribes to walker background execution completion events with queued async processing.
|
|
@@ -35396,7 +35431,14 @@ function listenDoneWalker(fn) {
|
|
|
35396
35431
|
*/
|
|
35397
35432
|
function listenDoneWalkerOnce(filterFn, fn) {
|
|
35398
35433
|
bt.loggerService.log(LISTEN_DONE_WALKER_ONCE_METHOD_NAME);
|
|
35399
|
-
|
|
35434
|
+
let disposeFn;
|
|
35435
|
+
const wrappedFn = async (event) => {
|
|
35436
|
+
if (filterFn(event)) {
|
|
35437
|
+
await fn(event);
|
|
35438
|
+
disposeFn && disposeFn();
|
|
35439
|
+
}
|
|
35440
|
+
};
|
|
35441
|
+
return disposeFn = listenDoneWalker(wrappedFn);
|
|
35400
35442
|
}
|
|
35401
35443
|
/**
|
|
35402
35444
|
* Subscribes to backtest progress events with queued async processing.
|
|
@@ -35577,7 +35619,14 @@ function listenWalker(fn) {
|
|
|
35577
35619
|
*/
|
|
35578
35620
|
function listenWalkerOnce(filterFn, fn) {
|
|
35579
35621
|
bt.loggerService.log(LISTEN_WALKER_ONCE_METHOD_NAME);
|
|
35580
|
-
|
|
35622
|
+
let disposeFn;
|
|
35623
|
+
const wrappedFn = async (event) => {
|
|
35624
|
+
if (filterFn(event)) {
|
|
35625
|
+
await fn(event);
|
|
35626
|
+
disposeFn && disposeFn();
|
|
35627
|
+
}
|
|
35628
|
+
};
|
|
35629
|
+
return disposeFn = listenWalker(wrappedFn);
|
|
35581
35630
|
}
|
|
35582
35631
|
/**
|
|
35583
35632
|
* Subscribes to walker completion events with queued async processing.
|
|
@@ -35702,7 +35751,14 @@ function listenPartialProfitAvailable(fn) {
|
|
|
35702
35751
|
*/
|
|
35703
35752
|
function listenPartialProfitAvailableOnce(filterFn, fn) {
|
|
35704
35753
|
bt.loggerService.log(LISTEN_PARTIAL_PROFIT_ONCE_METHOD_NAME);
|
|
35705
|
-
|
|
35754
|
+
let disposeFn;
|
|
35755
|
+
const wrappedFn = async (event) => {
|
|
35756
|
+
if (filterFn(event)) {
|
|
35757
|
+
await fn(event);
|
|
35758
|
+
disposeFn && disposeFn();
|
|
35759
|
+
}
|
|
35760
|
+
};
|
|
35761
|
+
return disposeFn = listenPartialProfitAvailable(wrappedFn);
|
|
35706
35762
|
}
|
|
35707
35763
|
/**
|
|
35708
35764
|
* Subscribes to partial loss level events with queued async processing.
|
|
@@ -35764,7 +35820,14 @@ function listenPartialLossAvailable(fn) {
|
|
|
35764
35820
|
*/
|
|
35765
35821
|
function listenPartialLossAvailableOnce(filterFn, fn) {
|
|
35766
35822
|
bt.loggerService.log(LISTEN_PARTIAL_LOSS_ONCE_METHOD_NAME);
|
|
35767
|
-
|
|
35823
|
+
let disposeFn;
|
|
35824
|
+
const wrappedFn = async (event) => {
|
|
35825
|
+
if (filterFn(event)) {
|
|
35826
|
+
await fn(event);
|
|
35827
|
+
disposeFn && disposeFn();
|
|
35828
|
+
}
|
|
35829
|
+
};
|
|
35830
|
+
return disposeFn = listenPartialLossAvailable(wrappedFn);
|
|
35768
35831
|
}
|
|
35769
35832
|
/**
|
|
35770
35833
|
* Subscribes to breakeven protection events with queued async processing.
|
|
@@ -35828,7 +35891,14 @@ function listenBreakevenAvailable(fn) {
|
|
|
35828
35891
|
*/
|
|
35829
35892
|
function listenBreakevenAvailableOnce(filterFn, fn) {
|
|
35830
35893
|
bt.loggerService.log(LISTEN_BREAKEVEN_ONCE_METHOD_NAME);
|
|
35831
|
-
|
|
35894
|
+
let disposeFn;
|
|
35895
|
+
const wrappedFn = async (event) => {
|
|
35896
|
+
if (filterFn(event)) {
|
|
35897
|
+
await fn(event);
|
|
35898
|
+
disposeFn && disposeFn();
|
|
35899
|
+
}
|
|
35900
|
+
};
|
|
35901
|
+
return disposeFn = listenBreakevenAvailable(wrappedFn);
|
|
35832
35902
|
}
|
|
35833
35903
|
/**
|
|
35834
35904
|
* Subscribes to risk rejection events with queued async processing.
|
|
@@ -35897,7 +35967,14 @@ function listenRisk(fn) {
|
|
|
35897
35967
|
*/
|
|
35898
35968
|
function listenRiskOnce(filterFn, fn) {
|
|
35899
35969
|
bt.loggerService.log(LISTEN_RISK_ONCE_METHOD_NAME);
|
|
35900
|
-
|
|
35970
|
+
let disposeFn;
|
|
35971
|
+
const wrappedFn = async (event) => {
|
|
35972
|
+
if (filterFn(event)) {
|
|
35973
|
+
await fn(event);
|
|
35974
|
+
disposeFn && disposeFn();
|
|
35975
|
+
}
|
|
35976
|
+
};
|
|
35977
|
+
return disposeFn = listenRisk(wrappedFn);
|
|
35901
35978
|
}
|
|
35902
35979
|
/**
|
|
35903
35980
|
* Subscribes to ping events during scheduled signal monitoring with queued async processing.
|
|
@@ -35924,7 +36001,16 @@ function listenRiskOnce(filterFn, fn) {
|
|
|
35924
36001
|
*/
|
|
35925
36002
|
function listenSchedulePing(fn) {
|
|
35926
36003
|
bt.loggerService.log(LISTEN_SCHEDULE_PING_METHOD_NAME);
|
|
35927
|
-
|
|
36004
|
+
const wrappedFn = async (event) => {
|
|
36005
|
+
if (await bt.strategyCoreService.hasScheduledSignal(event.backtest, event.symbol, {
|
|
36006
|
+
strategyName: event.data.strategyName,
|
|
36007
|
+
exchangeName: event.data.exchangeName,
|
|
36008
|
+
frameName: event.data.frameName,
|
|
36009
|
+
})) {
|
|
36010
|
+
await fn(event);
|
|
36011
|
+
}
|
|
36012
|
+
};
|
|
36013
|
+
return schedulePingSubject.subscribe(queued(wrappedFn));
|
|
35928
36014
|
}
|
|
35929
36015
|
/**
|
|
35930
36016
|
* Subscribes to filtered ping events with one-time execution.
|
|
@@ -35958,7 +36044,14 @@ function listenSchedulePing(fn) {
|
|
|
35958
36044
|
*/
|
|
35959
36045
|
function listenSchedulePingOnce(filterFn, fn) {
|
|
35960
36046
|
bt.loggerService.log(LISTEN_SCHEDULE_PING_ONCE_METHOD_NAME);
|
|
35961
|
-
|
|
36047
|
+
let disposeFn;
|
|
36048
|
+
const wrappedFn = async (event) => {
|
|
36049
|
+
if (filterFn(event)) {
|
|
36050
|
+
await fn(event);
|
|
36051
|
+
disposeFn && disposeFn();
|
|
36052
|
+
}
|
|
36053
|
+
};
|
|
36054
|
+
return disposeFn = listenSchedulePing(wrappedFn);
|
|
35962
36055
|
}
|
|
35963
36056
|
/**
|
|
35964
36057
|
* Subscribes to active ping events with queued async processing.
|
|
@@ -35989,7 +36082,16 @@ function listenSchedulePingOnce(filterFn, fn) {
|
|
|
35989
36082
|
*/
|
|
35990
36083
|
function listenActivePing(fn) {
|
|
35991
36084
|
bt.loggerService.log(LISTEN_ACTIVE_PING_METHOD_NAME);
|
|
35992
|
-
|
|
36085
|
+
const wrappedFn = async (event) => {
|
|
36086
|
+
if (await bt.strategyCoreService.hasPendingSignal(event.backtest, event.symbol, {
|
|
36087
|
+
strategyName: event.data.strategyName,
|
|
36088
|
+
exchangeName: event.data.exchangeName,
|
|
36089
|
+
frameName: event.data.frameName,
|
|
36090
|
+
})) {
|
|
36091
|
+
await fn(event);
|
|
36092
|
+
}
|
|
36093
|
+
};
|
|
36094
|
+
return activePingSubject.subscribe(queued(wrappedFn));
|
|
35993
36095
|
}
|
|
35994
36096
|
/**
|
|
35995
36097
|
* Subscribes to filtered active ping events with one-time execution.
|
|
@@ -36023,7 +36125,14 @@ function listenActivePing(fn) {
|
|
|
36023
36125
|
*/
|
|
36024
36126
|
function listenActivePingOnce(filterFn, fn) {
|
|
36025
36127
|
bt.loggerService.log(LISTEN_ACTIVE_PING_ONCE_METHOD_NAME);
|
|
36026
|
-
|
|
36128
|
+
let disposeFn;
|
|
36129
|
+
const wrappedFn = async (event) => {
|
|
36130
|
+
if (filterFn(event)) {
|
|
36131
|
+
await fn(event);
|
|
36132
|
+
disposeFn && disposeFn();
|
|
36133
|
+
}
|
|
36134
|
+
};
|
|
36135
|
+
return disposeFn = listenActivePing(wrappedFn);
|
|
36027
36136
|
}
|
|
36028
36137
|
/**
|
|
36029
36138
|
* Subscribes to strategy management events with queued async processing.
|
|
@@ -36095,7 +36204,14 @@ function listenStrategyCommit(fn) {
|
|
|
36095
36204
|
*/
|
|
36096
36205
|
function listenStrategyCommitOnce(filterFn, fn) {
|
|
36097
36206
|
bt.loggerService.log(LISTEN_STRATEGY_COMMIT_ONCE_METHOD_NAME);
|
|
36098
|
-
|
|
36207
|
+
let disposeFn;
|
|
36208
|
+
const wrappedFn = async (event) => {
|
|
36209
|
+
if (filterFn(event)) {
|
|
36210
|
+
await fn(event);
|
|
36211
|
+
disposeFn && disposeFn();
|
|
36212
|
+
}
|
|
36213
|
+
};
|
|
36214
|
+
return disposeFn = listenStrategyCommit(wrappedFn);
|
|
36099
36215
|
}
|
|
36100
36216
|
/**
|
|
36101
36217
|
* Subscribes to signal synchronization events with queued async processing.
|
|
@@ -36130,11 +36246,18 @@ function listenSyncOnce(filterFn, fn) {
|
|
|
36130
36246
|
{
|
|
36131
36247
|
console.error("listenSyncOnce is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
|
|
36132
36248
|
console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
|
|
36133
|
-
console.error("If listenSyncOnce throws the exchange
|
|
36249
|
+
console.error("If listenSyncOnce throws the exchange will not execute the order!");
|
|
36134
36250
|
console.error("");
|
|
36135
36251
|
console.error("You have been warned!");
|
|
36136
36252
|
}
|
|
36137
|
-
|
|
36253
|
+
let disposeFn;
|
|
36254
|
+
const wrappedFn = async (event) => {
|
|
36255
|
+
if (filterFn(event)) {
|
|
36256
|
+
await fn(event);
|
|
36257
|
+
disposeFn && disposeFn();
|
|
36258
|
+
}
|
|
36259
|
+
};
|
|
36260
|
+
return disposeFn = listenSync(wrappedFn);
|
|
36138
36261
|
}
|
|
36139
36262
|
/**
|
|
36140
36263
|
* Subscribes to highest profit events with queued async processing.
|
|
@@ -36161,7 +36284,14 @@ function listenHighestProfit(fn) {
|
|
|
36161
36284
|
*/
|
|
36162
36285
|
function listenHighestProfitOnce(filterFn, fn) {
|
|
36163
36286
|
bt.loggerService.log(LISTEN_HIGHEST_PROFIT_ONCE_METHOD_NAME);
|
|
36164
|
-
|
|
36287
|
+
let disposeFn;
|
|
36288
|
+
const wrappedFn = async (event) => {
|
|
36289
|
+
if (filterFn(event)) {
|
|
36290
|
+
await fn(event);
|
|
36291
|
+
disposeFn && disposeFn();
|
|
36292
|
+
}
|
|
36293
|
+
};
|
|
36294
|
+
return disposeFn = listenHighestProfit(wrappedFn);
|
|
36165
36295
|
}
|
|
36166
36296
|
|
|
36167
36297
|
const BACKTEST_METHOD_NAME_RUN = "BacktestUtils.run";
|