backtest-kit 3.0.16 → 3.0.18

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/README.md CHANGED
@@ -320,7 +320,7 @@ Order book fetching uses the same temporal alignment as candles, but with a conf
320
320
 
321
321
  #### Order Book Timestamp Convention:
322
322
 
323
- The `from`/`to` range is a **lookback window**. The adapter selects the closest snapshot to `to` in backtest mode, or returns real-time data in live mode. Unlike candles, most exchanges (e.g. Binance `GET /api/v3/depth`) only expose the **current** order book with no historical query support — for backtest you must provide your own snapshot storage.
323
+ Unlike candles, most exchanges (e.g. Binance `GET /api/v3/depth`) only expose the **current** order book with no historical query support — for backtest you must provide your own snapshot storage.
324
324
 
325
325
  **Key principles:**
326
326
  - Time range is aligned down to `CC_ORDER_BOOK_TIME_OFFSET_MINUTES` boundary
package/build/index.cjs CHANGED
@@ -715,7 +715,7 @@ async function writeFileAtomic(file, data, options = {}) {
715
715
  var _a$2;
716
716
  const BASE_WAIT_FOR_INIT_SYMBOL = Symbol("wait-for-init");
717
717
  // Calculate step in milliseconds for candle close time validation
718
- const INTERVAL_MINUTES$7 = {
718
+ const INTERVAL_MINUTES$8 = {
719
719
  "1m": 1,
720
720
  "3m": 3,
721
721
  "5m": 5,
@@ -727,7 +727,7 @@ const INTERVAL_MINUTES$7 = {
727
727
  "6h": 360,
728
728
  "8h": 480,
729
729
  };
730
- const MS_PER_MINUTE$5 = 60000;
730
+ const MS_PER_MINUTE$6 = 60000;
731
731
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_USE_PERSIST_SIGNAL_ADAPTER = "PersistSignalUtils.usePersistSignalAdapter";
732
732
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_READ_DATA = "PersistSignalUtils.readSignalData";
733
733
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_WRITE_DATA = "PersistSignalUtils.writeSignalData";
@@ -1627,7 +1627,7 @@ class PersistCandleUtils {
1627
1627
  const isInitial = !this.getCandlesStorage.has(key);
1628
1628
  const stateStorage = this.getCandlesStorage(symbol, interval, exchangeName);
1629
1629
  await stateStorage.waitForInit(isInitial);
1630
- const stepMs = INTERVAL_MINUTES$7[interval] * MS_PER_MINUTE$5;
1630
+ const stepMs = INTERVAL_MINUTES$8[interval] * MS_PER_MINUTE$6;
1631
1631
  // Calculate expected timestamps and fetch each candle directly
1632
1632
  const cachedCandles = [];
1633
1633
  for (let i = 0; i < limit; i++) {
@@ -1683,7 +1683,7 @@ class PersistCandleUtils {
1683
1683
  const stateStorage = this.getCandlesStorage(symbol, interval, exchangeName);
1684
1684
  await stateStorage.waitForInit(isInitial);
1685
1685
  // Calculate step in milliseconds to determine candle close time
1686
- const stepMs = INTERVAL_MINUTES$7[interval] * MS_PER_MINUTE$5;
1686
+ const stepMs = INTERVAL_MINUTES$8[interval] * MS_PER_MINUTE$6;
1687
1687
  const now = Date.now();
1688
1688
  // Write each candle as a separate file, skipping incomplete candles
1689
1689
  for (const candle of candles) {
@@ -1940,8 +1940,8 @@ class PersistNotificationUtils {
1940
1940
  */
1941
1941
  const PersistNotificationAdapter = new PersistNotificationUtils();
1942
1942
 
1943
- const MS_PER_MINUTE$4 = 60000;
1944
- const INTERVAL_MINUTES$6 = {
1943
+ const MS_PER_MINUTE$5 = 60000;
1944
+ const INTERVAL_MINUTES$7 = {
1945
1945
  "1m": 1,
1946
1946
  "3m": 3,
1947
1947
  "5m": 5,
@@ -1971,7 +1971,7 @@ const INTERVAL_MINUTES$6 = {
1971
1971
  * @returns Aligned timestamp rounded down to interval boundary
1972
1972
  */
1973
1973
  const ALIGN_TO_INTERVAL_FN$2 = (timestamp, intervalMinutes) => {
1974
- const intervalMs = intervalMinutes * MS_PER_MINUTE$4;
1974
+ const intervalMs = intervalMinutes * MS_PER_MINUTE$5;
1975
1975
  return Math.floor(timestamp / intervalMs) * intervalMs;
1976
1976
  };
1977
1977
  /**
@@ -2116,9 +2116,9 @@ const WRITE_CANDLES_CACHE_FN$1 = functoolsKit.trycatch(functoolsKit.queued(async
2116
2116
  * @returns Promise resolving to array of candle data
2117
2117
  */
2118
2118
  const GET_CANDLES_FN = async (dto, since, self) => {
2119
- const step = INTERVAL_MINUTES$6[dto.interval];
2119
+ const step = INTERVAL_MINUTES$7[dto.interval];
2120
2120
  const sinceTimestamp = since.getTime();
2121
- const untilTimestamp = sinceTimestamp + dto.limit * step * MS_PER_MINUTE$4;
2121
+ const untilTimestamp = sinceTimestamp + dto.limit * step * MS_PER_MINUTE$5;
2122
2122
  // Try to read from cache first
2123
2123
  const cachedCandles = await READ_CANDLES_CACHE_FN$1(dto, sinceTimestamp, untilTimestamp, self);
2124
2124
  if (cachedCandles !== null) {
@@ -2226,11 +2226,11 @@ class ClientExchange {
2226
2226
  interval,
2227
2227
  limit,
2228
2228
  });
2229
- const step = INTERVAL_MINUTES$6[interval];
2229
+ const step = INTERVAL_MINUTES$7[interval];
2230
2230
  if (!step) {
2231
2231
  throw new Error(`ClientExchange unknown interval=${interval}`);
2232
2232
  }
2233
- const stepMs = step * MS_PER_MINUTE$4;
2233
+ const stepMs = step * MS_PER_MINUTE$5;
2234
2234
  // Align when down to interval boundary
2235
2235
  const whenTimestamp = this.params.execution.context.when.getTime();
2236
2236
  const alignedWhen = ALIGN_TO_INTERVAL_FN$2(whenTimestamp, step);
@@ -2307,11 +2307,11 @@ class ClientExchange {
2307
2307
  if (!this.params.execution.context.backtest) {
2308
2308
  throw new Error(`ClientExchange getNextCandles: cannot fetch future candles in live mode`);
2309
2309
  }
2310
- const step = INTERVAL_MINUTES$6[interval];
2310
+ const step = INTERVAL_MINUTES$7[interval];
2311
2311
  if (!step) {
2312
2312
  throw new Error(`ClientExchange getNextCandles: unknown interval=${interval}`);
2313
2313
  }
2314
- const stepMs = step * MS_PER_MINUTE$4;
2314
+ const stepMs = step * MS_PER_MINUTE$5;
2315
2315
  const now = Date.now();
2316
2316
  // Align when down to interval boundary
2317
2317
  const whenTimestamp = this.params.execution.context.when.getTime();
@@ -2475,11 +2475,11 @@ class ClientExchange {
2475
2475
  sDate,
2476
2476
  eDate,
2477
2477
  });
2478
- const step = INTERVAL_MINUTES$6[interval];
2478
+ const step = INTERVAL_MINUTES$7[interval];
2479
2479
  if (!step) {
2480
2480
  throw new Error(`ClientExchange getRawCandles: unknown interval=${interval}`);
2481
2481
  }
2482
- const stepMs = step * MS_PER_MINUTE$4;
2482
+ const stepMs = step * MS_PER_MINUTE$5;
2483
2483
  const whenTimestamp = this.params.execution.context.when.getTime();
2484
2484
  const alignedWhen = ALIGN_TO_INTERVAL_FN$2(whenTimestamp, step);
2485
2485
  let sinceTimestamp;
@@ -2608,7 +2608,7 @@ class ClientExchange {
2608
2608
  const alignedTo = ALIGN_TO_INTERVAL_FN$2(whenTimestamp, GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES);
2609
2609
  const to = new Date(alignedTo);
2610
2610
  const from = new Date(alignedTo -
2611
- GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * MS_PER_MINUTE$4);
2611
+ GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * MS_PER_MINUTE$5);
2612
2612
  return await this.params.getOrderBook(symbol, depth, from, to, this.params.execution.context.backtest);
2613
2613
  }
2614
2614
  }
@@ -3073,7 +3073,7 @@ const beginTime = (run) => (...args) => {
3073
3073
  return fn();
3074
3074
  };
3075
3075
 
3076
- const INTERVAL_MINUTES$5 = {
3076
+ const INTERVAL_MINUTES$6 = {
3077
3077
  "1m": 1,
3078
3078
  "3m": 3,
3079
3079
  "5m": 5,
@@ -3586,14 +3586,15 @@ const GET_SIGNAL_FN = functoolsKit.trycatch(async (self) => {
3586
3586
  }
3587
3587
  const currentTime = self.params.execution.context.when.getTime();
3588
3588
  {
3589
- const intervalMinutes = INTERVAL_MINUTES$5[self.params.interval];
3589
+ const intervalMinutes = INTERVAL_MINUTES$6[self.params.interval];
3590
3590
  const intervalMs = intervalMinutes * 60 * 1000;
3591
- // Проверяем что прошел нужный интервал с последнего getSignal
3591
+ const alignedTime = Math.floor(currentTime / intervalMs) * intervalMs;
3592
+ // Проверяем что наступил новый интервал (по aligned timestamp)
3592
3593
  if (self._lastSignalTimestamp !== null &&
3593
- currentTime - self._lastSignalTimestamp < intervalMs) {
3594
+ alignedTime === self._lastSignalTimestamp) {
3594
3595
  return null;
3595
3596
  }
3596
- self._lastSignalTimestamp = currentTime;
3597
+ self._lastSignalTimestamp = alignedTime;
3597
3598
  }
3598
3599
  const currentPrice = await self.params.exchange.getAveragePrice(self.params.execution.context.symbol);
3599
3600
  const timeoutMs = GLOBAL_CONFIG.CC_MAX_SIGNAL_GENERATION_SECONDS * 1000;
@@ -8197,7 +8198,7 @@ class StrategyConnectionService {
8197
8198
  * Maps FrameInterval to minutes for timestamp calculation.
8198
8199
  * Used to generate timeframe arrays with proper spacing.
8199
8200
  */
8200
- const INTERVAL_MINUTES$4 = {
8201
+ const INTERVAL_MINUTES$5 = {
8201
8202
  "1m": 1,
8202
8203
  "3m": 3,
8203
8204
  "5m": 5,
@@ -8252,7 +8253,7 @@ const GET_TIMEFRAME_FN = async (symbol, self) => {
8252
8253
  symbol,
8253
8254
  });
8254
8255
  const { interval, startDate, endDate } = self.params;
8255
- const intervalMinutes = INTERVAL_MINUTES$4[interval];
8256
+ const intervalMinutes = INTERVAL_MINUTES$5[interval];
8256
8257
  if (!intervalMinutes) {
8257
8258
  throw new Error(`ClientFrame unknown interval: ${interval}`);
8258
8259
  }
@@ -13215,7 +13216,49 @@ class BacktestLogicPrivateService {
13215
13216
  }
13216
13217
  }
13217
13218
 
13218
- const TICK_TTL = 1 * 60 * 1000 + 1;
13219
+ const EMITTER_CHECK_INTERVAL = 5000;
13220
+ const MS_PER_MINUTE$4 = 60000;
13221
+ const INTERVAL_MINUTES$4 = {
13222
+ "1m": 1,
13223
+ "3m": 3,
13224
+ "5m": 5,
13225
+ "15m": 15,
13226
+ "30m": 30,
13227
+ "1h": 60,
13228
+ "2h": 120,
13229
+ "4h": 240,
13230
+ "6h": 360,
13231
+ "8h": 480,
13232
+ };
13233
+ const createEmitter = functoolsKit.memoize(([interval]) => `${interval}`, (interval) => {
13234
+ const tickSubject = new functoolsKit.Subject();
13235
+ const intervalMs = INTERVAL_MINUTES$4[interval] * MS_PER_MINUTE$4;
13236
+ {
13237
+ let lastAligned = Math.floor(Date.now() / intervalMs) * intervalMs;
13238
+ functoolsKit.Source.fromInterval(EMITTER_CHECK_INTERVAL)
13239
+ .map(() => Math.floor(Date.now() / intervalMs) * intervalMs)
13240
+ .filter((aligned) => {
13241
+ if (aligned !== lastAligned) {
13242
+ lastAligned = aligned;
13243
+ return true;
13244
+ }
13245
+ return false;
13246
+ })
13247
+ .connect(tickSubject.next);
13248
+ }
13249
+ return tickSubject;
13250
+ });
13251
+ /**
13252
+ * Waits for the next candle interval to start and returns the timestamp of the new candle.
13253
+ * @param {CandleInterval} interval - The candle interval (e.g., "1m", "1h") to wait for.
13254
+ * @returns {Promise<number>} A promise that resolves with the timestamp (in milliseconds) of the next candle start.
13255
+ */
13256
+ const waitForCandle = async (interval) => {
13257
+ const emitter = createEmitter(interval);
13258
+ // Subject is multicast
13259
+ return emitter.toPromise();
13260
+ };
13261
+
13219
13262
  /**
13220
13263
  * Private service for live trading orchestration using async generators.
13221
13264
  *
@@ -13285,7 +13328,7 @@ class LiveLogicPrivateService {
13285
13328
  message: functoolsKit.getErrorMessage(error),
13286
13329
  });
13287
13330
  await errorEmitter.next(error);
13288
- await functoolsKit.sleep(TICK_TTL);
13331
+ await waitForCandle("1m");
13289
13332
  continue;
13290
13333
  }
13291
13334
  this.loggerService.info("liveLogicPrivateService tick result", {
@@ -13320,19 +13363,19 @@ class LiveLogicPrivateService {
13320
13363
  });
13321
13364
  break;
13322
13365
  }
13323
- await functoolsKit.sleep(TICK_TTL);
13366
+ await waitForCandle("1m");
13324
13367
  continue;
13325
13368
  }
13326
13369
  if (result.action === "active") {
13327
- await functoolsKit.sleep(TICK_TTL);
13370
+ await waitForCandle("1m");
13328
13371
  continue;
13329
13372
  }
13330
13373
  if (result.action === "scheduled") {
13331
- await functoolsKit.sleep(TICK_TTL);
13374
+ await waitForCandle("1m");
13332
13375
  continue;
13333
13376
  }
13334
13377
  if (result.action === "waiting") {
13335
- await functoolsKit.sleep(TICK_TTL);
13378
+ await waitForCandle("1m");
13336
13379
  continue;
13337
13380
  }
13338
13381
  // Yield opened, closed, cancelled results
@@ -13351,7 +13394,7 @@ class LiveLogicPrivateService {
13351
13394
  break;
13352
13395
  }
13353
13396
  }
13354
- await functoolsKit.sleep(TICK_TTL);
13397
+ await waitForCandle("1m");
13355
13398
  }
13356
13399
  }
13357
13400
  }
@@ -37498,4 +37541,5 @@ exports.setConfig = setConfig;
37498
37541
  exports.setLogger = setLogger;
37499
37542
  exports.stopStrategy = stopStrategy;
37500
37543
  exports.validate = validate;
37544
+ exports.waitForCandle = waitForCandle;
37501
37545
  exports.warmCandles = warmCandles;
package/build/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createActivator } from 'di-kit';
2
2
  import { scoped } from 'di-scoped';
3
- import { Subject, makeExtendable, singleshot, getErrorMessage, memoize, not, errorData, trycatch, retry, queued, sleep, randomString, str, isObject, ToolRegistry, typo, and, resolveDocuments, timeout, TIMEOUT_SYMBOL as TIMEOUT_SYMBOL$1, compose, singlerun } from 'functools-kit';
3
+ import { Subject, makeExtendable, singleshot, getErrorMessage, memoize, not, errorData, trycatch, retry, queued, sleep, randomString, str, isObject, ToolRegistry, typo, and, Source, resolveDocuments, timeout, TIMEOUT_SYMBOL as TIMEOUT_SYMBOL$1, compose, singlerun } from 'functools-kit';
4
4
  import * as fs from 'fs/promises';
5
5
  import fs__default, { stat, opendir, readFile } from 'fs/promises';
6
6
  import path, { join, dirname } from 'path';
@@ -695,7 +695,7 @@ async function writeFileAtomic(file, data, options = {}) {
695
695
  var _a$2;
696
696
  const BASE_WAIT_FOR_INIT_SYMBOL = Symbol("wait-for-init");
697
697
  // Calculate step in milliseconds for candle close time validation
698
- const INTERVAL_MINUTES$7 = {
698
+ const INTERVAL_MINUTES$8 = {
699
699
  "1m": 1,
700
700
  "3m": 3,
701
701
  "5m": 5,
@@ -707,7 +707,7 @@ const INTERVAL_MINUTES$7 = {
707
707
  "6h": 360,
708
708
  "8h": 480,
709
709
  };
710
- const MS_PER_MINUTE$5 = 60000;
710
+ const MS_PER_MINUTE$6 = 60000;
711
711
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_USE_PERSIST_SIGNAL_ADAPTER = "PersistSignalUtils.usePersistSignalAdapter";
712
712
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_READ_DATA = "PersistSignalUtils.readSignalData";
713
713
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_WRITE_DATA = "PersistSignalUtils.writeSignalData";
@@ -1607,7 +1607,7 @@ class PersistCandleUtils {
1607
1607
  const isInitial = !this.getCandlesStorage.has(key);
1608
1608
  const stateStorage = this.getCandlesStorage(symbol, interval, exchangeName);
1609
1609
  await stateStorage.waitForInit(isInitial);
1610
- const stepMs = INTERVAL_MINUTES$7[interval] * MS_PER_MINUTE$5;
1610
+ const stepMs = INTERVAL_MINUTES$8[interval] * MS_PER_MINUTE$6;
1611
1611
  // Calculate expected timestamps and fetch each candle directly
1612
1612
  const cachedCandles = [];
1613
1613
  for (let i = 0; i < limit; i++) {
@@ -1663,7 +1663,7 @@ class PersistCandleUtils {
1663
1663
  const stateStorage = this.getCandlesStorage(symbol, interval, exchangeName);
1664
1664
  await stateStorage.waitForInit(isInitial);
1665
1665
  // Calculate step in milliseconds to determine candle close time
1666
- const stepMs = INTERVAL_MINUTES$7[interval] * MS_PER_MINUTE$5;
1666
+ const stepMs = INTERVAL_MINUTES$8[interval] * MS_PER_MINUTE$6;
1667
1667
  const now = Date.now();
1668
1668
  // Write each candle as a separate file, skipping incomplete candles
1669
1669
  for (const candle of candles) {
@@ -1920,8 +1920,8 @@ class PersistNotificationUtils {
1920
1920
  */
1921
1921
  const PersistNotificationAdapter = new PersistNotificationUtils();
1922
1922
 
1923
- const MS_PER_MINUTE$4 = 60000;
1924
- const INTERVAL_MINUTES$6 = {
1923
+ const MS_PER_MINUTE$5 = 60000;
1924
+ const INTERVAL_MINUTES$7 = {
1925
1925
  "1m": 1,
1926
1926
  "3m": 3,
1927
1927
  "5m": 5,
@@ -1951,7 +1951,7 @@ const INTERVAL_MINUTES$6 = {
1951
1951
  * @returns Aligned timestamp rounded down to interval boundary
1952
1952
  */
1953
1953
  const ALIGN_TO_INTERVAL_FN$2 = (timestamp, intervalMinutes) => {
1954
- const intervalMs = intervalMinutes * MS_PER_MINUTE$4;
1954
+ const intervalMs = intervalMinutes * MS_PER_MINUTE$5;
1955
1955
  return Math.floor(timestamp / intervalMs) * intervalMs;
1956
1956
  };
1957
1957
  /**
@@ -2096,9 +2096,9 @@ const WRITE_CANDLES_CACHE_FN$1 = trycatch(queued(async (candles, dto, self) => {
2096
2096
  * @returns Promise resolving to array of candle data
2097
2097
  */
2098
2098
  const GET_CANDLES_FN = async (dto, since, self) => {
2099
- const step = INTERVAL_MINUTES$6[dto.interval];
2099
+ const step = INTERVAL_MINUTES$7[dto.interval];
2100
2100
  const sinceTimestamp = since.getTime();
2101
- const untilTimestamp = sinceTimestamp + dto.limit * step * MS_PER_MINUTE$4;
2101
+ const untilTimestamp = sinceTimestamp + dto.limit * step * MS_PER_MINUTE$5;
2102
2102
  // Try to read from cache first
2103
2103
  const cachedCandles = await READ_CANDLES_CACHE_FN$1(dto, sinceTimestamp, untilTimestamp, self);
2104
2104
  if (cachedCandles !== null) {
@@ -2206,11 +2206,11 @@ class ClientExchange {
2206
2206
  interval,
2207
2207
  limit,
2208
2208
  });
2209
- const step = INTERVAL_MINUTES$6[interval];
2209
+ const step = INTERVAL_MINUTES$7[interval];
2210
2210
  if (!step) {
2211
2211
  throw new Error(`ClientExchange unknown interval=${interval}`);
2212
2212
  }
2213
- const stepMs = step * MS_PER_MINUTE$4;
2213
+ const stepMs = step * MS_PER_MINUTE$5;
2214
2214
  // Align when down to interval boundary
2215
2215
  const whenTimestamp = this.params.execution.context.when.getTime();
2216
2216
  const alignedWhen = ALIGN_TO_INTERVAL_FN$2(whenTimestamp, step);
@@ -2287,11 +2287,11 @@ class ClientExchange {
2287
2287
  if (!this.params.execution.context.backtest) {
2288
2288
  throw new Error(`ClientExchange getNextCandles: cannot fetch future candles in live mode`);
2289
2289
  }
2290
- const step = INTERVAL_MINUTES$6[interval];
2290
+ const step = INTERVAL_MINUTES$7[interval];
2291
2291
  if (!step) {
2292
2292
  throw new Error(`ClientExchange getNextCandles: unknown interval=${interval}`);
2293
2293
  }
2294
- const stepMs = step * MS_PER_MINUTE$4;
2294
+ const stepMs = step * MS_PER_MINUTE$5;
2295
2295
  const now = Date.now();
2296
2296
  // Align when down to interval boundary
2297
2297
  const whenTimestamp = this.params.execution.context.when.getTime();
@@ -2455,11 +2455,11 @@ class ClientExchange {
2455
2455
  sDate,
2456
2456
  eDate,
2457
2457
  });
2458
- const step = INTERVAL_MINUTES$6[interval];
2458
+ const step = INTERVAL_MINUTES$7[interval];
2459
2459
  if (!step) {
2460
2460
  throw new Error(`ClientExchange getRawCandles: unknown interval=${interval}`);
2461
2461
  }
2462
- const stepMs = step * MS_PER_MINUTE$4;
2462
+ const stepMs = step * MS_PER_MINUTE$5;
2463
2463
  const whenTimestamp = this.params.execution.context.when.getTime();
2464
2464
  const alignedWhen = ALIGN_TO_INTERVAL_FN$2(whenTimestamp, step);
2465
2465
  let sinceTimestamp;
@@ -2588,7 +2588,7 @@ class ClientExchange {
2588
2588
  const alignedTo = ALIGN_TO_INTERVAL_FN$2(whenTimestamp, GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES);
2589
2589
  const to = new Date(alignedTo);
2590
2590
  const from = new Date(alignedTo -
2591
- GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * MS_PER_MINUTE$4);
2591
+ GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * MS_PER_MINUTE$5);
2592
2592
  return await this.params.getOrderBook(symbol, depth, from, to, this.params.execution.context.backtest);
2593
2593
  }
2594
2594
  }
@@ -3053,7 +3053,7 @@ const beginTime = (run) => (...args) => {
3053
3053
  return fn();
3054
3054
  };
3055
3055
 
3056
- const INTERVAL_MINUTES$5 = {
3056
+ const INTERVAL_MINUTES$6 = {
3057
3057
  "1m": 1,
3058
3058
  "3m": 3,
3059
3059
  "5m": 5,
@@ -3566,14 +3566,15 @@ const GET_SIGNAL_FN = trycatch(async (self) => {
3566
3566
  }
3567
3567
  const currentTime = self.params.execution.context.when.getTime();
3568
3568
  {
3569
- const intervalMinutes = INTERVAL_MINUTES$5[self.params.interval];
3569
+ const intervalMinutes = INTERVAL_MINUTES$6[self.params.interval];
3570
3570
  const intervalMs = intervalMinutes * 60 * 1000;
3571
- // Проверяем что прошел нужный интервал с последнего getSignal
3571
+ const alignedTime = Math.floor(currentTime / intervalMs) * intervalMs;
3572
+ // Проверяем что наступил новый интервал (по aligned timestamp)
3572
3573
  if (self._lastSignalTimestamp !== null &&
3573
- currentTime - self._lastSignalTimestamp < intervalMs) {
3574
+ alignedTime === self._lastSignalTimestamp) {
3574
3575
  return null;
3575
3576
  }
3576
- self._lastSignalTimestamp = currentTime;
3577
+ self._lastSignalTimestamp = alignedTime;
3577
3578
  }
3578
3579
  const currentPrice = await self.params.exchange.getAveragePrice(self.params.execution.context.symbol);
3579
3580
  const timeoutMs = GLOBAL_CONFIG.CC_MAX_SIGNAL_GENERATION_SECONDS * 1000;
@@ -8177,7 +8178,7 @@ class StrategyConnectionService {
8177
8178
  * Maps FrameInterval to minutes for timestamp calculation.
8178
8179
  * Used to generate timeframe arrays with proper spacing.
8179
8180
  */
8180
- const INTERVAL_MINUTES$4 = {
8181
+ const INTERVAL_MINUTES$5 = {
8181
8182
  "1m": 1,
8182
8183
  "3m": 3,
8183
8184
  "5m": 5,
@@ -8232,7 +8233,7 @@ const GET_TIMEFRAME_FN = async (symbol, self) => {
8232
8233
  symbol,
8233
8234
  });
8234
8235
  const { interval, startDate, endDate } = self.params;
8235
- const intervalMinutes = INTERVAL_MINUTES$4[interval];
8236
+ const intervalMinutes = INTERVAL_MINUTES$5[interval];
8236
8237
  if (!intervalMinutes) {
8237
8238
  throw new Error(`ClientFrame unknown interval: ${interval}`);
8238
8239
  }
@@ -13195,7 +13196,49 @@ class BacktestLogicPrivateService {
13195
13196
  }
13196
13197
  }
13197
13198
 
13198
- const TICK_TTL = 1 * 60 * 1000 + 1;
13199
+ const EMITTER_CHECK_INTERVAL = 5000;
13200
+ const MS_PER_MINUTE$4 = 60000;
13201
+ const INTERVAL_MINUTES$4 = {
13202
+ "1m": 1,
13203
+ "3m": 3,
13204
+ "5m": 5,
13205
+ "15m": 15,
13206
+ "30m": 30,
13207
+ "1h": 60,
13208
+ "2h": 120,
13209
+ "4h": 240,
13210
+ "6h": 360,
13211
+ "8h": 480,
13212
+ };
13213
+ const createEmitter = memoize(([interval]) => `${interval}`, (interval) => {
13214
+ const tickSubject = new Subject();
13215
+ const intervalMs = INTERVAL_MINUTES$4[interval] * MS_PER_MINUTE$4;
13216
+ {
13217
+ let lastAligned = Math.floor(Date.now() / intervalMs) * intervalMs;
13218
+ Source.fromInterval(EMITTER_CHECK_INTERVAL)
13219
+ .map(() => Math.floor(Date.now() / intervalMs) * intervalMs)
13220
+ .filter((aligned) => {
13221
+ if (aligned !== lastAligned) {
13222
+ lastAligned = aligned;
13223
+ return true;
13224
+ }
13225
+ return false;
13226
+ })
13227
+ .connect(tickSubject.next);
13228
+ }
13229
+ return tickSubject;
13230
+ });
13231
+ /**
13232
+ * Waits for the next candle interval to start and returns the timestamp of the new candle.
13233
+ * @param {CandleInterval} interval - The candle interval (e.g., "1m", "1h") to wait for.
13234
+ * @returns {Promise<number>} A promise that resolves with the timestamp (in milliseconds) of the next candle start.
13235
+ */
13236
+ const waitForCandle = async (interval) => {
13237
+ const emitter = createEmitter(interval);
13238
+ // Subject is multicast
13239
+ return emitter.toPromise();
13240
+ };
13241
+
13199
13242
  /**
13200
13243
  * Private service for live trading orchestration using async generators.
13201
13244
  *
@@ -13265,7 +13308,7 @@ class LiveLogicPrivateService {
13265
13308
  message: getErrorMessage(error),
13266
13309
  });
13267
13310
  await errorEmitter.next(error);
13268
- await sleep(TICK_TTL);
13311
+ await waitForCandle("1m");
13269
13312
  continue;
13270
13313
  }
13271
13314
  this.loggerService.info("liveLogicPrivateService tick result", {
@@ -13300,19 +13343,19 @@ class LiveLogicPrivateService {
13300
13343
  });
13301
13344
  break;
13302
13345
  }
13303
- await sleep(TICK_TTL);
13346
+ await waitForCandle("1m");
13304
13347
  continue;
13305
13348
  }
13306
13349
  if (result.action === "active") {
13307
- await sleep(TICK_TTL);
13350
+ await waitForCandle("1m");
13308
13351
  continue;
13309
13352
  }
13310
13353
  if (result.action === "scheduled") {
13311
- await sleep(TICK_TTL);
13354
+ await waitForCandle("1m");
13312
13355
  continue;
13313
13356
  }
13314
13357
  if (result.action === "waiting") {
13315
- await sleep(TICK_TTL);
13358
+ await waitForCandle("1m");
13316
13359
  continue;
13317
13360
  }
13318
13361
  // Yield opened, closed, cancelled results
@@ -13331,7 +13374,7 @@ class LiveLogicPrivateService {
13331
13374
  break;
13332
13375
  }
13333
13376
  }
13334
- await sleep(TICK_TTL);
13377
+ await waitForCandle("1m");
13335
13378
  }
13336
13379
  }
13337
13380
  }
@@ -37341,4 +37384,4 @@ const set = (object, path, value) => {
37341
37384
  }
37342
37385
  };
37343
37386
 
37344
- export { ActionBase, Backtest, Breakeven, Cache, Constant, Exchange, ExecutionContextService, Heat, Live, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Storage, StorageBacktest, StorageLive, Strategy, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate, warmCandles };
37387
+ export { ActionBase, Backtest, Breakeven, Cache, Constant, Exchange, ExecutionContextService, Heat, Live, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Storage, StorageBacktest, StorageLive, Strategy, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate, waitForCandle, warmCandles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "3.0.16",
3
+ "version": "3.0.18",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -1961,37 +1961,11 @@ interface IActionSchema {
1961
1961
  * @see TActionCtor for constructor signature requirements
1962
1962
  * @see ClientAction for internal wrapper that manages lifecycle
1963
1963
  */
1964
- interface IPublicAction extends IAction {
1965
- /**
1966
- * Async initialization method called once after construction.
1967
- *
1968
- * Use this method to:
1969
- * - Establish database connections
1970
- * - Initialize API clients
1971
- * - Load configuration files
1972
- * - Open file handles or network sockets
1973
- * - Perform any async setup required before handling events
1974
- *
1975
- * Guaranteed to:
1976
- * - Run exactly once per action handler instance
1977
- * - Complete before any event methods are called
1978
- * - Run after constructor but before first event
1979
- *
1980
- * @returns Promise that resolves when initialization is complete
1981
- * @throws Error if initialization fails (will prevent strategy execution)
1982
- *
1983
- * @example
1984
- * ```typescript
1985
- * async init() {
1986
- * this.db = await connectToDatabase();
1987
- * this.cache = new Redis(process.env.REDIS_URL);
1988
- * await this.cache.connect();
1989
- * console.log('Action initialized');
1990
- * }
1991
- * ```
1992
- */
1993
- init(): void | Promise<void>;
1994
- }
1964
+ type IPublicAction = {
1965
+ [key in keyof IAction]?: IAction[key];
1966
+ } & {
1967
+ init?(): void | Promise<void>;
1968
+ };
1995
1969
  /**
1996
1970
  * Action interface for state manager integration.
1997
1971
  *
@@ -16201,6 +16175,13 @@ declare namespace emitters {
16201
16175
  */
16202
16176
  declare const alignToInterval: (date: Date, interval: CandleInterval) => Date;
16203
16177
 
16178
+ /**
16179
+ * Waits for the next candle interval to start and returns the timestamp of the new candle.
16180
+ * @param {CandleInterval} interval - The candle interval (e.g., "1m", "1h") to wait for.
16181
+ * @returns {Promise<number>} A promise that resolves with the timestamp (in milliseconds) of the next candle start.
16182
+ */
16183
+ declare const waitForCandle: (interval: CandleInterval) => Promise<number>;
16184
+
16204
16185
  /**
16205
16186
  * Rounds a price to the appropriate precision based on the tick size.
16206
16187
  *
@@ -20842,4 +20823,4 @@ declare const backtest: {
20842
20823
  loggerService: LoggerService;
20843
20824
  };
20844
20825
 
20845
- export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, 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, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, 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, 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 SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, 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, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate, warmCandles };
20826
+ export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, 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, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, 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, 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 SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, 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, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate, waitForCandle, warmCandles };