@tradejs/node 1.0.0 → 1.0.3

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.
@@ -5,9 +5,9 @@ import {
5
5
  buildAiPayload,
6
6
  buildAiSystemPrompt,
7
7
  trimSeriesDeep
8
- } from "./chunk-ZIMX3JX2.mjs";
9
- import "./chunk-MHCXPD2B.mjs";
10
- import "./chunk-DE7ADBIR.mjs";
8
+ } from "./chunk-QDYCJ2OK.mjs";
9
+ import "./chunk-CK2PW4L5.mjs";
10
+ import "./chunk-3C76HVLA.mjs";
11
11
  import "./chunk-6DZX6EAA.mjs";
12
12
  export {
13
13
  MAX_AI_SERIES_POINTS,
@@ -1,7 +1,7 @@
1
1
  export * from '@tradejs/core/backtest';
2
2
  import { TestingBox, TestConnectorCreator } from '@tradejs/types';
3
3
 
4
- declare const resetTestingKlineCache: () => void;
4
+ declare const resetTestingKlineCache: (cwd?: string) => void;
5
5
  declare const testing: TestingBox;
6
6
 
7
7
  declare const createTestConnector: TestConnectorCreator;
@@ -1,7 +1,7 @@
1
1
  export * from '@tradejs/core/backtest';
2
2
  import { TestingBox, TestConnectorCreator } from '@tradejs/types';
3
3
 
4
- declare const resetTestingKlineCache: () => void;
4
+ declare const resetTestingKlineCache: (cwd?: string) => void;
5
5
  declare const testing: TestingBox;
6
6
 
7
7
  declare const createTestConnector: TestConnectorCreator;
package/dist/backtest.js CHANGED
@@ -5733,14 +5733,29 @@ var loadTradejsConfig = async (cwd = getTradejsProjectCwd()) => {
5733
5733
  };
5734
5734
 
5735
5735
  // src/strategy/manifests.ts
5736
- var strategyCreators = /* @__PURE__ */ new Map();
5737
- var strategyManifestsMap = /* @__PURE__ */ new Map();
5738
- var pluginsLoadPromise = null;
5736
+ var createStrategyRegistryState = () => ({
5737
+ strategyCreators: /* @__PURE__ */ new Map(),
5738
+ strategyManifestsMap: /* @__PURE__ */ new Map(),
5739
+ pluginsLoadPromise: null
5740
+ });
5741
+ var registryStateByProjectRoot = /* @__PURE__ */ new Map();
5742
+ var getStrategyRegistryState = (cwd = getTradejsProjectCwd()) => {
5743
+ const projectRoot = getTradejsProjectCwd(cwd);
5744
+ let state = registryStateByProjectRoot.get(projectRoot);
5745
+ if (!state) {
5746
+ state = createStrategyRegistryState();
5747
+ registryStateByProjectRoot.set(projectRoot, state);
5748
+ }
5749
+ return {
5750
+ projectRoot,
5751
+ state
5752
+ };
5753
+ };
5739
5754
  var toUniqueModules = (modules = []) => [
5740
5755
  ...new Set(modules.map((moduleName) => moduleName.trim()).filter(Boolean))
5741
5756
  ];
5742
- var getConfiguredPluginModuleNames = async () => {
5743
- const config = await loadTradejsConfig();
5757
+ var getConfiguredPluginModuleNames = async (cwd = getTradejsProjectCwd()) => {
5758
+ const config = await loadTradejsConfig(cwd);
5744
5759
  return {
5745
5760
  strategyModules: toUniqueModules(config.strategies),
5746
5761
  indicatorModules: toUniqueModules(config.indicators)
@@ -5774,14 +5789,14 @@ var extractIndicatorPluginDefinition = (moduleExport) => {
5774
5789
  );
5775
5790
  return indicatorEntries ? { indicatorEntries } : null;
5776
5791
  };
5777
- var registerEntries = (entries, source) => {
5792
+ var registerEntries = (entries, source, state) => {
5778
5793
  for (const entry of entries) {
5779
5794
  const strategyName = entry.manifest?.name;
5780
5795
  if (!strategyName) {
5781
5796
  import_logger2.logger.warn("Skip strategy entry without name from %s", source);
5782
5797
  continue;
5783
5798
  }
5784
- if (strategyCreators.has(strategyName)) {
5799
+ if (state.strategyCreators.has(strategyName)) {
5785
5800
  import_logger2.logger.warn(
5786
5801
  'Skip duplicate strategy "%s" from %s: already registered',
5787
5802
  strategyName,
@@ -5789,8 +5804,8 @@ var registerEntries = (entries, source) => {
5789
5804
  );
5790
5805
  continue;
5791
5806
  }
5792
- strategyCreators.set(strategyName, entry.creator);
5793
- strategyManifestsMap.set(strategyName, entry.manifest);
5807
+ state.strategyCreators.set(strategyName, entry.creator);
5808
+ state.strategyManifestsMap.set(strategyName, entry.manifest);
5794
5809
  }
5795
5810
  };
5796
5811
  var importStrategyPluginModule = async (moduleName) => {
@@ -5802,70 +5817,86 @@ var importStrategyPluginModule = async (moduleName) => {
5802
5817
  moduleName
5803
5818
  );
5804
5819
  };
5805
- var ensureStrategyPluginsLoaded = async () => {
5806
- if (pluginsLoadPromise) {
5807
- return pluginsLoadPromise;
5808
- }
5809
- pluginsLoadPromise = (async () => {
5810
- const { strategyModules, indicatorModules } = await getConfiguredPluginModuleNames();
5811
- const strategySet = new Set(strategyModules);
5812
- const indicatorSet = new Set(indicatorModules);
5813
- const pluginModuleNames = [
5814
- .../* @__PURE__ */ new Set([...strategyModules, ...indicatorModules])
5815
- ];
5816
- if (!pluginModuleNames.length) return;
5817
- for (const moduleName of pluginModuleNames) {
5818
- try {
5819
- const resolvedModuleName = resolvePluginModuleSpecifier(moduleName);
5820
- const moduleExport = await importStrategyPluginModule(resolvedModuleName);
5821
- if (strategySet.has(moduleName)) {
5822
- const pluginDefinition = extractStrategyPluginDefinition(moduleExport);
5823
- if (!pluginDefinition) {
5824
- import_logger2.logger.warn(
5825
- 'Skip strategy plugin "%s": export { strategyEntries } is missing',
5826
- moduleName
5827
- );
5828
- } else {
5829
- registerEntries(pluginDefinition.strategyEntries, moduleName);
5820
+ var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
5821
+ const { projectRoot, state } = getStrategyRegistryState(cwd);
5822
+ if (!state.pluginsLoadPromise) {
5823
+ (0, import_indicators.resetIndicatorRegistryCache)(projectRoot);
5824
+ state.pluginsLoadPromise = (async () => {
5825
+ const { strategyModules, indicatorModules } = await getConfiguredPluginModuleNames(projectRoot);
5826
+ const strategySet = new Set(strategyModules);
5827
+ const indicatorSet = new Set(indicatorModules);
5828
+ const pluginModuleNames = [
5829
+ .../* @__PURE__ */ new Set([...strategyModules, ...indicatorModules])
5830
+ ];
5831
+ if (!pluginModuleNames.length) {
5832
+ return;
5833
+ }
5834
+ for (const moduleName of pluginModuleNames) {
5835
+ try {
5836
+ const resolvedModuleName = resolvePluginModuleSpecifier(
5837
+ moduleName,
5838
+ projectRoot
5839
+ );
5840
+ const moduleExport = await importStrategyPluginModule(resolvedModuleName);
5841
+ if (strategySet.has(moduleName)) {
5842
+ const pluginDefinition = extractStrategyPluginDefinition(moduleExport);
5843
+ if (!pluginDefinition) {
5844
+ import_logger2.logger.warn(
5845
+ 'Skip strategy plugin "%s": export { strategyEntries } is missing',
5846
+ moduleName
5847
+ );
5848
+ } else {
5849
+ registerEntries(
5850
+ pluginDefinition.strategyEntries,
5851
+ moduleName,
5852
+ state
5853
+ );
5854
+ }
5830
5855
  }
5831
- }
5832
- if (indicatorSet.has(moduleName)) {
5833
- const indicatorPluginDefinition = extractIndicatorPluginDefinition(moduleExport);
5834
- if (!indicatorPluginDefinition) {
5856
+ if (indicatorSet.has(moduleName)) {
5857
+ const indicatorPluginDefinition = extractIndicatorPluginDefinition(moduleExport);
5858
+ if (!indicatorPluginDefinition) {
5859
+ import_logger2.logger.warn(
5860
+ 'Skip indicator plugin "%s": export { indicatorEntries } is missing',
5861
+ moduleName
5862
+ );
5863
+ } else {
5864
+ (0, import_indicators.registerIndicatorEntries)(
5865
+ indicatorPluginDefinition.indicatorEntries,
5866
+ moduleName,
5867
+ projectRoot
5868
+ );
5869
+ }
5870
+ }
5871
+ if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
5835
5872
  import_logger2.logger.warn(
5836
- 'Skip indicator plugin "%s": export { indicatorEntries } is missing',
5837
- moduleName
5838
- );
5839
- } else {
5840
- (0, import_indicators.registerIndicatorEntries)(
5841
- indicatorPluginDefinition.indicatorEntries,
5873
+ 'Skip plugin "%s": no strategy/indicator sections requested in config',
5842
5874
  moduleName
5843
5875
  );
5844
5876
  }
5845
- }
5846
- if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
5877
+ } catch (error) {
5847
5878
  import_logger2.logger.warn(
5848
- 'Skip plugin "%s": no strategy/indicator sections requested in config',
5849
- moduleName
5879
+ 'Failed to load plugin "%s": %s',
5880
+ moduleName,
5881
+ String(error)
5850
5882
  );
5851
5883
  }
5852
- } catch (error) {
5853
- import_logger2.logger.warn(
5854
- 'Failed to load plugin "%s": %s',
5855
- moduleName,
5856
- String(error)
5857
- );
5858
5884
  }
5859
- }
5860
- })();
5861
- return pluginsLoadPromise;
5885
+ })();
5886
+ }
5887
+ await state.pluginsLoadPromise;
5862
5888
  };
5863
- var getStrategyCreator = async (name) => {
5864
- await ensureStrategyPluginsLoaded();
5865
- return strategyCreators.get(name);
5889
+ var getStrategyCreator = async (name, cwd = getTradejsProjectCwd()) => {
5890
+ await ensureStrategyPluginsLoaded(cwd);
5891
+ const { state } = getStrategyRegistryState(cwd);
5892
+ return state.strategyCreators.get(name);
5866
5893
  };
5867
- var getStrategyManifest = (name) => {
5868
- return name ? strategyManifestsMap.get(name) : void 0;
5894
+ var getStrategyManifest = (name, cwd = getTradejsProjectCwd()) => {
5895
+ if (!name) {
5896
+ return void 0;
5897
+ }
5898
+ const { state } = getStrategyRegistryState(cwd);
5899
+ return state.strategyManifestsMap.get(name);
5869
5900
  };
5870
5901
  var strategies = new Proxy(
5871
5902
  {},
@@ -5874,10 +5905,10 @@ var strategies = new Proxy(
5874
5905
  if (typeof property !== "string") {
5875
5906
  return void 0;
5876
5907
  }
5877
- return strategyCreators.get(property);
5908
+ return getStrategyRegistryState().state.strategyCreators.get(property);
5878
5909
  },
5879
5910
  ownKeys: () => {
5880
- return [...strategyCreators.keys()];
5911
+ return [...getStrategyRegistryState().state.strategyCreators.keys()];
5881
5912
  },
5882
5913
  getOwnPropertyDescriptor: () => ({
5883
5914
  enumerable: true,
@@ -5930,9 +5961,24 @@ var buildMlPayload = (payload) => {
5930
5961
 
5931
5962
  // src/connectorsRegistry.ts
5932
5963
  var import_logger3 = require("@tradejs/infra/logger");
5933
- var connectorCreators = /* @__PURE__ */ new Map();
5934
- var providerToConnectorName = /* @__PURE__ */ new Map();
5935
- var pluginsLoadPromise2 = null;
5964
+ var createConnectorRegistryState = () => ({
5965
+ connectorCreators: /* @__PURE__ */ new Map(),
5966
+ providerToConnectorName: /* @__PURE__ */ new Map(),
5967
+ pluginsLoadPromise: null
5968
+ });
5969
+ var registryStateByProjectRoot2 = /* @__PURE__ */ new Map();
5970
+ var getConnectorRegistryState = (cwd = getTradejsProjectCwd()) => {
5971
+ const projectRoot = getTradejsProjectCwd(cwd);
5972
+ let state = registryStateByProjectRoot2.get(projectRoot);
5973
+ if (!state) {
5974
+ state = createConnectorRegistryState();
5975
+ registryStateByProjectRoot2.set(projectRoot, state);
5976
+ }
5977
+ return {
5978
+ projectRoot,
5979
+ state
5980
+ };
5981
+ };
5936
5982
  var BUILTIN_CONNECTOR_NAMES = {
5937
5983
  ByBit: "ByBit",
5938
5984
  Binance: "Binance",
@@ -5943,7 +5989,7 @@ var normalizeProvider = (value) => String(value ?? "").trim().toLowerCase();
5943
5989
  var toUniqueModules2 = (modules = []) => [
5944
5990
  ...new Set(modules.map((moduleName) => moduleName.trim()).filter(Boolean))
5945
5991
  ];
5946
- var findConnectorNameInsensitive = (name) => {
5992
+ var findConnectorNameInsensitive = (name, connectorCreators) => {
5947
5993
  const normalized = name.trim().toLowerCase();
5948
5994
  if (!normalized) {
5949
5995
  return null;
@@ -5963,7 +6009,7 @@ var normalizeProviders = (providers, connectorName) => {
5963
6009
  }
5964
6010
  return [normalizeProvider(connectorName)];
5965
6011
  };
5966
- var registerProvider = (provider, connectorName, source) => {
6012
+ var registerProvider = (provider, connectorName, source, providerToConnectorName) => {
5967
6013
  const existing = providerToConnectorName.get(provider);
5968
6014
  if (existing && existing !== connectorName) {
5969
6015
  import_logger3.logger.warn(
@@ -5976,7 +6022,7 @@ var registerProvider = (provider, connectorName, source) => {
5976
6022
  }
5977
6023
  providerToConnectorName.set(provider, connectorName);
5978
6024
  };
5979
- var registerEntry = (entry, source) => {
6025
+ var registerEntry = (entry, source, state) => {
5980
6026
  const connectorName = String(entry?.name ?? "").trim();
5981
6027
  if (!connectorName) {
5982
6028
  import_logger3.logger.warn("Skip connector entry without name from %s", source);
@@ -5990,7 +6036,10 @@ var registerEntry = (entry, source) => {
5990
6036
  );
5991
6037
  return;
5992
6038
  }
5993
- const existingByName = findConnectorNameInsensitive(connectorName);
6039
+ const existingByName = findConnectorNameInsensitive(
6040
+ connectorName,
6041
+ state.connectorCreators
6042
+ );
5994
6043
  if (existingByName) {
5995
6044
  import_logger3.logger.warn(
5996
6045
  'Skip duplicate connector "%s" from %s: already registered as %s',
@@ -6000,15 +6049,20 @@ var registerEntry = (entry, source) => {
6000
6049
  );
6001
6050
  return;
6002
6051
  }
6003
- connectorCreators.set(connectorName, entry.creator);
6052
+ state.connectorCreators.set(connectorName, entry.creator);
6004
6053
  const providers = normalizeProviders(entry.providers, connectorName);
6005
6054
  for (const provider of providers) {
6006
- registerProvider(provider, connectorName, source);
6055
+ registerProvider(
6056
+ provider,
6057
+ connectorName,
6058
+ source,
6059
+ state.providerToConnectorName
6060
+ );
6007
6061
  }
6008
6062
  };
6009
- var registerEntries2 = (entries, source) => {
6063
+ var registerEntries2 = (entries, source, state) => {
6010
6064
  for (const entry of entries) {
6011
- registerEntry(entry, source);
6065
+ registerEntry(entry, source, state);
6012
6066
  }
6013
6067
  };
6014
6068
  var extractConnectorPluginDefinition = (moduleExport) => {
@@ -6038,55 +6092,59 @@ var importConnectorPluginModule = async (moduleName) => {
6038
6092
  moduleName
6039
6093
  );
6040
6094
  };
6041
- var ensureConnectorPluginsLoaded = async () => {
6042
- if (pluginsLoadPromise2) {
6043
- return pluginsLoadPromise2;
6044
- }
6045
- pluginsLoadPromise2 = (async () => {
6046
- const config = await loadTradejsConfig();
6047
- const connectorModules = toUniqueModules2(config.connectors);
6048
- if (!connectorModules.length) {
6049
- return;
6050
- }
6051
- for (const moduleName of connectorModules) {
6052
- try {
6053
- const resolvedModuleName = resolvePluginModuleSpecifier(moduleName);
6054
- const moduleExport = await importConnectorPluginModule(resolvedModuleName);
6055
- const pluginDefinition = extractConnectorPluginDefinition(moduleExport);
6056
- if (!pluginDefinition) {
6095
+ var ensureConnectorPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
6096
+ const { projectRoot, state } = getConnectorRegistryState(cwd);
6097
+ if (!state.pluginsLoadPromise) {
6098
+ state.pluginsLoadPromise = (async () => {
6099
+ const config = await loadTradejsConfig(projectRoot);
6100
+ const connectorModules = toUniqueModules2(config.connectors);
6101
+ if (!connectorModules.length) {
6102
+ return;
6103
+ }
6104
+ for (const moduleName of connectorModules) {
6105
+ try {
6106
+ const resolvedModuleName = resolvePluginModuleSpecifier(
6107
+ moduleName,
6108
+ projectRoot
6109
+ );
6110
+ const moduleExport = await importConnectorPluginModule(resolvedModuleName);
6111
+ const pluginDefinition = extractConnectorPluginDefinition(moduleExport);
6112
+ if (!pluginDefinition) {
6113
+ import_logger3.logger.warn(
6114
+ 'Skip connector plugin "%s": export { connectorEntries } is missing',
6115
+ moduleName
6116
+ );
6117
+ continue;
6118
+ }
6119
+ registerEntries2(pluginDefinition.connectorEntries, moduleName, state);
6120
+ } catch (error) {
6057
6121
  import_logger3.logger.warn(
6058
- 'Skip connector plugin "%s": export { connectorEntries } is missing',
6059
- moduleName
6122
+ 'Failed to load connector plugin "%s": %s',
6123
+ moduleName,
6124
+ String(error)
6060
6125
  );
6061
- continue;
6062
- }
6063
- registerEntries2(pluginDefinition.connectorEntries, moduleName);
6064
- } catch (error) {
6065
- import_logger3.logger.warn(
6066
- 'Failed to load connector plugin "%s": %s',
6067
- moduleName,
6068
- String(error)
6069
- );
6126
+ }
6070
6127
  }
6071
- }
6072
- })();
6073
- return pluginsLoadPromise2;
6128
+ })();
6129
+ }
6130
+ await state.pluginsLoadPromise;
6074
6131
  };
6075
- var getConnectorCreatorByName = async (connectorName) => {
6076
- await ensureConnectorPluginsLoaded();
6132
+ var getConnectorCreatorByName = async (connectorName, cwd = getTradejsProjectCwd()) => {
6133
+ await ensureConnectorPluginsLoaded(cwd);
6134
+ const { state } = getConnectorRegistryState(cwd);
6077
6135
  const raw = String(connectorName ?? "").trim();
6078
6136
  if (!raw) {
6079
6137
  return void 0;
6080
6138
  }
6081
- const direct = connectorCreators.get(raw);
6139
+ const direct = state.connectorCreators.get(raw);
6082
6140
  if (direct) {
6083
6141
  return direct;
6084
6142
  }
6085
- const existing = findConnectorNameInsensitive(raw);
6143
+ const existing = findConnectorNameInsensitive(raw, state.connectorCreators);
6086
6144
  if (!existing) {
6087
6145
  return void 0;
6088
6146
  }
6089
- return connectorCreators.get(existing);
6147
+ return state.connectorCreators.get(existing);
6090
6148
  };
6091
6149
  var DEFAULT_CONNECTOR_NAME = BUILTIN_CONNECTOR_NAMES.ByBit;
6092
6150
 
@@ -6291,10 +6349,25 @@ var createTestConnector = (connector, context) => {
6291
6349
 
6292
6350
  // src/testing.ts
6293
6351
  var preloadStart = (0, import_time.getTimestamp)(import_constants2.PRELOAD_DAYS);
6294
- var coinKlineCache = /* @__PURE__ */ new Map();
6295
- var btcKlineCache = /* @__PURE__ */ new Map();
6296
- var btcBinanceKlineCache = /* @__PURE__ */ new Map();
6297
- var btcCoinbaseKlineCache = /* @__PURE__ */ new Map();
6352
+ var createTestingKlineCacheState = () => ({
6353
+ coinKlineCache: /* @__PURE__ */ new Map(),
6354
+ btcKlineCache: /* @__PURE__ */ new Map(),
6355
+ btcBinanceKlineCache: /* @__PURE__ */ new Map(),
6356
+ btcCoinbaseKlineCache: /* @__PURE__ */ new Map()
6357
+ });
6358
+ var testingKlineCacheStateByProjectRoot = /* @__PURE__ */ new Map();
6359
+ var getTestingKlineCacheState = (cwd = getTradejsProjectCwd()) => {
6360
+ const projectRoot = getTradejsProjectCwd(cwd);
6361
+ let state = testingKlineCacheStateByProjectRoot.get(projectRoot);
6362
+ if (!state) {
6363
+ state = createTestingKlineCacheState();
6364
+ testingKlineCacheStateByProjectRoot.set(projectRoot, state);
6365
+ }
6366
+ return {
6367
+ projectRoot,
6368
+ state
6369
+ };
6370
+ };
6298
6371
  var getKlineCacheKey = (params) => {
6299
6372
  const { userName, connectorName, symbol, end, interval, cacheOnly } = params;
6300
6373
  return [
@@ -6307,11 +6380,15 @@ var getKlineCacheKey = (params) => {
6307
6380
  cacheOnly ? 1 : 0
6308
6381
  ].join(":");
6309
6382
  };
6310
- var resetTestingKlineCache = () => {
6311
- coinKlineCache.clear();
6312
- btcKlineCache.clear();
6313
- btcBinanceKlineCache.clear();
6314
- btcCoinbaseKlineCache.clear();
6383
+ var resetTestingKlineCache = (cwd) => {
6384
+ const normalizedCwd = String(cwd ?? "").trim();
6385
+ if (!normalizedCwd) {
6386
+ testingKlineCacheStateByProjectRoot.clear();
6387
+ return;
6388
+ }
6389
+ testingKlineCacheStateByProjectRoot.delete(
6390
+ getTradejsProjectCwd(normalizedCwd)
6391
+ );
6315
6392
  };
6316
6393
  var testing = async ({
6317
6394
  userName,
@@ -6329,22 +6406,28 @@ var testing = async ({
6329
6406
  if (!start) {
6330
6407
  throw new Error("no start");
6331
6408
  }
6332
- const connectorCreator = await getConnectorCreatorByName(connectorName);
6409
+ const { projectRoot, state } = getTestingKlineCacheState();
6410
+ const connectorCreator = await getConnectorCreatorByName(
6411
+ connectorName,
6412
+ projectRoot
6413
+ );
6333
6414
  if (!connectorCreator) {
6334
6415
  throw new Error(`Unknown connector: ${connectorName}`);
6335
6416
  }
6336
6417
  const connector = await connectorCreator({
6337
6418
  userName
6338
6419
  });
6339
- const strategyCreator = await getStrategyCreator(strategyName);
6420
+ const strategyCreator = await getStrategyCreator(strategyName, projectRoot);
6340
6421
  if (!strategyCreator) {
6341
6422
  throw new Error(`Unknown strategy: ${strategyName}`);
6342
6423
  }
6343
6424
  const binanceCreator = await getConnectorCreatorByName(
6344
- BUILTIN_CONNECTOR_NAMES.Binance
6425
+ BUILTIN_CONNECTOR_NAMES.Binance,
6426
+ projectRoot
6345
6427
  );
6346
6428
  const coinbaseCreator = await getConnectorCreatorByName(
6347
- BUILTIN_CONNECTOR_NAMES.Coinbase
6429
+ BUILTIN_CONNECTOR_NAMES.Coinbase,
6430
+ projectRoot
6348
6431
  );
6349
6432
  if (!binanceCreator || !coinbaseCreator) {
6350
6433
  import_logger4.logger.warn(
@@ -6370,8 +6453,8 @@ var testing = async ({
6370
6453
  interval,
6371
6454
  cacheOnly
6372
6455
  });
6373
- const cachedCoinData = coinKlineCache.get(coinCacheKey);
6374
- const cachedBtcData = btcKlineCache.get(btcCacheKey);
6456
+ const cachedCoinData = state.coinKlineCache.get(coinCacheKey);
6457
+ const cachedBtcData = state.btcKlineCache.get(btcCacheKey);
6375
6458
  const btcBinanceCacheKey = getKlineCacheKey({
6376
6459
  userName,
6377
6460
  connectorName: binanceCreator ? BUILTIN_CONNECTOR_NAMES.Binance : connectorName,
@@ -6388,8 +6471,8 @@ var testing = async ({
6388
6471
  interval,
6389
6472
  cacheOnly
6390
6473
  });
6391
- const cachedBtcBinanceData = btcBinanceKlineCache.get(btcBinanceCacheKey);
6392
- const cachedBtcCoinbaseData = btcCoinbaseKlineCache.get(btcCoinbaseCacheKey);
6474
+ const cachedBtcBinanceData = state.btcBinanceKlineCache.get(btcBinanceCacheKey);
6475
+ const cachedBtcCoinbaseData = state.btcCoinbaseKlineCache.get(btcCoinbaseCacheKey);
6393
6476
  const [data, btcData, btcBinanceData, btcCoinbaseData] = await Promise.all([
6394
6477
  cachedCoinData ? Promise.resolve(cachedCoinData) : connector.kline({
6395
6478
  symbol,
@@ -6443,16 +6526,16 @@ var testing = async ({
6443
6526
  })
6444
6527
  ]);
6445
6528
  if (!cachedCoinData) {
6446
- coinKlineCache.set(coinCacheKey, data);
6529
+ state.coinKlineCache.set(coinCacheKey, data);
6447
6530
  }
6448
6531
  if (!cachedBtcData) {
6449
- btcKlineCache.set(btcCacheKey, btcData);
6532
+ state.btcKlineCache.set(btcCacheKey, btcData);
6450
6533
  }
6451
6534
  if (!cachedBtcBinanceData) {
6452
- btcBinanceKlineCache.set(btcBinanceCacheKey, btcBinanceData);
6535
+ state.btcBinanceKlineCache.set(btcBinanceCacheKey, btcBinanceData);
6453
6536
  }
6454
6537
  if (!cachedBtcCoinbaseData) {
6455
- btcCoinbaseKlineCache.set(btcCoinbaseCacheKey, btcCoinbaseData);
6538
+ state.btcCoinbaseKlineCache.set(btcCoinbaseCacheKey, btcCoinbaseData);
6456
6539
  }
6457
6540
  const prevDataRaw = data.filter(
6458
6541
  (candle) => candle.timestamp >= preloadStart && candle.timestamp < start