backtest-kit 5.6.4 → 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 CHANGED
@@ -33318,6 +33318,8 @@ const GET_POSITION_HIGHEST_PROFIT_BREAKEVEN_METHOD_NAME = "strategy.getPositionH
33318
33318
  const GET_POSITION_DRAWDOWN_MINUTES_METHOD_NAME = "strategy.getPositionDrawdownMinutes";
33319
33319
  const GET_POSITION_ENTRY_OVERLAP_METHOD_NAME = "strategy.getPositionEntryOverlap";
33320
33320
  const GET_POSITION_PARTIAL_OVERLAP_METHOD_NAME = "strategy.getPositionPartialOverlap";
33321
+ const HAS_NO_PENDING_SIGNAL_METHOD_NAME = "strategy.hasNoPendingSignal";
33322
+ const HAS_NO_SCHEDULED_SIGNAL_METHOD_NAME = "strategy.hasNoScheduledSignal";
33321
33323
  /**
33322
33324
  * Cancels the scheduled signal without stopping the strategy.
33323
33325
  *
@@ -34871,6 +34873,68 @@ async function getPositionPartialOverlap(symbol, currentPrice, ladder = POSITION
34871
34873
  return currentPrice >= partial.currentPrice - lowerStep && currentPrice <= partial.currentPrice + upperStep;
34872
34874
  });
34873
34875
  }
34876
+ /**
34877
+ * Returns true if there is NO active pending signal for the given symbol.
34878
+ *
34879
+ * Inverse of hasPendingSignal. Use to guard signal generation logic.
34880
+ *
34881
+ * Automatically detects backtest/live mode from execution context.
34882
+ *
34883
+ * @param symbol - Trading pair symbol
34884
+ * @returns Promise<boolean> - true if no pending signal exists, false if one does
34885
+ *
34886
+ * @example
34887
+ * ```typescript
34888
+ * import { hasNoPendingSignal } from "backtest-kit";
34889
+ *
34890
+ * if (await hasNoPendingSignal("BTCUSDT")) {
34891
+ * // safe to open a new position
34892
+ * }
34893
+ * ```
34894
+ */
34895
+ async function hasNoPendingSignal(symbol) {
34896
+ bt.loggerService.info(HAS_NO_PENDING_SIGNAL_METHOD_NAME, { symbol });
34897
+ if (!ExecutionContextService.hasContext()) {
34898
+ throw new Error("hasNoPendingSignal requires an execution context");
34899
+ }
34900
+ if (!MethodContextService.hasContext()) {
34901
+ throw new Error("hasNoPendingSignal requires a method context");
34902
+ }
34903
+ const { backtest: isBacktest } = bt.executionContextService.context;
34904
+ const { exchangeName, frameName, strategyName } = bt.methodContextService.context;
34905
+ return await functoolsKit.not(bt.strategyCoreService.hasPendingSignal(isBacktest, symbol, { exchangeName, frameName, strategyName }));
34906
+ }
34907
+ /**
34908
+ * Returns true if there is NO active scheduled signal for the given symbol.
34909
+ *
34910
+ * Inverse of hasScheduledSignal. Use to guard signal generation logic.
34911
+ *
34912
+ * Automatically detects backtest/live mode from execution context.
34913
+ *
34914
+ * @param symbol - Trading pair symbol
34915
+ * @returns Promise<boolean> - true if no scheduled signal exists, false if one does
34916
+ *
34917
+ * @example
34918
+ * ```typescript
34919
+ * import { hasNoScheduledSignal } from "backtest-kit";
34920
+ *
34921
+ * if (await hasNoScheduledSignal("BTCUSDT")) {
34922
+ * // safe to schedule a new signal
34923
+ * }
34924
+ * ```
34925
+ */
34926
+ async function hasNoScheduledSignal(symbol) {
34927
+ bt.loggerService.info(HAS_NO_SCHEDULED_SIGNAL_METHOD_NAME, { symbol });
34928
+ if (!ExecutionContextService.hasContext()) {
34929
+ throw new Error("hasNoScheduledSignal requires an execution context");
34930
+ }
34931
+ if (!MethodContextService.hasContext()) {
34932
+ throw new Error("hasNoScheduledSignal requires a method context");
34933
+ }
34934
+ const { backtest: isBacktest } = bt.executionContextService.context;
34935
+ const { exchangeName, frameName, strategyName } = bt.methodContextService.context;
34936
+ return await functoolsKit.not(bt.strategyCoreService.hasScheduledSignal(isBacktest, symbol, { exchangeName, frameName, strategyName }));
34937
+ }
34874
34938
 
34875
34939
  const STOP_STRATEGY_METHOD_NAME = "control.stopStrategy";
34876
34940
  /**
@@ -35015,7 +35079,14 @@ function listenSignal(fn) {
35015
35079
  */
35016
35080
  function listenSignalOnce(filterFn, fn) {
35017
35081
  bt.loggerService.log(LISTEN_SIGNAL_ONCE_METHOD_NAME);
35018
- return signalEmitter.filter(filterFn).once(fn);
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);
35019
35090
  }
35020
35091
  /**
35021
35092
  * Subscribes to live trading signal events with queued async processing.
@@ -35064,7 +35135,14 @@ function listenSignalLive(fn) {
35064
35135
  */
35065
35136
  function listenSignalLiveOnce(filterFn, fn) {
35066
35137
  bt.loggerService.log(LISTEN_SIGNAL_LIVE_ONCE_METHOD_NAME);
35067
- return signalLiveEmitter.filter(filterFn).once(fn);
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);
35068
35146
  }
35069
35147
  /**
35070
35148
  * Subscribes to backtest signal events with queued async processing.
@@ -35113,7 +35191,14 @@ function listenSignalBacktest(fn) {
35113
35191
  */
35114
35192
  function listenSignalBacktestOnce(filterFn, fn) {
35115
35193
  bt.loggerService.log(LISTEN_SIGNAL_BACKTEST_ONCE_METHOD_NAME);
35116
- return signalBacktestEmitter.filter(filterFn).once(fn);
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);
35117
35202
  }
35118
35203
  /**
35119
35204
  * Subscribes to recoverable execution errors with queued async processing.
@@ -35230,7 +35315,14 @@ function listenDoneLive(fn) {
35230
35315
  */
35231
35316
  function listenDoneLiveOnce(filterFn, fn) {
35232
35317
  bt.loggerService.log(LISTEN_DONE_LIVE_ONCE_METHOD_NAME);
35233
- return doneLiveSubject.filter(filterFn).once(fn);
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);
35234
35326
  }
35235
35327
  /**
35236
35328
  * Subscribes to backtest background execution completion events with queued async processing.
@@ -35293,7 +35385,14 @@ function listenDoneBacktest(fn) {
35293
35385
  */
35294
35386
  function listenDoneBacktestOnce(filterFn, fn) {
35295
35387
  bt.loggerService.log(LISTEN_DONE_BACKTEST_ONCE_METHOD_NAME);
35296
- return doneBacktestSubject.filter(filterFn).once(fn);
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);
35297
35396
  }
35298
35397
  /**
35299
35398
  * Subscribes to walker background execution completion events with queued async processing.
@@ -35352,7 +35451,14 @@ function listenDoneWalker(fn) {
35352
35451
  */
35353
35452
  function listenDoneWalkerOnce(filterFn, fn) {
35354
35453
  bt.loggerService.log(LISTEN_DONE_WALKER_ONCE_METHOD_NAME);
35355
- return doneWalkerSubject.filter(filterFn).once(fn);
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);
35356
35462
  }
35357
35463
  /**
35358
35464
  * Subscribes to backtest progress events with queued async processing.
@@ -35533,7 +35639,14 @@ function listenWalker(fn) {
35533
35639
  */
35534
35640
  function listenWalkerOnce(filterFn, fn) {
35535
35641
  bt.loggerService.log(LISTEN_WALKER_ONCE_METHOD_NAME);
35536
- return walkerEmitter.filter(filterFn).once(fn);
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);
35537
35650
  }
35538
35651
  /**
35539
35652
  * Subscribes to walker completion events with queued async processing.
@@ -35658,7 +35771,14 @@ function listenPartialProfitAvailable(fn) {
35658
35771
  */
35659
35772
  function listenPartialProfitAvailableOnce(filterFn, fn) {
35660
35773
  bt.loggerService.log(LISTEN_PARTIAL_PROFIT_ONCE_METHOD_NAME);
35661
- return partialProfitSubject.filter(filterFn).once(fn);
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);
35662
35782
  }
35663
35783
  /**
35664
35784
  * Subscribes to partial loss level events with queued async processing.
@@ -35720,7 +35840,14 @@ function listenPartialLossAvailable(fn) {
35720
35840
  */
35721
35841
  function listenPartialLossAvailableOnce(filterFn, fn) {
35722
35842
  bt.loggerService.log(LISTEN_PARTIAL_LOSS_ONCE_METHOD_NAME);
35723
- return partialLossSubject.filter(filterFn).once(fn);
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);
35724
35851
  }
35725
35852
  /**
35726
35853
  * Subscribes to breakeven protection events with queued async processing.
@@ -35784,7 +35911,14 @@ function listenBreakevenAvailable(fn) {
35784
35911
  */
35785
35912
  function listenBreakevenAvailableOnce(filterFn, fn) {
35786
35913
  bt.loggerService.log(LISTEN_BREAKEVEN_ONCE_METHOD_NAME);
35787
- return breakevenSubject.filter(filterFn).once(fn);
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);
35788
35922
  }
35789
35923
  /**
35790
35924
  * Subscribes to risk rejection events with queued async processing.
@@ -35853,7 +35987,14 @@ function listenRisk(fn) {
35853
35987
  */
35854
35988
  function listenRiskOnce(filterFn, fn) {
35855
35989
  bt.loggerService.log(LISTEN_RISK_ONCE_METHOD_NAME);
35856
- return riskSubject.filter(filterFn).once(fn);
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);
35857
35998
  }
35858
35999
  /**
35859
36000
  * Subscribes to ping events during scheduled signal monitoring with queued async processing.
@@ -35880,7 +36021,16 @@ function listenRiskOnce(filterFn, fn) {
35880
36021
  */
35881
36022
  function listenSchedulePing(fn) {
35882
36023
  bt.loggerService.log(LISTEN_SCHEDULE_PING_METHOD_NAME);
35883
- return schedulePingSubject.subscribe(functoolsKit.queued(async (event) => fn(event)));
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));
35884
36034
  }
35885
36035
  /**
35886
36036
  * Subscribes to filtered ping events with one-time execution.
@@ -35914,7 +36064,14 @@ function listenSchedulePing(fn) {
35914
36064
  */
35915
36065
  function listenSchedulePingOnce(filterFn, fn) {
35916
36066
  bt.loggerService.log(LISTEN_SCHEDULE_PING_ONCE_METHOD_NAME);
35917
- return schedulePingSubject.filter(filterFn).once(fn);
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);
35918
36075
  }
35919
36076
  /**
35920
36077
  * Subscribes to active ping events with queued async processing.
@@ -35945,7 +36102,16 @@ function listenSchedulePingOnce(filterFn, fn) {
35945
36102
  */
35946
36103
  function listenActivePing(fn) {
35947
36104
  bt.loggerService.log(LISTEN_ACTIVE_PING_METHOD_NAME);
35948
- return activePingSubject.subscribe(functoolsKit.queued(async (event) => fn(event)));
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));
35949
36115
  }
35950
36116
  /**
35951
36117
  * Subscribes to filtered active ping events with one-time execution.
@@ -35979,7 +36145,14 @@ function listenActivePing(fn) {
35979
36145
  */
35980
36146
  function listenActivePingOnce(filterFn, fn) {
35981
36147
  bt.loggerService.log(LISTEN_ACTIVE_PING_ONCE_METHOD_NAME);
35982
- return activePingSubject.filter(filterFn).once(fn);
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);
35983
36156
  }
35984
36157
  /**
35985
36158
  * Subscribes to strategy management events with queued async processing.
@@ -36051,7 +36224,14 @@ function listenStrategyCommit(fn) {
36051
36224
  */
36052
36225
  function listenStrategyCommitOnce(filterFn, fn) {
36053
36226
  bt.loggerService.log(LISTEN_STRATEGY_COMMIT_ONCE_METHOD_NAME);
36054
- return strategyCommitSubject.filter(filterFn).once(fn);
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);
36055
36235
  }
36056
36236
  /**
36057
36237
  * Subscribes to signal synchronization events with queued async processing.
@@ -36086,11 +36266,18 @@ function listenSyncOnce(filterFn, fn) {
36086
36266
  {
36087
36267
  console.error("listenSyncOnce is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
36088
36268
  console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
36089
- console.error("If listenSyncOnce throws the exchange WILL EXECUTE the order!");
36269
+ console.error("If listenSyncOnce throws the exchange will not execute the order!");
36090
36270
  console.error("");
36091
36271
  console.error("You have been warned!");
36092
36272
  }
36093
- return syncSubject.filter(filterFn).once(fn);
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);
36094
36281
  }
36095
36282
  /**
36096
36283
  * Subscribes to highest profit events with queued async processing.
@@ -36117,7 +36304,14 @@ function listenHighestProfit(fn) {
36117
36304
  */
36118
36305
  function listenHighestProfitOnce(filterFn, fn) {
36119
36306
  bt.loggerService.log(LISTEN_HIGHEST_PROFIT_ONCE_METHOD_NAME);
36120
- return highestProfitSubject.filter(filterFn).once(fn);
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);
36121
36315
  }
36122
36316
 
36123
36317
  const BACKTEST_METHOD_NAME_RUN = "BacktestUtils.run";
@@ -48643,6 +48837,8 @@ exports.getTotalClosed = getTotalClosed;
48643
48837
  exports.getTotalCostClosed = getTotalCostClosed;
48644
48838
  exports.getTotalPercentClosed = getTotalPercentClosed;
48645
48839
  exports.getWalkerSchema = getWalkerSchema;
48840
+ exports.hasNoPendingSignal = hasNoPendingSignal;
48841
+ exports.hasNoScheduledSignal = hasNoScheduledSignal;
48646
48842
  exports.hasTradeContext = hasTradeContext;
48647
48843
  exports.investedCostToPercent = investedCostToPercent;
48648
48844
  exports.lib = backtest;
package/build/index.mjs CHANGED
@@ -33298,6 +33298,8 @@ const GET_POSITION_HIGHEST_PROFIT_BREAKEVEN_METHOD_NAME = "strategy.getPositionH
33298
33298
  const GET_POSITION_DRAWDOWN_MINUTES_METHOD_NAME = "strategy.getPositionDrawdownMinutes";
33299
33299
  const GET_POSITION_ENTRY_OVERLAP_METHOD_NAME = "strategy.getPositionEntryOverlap";
33300
33300
  const GET_POSITION_PARTIAL_OVERLAP_METHOD_NAME = "strategy.getPositionPartialOverlap";
33301
+ const HAS_NO_PENDING_SIGNAL_METHOD_NAME = "strategy.hasNoPendingSignal";
33302
+ const HAS_NO_SCHEDULED_SIGNAL_METHOD_NAME = "strategy.hasNoScheduledSignal";
33301
33303
  /**
33302
33304
  * Cancels the scheduled signal without stopping the strategy.
33303
33305
  *
@@ -34851,6 +34853,68 @@ async function getPositionPartialOverlap(symbol, currentPrice, ladder = POSITION
34851
34853
  return currentPrice >= partial.currentPrice - lowerStep && currentPrice <= partial.currentPrice + upperStep;
34852
34854
  });
34853
34855
  }
34856
+ /**
34857
+ * Returns true if there is NO active pending signal for the given symbol.
34858
+ *
34859
+ * Inverse of hasPendingSignal. Use to guard signal generation logic.
34860
+ *
34861
+ * Automatically detects backtest/live mode from execution context.
34862
+ *
34863
+ * @param symbol - Trading pair symbol
34864
+ * @returns Promise<boolean> - true if no pending signal exists, false if one does
34865
+ *
34866
+ * @example
34867
+ * ```typescript
34868
+ * import { hasNoPendingSignal } from "backtest-kit";
34869
+ *
34870
+ * if (await hasNoPendingSignal("BTCUSDT")) {
34871
+ * // safe to open a new position
34872
+ * }
34873
+ * ```
34874
+ */
34875
+ async function hasNoPendingSignal(symbol) {
34876
+ bt.loggerService.info(HAS_NO_PENDING_SIGNAL_METHOD_NAME, { symbol });
34877
+ if (!ExecutionContextService.hasContext()) {
34878
+ throw new Error("hasNoPendingSignal requires an execution context");
34879
+ }
34880
+ if (!MethodContextService.hasContext()) {
34881
+ throw new Error("hasNoPendingSignal requires a method context");
34882
+ }
34883
+ const { backtest: isBacktest } = bt.executionContextService.context;
34884
+ const { exchangeName, frameName, strategyName } = bt.methodContextService.context;
34885
+ return await not(bt.strategyCoreService.hasPendingSignal(isBacktest, symbol, { exchangeName, frameName, strategyName }));
34886
+ }
34887
+ /**
34888
+ * Returns true if there is NO active scheduled signal for the given symbol.
34889
+ *
34890
+ * Inverse of hasScheduledSignal. Use to guard signal generation logic.
34891
+ *
34892
+ * Automatically detects backtest/live mode from execution context.
34893
+ *
34894
+ * @param symbol - Trading pair symbol
34895
+ * @returns Promise<boolean> - true if no scheduled signal exists, false if one does
34896
+ *
34897
+ * @example
34898
+ * ```typescript
34899
+ * import { hasNoScheduledSignal } from "backtest-kit";
34900
+ *
34901
+ * if (await hasNoScheduledSignal("BTCUSDT")) {
34902
+ * // safe to schedule a new signal
34903
+ * }
34904
+ * ```
34905
+ */
34906
+ async function hasNoScheduledSignal(symbol) {
34907
+ bt.loggerService.info(HAS_NO_SCHEDULED_SIGNAL_METHOD_NAME, { symbol });
34908
+ if (!ExecutionContextService.hasContext()) {
34909
+ throw new Error("hasNoScheduledSignal requires an execution context");
34910
+ }
34911
+ if (!MethodContextService.hasContext()) {
34912
+ throw new Error("hasNoScheduledSignal requires a method context");
34913
+ }
34914
+ const { backtest: isBacktest } = bt.executionContextService.context;
34915
+ const { exchangeName, frameName, strategyName } = bt.methodContextService.context;
34916
+ return await not(bt.strategyCoreService.hasScheduledSignal(isBacktest, symbol, { exchangeName, frameName, strategyName }));
34917
+ }
34854
34918
 
34855
34919
  const STOP_STRATEGY_METHOD_NAME = "control.stopStrategy";
34856
34920
  /**
@@ -34995,7 +35059,14 @@ function listenSignal(fn) {
34995
35059
  */
34996
35060
  function listenSignalOnce(filterFn, fn) {
34997
35061
  bt.loggerService.log(LISTEN_SIGNAL_ONCE_METHOD_NAME);
34998
- return signalEmitter.filter(filterFn).once(fn);
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);
34999
35070
  }
35000
35071
  /**
35001
35072
  * Subscribes to live trading signal events with queued async processing.
@@ -35044,7 +35115,14 @@ function listenSignalLive(fn) {
35044
35115
  */
35045
35116
  function listenSignalLiveOnce(filterFn, fn) {
35046
35117
  bt.loggerService.log(LISTEN_SIGNAL_LIVE_ONCE_METHOD_NAME);
35047
- return signalLiveEmitter.filter(filterFn).once(fn);
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);
35048
35126
  }
35049
35127
  /**
35050
35128
  * Subscribes to backtest signal events with queued async processing.
@@ -35093,7 +35171,14 @@ function listenSignalBacktest(fn) {
35093
35171
  */
35094
35172
  function listenSignalBacktestOnce(filterFn, fn) {
35095
35173
  bt.loggerService.log(LISTEN_SIGNAL_BACKTEST_ONCE_METHOD_NAME);
35096
- return signalBacktestEmitter.filter(filterFn).once(fn);
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);
35097
35182
  }
35098
35183
  /**
35099
35184
  * Subscribes to recoverable execution errors with queued async processing.
@@ -35210,7 +35295,14 @@ function listenDoneLive(fn) {
35210
35295
  */
35211
35296
  function listenDoneLiveOnce(filterFn, fn) {
35212
35297
  bt.loggerService.log(LISTEN_DONE_LIVE_ONCE_METHOD_NAME);
35213
- return doneLiveSubject.filter(filterFn).once(fn);
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);
35214
35306
  }
35215
35307
  /**
35216
35308
  * Subscribes to backtest background execution completion events with queued async processing.
@@ -35273,7 +35365,14 @@ function listenDoneBacktest(fn) {
35273
35365
  */
35274
35366
  function listenDoneBacktestOnce(filterFn, fn) {
35275
35367
  bt.loggerService.log(LISTEN_DONE_BACKTEST_ONCE_METHOD_NAME);
35276
- return doneBacktestSubject.filter(filterFn).once(fn);
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);
35277
35376
  }
35278
35377
  /**
35279
35378
  * Subscribes to walker background execution completion events with queued async processing.
@@ -35332,7 +35431,14 @@ function listenDoneWalker(fn) {
35332
35431
  */
35333
35432
  function listenDoneWalkerOnce(filterFn, fn) {
35334
35433
  bt.loggerService.log(LISTEN_DONE_WALKER_ONCE_METHOD_NAME);
35335
- return doneWalkerSubject.filter(filterFn).once(fn);
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);
35336
35442
  }
35337
35443
  /**
35338
35444
  * Subscribes to backtest progress events with queued async processing.
@@ -35513,7 +35619,14 @@ function listenWalker(fn) {
35513
35619
  */
35514
35620
  function listenWalkerOnce(filterFn, fn) {
35515
35621
  bt.loggerService.log(LISTEN_WALKER_ONCE_METHOD_NAME);
35516
- return walkerEmitter.filter(filterFn).once(fn);
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);
35517
35630
  }
35518
35631
  /**
35519
35632
  * Subscribes to walker completion events with queued async processing.
@@ -35638,7 +35751,14 @@ function listenPartialProfitAvailable(fn) {
35638
35751
  */
35639
35752
  function listenPartialProfitAvailableOnce(filterFn, fn) {
35640
35753
  bt.loggerService.log(LISTEN_PARTIAL_PROFIT_ONCE_METHOD_NAME);
35641
- return partialProfitSubject.filter(filterFn).once(fn);
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);
35642
35762
  }
35643
35763
  /**
35644
35764
  * Subscribes to partial loss level events with queued async processing.
@@ -35700,7 +35820,14 @@ function listenPartialLossAvailable(fn) {
35700
35820
  */
35701
35821
  function listenPartialLossAvailableOnce(filterFn, fn) {
35702
35822
  bt.loggerService.log(LISTEN_PARTIAL_LOSS_ONCE_METHOD_NAME);
35703
- return partialLossSubject.filter(filterFn).once(fn);
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);
35704
35831
  }
35705
35832
  /**
35706
35833
  * Subscribes to breakeven protection events with queued async processing.
@@ -35764,7 +35891,14 @@ function listenBreakevenAvailable(fn) {
35764
35891
  */
35765
35892
  function listenBreakevenAvailableOnce(filterFn, fn) {
35766
35893
  bt.loggerService.log(LISTEN_BREAKEVEN_ONCE_METHOD_NAME);
35767
- return breakevenSubject.filter(filterFn).once(fn);
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);
35768
35902
  }
35769
35903
  /**
35770
35904
  * Subscribes to risk rejection events with queued async processing.
@@ -35833,7 +35967,14 @@ function listenRisk(fn) {
35833
35967
  */
35834
35968
  function listenRiskOnce(filterFn, fn) {
35835
35969
  bt.loggerService.log(LISTEN_RISK_ONCE_METHOD_NAME);
35836
- return riskSubject.filter(filterFn).once(fn);
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);
35837
35978
  }
35838
35979
  /**
35839
35980
  * Subscribes to ping events during scheduled signal monitoring with queued async processing.
@@ -35860,7 +36001,16 @@ function listenRiskOnce(filterFn, fn) {
35860
36001
  */
35861
36002
  function listenSchedulePing(fn) {
35862
36003
  bt.loggerService.log(LISTEN_SCHEDULE_PING_METHOD_NAME);
35863
- return schedulePingSubject.subscribe(queued(async (event) => fn(event)));
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));
35864
36014
  }
35865
36015
  /**
35866
36016
  * Subscribes to filtered ping events with one-time execution.
@@ -35894,7 +36044,14 @@ function listenSchedulePing(fn) {
35894
36044
  */
35895
36045
  function listenSchedulePingOnce(filterFn, fn) {
35896
36046
  bt.loggerService.log(LISTEN_SCHEDULE_PING_ONCE_METHOD_NAME);
35897
- return schedulePingSubject.filter(filterFn).once(fn);
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);
35898
36055
  }
35899
36056
  /**
35900
36057
  * Subscribes to active ping events with queued async processing.
@@ -35925,7 +36082,16 @@ function listenSchedulePingOnce(filterFn, fn) {
35925
36082
  */
35926
36083
  function listenActivePing(fn) {
35927
36084
  bt.loggerService.log(LISTEN_ACTIVE_PING_METHOD_NAME);
35928
- return activePingSubject.subscribe(queued(async (event) => fn(event)));
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));
35929
36095
  }
35930
36096
  /**
35931
36097
  * Subscribes to filtered active ping events with one-time execution.
@@ -35959,7 +36125,14 @@ function listenActivePing(fn) {
35959
36125
  */
35960
36126
  function listenActivePingOnce(filterFn, fn) {
35961
36127
  bt.loggerService.log(LISTEN_ACTIVE_PING_ONCE_METHOD_NAME);
35962
- return activePingSubject.filter(filterFn).once(fn);
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);
35963
36136
  }
35964
36137
  /**
35965
36138
  * Subscribes to strategy management events with queued async processing.
@@ -36031,7 +36204,14 @@ function listenStrategyCommit(fn) {
36031
36204
  */
36032
36205
  function listenStrategyCommitOnce(filterFn, fn) {
36033
36206
  bt.loggerService.log(LISTEN_STRATEGY_COMMIT_ONCE_METHOD_NAME);
36034
- return strategyCommitSubject.filter(filterFn).once(fn);
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);
36035
36215
  }
36036
36216
  /**
36037
36217
  * Subscribes to signal synchronization events with queued async processing.
@@ -36066,11 +36246,18 @@ function listenSyncOnce(filterFn, fn) {
36066
36246
  {
36067
36247
  console.error("listenSyncOnce is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
36068
36248
  console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
36069
- console.error("If listenSyncOnce throws the exchange WILL EXECUTE the order!");
36249
+ console.error("If listenSyncOnce throws the exchange will not execute the order!");
36070
36250
  console.error("");
36071
36251
  console.error("You have been warned!");
36072
36252
  }
36073
- return syncSubject.filter(filterFn).once(fn);
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);
36074
36261
  }
36075
36262
  /**
36076
36263
  * Subscribes to highest profit events with queued async processing.
@@ -36097,7 +36284,14 @@ function listenHighestProfit(fn) {
36097
36284
  */
36098
36285
  function listenHighestProfitOnce(filterFn, fn) {
36099
36286
  bt.loggerService.log(LISTEN_HIGHEST_PROFIT_ONCE_METHOD_NAME);
36100
- return highestProfitSubject.filter(filterFn).once(fn);
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);
36101
36295
  }
36102
36296
 
36103
36297
  const BACKTEST_METHOD_NAME_RUN = "BacktestUtils.run";
@@ -48504,4 +48698,4 @@ const percentValue = (yesterdayValue, todayValue) => {
48504
48698
  return yesterdayValue / todayValue - 1;
48505
48699
  };
48506
48700
 
48507
- export { ActionBase, Backtest, Breakeven, Broker, BrokerBase, Cache, Constant, Exchange, ExecutionContextService, Heat, HighestProfit, Live, Log, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Storage, StorageBacktest, StorageLive, Strategy, Sync, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles };
48701
+ export { ActionBase, Backtest, Breakeven, Broker, BrokerBase, Cache, Constant, Exchange, ExecutionContextService, Heat, HighestProfit, Live, Log, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Storage, StorageBacktest, StorageLive, Strategy, Sync, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "5.6.4",
3
+ "version": "5.6.6",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -5392,6 +5392,46 @@ declare function getPositionEntryOverlap(symbol: string, currentPrice: number, l
5392
5392
  * ```
5393
5393
  */
5394
5394
  declare function getPositionPartialOverlap(symbol: string, currentPrice: number, ladder?: IPositionOverlapLadder): Promise<boolean>;
5395
+ /**
5396
+ * Returns true if there is NO active pending signal for the given symbol.
5397
+ *
5398
+ * Inverse of hasPendingSignal. Use to guard signal generation logic.
5399
+ *
5400
+ * Automatically detects backtest/live mode from execution context.
5401
+ *
5402
+ * @param symbol - Trading pair symbol
5403
+ * @returns Promise<boolean> - true if no pending signal exists, false if one does
5404
+ *
5405
+ * @example
5406
+ * ```typescript
5407
+ * import { hasNoPendingSignal } from "backtest-kit";
5408
+ *
5409
+ * if (await hasNoPendingSignal("BTCUSDT")) {
5410
+ * // safe to open a new position
5411
+ * }
5412
+ * ```
5413
+ */
5414
+ declare function hasNoPendingSignal(symbol: string): Promise<boolean>;
5415
+ /**
5416
+ * Returns true if there is NO active scheduled signal for the given symbol.
5417
+ *
5418
+ * Inverse of hasScheduledSignal. Use to guard signal generation logic.
5419
+ *
5420
+ * Automatically detects backtest/live mode from execution context.
5421
+ *
5422
+ * @param symbol - Trading pair symbol
5423
+ * @returns Promise<boolean> - true if no scheduled signal exists, false if one does
5424
+ *
5425
+ * @example
5426
+ * ```typescript
5427
+ * import { hasNoScheduledSignal } from "backtest-kit";
5428
+ *
5429
+ * if (await hasNoScheduledSignal("BTCUSDT")) {
5430
+ * // safe to schedule a new signal
5431
+ * }
5432
+ * ```
5433
+ */
5434
+ declare function hasNoScheduledSignal(symbol: string): Promise<boolean>;
5395
5435
 
5396
5436
  /**
5397
5437
  * Stops the strategy from generating new signals.
@@ -27058,4 +27098,4 @@ declare const getTotalClosed: (signal: Signal) => {
27058
27098
  remainingCostBasis: number;
27059
27099
  };
27060
27100
 
27061
- export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MeasureData, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TLogCtor, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles };
27101
+ export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MeasureData, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TLogCtor, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles };