@tradejs/node 3.1.15 → 3.1.16

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/dist/cli.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { TradejsRuntimeDeclaration, TestStat, TestThresholdsKey, RuntimeStrategyCloseNotification, Connector, Signal, Interval } from '@tradejs/types';
1
+ import { TradejsRuntimeDeclaration, StrategyRuntimeAiOptions, TestStat, TestThresholdsKey, RuntimeStrategyCloseNotification, Connector, Signal, Interval } from '@tradejs/types';
2
2
  import { TradejsConfigHooks } from '@tradejs/core/config';
3
3
 
4
4
  declare const sendTextToTG: (message: string, options?: {
@@ -36,6 +36,8 @@ declare const makeScreenshots: (signals: Signal[], interval: Interval, userName?
36
36
  declare const sendToAI: (signals: Signal[], userName?: string) => Promise<void>;
37
37
  declare const formatRuntimeCloseNotification: (event: RuntimeStrategyCloseNotification, _userName?: string) => string;
38
38
  declare const sendRuntimeCloseNotificationsToTG: (events: RuntimeStrategyCloseNotification[], userName?: string) => Promise<void>;
39
- declare const sendToTG: (signals: Signal[], imgInterval: Interval, userName?: string) => Promise<void>;
39
+ type SignalNotificationAiOptions = Pick<StrategyRuntimeAiOptions, 'enabled' | 'mode' | 'minQuality'>;
40
+ type SignalNotificationAiOptionsByStrategy = ReadonlyMap<string, SignalNotificationAiOptions>;
41
+ declare const sendToTG: (signals: Signal[], imgInterval: Interval, userName?: string, aiOptionsByStrategy?: SignalNotificationAiOptionsByStrategy) => Promise<void>;
40
42
 
41
- export { cleanFiles, cleanRedis, drawStatInCLI, formatRuntimeCloseNotification, getTickers, loadTradejsConfig, makeScreenshots, sendDocumentToTG, sendRuntimeCloseNotificationsToTG, sendTextToTG, sendToAI, sendToTG, update };
43
+ export { type SignalNotificationAiOptions, type SignalNotificationAiOptionsByStrategy, cleanFiles, cleanRedis, drawStatInCLI, formatRuntimeCloseNotification, getTickers, loadTradejsConfig, makeScreenshots, sendDocumentToTG, sendRuntimeCloseNotificationsToTG, sendTextToTG, sendToAI, sendToTG, update };
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TradejsRuntimeDeclaration, TestStat, TestThresholdsKey, RuntimeStrategyCloseNotification, Connector, Signal, Interval } from '@tradejs/types';
1
+ import { TradejsRuntimeDeclaration, StrategyRuntimeAiOptions, TestStat, TestThresholdsKey, RuntimeStrategyCloseNotification, Connector, Signal, Interval } from '@tradejs/types';
2
2
  import { TradejsConfigHooks } from '@tradejs/core/config';
3
3
 
4
4
  declare const sendTextToTG: (message: string, options?: {
@@ -36,6 +36,8 @@ declare const makeScreenshots: (signals: Signal[], interval: Interval, userName?
36
36
  declare const sendToAI: (signals: Signal[], userName?: string) => Promise<void>;
37
37
  declare const formatRuntimeCloseNotification: (event: RuntimeStrategyCloseNotification, _userName?: string) => string;
38
38
  declare const sendRuntimeCloseNotificationsToTG: (events: RuntimeStrategyCloseNotification[], userName?: string) => Promise<void>;
39
- declare const sendToTG: (signals: Signal[], imgInterval: Interval, userName?: string) => Promise<void>;
39
+ type SignalNotificationAiOptions = Pick<StrategyRuntimeAiOptions, 'enabled' | 'mode' | 'minQuality'>;
40
+ type SignalNotificationAiOptionsByStrategy = ReadonlyMap<string, SignalNotificationAiOptions>;
41
+ declare const sendToTG: (signals: Signal[], imgInterval: Interval, userName?: string, aiOptionsByStrategy?: SignalNotificationAiOptionsByStrategy) => Promise<void>;
40
42
 
41
- export { cleanFiles, cleanRedis, drawStatInCLI, formatRuntimeCloseNotification, getTickers, loadTradejsConfig, makeScreenshots, sendDocumentToTG, sendRuntimeCloseNotificationsToTG, sendTextToTG, sendToAI, sendToTG, update };
43
+ export { type SignalNotificationAiOptions, type SignalNotificationAiOptionsByStrategy, cleanFiles, cleanRedis, drawStatInCLI, formatRuntimeCloseNotification, getTickers, loadTradejsConfig, makeScreenshots, sendDocumentToTG, sendRuntimeCloseNotificationsToTG, sendTextToTG, sendToAI, sendToTG, update };
package/dist/cli.js CHANGED
@@ -2911,20 +2911,8 @@ var sendRuntimeCloseNotificationsToTG = async (events, userName = "root") => {
2911
2911
  });
2912
2912
  import_logger4.logger.info("");
2913
2913
  };
2914
- var sendToTG = async (signals, imgInterval, userName = "root") => {
2914
+ var sendToTG = async (signals, imgInterval, userName = "root", aiOptionsByStrategy = /* @__PURE__ */ new Map()) => {
2915
2915
  await ensureStrategyPluginsLoaded();
2916
- const strategyConfigCache = /* @__PURE__ */ new Map();
2917
- const resolveStrategyConfig = async (strategyName) => {
2918
- if (strategyConfigCache.has(strategyName)) {
2919
- return strategyConfigCache.get(strategyName);
2920
- }
2921
- const config = await (0, import_redis3.getData)(
2922
- `users:${userName}:strategies:${strategyName}:config`,
2923
- null
2924
- );
2925
- strategyConfigCache.set(strategyName, config);
2926
- return config;
2927
- };
2928
2916
  const resolveDecision = (analysis, direction, minQuality = 4) => {
2929
2917
  if (analysis?.needRetest === true) {
2930
2918
  return "rejected";
@@ -2959,11 +2947,10 @@ var sendToTG = async (signals, imgInterval, userName = "root") => {
2959
2947
  null
2960
2948
  );
2961
2949
  let shouldSendSignalAnalysis = analysis && typeof analysis === "object" && Object.keys(analysis).length > 0;
2962
- const strategyConfig = await resolveStrategyConfig(signal.strategy);
2963
- const aiMode = strategyConfig?.AI_MODE;
2950
+ const aiOptions = aiOptionsByStrategy.get(signal.strategy);
2964
2951
  const gateAnalysis = signal.aiAnalysis;
2965
- if (aiMode === "gate" && gateAnalysis) {
2966
- const minQuality = Number(strategyConfig?.MIN_AI_QUALITY) || 4;
2952
+ if (aiOptions?.enabled !== false && aiOptions?.mode === "gate" && gateAnalysis) {
2953
+ const minQuality = Number.isFinite(aiOptions.minQuality) ? Number(aiOptions.minQuality) : 4;
2967
2954
  const gateDecision = resolveDecision(
2968
2955
  gateAnalysis,
2969
2956
  signal.direction,
@@ -2983,6 +2970,18 @@ var sendToTG = async (signals, imgInterval, userName = "root") => {
2983
2970
  llmDecision,
2984
2971
  gateContradictsLlm: gateDecision !== llmDecision
2985
2972
  };
2973
+ try {
2974
+ await (0, import_redis3.setData)(
2975
+ import_redis3.redisKeys.analysis(signal.symbol, signal.signalId),
2976
+ analysis
2977
+ );
2978
+ } catch (error) {
2979
+ import_logger4.logger.error(
2980
+ "LLM comparison persistence failed: %s (%s)",
2981
+ signal.symbol,
2982
+ error?.message || String(error)
2983
+ );
2984
+ }
2986
2985
  shouldSendSignalAnalysis = true;
2987
2986
  } catch (error) {
2988
2987
  import_logger4.logger.error(
package/dist/cli.mjs CHANGED
@@ -30,7 +30,8 @@ import {
30
30
  delKeyWithOptions,
31
31
  getKeys,
32
32
  getData,
33
- redisKeys
33
+ redisKeys,
34
+ setData
34
35
  } from "@tradejs/infra/redis";
35
36
  import { logger as logger3 } from "@tradejs/infra/logger";
36
37
  import { getDataEdgesForSymbols } from "@tradejs/infra/timescale/candles";
@@ -1324,20 +1325,8 @@ var sendRuntimeCloseNotificationsToTG = async (events, userName = "root") => {
1324
1325
  });
1325
1326
  logger3.info("");
1326
1327
  };
1327
- var sendToTG = async (signals, imgInterval, userName = "root") => {
1328
+ var sendToTG = async (signals, imgInterval, userName = "root", aiOptionsByStrategy = /* @__PURE__ */ new Map()) => {
1328
1329
  await ensureStrategyPluginsLoaded();
1329
- const strategyConfigCache = /* @__PURE__ */ new Map();
1330
- const resolveStrategyConfig = async (strategyName) => {
1331
- if (strategyConfigCache.has(strategyName)) {
1332
- return strategyConfigCache.get(strategyName);
1333
- }
1334
- const config = await getData(
1335
- `users:${userName}:strategies:${strategyName}:config`,
1336
- null
1337
- );
1338
- strategyConfigCache.set(strategyName, config);
1339
- return config;
1340
- };
1341
1330
  const resolveDecision = (analysis, direction, minQuality = 4) => {
1342
1331
  if (analysis?.needRetest === true) {
1343
1332
  return "rejected";
@@ -1372,11 +1361,10 @@ var sendToTG = async (signals, imgInterval, userName = "root") => {
1372
1361
  null
1373
1362
  );
1374
1363
  let shouldSendSignalAnalysis = analysis && typeof analysis === "object" && Object.keys(analysis).length > 0;
1375
- const strategyConfig = await resolveStrategyConfig(signal.strategy);
1376
- const aiMode = strategyConfig?.AI_MODE;
1364
+ const aiOptions = aiOptionsByStrategy.get(signal.strategy);
1377
1365
  const gateAnalysis = signal.aiAnalysis;
1378
- if (aiMode === "gate" && gateAnalysis) {
1379
- const minQuality = Number(strategyConfig?.MIN_AI_QUALITY) || 4;
1366
+ if (aiOptions?.enabled !== false && aiOptions?.mode === "gate" && gateAnalysis) {
1367
+ const minQuality = Number.isFinite(aiOptions.minQuality) ? Number(aiOptions.minQuality) : 4;
1380
1368
  const gateDecision = resolveDecision(
1381
1369
  gateAnalysis,
1382
1370
  signal.direction,
@@ -1396,6 +1384,18 @@ var sendToTG = async (signals, imgInterval, userName = "root") => {
1396
1384
  llmDecision,
1397
1385
  gateContradictsLlm: gateDecision !== llmDecision
1398
1386
  };
1387
+ try {
1388
+ await setData(
1389
+ redisKeys.analysis(signal.symbol, signal.signalId),
1390
+ analysis
1391
+ );
1392
+ } catch (error) {
1393
+ logger3.error(
1394
+ "LLM comparison persistence failed: %s (%s)",
1395
+ signal.symbol,
1396
+ error?.message || String(error)
1397
+ );
1398
+ }
1399
1399
  shouldSendSignalAnalysis = true;
1400
1400
  } catch (error) {
1401
1401
  logger3.error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/node",
3
- "version": "3.1.15",
3
+ "version": "3.1.16",
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",
@@ -89,9 +89,9 @@
89
89
  "dependencies": {
90
90
  "@langchain/core": "^1.2.3",
91
91
  "@langchain/openai": "^1.5.5",
92
- "@tradejs/core": "^3.1.15",
93
- "@tradejs/infra": "^3.1.15",
94
- "@tradejs/types": "^3.1.15",
92
+ "@tradejs/core": "^3.1.16",
93
+ "@tradejs/infra": "^3.1.16",
94
+ "@tradejs/types": "^3.1.16",
95
95
  "@types/node": "^24",
96
96
  "chalk": "4.1.2",
97
97
  "ioredis": "5.11.1",
@@ -104,7 +104,7 @@
104
104
  "typescript": "^5.9"
105
105
  },
106
106
  "devDependencies": {
107
- "@tradejs/indicators": "^3.1.15",
107
+ "@tradejs/indicators": "^3.1.16",
108
108
  "@tradejs/strategy-adaptive-momentum-ribbon": "3.0.2",
109
109
  "@tradejs/strategy-hyperliquid-consensus": "3.0.2",
110
110
  "@tradejs/strategy-kit": "3.0.3",