@tradejs/node 1.0.9 → 1.0.11

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.
@@ -3,7 +3,7 @@ import {
3
3
  importTradejsModule,
4
4
  loadTradejsConfig,
5
5
  resolvePluginModuleSpecifier
6
- } from "./chunk-JU77QVJ3.mjs";
6
+ } from "./chunk-WS5DYEVZ.mjs";
7
7
 
8
8
  // src/strategy/manifests.ts
9
9
  import {
@@ -3,7 +3,7 @@ import {
3
3
  importTradejsModule,
4
4
  loadTradejsConfig,
5
5
  resolvePluginModuleSpecifier
6
- } from "./chunk-JU77QVJ3.mjs";
6
+ } from "./chunk-WS5DYEVZ.mjs";
7
7
 
8
8
  // src/connectorsRegistry.ts
9
9
  import { logger } from "@tradejs/infra/logger";
@@ -1,7 +1,6 @@
1
1
  // src/tradejsConfig.ts
2
2
  import fs from "fs";
3
3
  import path from "path";
4
- import { createRequire } from "module";
5
4
  import { fileURLToPath, pathToFileURL } from "url";
6
5
  import {
7
6
  normalizeTradejsConfigHooks
@@ -19,6 +18,7 @@ var cachedByCwd = /* @__PURE__ */ new Map();
19
18
  var announcedConfigFile = /* @__PURE__ */ new Set();
20
19
  var tsNodeRegistered = false;
21
20
  var tsconfigPathsRegisteredByCwd = /* @__PURE__ */ new Set();
21
+ var tsconfigPathMatchersByCwd = /* @__PURE__ */ new Map();
22
22
  var getTradejsProjectCwd = (cwd) => {
23
23
  const explicit = String(cwd ?? "").trim();
24
24
  if (explicit) {
@@ -48,7 +48,14 @@ var normalizeConfig = (rawConfig) => {
48
48
  ...hooks ? { hooks } : {}
49
49
  };
50
50
  };
51
- var getRequireFn = (cwd = getTradejsProjectCwd()) => createRequire(path.join(path.resolve(cwd), "__tradejs_loader__.js"));
51
+ var getNodeCreateRequire = () => {
52
+ const builtinModule = process.getBuiltinModule?.("module");
53
+ if (typeof builtinModule?.createRequire === "function") {
54
+ return builtinModule.createRequire;
55
+ }
56
+ throw new TypeError("module.createRequire is not available");
57
+ };
58
+ var getRequireFn = (cwd = getTradejsProjectCwd()) => getNodeCreateRequire()(path.join(path.resolve(cwd), "__tradejs_loader__.js"));
52
59
  var ensureTsNodeRegistered = async () => {
53
60
  if (tsNodeRegistered) {
54
61
  return;
@@ -58,8 +65,8 @@ var ensureTsNodeRegistered = async () => {
58
65
  tsNode.register?.({
59
66
  transpileOnly: true,
60
67
  compilerOptions: {
61
- module: "commonjs",
62
- moduleResolution: "node"
68
+ module: "Node16",
69
+ moduleResolution: "node16"
63
70
  }
64
71
  });
65
72
  tsNodeRegistered = true;
@@ -86,6 +93,42 @@ var ensureTsconfigPathsRegistered = async (cwd = getTradejsProjectCwd()) => {
86
93
  });
87
94
  tsconfigPathsRegisteredByCwd.add(projectRoot);
88
95
  };
96
+ var resolveTsconfigPathModule = async (moduleName, cwd = getTradejsProjectCwd()) => {
97
+ const projectRoot = getTradejsProjectCwd(cwd);
98
+ const cachedMatcher = tsconfigPathMatchersByCwd.get(projectRoot);
99
+ if (cachedMatcher) {
100
+ const resolved2 = cachedMatcher(moduleName);
101
+ return resolved2 || null;
102
+ }
103
+ const tsconfigPathsModule = await import("tsconfig-paths");
104
+ const loadConfig = tsconfigPathsModule.loadConfig;
105
+ const createMatchPath = tsconfigPathsModule.createMatchPath;
106
+ if (typeof loadConfig !== "function" || typeof createMatchPath !== "function") {
107
+ return null;
108
+ }
109
+ const loadedConfig = loadConfig(projectRoot);
110
+ if (loadedConfig.resultType !== "success") {
111
+ return null;
112
+ }
113
+ const matchPath = createMatchPath(
114
+ loadedConfig.absoluteBaseUrl,
115
+ loadedConfig.paths
116
+ );
117
+ const matcher = (requestedModule) => matchPath(requestedModule, void 0, fs.existsSync, [
118
+ ".ts",
119
+ ".tsx",
120
+ ".mts",
121
+ ".cts",
122
+ ".js",
123
+ ".jsx",
124
+ ".mjs",
125
+ ".cjs",
126
+ ".json"
127
+ ]) || "";
128
+ tsconfigPathMatchersByCwd.set(projectRoot, matcher);
129
+ const resolved = matcher(moduleName);
130
+ return resolved || null;
131
+ };
89
132
  var toImportSpecifier = (moduleName) => {
90
133
  if (moduleName.startsWith("file://")) {
91
134
  return moduleName;
@@ -144,7 +187,18 @@ var importTradejsModule = async (moduleName, cwd = getTradejsProjectCwd()) => {
144
187
  }
145
188
  if (isBareModuleSpecifier(normalized)) {
146
189
  await ensureTsconfigPathsRegistered(cwd);
147
- return requireFn(normalized);
190
+ try {
191
+ return requireFn(normalized);
192
+ } catch (error) {
193
+ const resolvedByTsconfig = await resolveTsconfigPathModule(
194
+ normalized,
195
+ cwd
196
+ );
197
+ if (resolvedByTsconfig && resolvedByTsconfig !== normalized) {
198
+ return requireFn(resolvedByTsconfig);
199
+ }
200
+ throw error;
201
+ }
148
202
  }
149
203
  try {
150
204
  return await import(
package/dist/cli.d.mts CHANGED
@@ -1,10 +1,17 @@
1
- import { TestStat, TestThresholdsKey, Connector, Signal, Interval } from '@tradejs/types';
1
+ import { 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?: {
5
5
  userName?: string;
6
6
  markup?: Record<string, unknown>;
7
7
  }) => Promise<any>;
8
+ declare const sendDocumentToTG: (document: {
9
+ filename: string;
10
+ content: string | Uint8Array;
11
+ caption?: string;
12
+ }, options?: {
13
+ userName?: string;
14
+ }) => Promise<any>;
8
15
 
9
16
  interface TradejsProjectConfig {
10
17
  strategies?: string[];
@@ -20,11 +27,14 @@ declare const update: (connector: Connector, interval: Interval, tickers: string
20
27
  connectorLabel?: string;
21
28
  preloadStart?: number;
22
29
  preloadEnd?: number;
30
+ skipCovered?: boolean;
23
31
  }) => Promise<void>;
24
32
  declare const drawStatInCLI: (stat: Partial<TestStat> | undefined, keys: TestThresholdsKey[]) => string[];
25
- declare const getTickers: (connector: Connector, include?: string, exclude?: string, limit?: number, chunk?: string) => Promise<string[]>;
33
+ declare const getTickers: (connector: Connector, include?: string, exclude?: string, limit?: number, chunk?: string, query?: Parameters<Connector["getTickers"]>[0]) => Promise<string[]>;
26
34
  declare const makeScreenshots: (signals: Signal[], interval: Interval, userName?: string) => Promise<void>;
27
35
  declare const sendToAI: (signals: Signal[], userName?: string) => Promise<void>;
36
+ declare const formatRuntimeCloseNotification: (event: RuntimeStrategyCloseNotification, _userName?: string) => string;
37
+ declare const sendRuntimeCloseNotificationsToTG: (events: RuntimeStrategyCloseNotification[], userName?: string) => Promise<void>;
28
38
  declare const sendToTG: (signals: Signal[], imgInterval: Interval, userName?: string) => Promise<void>;
29
39
 
30
- export { cleanFiles, cleanRedis, drawStatInCLI, getTickers, loadTradejsConfig, makeScreenshots, sendTextToTG, sendToAI, sendToTG, update };
40
+ export { cleanFiles, cleanRedis, drawStatInCLI, formatRuntimeCloseNotification, getTickers, loadTradejsConfig, makeScreenshots, sendDocumentToTG, sendRuntimeCloseNotificationsToTG, sendTextToTG, sendToAI, sendToTG, update };
package/dist/cli.d.ts CHANGED
@@ -1,10 +1,17 @@
1
- import { TestStat, TestThresholdsKey, Connector, Signal, Interval } from '@tradejs/types';
1
+ import { 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?: {
5
5
  userName?: string;
6
6
  markup?: Record<string, unknown>;
7
7
  }) => Promise<any>;
8
+ declare const sendDocumentToTG: (document: {
9
+ filename: string;
10
+ content: string | Uint8Array;
11
+ caption?: string;
12
+ }, options?: {
13
+ userName?: string;
14
+ }) => Promise<any>;
8
15
 
9
16
  interface TradejsProjectConfig {
10
17
  strategies?: string[];
@@ -20,11 +27,14 @@ declare const update: (connector: Connector, interval: Interval, tickers: string
20
27
  connectorLabel?: string;
21
28
  preloadStart?: number;
22
29
  preloadEnd?: number;
30
+ skipCovered?: boolean;
23
31
  }) => Promise<void>;
24
32
  declare const drawStatInCLI: (stat: Partial<TestStat> | undefined, keys: TestThresholdsKey[]) => string[];
25
- declare const getTickers: (connector: Connector, include?: string, exclude?: string, limit?: number, chunk?: string) => Promise<string[]>;
33
+ declare const getTickers: (connector: Connector, include?: string, exclude?: string, limit?: number, chunk?: string, query?: Parameters<Connector["getTickers"]>[0]) => Promise<string[]>;
26
34
  declare const makeScreenshots: (signals: Signal[], interval: Interval, userName?: string) => Promise<void>;
27
35
  declare const sendToAI: (signals: Signal[], userName?: string) => Promise<void>;
36
+ declare const formatRuntimeCloseNotification: (event: RuntimeStrategyCloseNotification, _userName?: string) => string;
37
+ declare const sendRuntimeCloseNotificationsToTG: (events: RuntimeStrategyCloseNotification[], userName?: string) => Promise<void>;
28
38
  declare const sendToTG: (signals: Signal[], imgInterval: Interval, userName?: string) => Promise<void>;
29
39
 
30
- export { cleanFiles, cleanRedis, drawStatInCLI, getTickers, loadTradejsConfig, makeScreenshots, sendTextToTG, sendToAI, sendToTG, update };
40
+ export { cleanFiles, cleanRedis, drawStatInCLI, formatRuntimeCloseNotification, getTickers, loadTradejsConfig, makeScreenshots, sendDocumentToTG, sendRuntimeCloseNotificationsToTG, sendTextToTG, sendToAI, sendToTG, update };