@tradejs/node 3.1.11 → 3.1.12-beta.217

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.
@@ -1,18 +1,26 @@
1
1
  import {
2
+ RUNTIME_PACKAGE_MANIFEST_SCHEMA,
3
+ computeDeploymentCompositionId,
4
+ computeStrategyRevision,
2
5
  getRuntimeDeployment,
3
6
  getRuntimeStrategyPackageMetadata,
4
7
  listRuntimeDeployments,
5
8
  loadResolvedRuntimeStrategies,
9
+ resolveRuntimeComposition,
6
10
  verifyRuntimeDeclaration
7
- } from "./chunk-7BAL7EN3.mjs";
8
- import "./chunk-B6X2HEGL.mjs";
9
- import "./chunk-C3KRBNUR.mjs";
11
+ } from "./chunk-NQO2MFP6.mjs";
12
+ import "./chunk-6PIVDS4M.mjs";
13
+ import "./chunk-IKRSNRP6.mjs";
10
14
  import "./chunk-LZDXRXIU.mjs";
11
15
  import "./chunk-Y6FXYEAI.mjs";
12
16
  export {
17
+ RUNTIME_PACKAGE_MANIFEST_SCHEMA,
18
+ computeDeploymentCompositionId,
19
+ computeStrategyRevision,
13
20
  getRuntimeDeployment,
14
21
  getRuntimeStrategyPackageMetadata,
15
22
  listRuntimeDeployments,
16
23
  loadResolvedRuntimeStrategies,
24
+ resolveRuntimeComposition,
17
25
  verifyRuntimeDeclaration
18
26
  };
@@ -669,7 +669,6 @@ var buildAiMarketContext = (signal) => ({
669
669
 
670
670
  // src/strategy/manifests.ts
671
671
  var import_indicators = require("@tradejs/core/indicators");
672
- var import_logger2 = require("@tradejs/infra/logger");
673
672
 
674
673
  // src/tradejsConfig.ts
675
674
  var import_fs = __toESM(require("fs"));
@@ -1022,21 +1021,34 @@ var extractIndicatorPluginDefinition = (moduleExport) => {
1022
1021
  );
1023
1022
  return indicatorEntries ? { indicatorEntries } : null;
1024
1023
  };
1025
- var registerEntries = (entries, source, state) => {
1026
- for (const entry of entries) {
1027
- const strategyName = entry.manifest?.name;
1028
- if (!strategyName) {
1029
- import_logger2.logger.warn("Skip strategy entry without name from %s", source);
1030
- continue;
1024
+ var validateStrategyEntries = (moduleName, entries, state) => {
1025
+ const issues = [];
1026
+ const names = /* @__PURE__ */ new Set();
1027
+ entries.forEach((entry, index) => {
1028
+ const entryPath = `${moduleName}.strategyEntries[${index}]`;
1029
+ const strategyName = entry?.manifest?.name;
1030
+ if (typeof strategyName !== "string" || !strategyName.trim()) {
1031
+ issues.push(`${entryPath}: manifest.name is required`);
1032
+ } else if (names.has(strategyName) || state.strategyEntriesMap.has(strategyName)) {
1033
+ issues.push(`${entryPath}: duplicate strategy ${strategyName}`);
1034
+ } else {
1035
+ names.add(strategyName);
1031
1036
  }
1032
- if (state.strategyCreators.has(strategyName)) {
1033
- import_logger2.logger.warn(
1034
- 'Skip duplicate strategy "%s" from %s: already registered',
1035
- strategyName,
1036
- source
1037
- );
1038
- continue;
1037
+ if (!entry || typeof entry !== "object" || !entry.defaults || typeof entry.defaults !== "object" || Array.isArray(entry.defaults)) {
1038
+ issues.push(`${entryPath}: defaults must be an object`);
1039
+ }
1040
+ if (typeof entry?.parseConfig !== "function") {
1041
+ issues.push(`${entryPath}: parseConfig is required`);
1042
+ }
1043
+ if (typeof entry?.createCore !== "function") {
1044
+ issues.push(`${entryPath}: createCore is required`);
1039
1045
  }
1046
+ });
1047
+ return issues;
1048
+ };
1049
+ var registerEntries = (entries, source, state) => {
1050
+ for (const entry of entries) {
1051
+ const strategyName = entry.manifest.name;
1040
1052
  state.strategyManifestsMap.set(strategyName, entry.manifest);
1041
1053
  state.strategyEntriesMap.set(strategyName, entry);
1042
1054
  state.strategySourcesMap.set(strategyName, source);
@@ -1093,6 +1105,7 @@ var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
1093
1105
  if (!pluginModuleNames.length) {
1094
1106
  return;
1095
1107
  }
1108
+ const issues = [];
1096
1109
  for (const moduleName of pluginModuleNames) {
1097
1110
  try {
1098
1111
  const resolvedModuleName = resolvePluginModuleSpecifier(
@@ -1106,24 +1119,30 @@ var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
1106
1119
  if (strategySet.has(moduleName)) {
1107
1120
  const pluginDefinition = extractStrategyPluginDefinition(moduleExport);
1108
1121
  if (!pluginDefinition) {
1109
- import_logger2.logger.warn(
1110
- 'Skip strategy plugin "%s": export { strategyEntries } is missing',
1111
- moduleName
1122
+ issues.push(
1123
+ `${moduleName}: export { strategyEntries } is missing`
1112
1124
  );
1113
1125
  } else {
1114
- registerEntries(
1115
- pluginDefinition.strategyEntries,
1126
+ const entryIssues = validateStrategyEntries(
1116
1127
  moduleName,
1128
+ pluginDefinition.strategyEntries,
1117
1129
  state
1118
1130
  );
1131
+ issues.push(...entryIssues);
1132
+ if (entryIssues.length === 0) {
1133
+ registerEntries(
1134
+ pluginDefinition.strategyEntries,
1135
+ moduleName,
1136
+ state
1137
+ );
1138
+ }
1119
1139
  }
1120
1140
  }
1121
1141
  if (indicatorSet.has(moduleName)) {
1122
1142
  const indicatorPluginDefinition = extractIndicatorPluginDefinition(moduleExport);
1123
1143
  if (!indicatorPluginDefinition) {
1124
- import_logger2.logger.warn(
1125
- 'Skip indicator plugin "%s": export { indicatorEntries } is missing',
1126
- moduleName
1144
+ issues.push(
1145
+ `${moduleName}: export { indicatorEntries } is missing`
1127
1146
  );
1128
1147
  } else {
1129
1148
  (0, import_indicators.registerIndicatorEntries)(
@@ -1134,19 +1153,17 @@ var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
1134
1153
  }
1135
1154
  }
1136
1155
  if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
1137
- import_logger2.logger.warn(
1138
- 'Skip plugin "%s": no strategy/indicator sections requested in config',
1139
- moduleName
1140
- );
1156
+ issues.push(`${moduleName}: plugin is not declared in config`);
1141
1157
  }
1142
1158
  } catch (error) {
1143
- import_logger2.logger.warn(
1144
- 'Failed to load plugin "%s": %s',
1145
- moduleName,
1146
- String(error)
1147
- );
1159
+ issues.push(`${moduleName}: failed to import: ${String(error)}`);
1148
1160
  }
1149
1161
  }
1162
+ if (issues.length > 0) {
1163
+ throw new Error(
1164
+ ["Invalid TradeJS plugin catalog:", ...issues].join("\n")
1165
+ );
1166
+ }
1150
1167
  })();
1151
1168
  }
1152
1169
  await state.pluginsLoadPromise;
@@ -1193,6 +1210,10 @@ var isKnownStrategy = (name, cwd = getTradejsProjectCwd()) => {
1193
1210
  };
1194
1211
  var registerStrategyEntries = (entries, cwd = getTradejsProjectCwd()) => {
1195
1212
  const { state } = getStrategyRegistryState(cwd);
1213
+ const issues = validateStrategyEntries("runtime", entries, state);
1214
+ if (issues.length > 0) {
1215
+ throw new Error(["Invalid TradeJS plugin catalog:", ...issues].join("\n"));
1216
+ }
1196
1217
  registerEntries(entries, "runtime", state);
1197
1218
  };
1198
1219
  var resetStrategyRegistryCache = (cwd) => {
@@ -1812,10 +1833,10 @@ var askAI = async (signal, options = {}) => {
1812
1833
  // src/strategyRuntime.ts
1813
1834
  var import_constants5 = require("@tradejs/core/constants");
1814
1835
  var import_strategies6 = require("@tradejs/core/strategies");
1815
- var import_logger11 = require("@tradejs/infra/logger");
1836
+ var import_logger10 = require("@tradejs/infra/logger");
1816
1837
 
1817
1838
  // src/strategyHelpers/runtime.ts
1818
- var import_logger9 = require("@tradejs/infra/logger");
1839
+ var import_logger8 = require("@tradejs/infra/logger");
1819
1840
  var import_constants3 = require("@tradejs/core/constants");
1820
1841
  var import_ml2 = require("@tradejs/infra/ml");
1821
1842
 
@@ -1872,7 +1893,7 @@ var import_node_crypto = require("crypto");
1872
1893
  var import_constants = require("@tradejs/core/constants");
1873
1894
  var import_time = require("@tradejs/core/time");
1874
1895
  var import_trade = require("@tradejs/core/trade");
1875
- var import_logger3 = require("@tradejs/infra/logger");
1896
+ var import_logger2 = require("@tradejs/infra/logger");
1876
1897
  var import_redis2 = require("@tradejs/infra/redis");
1877
1898
  var now = () => Date.now();
1878
1899
  var toRandomOrderSuffix = () => (0, import_node_crypto.randomUUID)().replace(/-/g, "").slice(0, 12).toLowerCase();
@@ -1931,7 +1952,7 @@ var recordRuntimeTradeOpen = async (params) => {
1931
1952
  )
1932
1953
  ]);
1933
1954
  } catch (error) {
1934
- import_logger3.logger.error(
1955
+ import_logger2.logger.error(
1935
1956
  "runtime trade open journal failed: %s %s",
1936
1957
  record.symbol,
1937
1958
  error?.message || String(error)
@@ -1998,7 +2019,7 @@ var recordRuntimeTradeIncrease = async (params) => {
1998
2019
  )
1999
2020
  ]);
2000
2021
  } catch (error) {
2001
- import_logger3.logger.error(
2022
+ import_logger2.logger.error(
2002
2023
  "runtime trade increase journal failed: %s %s",
2003
2024
  symbol,
2004
2025
  error?.message || String(error)
@@ -2105,7 +2126,7 @@ var markRuntimeTradeClosed = async (params) => {
2105
2126
  )
2106
2127
  ]);
2107
2128
  } catch (error) {
2108
- import_logger3.logger.error(
2129
+ import_logger2.logger.error(
2109
2130
  "runtime trade close journal failed: %s %s",
2110
2131
  symbol,
2111
2132
  error?.message || String(error)
@@ -2115,11 +2136,11 @@ var markRuntimeTradeClosed = async (params) => {
2115
2136
  };
2116
2137
 
2117
2138
  // src/strategyHelpers/marketContextStages.ts
2118
- var import_logger8 = require("@tradejs/infra/logger");
2139
+ var import_logger7 = require("@tradejs/infra/logger");
2119
2140
 
2120
2141
  // src/strategyHelpers/binanceMarketContext.ts
2121
2142
  var import_marketContext = require("@tradejs/infra/timescale/marketContext");
2122
- var import_logger4 = require("@tradejs/infra/logger");
2143
+ var import_logger3 = require("@tradejs/infra/logger");
2123
2144
  var import_strategies = require("@tradejs/core/strategies");
2124
2145
 
2125
2146
  // src/binanceBreadthUniverses.ts
@@ -2717,7 +2738,7 @@ var enrichSignalWithBinanceMarketContext = async (params) => {
2717
2738
  throw error;
2718
2739
  }
2719
2740
  binanceMarketContextUnavailable = true;
2720
- import_logger4.logger.warn(
2741
+ import_logger3.logger.warn(
2721
2742
  "Binance market context disabled after Timescale read failure: %s",
2722
2743
  String(error)
2723
2744
  );
@@ -2727,7 +2748,7 @@ var enrichSignalWithBinanceMarketContext = async (params) => {
2727
2748
 
2728
2749
  // src/strategyHelpers/coinMarketCapContext.ts
2729
2750
  var import_strategies2 = require("@tradejs/core/strategies");
2730
- var import_logger5 = require("@tradejs/infra/logger");
2751
+ var import_logger4 = require("@tradejs/infra/logger");
2731
2752
  var import_marketContext2 = require("@tradejs/infra/timescale/marketContext");
2732
2753
  var DEFAULT_MAX_AGE_MS = 48 * 60 * 6e4;
2733
2754
  var SOURCE_GLOBAL_DAILY = "coinmarketcap_global";
@@ -3216,7 +3237,7 @@ var enrichSignalWithCoinMarketCapContext = async (params) => {
3216
3237
  throw error;
3217
3238
  }
3218
3239
  coinMarketCapContextUnavailable = true;
3219
- import_logger5.logger.warn(
3240
+ import_logger4.logger.warn(
3220
3241
  "CoinMarketCap context disabled after Timescale read failure: %s",
3221
3242
  String(error)
3222
3243
  );
@@ -3230,7 +3251,7 @@ var import_data = require("@tradejs/core/data");
3230
3251
  var import_strategies3 = require("@tradejs/core/strategies");
3231
3252
  var import_constants2 = require("@tradejs/core/constants");
3232
3253
  var import_derivatives = require("@tradejs/infra/timescale/derivatives");
3233
- var import_logger6 = require("@tradejs/infra/logger");
3254
+ var import_logger5 = require("@tradejs/infra/logger");
3234
3255
  var STORED_INTERVALS = ["15m", "1h"];
3235
3256
  var CONTEXT_INTERVALS = ["15m", "1h"];
3236
3257
  var DEFAULT_LOOKBACK_HOURS = 48;
@@ -3462,7 +3483,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
3462
3483
  throw error;
3463
3484
  }
3464
3485
  derivativesContextUnavailable = true;
3465
- import_logger6.logger.warn(
3486
+ import_logger5.logger.warn(
3466
3487
  "Derivatives context disabled after Timescale read failure: %s",
3467
3488
  String(error)
3468
3489
  );
@@ -3474,7 +3495,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
3474
3495
  var import_data2 = require("@tradejs/core/data");
3475
3496
  var import_strategies4 = require("@tradejs/core/strategies");
3476
3497
  var import_hyperliquidWhales2 = require("@tradejs/infra/timescale/hyperliquidWhales");
3477
- var import_logger7 = require("@tradejs/infra/logger");
3498
+ var import_logger6 = require("@tradejs/infra/logger");
3478
3499
 
3479
3500
  // src/hyperliquidWhaleUniverse.ts
3480
3501
  var import_node_crypto3 = require("crypto");
@@ -3998,7 +4019,7 @@ var loadHyperliquidWhaleFlowContext = async (params) => {
3998
4019
  throw error;
3999
4020
  }
4000
4021
  hyperliquidWhaleContextUnavailable = true;
4001
- import_logger7.logger.warn(
4022
+ import_logger6.logger.warn(
4002
4023
  "Hyperliquid whale context disabled after Timescale read failure: %s",
4003
4024
  String(error)
4004
4025
  );
@@ -4081,7 +4102,7 @@ var runMarketContextStage = async ({
4081
4102
  elapsedMs: Date.now() - startedAt
4082
4103
  };
4083
4104
  if (status === "timed_out") {
4084
- import_logger8.logger.warn(
4105
+ import_logger7.logger.warn(
4085
4106
  "Market context stage timed out: %s after %sms",
4086
4107
  stage,
4087
4108
  result.elapsedMs
@@ -4271,7 +4292,7 @@ var enrichSignalWithAi = async ({
4271
4292
  signal.aiAnalysis = analysis;
4272
4293
  return resolveAiQuality(analysis, direction);
4273
4294
  } catch (err) {
4274
- import_logger9.logger.error("AI analysis error: %s %s", symbol, formatAiError(err));
4295
+ import_logger8.logger.error("AI analysis error: %s %s", symbol, formatAiError(err));
4275
4296
  }
4276
4297
  return void 0;
4277
4298
  };
@@ -4319,7 +4340,7 @@ var getOrderArrivalSnapshot = async ({
4319
4340
  spreadBps
4320
4341
  };
4321
4342
  } catch (error) {
4322
- import_logger9.logger.warn(
4343
+ import_logger8.logger.warn(
4323
4344
  "runtime order arrival snapshot failed: %s %s",
4324
4345
  symbol,
4325
4346
  error?.message || String(error)
@@ -4548,7 +4569,7 @@ var executeEntryOrder = async ({
4548
4569
  deploymentId: signal.deploymentId,
4549
4570
  policyProfileId: signal.policyProfileId,
4550
4571
  runtimeConfigId: signal.runtimeConfigId,
4551
- runtimeVersion: signal.runtimeVersion,
4572
+ strategyRevision: signal.strategyRevision,
4552
4573
  runtimeLineage: signal.runtimeLineage,
4553
4574
  ...signal.aiAnalysis ? { aiAnalysis: signal.aiAnalysis } : {}
4554
4575
  });
@@ -5100,7 +5121,7 @@ var canUseSharedReplayState = ({
5100
5121
  }) => (env === "BACKTEST" || env === "PARITY") && Boolean(sharedReplayKey);
5101
5122
 
5102
5123
  // src/strategy/runtimeExecution.ts
5103
- var import_logger10 = require("@tradejs/infra/logger");
5124
+ var import_logger9 = require("@tradejs/infra/logger");
5104
5125
  var import_types = require("@tradejs/types");
5105
5126
  var buildExitOrderSignal = ({
5106
5127
  strategyName,
@@ -5152,7 +5173,7 @@ var handleExitDecision = async ({
5152
5173
  deploymentId: connector.deploymentId
5153
5174
  });
5154
5175
  if (!activeTrade) {
5155
- import_logger10.logger.warn(
5176
+ import_logger9.logger.warn(
5156
5177
  "[%s] blocked closePosition for untracked runtime position: %s",
5157
5178
  strategyName ?? "unknown",
5158
5179
  symbol
@@ -5160,7 +5181,7 @@ var handleExitDecision = async ({
5160
5181
  return "CLOSE_BLOCKED_BY_UNTRACKED_POSITION";
5161
5182
  }
5162
5183
  if (!strategyName || activeTrade.strategy !== strategyName) {
5163
- import_logger10.logger.warn(
5184
+ import_logger9.logger.warn(
5164
5185
  "[%s] blocked closePosition for foreign runtime position: %s ownedBy=%s",
5165
5186
  strategyName ?? "unknown",
5166
5187
  symbol,
@@ -5212,7 +5233,7 @@ var handleExitDecision = async ({
5212
5233
  exitType: closedTrade?.exitType ?? "exit"
5213
5234
  });
5214
5235
  } catch (notificationError) {
5215
- import_logger10.logger.error(
5236
+ import_logger9.logger.error(
5216
5237
  "runtime close notification error: %s %s",
5217
5238
  symbol,
5218
5239
  notificationError
@@ -5226,7 +5247,7 @@ var handleExitDecision = async ({
5226
5247
  decision,
5227
5248
  market
5228
5249
  });
5229
- import_logger10.logger.error("close order error: %s %s", symbol, err);
5250
+ import_logger9.logger.error("close order error: %s %s", symbol, err);
5230
5251
  return "ORDER_ERROR";
5231
5252
  }
5232
5253
  return decision.code;
@@ -5253,7 +5274,7 @@ var handleProtectDecision = async ({
5253
5274
  decision,
5254
5275
  market
5255
5276
  });
5256
- import_logger10.logger.error("protect position error: %s %s", symbol, err);
5277
+ import_logger9.logger.error("protect position error: %s %s", symbol, err);
5257
5278
  return "ORDER_ERROR";
5258
5279
  }
5259
5280
  return decision.code;
@@ -5416,9 +5437,9 @@ var executeEntryDecision = async ({
5416
5437
  market
5417
5438
  });
5418
5439
  if (err?.message === import_types.BACKTEST_WARNING_CODES.TAKE_PROFIT_CROSSED_BEFORE_ENTRY) {
5419
- import_logger10.logger.warn("order warning: %s %s", symbol, err);
5440
+ import_logger9.logger.warn("order warning: %s %s", symbol, err);
5420
5441
  } else {
5421
- import_logger10.logger.error("order error: %s %s", symbol, err);
5442
+ import_logger9.logger.error("order error: %s %s", symbol, err);
5422
5443
  }
5423
5444
  return signal ?? "ORDER_ERROR";
5424
5445
  }
@@ -5459,7 +5480,7 @@ var createStrategyRuntime = ({
5459
5480
  deploymentId: requestedDeploymentId,
5460
5481
  policyProfileId,
5461
5482
  runtimeConfigId,
5462
- runtimeVersion,
5483
+ strategyRevision,
5463
5484
  entriesPaused = false,
5464
5485
  runtimeLineage,
5465
5486
  runtimeConfigSnapshot,
@@ -5572,7 +5593,7 @@ var createStrategyRuntime = ({
5572
5593
  try {
5573
5594
  await projectHook(errorParams);
5574
5595
  } catch (hookError) {
5575
- import_logger11.logger.error(
5596
+ import_logger10.logger.error(
5576
5597
  "project hook onRuntimeError failed: %s %s",
5577
5598
  strategyName,
5578
5599
  hookError
@@ -5586,7 +5607,7 @@ var createStrategyRuntime = ({
5586
5607
  try {
5587
5608
  await onRuntimeError(errorParams);
5588
5609
  } catch (hookError) {
5589
- import_logger11.logger.error(
5610
+ import_logger10.logger.error(
5590
5611
  "runtime hook onRuntimeError failed: %s %s",
5591
5612
  strategyName,
5592
5613
  hookError
@@ -5600,7 +5621,7 @@ var createStrategyRuntime = ({
5600
5621
  try {
5601
5622
  return await hook(params);
5602
5623
  } catch (error) {
5603
- import_logger11.logger.error(
5624
+ import_logger10.logger.error(
5604
5625
  'strategy hook "%s" failed for %s: %s',
5605
5626
  stage,
5606
5627
  strategyName,
@@ -6131,8 +6152,8 @@ var createStrategyRuntime = ({
6131
6152
  signal.signalId = `${signal.signalId}:${runtimeConfigId}`;
6132
6153
  }
6133
6154
  }
6134
- if (runtimeVersion) {
6135
- signal.runtimeVersion = runtimeVersion;
6155
+ if (strategyRevision) {
6156
+ signal.strategyRevision = strategyRevision;
6136
6157
  }
6137
6158
  if (decisionHookCtx.policyProfileId) {
6138
6159
  signal.policyProfileId = decisionHookCtx.policyProfileId;
@@ -6245,7 +6266,7 @@ var createStrategyRuntime = ({
6245
6266
  if (signal) {
6246
6267
  signal.orderStatus = "skipped";
6247
6268
  signal.orderSkipReason = skipReason;
6248
- signal.runtimeVersion = runtimeVersion;
6269
+ signal.strategyRevision = strategyRevision;
6249
6270
  }
6250
6271
  return signal ?? skipReason;
6251
6272
  }
@@ -6358,7 +6379,7 @@ setStrategyRuntimeFactory(createStrategyRuntime);
6358
6379
 
6359
6380
  // src/strategyHooks/closeOppositePositionsBeforeOpen.ts
6360
6381
  var import_lodash2 = __toESM(require("lodash"));
6361
- var import_logger12 = require("@tradejs/infra/logger");
6382
+ var import_logger11 = require("@tradejs/infra/logger");
6362
6383
  var closeOppositePositionsBeforeOpen = async ({
6363
6384
  connector,
6364
6385
  entryContext
@@ -6372,7 +6393,7 @@ var closeOppositePositionsBeforeOpen = async ({
6372
6393
  } = entryContext;
6373
6394
  const price = prices.currentPrice;
6374
6395
  try {
6375
- import_logger12.logger.log(
6396
+ import_logger11.logger.log(
6376
6397
  "info",
6377
6398
  "[%s] checking open positions before open: %s %s",
6378
6399
  strategyName,
@@ -6383,7 +6404,7 @@ var closeOppositePositionsBeforeOpen = async ({
6383
6404
  const openPositions = (positions || []).filter(
6384
6405
  (item) => item && Number(item.qty) > 0
6385
6406
  );
6386
- import_logger12.logger.log(
6407
+ import_logger11.logger.log(
6387
6408
  "info",
6388
6409
  "[%s] open positions found: %s",
6389
6410
  strategyName,
@@ -6393,7 +6414,7 @@ var closeOppositePositionsBeforeOpen = async ({
6393
6414
  (item) => item.symbol !== currentSymbol && item.direction !== currentDirection
6394
6415
  );
6395
6416
  if (import_lodash2.default.isEmpty(oppositePositions)) {
6396
- import_logger12.logger.log(
6417
+ import_logger11.logger.log(
6397
6418
  "info",
6398
6419
  "[%s] no opposite positions to close before open: %s",
6399
6420
  strategyName,
@@ -6402,7 +6423,7 @@ var closeOppositePositionsBeforeOpen = async ({
6402
6423
  return;
6403
6424
  }
6404
6425
  for (const position of oppositePositions) {
6405
- import_logger12.logger.log(
6426
+ import_logger11.logger.log(
6406
6427
  "info",
6407
6428
  "[%s] closing opposite position: %s %s qty=%s",
6408
6429
  strategyName,
@@ -6417,14 +6438,14 @@ var closeOppositePositionsBeforeOpen = async ({
6417
6438
  timestamp,
6418
6439
  direction: position.direction
6419
6440
  });
6420
- import_logger12.logger.log(
6441
+ import_logger11.logger.log(
6421
6442
  "info",
6422
6443
  "[%s] opposite position closed: %s",
6423
6444
  strategyName,
6424
6445
  position.symbol
6425
6446
  );
6426
6447
  } catch (err) {
6427
- import_logger12.logger.log(
6448
+ import_logger11.logger.log(
6428
6449
  "error",
6429
6450
  "[%s] failed to close opposite position: %s %s",
6430
6451
  strategyName,
@@ -6434,7 +6455,7 @@ var closeOppositePositionsBeforeOpen = async ({
6434
6455
  }
6435
6456
  }
6436
6457
  } catch (err) {
6437
- import_logger12.logger.log(
6458
+ import_logger11.logger.log(
6438
6459
  "error",
6439
6460
  "[%s] failed to load open positions before open: %s %s",
6440
6461
  strategyName,
@@ -6646,7 +6667,7 @@ var createMoveStopToBreakEvenOnBarHook = ({
6646
6667
  var createMoveStopToBreakEvenAfterCoreDecisionHook = createMoveStopToBreakEvenOnBarHook;
6647
6668
 
6648
6669
  // src/signalsHooks/closeAllPositionsOnGlobalProfitBeforeSignals.ts
6649
- var import_logger13 = require("@tradejs/infra/logger");
6670
+ var import_logger12 = require("@tradejs/infra/logger");
6650
6671
  var createCloseAllOnGlobalProfitBeforeSignalsHook = ({
6651
6672
  getStrategyDefaultConfig = () => void 0,
6652
6673
  profitRiskMultiplier = DEFAULT_GLOBAL_UNREALIZED_PNL_TRIGGER_RISK_MULTIPLIER
@@ -6685,7 +6706,7 @@ var createCloseAllOnGlobalProfitBeforeSignalsHook = ({
6685
6706
  if (!Number.isFinite(unrealizedPnlThreshold) || unrealizedPnlThreshold <= 0 || totalUnrealizedPnl < unrealizedPnlThreshold) {
6686
6707
  return;
6687
6708
  }
6688
- import_logger13.logger.info(
6709
+ import_logger12.logger.info(
6689
6710
  "closing all positions before signals by global unrealized pnl threshold: totalPnl=%s threshold=%s positions=%s",
6690
6711
  totalUnrealizedPnl,
6691
6712
  unrealizedPnlThreshold,
@@ -6711,7 +6732,7 @@ var createCloseAllOnGlobalProfitBeforeSignalsHook = ({
6711
6732
  ];
6712
6733
  });
6713
6734
  if (failedClosures.length) {
6714
- import_logger13.logger.warn(
6735
+ import_logger12.logger.warn(
6715
6736
  "close-all before signals hook could not confirm closures for %s",
6716
6737
  failedClosures.join(", ")
6717
6738
  );
@@ -22,7 +22,7 @@ import {
22
22
  resolveHyperliquidPerpFromSignalSymbol,
23
23
  resolveStrategyConfig,
24
24
  validateEntryProtectionAtArrival
25
- } from "./chunk-B6X2HEGL.mjs";
25
+ } from "./chunk-6PIVDS4M.mjs";
26
26
  import {
27
27
  DEFAULT_AI_MODEL,
28
28
  MAX_AI_SERIES_POINTS,
@@ -52,7 +52,7 @@ import {
52
52
  runAiPromptLocal,
53
53
  strategies,
54
54
  trimSeriesDeep
55
- } from "./chunk-C3KRBNUR.mjs";
55
+ } from "./chunk-IKRSNRP6.mjs";
56
56
  import "./chunk-LZDXRXIU.mjs";
57
57
  import "./chunk-Y6FXYEAI.mjs";
58
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/node",
3
- "version": "3.1.11",
3
+ "version": "3.1.12-beta.217",
4
4
  "description": "Node-only runtime for the TradeJS TypeScript framework: strategies, backtests, Pine strategy loading, and plugin registries.",
5
5
  "keywords": [
6
6
  "tradejs",
@@ -10,6 +10,10 @@
10
10
  "runtime",
11
11
  "strategy",
12
12
  "pine-script",
13
+ "crypto",
14
+ "bybit",
15
+ "binance",
16
+ "coinbase",
13
17
  "ai",
14
18
  "claude",
15
19
  "codex"
@@ -85,9 +89,9 @@
85
89
  "dependencies": {
86
90
  "@langchain/core": "^1.2.3",
87
91
  "@langchain/openai": "^1.5.5",
88
- "@tradejs/core": "^3.1.11",
89
- "@tradejs/infra": "^3.1.11",
90
- "@tradejs/types": "^3.1.11",
92
+ "@tradejs/core": "^3.1.12-beta.217",
93
+ "@tradejs/infra": "^3.1.12-beta.217",
94
+ "@tradejs/types": "^3.1.12-beta.217",
91
95
  "chalk": "4.1.2",
92
96
  "ioredis": "5.11.1",
93
97
  "lodash": "^4.18.1",
@@ -98,10 +102,12 @@
98
102
  "tsconfig-paths": "^4.2.0"
99
103
  },
100
104
  "devDependencies": {
101
- "@tradejs/strategy-adaptive-momentum-ribbon": "^3.0.0",
102
- "@tradejs/strategy-hyperliquid-consensus": "^3.0.0",
103
- "@tradejs/strategy-trend-line": "^3.0.0",
104
- "@tradejs/strategy-volume-divergence": "^3.0.0",
105
+ "@tradejs/indicators": "^3.1.12-beta.217",
106
+ "@tradejs/strategy-adaptive-momentum-ribbon": "3.0.2",
107
+ "@tradejs/strategy-hyperliquid-consensus": "3.0.2",
108
+ "@tradejs/strategy-kit": "3.0.2",
109
+ "@tradejs/strategy-trend-line": "3.0.2",
110
+ "@tradejs/strategy-volume-divergence": "3.0.2",
105
111
  "@types/node": "^24",
106
112
  "tsup": "^8.5.1",
107
113
  "typescript": "^5.9"