@tradejs/node 3.1.8-beta.212 → 3.1.8
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/ai.mjs +1 -2
- package/dist/backtest.mjs +6 -8
- package/dist/{chunk-SVAUSZUE.mjs → chunk-B6X2HEGL.mjs} +3 -5
- package/dist/{chunk-733VVTWU.mjs → chunk-C3KRBNUR.mjs} +291 -2
- package/dist/{chunk-F7ODY5W4.mjs → chunk-LPHWIFLB.mjs} +1 -1
- package/dist/cli.mjs +2 -4
- package/dist/registry.mjs +2 -3
- package/dist/runtimeDashboard.js +5704 -17
- package/dist/runtimeDashboard.mjs +3 -2
- package/dist/runtimeStrategies.js +5687 -0
- package/dist/runtimeStrategies.mjs +3 -2
- package/dist/strategies.mjs +10 -12
- package/package.json +4 -4
- package/dist/chunk-MEZIXBZ3.mjs +0 -295
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
listRuntimeDeployments,
|
|
5
5
|
loadResolvedRuntimeStrategies,
|
|
6
6
|
verifyRuntimeDeclaration
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-LPHWIFLB.mjs";
|
|
8
|
+
import "./chunk-B6X2HEGL.mjs";
|
|
9
|
+
import "./chunk-C3KRBNUR.mjs";
|
|
9
10
|
import "./chunk-LZDXRXIU.mjs";
|
|
10
11
|
import "./chunk-Y6FXYEAI.mjs";
|
|
11
12
|
export {
|
package/dist/strategies.mjs
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveHyperliquidPerpFromSignalSymbol,
|
|
23
23
|
resolveStrategyConfig,
|
|
24
24
|
validateEntryProtectionAtArrival
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-B6X2HEGL.mjs";
|
|
26
26
|
import {
|
|
27
27
|
DEFAULT_AI_MODEL,
|
|
28
28
|
MAX_AI_SERIES_POINTS,
|
|
@@ -32,29 +32,27 @@ import {
|
|
|
32
32
|
buildAiPrompts,
|
|
33
33
|
buildAiSystemPrompt,
|
|
34
34
|
buildCompactAiIndicatorsSnapshot,
|
|
35
|
-
getDeterministicAiGateContext,
|
|
36
|
-
getOpenRouterModelKwargs,
|
|
37
|
-
invokeAiChat,
|
|
38
|
-
resetAiRuntimeCache,
|
|
39
|
-
runAiPrompt,
|
|
40
|
-
runAiPromptLocal,
|
|
41
|
-
trimSeriesDeep
|
|
42
|
-
} from "./chunk-733VVTWU.mjs";
|
|
43
|
-
import {
|
|
44
35
|
ensureIndicatorPluginsLoaded,
|
|
45
36
|
ensureStrategyPluginsLoaded,
|
|
46
37
|
getAvailableStrategyNames,
|
|
38
|
+
getDeterministicAiGateContext,
|
|
39
|
+
getOpenRouterModelKwargs,
|
|
47
40
|
getRegisteredManifests,
|
|
48
41
|
getRegisteredStrategies,
|
|
49
42
|
getStrategyCreator,
|
|
50
43
|
getStrategyDefaults,
|
|
51
44
|
getStrategyManifest,
|
|
52
45
|
getStrategyPluginSource,
|
|
46
|
+
invokeAiChat,
|
|
53
47
|
isKnownStrategy,
|
|
54
48
|
registerStrategyEntries,
|
|
49
|
+
resetAiRuntimeCache,
|
|
55
50
|
resetStrategyRegistryCache,
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
runAiPrompt,
|
|
52
|
+
runAiPromptLocal,
|
|
53
|
+
strategies,
|
|
54
|
+
trimSeriesDeep
|
|
55
|
+
} from "./chunk-C3KRBNUR.mjs";
|
|
58
56
|
import "./chunk-LZDXRXIU.mjs";
|
|
59
57
|
import "./chunk-Y6FXYEAI.mjs";
|
|
60
58
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/node",
|
|
3
|
-
"version": "3.1.8
|
|
3
|
+
"version": "3.1.8",
|
|
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",
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@langchain/core": "^1.2.3",
|
|
87
87
|
"@langchain/openai": "^1.5.5",
|
|
88
|
-
"@tradejs/core": "^3.1.8
|
|
89
|
-
"@tradejs/infra": "^3.1.8
|
|
90
|
-
"@tradejs/types": "^3.1.8
|
|
88
|
+
"@tradejs/core": "^3.1.8",
|
|
89
|
+
"@tradejs/infra": "^3.1.8",
|
|
90
|
+
"@tradejs/types": "^3.1.8",
|
|
91
91
|
"chalk": "4.1.2",
|
|
92
92
|
"ioredis": "5.11.1",
|
|
93
93
|
"lodash": "^4.18.1",
|
package/dist/chunk-MEZIXBZ3.mjs
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTradejsProjectCwd,
|
|
3
|
-
importTradejsModule,
|
|
4
|
-
loadTradejsConfig,
|
|
5
|
-
resolvePluginModuleSpecifier
|
|
6
|
-
} from "./chunk-LZDXRXIU.mjs";
|
|
7
|
-
|
|
8
|
-
// src/strategy/manifests.ts
|
|
9
|
-
import {
|
|
10
|
-
registerIndicatorEntries,
|
|
11
|
-
resetIndicatorRegistryCache
|
|
12
|
-
} from "@tradejs/core/indicators";
|
|
13
|
-
import { logger } from "@tradejs/infra/logger";
|
|
14
|
-
var SHARED_STRATEGY_REGISTRY_KEY = "__tradejsNodeSharedStrategyRegistryV1__";
|
|
15
|
-
var sharedRegistryScope = globalThis;
|
|
16
|
-
var sharedStrategyRegistry = sharedRegistryScope[SHARED_STRATEGY_REGISTRY_KEY] ?? (sharedRegistryScope[SHARED_STRATEGY_REGISTRY_KEY] = {
|
|
17
|
-
registryStateByProjectRoot: /* @__PURE__ */ new Map()
|
|
18
|
-
});
|
|
19
|
-
var createStrategyRegistryState = () => ({
|
|
20
|
-
strategyCreators: /* @__PURE__ */ new Map(),
|
|
21
|
-
strategyManifestsMap: /* @__PURE__ */ new Map(),
|
|
22
|
-
strategyEntriesMap: /* @__PURE__ */ new Map(),
|
|
23
|
-
strategySourcesMap: /* @__PURE__ */ new Map(),
|
|
24
|
-
pluginsLoadPromise: null
|
|
25
|
-
});
|
|
26
|
-
var registryStateByProjectRoot = sharedStrategyRegistry.registryStateByProjectRoot;
|
|
27
|
-
var getStrategyRegistryState = (cwd = getTradejsProjectCwd()) => {
|
|
28
|
-
const projectRoot = getTradejsProjectCwd(cwd);
|
|
29
|
-
let state = registryStateByProjectRoot.get(projectRoot);
|
|
30
|
-
if (!state) {
|
|
31
|
-
state = createStrategyRegistryState();
|
|
32
|
-
registryStateByProjectRoot.set(projectRoot, state);
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
projectRoot,
|
|
36
|
-
state
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
var toUniqueModules = (modules = []) => [
|
|
40
|
-
...new Set(modules.map((moduleName) => moduleName.trim()).filter(Boolean))
|
|
41
|
-
];
|
|
42
|
-
var getConfiguredPluginModuleNames = async (cwd = getTradejsProjectCwd()) => {
|
|
43
|
-
const config = await loadTradejsConfig(cwd);
|
|
44
|
-
return {
|
|
45
|
-
strategyModules: toUniqueModules(config.strategies),
|
|
46
|
-
indicatorModules: toUniqueModules(config.indicators)
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
var extractModuleEntries = (moduleExport, key) => {
|
|
50
|
-
if (!moduleExport || typeof moduleExport !== "object") {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const candidate = moduleExport;
|
|
54
|
-
if (Array.isArray(candidate[key])) {
|
|
55
|
-
return candidate[key];
|
|
56
|
-
}
|
|
57
|
-
const defaultExport = candidate.default;
|
|
58
|
-
if (defaultExport && Array.isArray(defaultExport[key])) {
|
|
59
|
-
return defaultExport[key];
|
|
60
|
-
}
|
|
61
|
-
return null;
|
|
62
|
-
};
|
|
63
|
-
var extractStrategyPluginDefinition = (moduleExport) => {
|
|
64
|
-
const strategyEntries = extractModuleEntries(
|
|
65
|
-
moduleExport,
|
|
66
|
-
"strategyEntries"
|
|
67
|
-
);
|
|
68
|
-
return strategyEntries ? { strategyEntries } : null;
|
|
69
|
-
};
|
|
70
|
-
var extractIndicatorPluginDefinition = (moduleExport) => {
|
|
71
|
-
const indicatorEntries = extractModuleEntries(
|
|
72
|
-
moduleExport,
|
|
73
|
-
"indicatorEntries"
|
|
74
|
-
);
|
|
75
|
-
return indicatorEntries ? { indicatorEntries } : null;
|
|
76
|
-
};
|
|
77
|
-
var registerEntries = (entries, source, state) => {
|
|
78
|
-
for (const entry of entries) {
|
|
79
|
-
const strategyName = entry.manifest?.name;
|
|
80
|
-
if (!strategyName) {
|
|
81
|
-
logger.warn("Skip strategy entry without name from %s", source);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (state.strategyCreators.has(strategyName)) {
|
|
85
|
-
logger.warn(
|
|
86
|
-
'Skip duplicate strategy "%s" from %s: already registered',
|
|
87
|
-
strategyName,
|
|
88
|
-
source
|
|
89
|
-
);
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
state.strategyManifestsMap.set(strategyName, entry.manifest);
|
|
93
|
-
state.strategyEntriesMap.set(strategyName, entry);
|
|
94
|
-
state.strategySourcesMap.set(strategyName, source);
|
|
95
|
-
materializeStrategyCreator(strategyName, state);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var materializeStrategyCreator = (strategyName, state) => {
|
|
99
|
-
if (state.strategyCreators.has(strategyName) || !sharedStrategyRegistry.strategyRuntimeFactory) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const entry = state.strategyEntriesMap.get(strategyName);
|
|
103
|
-
if (!entry) return;
|
|
104
|
-
state.strategyCreators.set(
|
|
105
|
-
strategyName,
|
|
106
|
-
sharedStrategyRegistry.strategyRuntimeFactory({
|
|
107
|
-
strategyName,
|
|
108
|
-
defaults: entry.defaults,
|
|
109
|
-
createCore: entry.createCore,
|
|
110
|
-
manifest: entry.manifest,
|
|
111
|
-
detectorKey: entry.detectorKey,
|
|
112
|
-
detectorNoSignalSkipReason: entry.detectorNoSignalSkipReason,
|
|
113
|
-
resolveRegisteredManifest: (name) => state.strategyManifestsMap.get(name)
|
|
114
|
-
})
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
var setStrategyRuntimeFactory = (factory) => {
|
|
118
|
-
sharedStrategyRegistry.strategyRuntimeFactory = factory;
|
|
119
|
-
for (const state of registryStateByProjectRoot.values()) {
|
|
120
|
-
for (const strategyName of state.strategyEntriesMap.keys()) {
|
|
121
|
-
materializeStrategyCreator(strategyName, state);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var importStrategyPluginModule = async (moduleName, cwd = getTradejsProjectCwd()) => {
|
|
126
|
-
if (typeof importTradejsModule === "function") {
|
|
127
|
-
return importTradejsModule(moduleName, cwd);
|
|
128
|
-
}
|
|
129
|
-
return import(
|
|
130
|
-
/* webpackIgnore: true */
|
|
131
|
-
moduleName
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
|
|
135
|
-
const { projectRoot, state } = getStrategyRegistryState(cwd);
|
|
136
|
-
if (!state.pluginsLoadPromise) {
|
|
137
|
-
resetIndicatorRegistryCache(projectRoot);
|
|
138
|
-
state.pluginsLoadPromise = (async () => {
|
|
139
|
-
const { strategyModules, indicatorModules } = await getConfiguredPluginModuleNames(projectRoot);
|
|
140
|
-
const strategySet = new Set(strategyModules);
|
|
141
|
-
const indicatorSet = new Set(indicatorModules);
|
|
142
|
-
const pluginModuleNames = [
|
|
143
|
-
.../* @__PURE__ */ new Set([...strategyModules, ...indicatorModules])
|
|
144
|
-
];
|
|
145
|
-
if (!pluginModuleNames.length) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
for (const moduleName of pluginModuleNames) {
|
|
149
|
-
try {
|
|
150
|
-
const resolvedModuleName = resolvePluginModuleSpecifier(
|
|
151
|
-
moduleName,
|
|
152
|
-
projectRoot
|
|
153
|
-
);
|
|
154
|
-
const moduleExport = await importStrategyPluginModule(
|
|
155
|
-
resolvedModuleName,
|
|
156
|
-
projectRoot
|
|
157
|
-
);
|
|
158
|
-
if (strategySet.has(moduleName)) {
|
|
159
|
-
const pluginDefinition = extractStrategyPluginDefinition(moduleExport);
|
|
160
|
-
if (!pluginDefinition) {
|
|
161
|
-
logger.warn(
|
|
162
|
-
'Skip strategy plugin "%s": export { strategyEntries } is missing',
|
|
163
|
-
moduleName
|
|
164
|
-
);
|
|
165
|
-
} else {
|
|
166
|
-
registerEntries(
|
|
167
|
-
pluginDefinition.strategyEntries,
|
|
168
|
-
moduleName,
|
|
169
|
-
state
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (indicatorSet.has(moduleName)) {
|
|
174
|
-
const indicatorPluginDefinition = extractIndicatorPluginDefinition(moduleExport);
|
|
175
|
-
if (!indicatorPluginDefinition) {
|
|
176
|
-
logger.warn(
|
|
177
|
-
'Skip indicator plugin "%s": export { indicatorEntries } is missing',
|
|
178
|
-
moduleName
|
|
179
|
-
);
|
|
180
|
-
} else {
|
|
181
|
-
registerIndicatorEntries(
|
|
182
|
-
indicatorPluginDefinition.indicatorEntries,
|
|
183
|
-
moduleName,
|
|
184
|
-
projectRoot
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
|
|
189
|
-
logger.warn(
|
|
190
|
-
'Skip plugin "%s": no strategy/indicator sections requested in config',
|
|
191
|
-
moduleName
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
} catch (error) {
|
|
195
|
-
logger.warn(
|
|
196
|
-
'Failed to load plugin "%s": %s',
|
|
197
|
-
moduleName,
|
|
198
|
-
String(error)
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
})();
|
|
203
|
-
}
|
|
204
|
-
await state.pluginsLoadPromise;
|
|
205
|
-
};
|
|
206
|
-
var ensureIndicatorPluginsLoaded = async (cwd = getTradejsProjectCwd()) => ensureStrategyPluginsLoaded(cwd);
|
|
207
|
-
var getStrategyCreator = async (name, cwd = getTradejsProjectCwd()) => {
|
|
208
|
-
await ensureStrategyPluginsLoaded(cwd);
|
|
209
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
210
|
-
return state.strategyCreators.get(name);
|
|
211
|
-
};
|
|
212
|
-
var getStrategyDefaults = async (name, cwd = getTradejsProjectCwd()) => {
|
|
213
|
-
await ensureStrategyPluginsLoaded(cwd);
|
|
214
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
215
|
-
return state.strategyEntriesMap.get(name)?.defaults;
|
|
216
|
-
};
|
|
217
|
-
var getStrategyPluginSource = async (name, cwd = getTradejsProjectCwd()) => {
|
|
218
|
-
await ensureStrategyPluginsLoaded(cwd);
|
|
219
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
220
|
-
return state.strategySourcesMap.get(name);
|
|
221
|
-
};
|
|
222
|
-
var getAvailableStrategyNames = async (cwd = getTradejsProjectCwd()) => {
|
|
223
|
-
await ensureStrategyPluginsLoaded(cwd);
|
|
224
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
225
|
-
return [...state.strategyCreators.keys()].sort((a, b) => a.localeCompare(b));
|
|
226
|
-
};
|
|
227
|
-
var getRegisteredStrategies = (cwd = getTradejsProjectCwd()) => {
|
|
228
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
229
|
-
return Object.fromEntries(state.strategyCreators.entries());
|
|
230
|
-
};
|
|
231
|
-
var getRegisteredManifests = (cwd = getTradejsProjectCwd()) => {
|
|
232
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
233
|
-
return [...state.strategyManifestsMap.values()];
|
|
234
|
-
};
|
|
235
|
-
var getStrategyManifest = (name, cwd = getTradejsProjectCwd()) => {
|
|
236
|
-
if (!name) {
|
|
237
|
-
return void 0;
|
|
238
|
-
}
|
|
239
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
240
|
-
return state.strategyManifestsMap.get(name);
|
|
241
|
-
};
|
|
242
|
-
var isKnownStrategy = (name, cwd = getTradejsProjectCwd()) => {
|
|
243
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
244
|
-
return state.strategyCreators.has(name);
|
|
245
|
-
};
|
|
246
|
-
var registerStrategyEntries = (entries, cwd = getTradejsProjectCwd()) => {
|
|
247
|
-
const { state } = getStrategyRegistryState(cwd);
|
|
248
|
-
registerEntries(entries, "runtime", state);
|
|
249
|
-
};
|
|
250
|
-
var resetStrategyRegistryCache = (cwd) => {
|
|
251
|
-
const normalizedCwd = String(cwd ?? "").trim();
|
|
252
|
-
if (!normalizedCwd) {
|
|
253
|
-
registryStateByProjectRoot.clear();
|
|
254
|
-
resetIndicatorRegistryCache();
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
const projectRoot = getTradejsProjectCwd(normalizedCwd);
|
|
258
|
-
registryStateByProjectRoot.delete(projectRoot);
|
|
259
|
-
resetIndicatorRegistryCache(projectRoot);
|
|
260
|
-
};
|
|
261
|
-
var strategies = new Proxy(
|
|
262
|
-
{},
|
|
263
|
-
{
|
|
264
|
-
get: (_target, property) => {
|
|
265
|
-
if (typeof property !== "string") {
|
|
266
|
-
return void 0;
|
|
267
|
-
}
|
|
268
|
-
return getStrategyRegistryState().state.strategyCreators.get(property);
|
|
269
|
-
},
|
|
270
|
-
ownKeys: () => {
|
|
271
|
-
return [...getStrategyRegistryState().state.strategyCreators.keys()];
|
|
272
|
-
},
|
|
273
|
-
getOwnPropertyDescriptor: () => ({
|
|
274
|
-
enumerable: true,
|
|
275
|
-
configurable: true
|
|
276
|
-
})
|
|
277
|
-
}
|
|
278
|
-
);
|
|
279
|
-
|
|
280
|
-
export {
|
|
281
|
-
setStrategyRuntimeFactory,
|
|
282
|
-
ensureStrategyPluginsLoaded,
|
|
283
|
-
ensureIndicatorPluginsLoaded,
|
|
284
|
-
getStrategyCreator,
|
|
285
|
-
getStrategyDefaults,
|
|
286
|
-
getStrategyPluginSource,
|
|
287
|
-
getAvailableStrategyNames,
|
|
288
|
-
getRegisteredStrategies,
|
|
289
|
-
getRegisteredManifests,
|
|
290
|
-
getStrategyManifest,
|
|
291
|
-
isKnownStrategy,
|
|
292
|
-
registerStrategyEntries,
|
|
293
|
-
resetStrategyRegistryCache,
|
|
294
|
-
strategies
|
|
295
|
-
};
|