@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.
- package/dist/{ai-NNJ3RLLL.mjs → ai-MDMDKAEE.mjs} +3 -3
- package/dist/backtest.d.mts +1 -1
- package/dist/backtest.d.ts +1 -1
- package/dist/backtest.js +214 -131
- package/dist/backtest.mjs +52 -25
- package/dist/{chunk-DE7ADBIR.mjs → chunk-3C76HVLA.mjs} +1 -0
- package/dist/{chunk-CVTV6S2V.mjs → chunk-7ICOZAKA.mjs} +26 -1
- package/dist/chunk-CK2PW4L5.mjs +243 -0
- package/dist/{chunk-PXJJPAQT.mjs → chunk-H4HXW3EZ.mjs} +1 -1
- package/dist/chunk-MGFEID6K.mjs +268 -0
- package/dist/{chunk-ZIMX3JX2.mjs → chunk-QDYCJ2OK.mjs} +1 -1
- package/dist/cli.js +131 -99
- package/dist/cli.mjs +17 -15
- package/dist/connectors.d.mts +9 -9
- package/dist/connectors.d.ts +9 -9
- package/dist/connectors.js +110 -70
- package/dist/connectors.mjs +2 -2
- package/dist/pine.d.mts +27 -3
- package/dist/pine.d.ts +27 -3
- package/dist/pine.js +31 -4
- package/dist/pine.mjs +9 -1
- package/dist/registry.d.mts +10 -10
- package/dist/registry.d.ts +10 -10
- package/dist/registry.js +122 -81
- package/dist/registry.mjs +2 -2
- package/dist/strategies.js +132 -151
- package/dist/strategies.mjs +15 -10
- package/package.json +13 -4
- package/dist/chunk-E2QNOA5M.mjs +0 -227
- package/dist/chunk-MHCXPD2B.mjs +0 -201
package/dist/strategies.js
CHANGED
|
@@ -5751,7 +5751,7 @@ var init_tradejsConfig = __esm({
|
|
|
5751
5751
|
});
|
|
5752
5752
|
|
|
5753
5753
|
// src/strategy/manifests.ts
|
|
5754
|
-
var import_indicators, import_logger3,
|
|
5754
|
+
var import_indicators, import_logger3, createStrategyRegistryState, registryStateByProjectRoot, getStrategyRegistryState, toUniqueModules, getConfiguredPluginModuleNames, extractModuleEntries, extractStrategyPluginDefinition, extractIndicatorPluginDefinition, registerEntries, importStrategyPluginModule, ensureStrategyPluginsLoaded, ensureIndicatorPluginsLoaded, getStrategyCreator, getAvailableStrategyNames, getRegisteredStrategies, getRegisteredManifests, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies;
|
|
5755
5755
|
var init_manifests = __esm({
|
|
5756
5756
|
"src/strategy/manifests.ts"() {
|
|
5757
5757
|
"use strict";
|
|
@@ -5759,14 +5759,29 @@ var init_manifests = __esm({
|
|
|
5759
5759
|
import_logger3 = require("@tradejs/infra/logger");
|
|
5760
5760
|
init_tradejsConfig();
|
|
5761
5761
|
init_tradejsConfig();
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5762
|
+
createStrategyRegistryState = () => ({
|
|
5763
|
+
strategyCreators: /* @__PURE__ */ new Map(),
|
|
5764
|
+
strategyManifestsMap: /* @__PURE__ */ new Map(),
|
|
5765
|
+
pluginsLoadPromise: null
|
|
5766
|
+
});
|
|
5767
|
+
registryStateByProjectRoot = /* @__PURE__ */ new Map();
|
|
5768
|
+
getStrategyRegistryState = (cwd = getTradejsProjectCwd()) => {
|
|
5769
|
+
const projectRoot = getTradejsProjectCwd(cwd);
|
|
5770
|
+
let state = registryStateByProjectRoot.get(projectRoot);
|
|
5771
|
+
if (!state) {
|
|
5772
|
+
state = createStrategyRegistryState();
|
|
5773
|
+
registryStateByProjectRoot.set(projectRoot, state);
|
|
5774
|
+
}
|
|
5775
|
+
return {
|
|
5776
|
+
projectRoot,
|
|
5777
|
+
state
|
|
5778
|
+
};
|
|
5779
|
+
};
|
|
5765
5780
|
toUniqueModules = (modules = []) => [
|
|
5766
5781
|
...new Set(modules.map((moduleName) => moduleName.trim()).filter(Boolean))
|
|
5767
5782
|
];
|
|
5768
|
-
getConfiguredPluginModuleNames = async () => {
|
|
5769
|
-
const config = await loadTradejsConfig();
|
|
5783
|
+
getConfiguredPluginModuleNames = async (cwd = getTradejsProjectCwd()) => {
|
|
5784
|
+
const config = await loadTradejsConfig(cwd);
|
|
5770
5785
|
return {
|
|
5771
5786
|
strategyModules: toUniqueModules(config.strategies),
|
|
5772
5787
|
indicatorModules: toUniqueModules(config.indicators)
|
|
@@ -5800,14 +5815,14 @@ var init_manifests = __esm({
|
|
|
5800
5815
|
);
|
|
5801
5816
|
return indicatorEntries ? { indicatorEntries } : null;
|
|
5802
5817
|
};
|
|
5803
|
-
registerEntries = (entries, source) => {
|
|
5818
|
+
registerEntries = (entries, source, state) => {
|
|
5804
5819
|
for (const entry of entries) {
|
|
5805
5820
|
const strategyName = entry.manifest?.name;
|
|
5806
5821
|
if (!strategyName) {
|
|
5807
5822
|
import_logger3.logger.warn("Skip strategy entry without name from %s", source);
|
|
5808
5823
|
continue;
|
|
5809
5824
|
}
|
|
5810
|
-
if (strategyCreators.has(strategyName)) {
|
|
5825
|
+
if (state.strategyCreators.has(strategyName)) {
|
|
5811
5826
|
import_logger3.logger.warn(
|
|
5812
5827
|
'Skip duplicate strategy "%s" from %s: already registered',
|
|
5813
5828
|
strategyName,
|
|
@@ -5815,8 +5830,8 @@ var init_manifests = __esm({
|
|
|
5815
5830
|
);
|
|
5816
5831
|
continue;
|
|
5817
5832
|
}
|
|
5818
|
-
strategyCreators.set(strategyName, entry.creator);
|
|
5819
|
-
strategyManifestsMap.set(strategyName, entry.manifest);
|
|
5833
|
+
state.strategyCreators.set(strategyName, entry.creator);
|
|
5834
|
+
state.strategyManifestsMap.set(strategyName, entry.manifest);
|
|
5820
5835
|
}
|
|
5821
5836
|
};
|
|
5822
5837
|
importStrategyPluginModule = async (moduleName) => {
|
|
@@ -5828,93 +5843,119 @@ var init_manifests = __esm({
|
|
|
5828
5843
|
moduleName
|
|
5829
5844
|
);
|
|
5830
5845
|
};
|
|
5831
|
-
ensureStrategyPluginsLoaded = async () => {
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
);
|
|
5854
|
-
|
|
5855
|
-
|
|
5846
|
+
ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
|
|
5847
|
+
const { projectRoot, state } = getStrategyRegistryState(cwd);
|
|
5848
|
+
if (!state.pluginsLoadPromise) {
|
|
5849
|
+
(0, import_indicators.resetIndicatorRegistryCache)(projectRoot);
|
|
5850
|
+
state.pluginsLoadPromise = (async () => {
|
|
5851
|
+
const { strategyModules, indicatorModules } = await getConfiguredPluginModuleNames(projectRoot);
|
|
5852
|
+
const strategySet = new Set(strategyModules);
|
|
5853
|
+
const indicatorSet = new Set(indicatorModules);
|
|
5854
|
+
const pluginModuleNames = [
|
|
5855
|
+
.../* @__PURE__ */ new Set([...strategyModules, ...indicatorModules])
|
|
5856
|
+
];
|
|
5857
|
+
if (!pluginModuleNames.length) {
|
|
5858
|
+
return;
|
|
5859
|
+
}
|
|
5860
|
+
for (const moduleName of pluginModuleNames) {
|
|
5861
|
+
try {
|
|
5862
|
+
const resolvedModuleName = resolvePluginModuleSpecifier(
|
|
5863
|
+
moduleName,
|
|
5864
|
+
projectRoot
|
|
5865
|
+
);
|
|
5866
|
+
const moduleExport = await importStrategyPluginModule(resolvedModuleName);
|
|
5867
|
+
if (strategySet.has(moduleName)) {
|
|
5868
|
+
const pluginDefinition = extractStrategyPluginDefinition(moduleExport);
|
|
5869
|
+
if (!pluginDefinition) {
|
|
5870
|
+
import_logger3.logger.warn(
|
|
5871
|
+
'Skip strategy plugin "%s": export { strategyEntries } is missing',
|
|
5872
|
+
moduleName
|
|
5873
|
+
);
|
|
5874
|
+
} else {
|
|
5875
|
+
registerEntries(
|
|
5876
|
+
pluginDefinition.strategyEntries,
|
|
5877
|
+
moduleName,
|
|
5878
|
+
state
|
|
5879
|
+
);
|
|
5880
|
+
}
|
|
5856
5881
|
}
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5882
|
+
if (indicatorSet.has(moduleName)) {
|
|
5883
|
+
const indicatorPluginDefinition = extractIndicatorPluginDefinition(moduleExport);
|
|
5884
|
+
if (!indicatorPluginDefinition) {
|
|
5885
|
+
import_logger3.logger.warn(
|
|
5886
|
+
'Skip indicator plugin "%s": export { indicatorEntries } is missing',
|
|
5887
|
+
moduleName
|
|
5888
|
+
);
|
|
5889
|
+
} else {
|
|
5890
|
+
(0, import_indicators.registerIndicatorEntries)(
|
|
5891
|
+
indicatorPluginDefinition.indicatorEntries,
|
|
5892
|
+
moduleName,
|
|
5893
|
+
projectRoot
|
|
5894
|
+
);
|
|
5895
|
+
}
|
|
5896
|
+
}
|
|
5897
|
+
if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
|
|
5861
5898
|
import_logger3.logger.warn(
|
|
5862
|
-
'Skip
|
|
5863
|
-
moduleName
|
|
5864
|
-
);
|
|
5865
|
-
} else {
|
|
5866
|
-
(0, import_indicators.registerIndicatorEntries)(
|
|
5867
|
-
indicatorPluginDefinition.indicatorEntries,
|
|
5899
|
+
'Skip plugin "%s": no strategy/indicator sections requested in config',
|
|
5868
5900
|
moduleName
|
|
5869
5901
|
);
|
|
5870
5902
|
}
|
|
5871
|
-
}
|
|
5872
|
-
if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
|
|
5903
|
+
} catch (error) {
|
|
5873
5904
|
import_logger3.logger.warn(
|
|
5874
|
-
'
|
|
5875
|
-
moduleName
|
|
5905
|
+
'Failed to load plugin "%s": %s',
|
|
5906
|
+
moduleName,
|
|
5907
|
+
String(error)
|
|
5876
5908
|
);
|
|
5877
5909
|
}
|
|
5878
|
-
} catch (error) {
|
|
5879
|
-
import_logger3.logger.warn(
|
|
5880
|
-
'Failed to load plugin "%s": %s',
|
|
5881
|
-
moduleName,
|
|
5882
|
-
String(error)
|
|
5883
|
-
);
|
|
5884
5910
|
}
|
|
5885
|
-
}
|
|
5886
|
-
}
|
|
5887
|
-
|
|
5911
|
+
})();
|
|
5912
|
+
}
|
|
5913
|
+
await state.pluginsLoadPromise;
|
|
5888
5914
|
};
|
|
5889
|
-
ensureIndicatorPluginsLoaded = ensureStrategyPluginsLoaded;
|
|
5890
|
-
getStrategyCreator = async (name) => {
|
|
5891
|
-
await ensureStrategyPluginsLoaded();
|
|
5892
|
-
|
|
5915
|
+
ensureIndicatorPluginsLoaded = async (cwd = getTradejsProjectCwd()) => ensureStrategyPluginsLoaded(cwd);
|
|
5916
|
+
getStrategyCreator = async (name, cwd = getTradejsProjectCwd()) => {
|
|
5917
|
+
await ensureStrategyPluginsLoaded(cwd);
|
|
5918
|
+
const { state } = getStrategyRegistryState(cwd);
|
|
5919
|
+
return state.strategyCreators.get(name);
|
|
5893
5920
|
};
|
|
5894
|
-
getAvailableStrategyNames = async () => {
|
|
5895
|
-
await ensureStrategyPluginsLoaded();
|
|
5896
|
-
|
|
5921
|
+
getAvailableStrategyNames = async (cwd = getTradejsProjectCwd()) => {
|
|
5922
|
+
await ensureStrategyPluginsLoaded(cwd);
|
|
5923
|
+
const { state } = getStrategyRegistryState(cwd);
|
|
5924
|
+
return [...state.strategyCreators.keys()].sort((a, b) => a.localeCompare(b));
|
|
5897
5925
|
};
|
|
5898
|
-
getRegisteredStrategies = () => {
|
|
5899
|
-
|
|
5926
|
+
getRegisteredStrategies = (cwd = getTradejsProjectCwd()) => {
|
|
5927
|
+
const { state } = getStrategyRegistryState(cwd);
|
|
5928
|
+
return Object.fromEntries(state.strategyCreators.entries());
|
|
5900
5929
|
};
|
|
5901
|
-
getRegisteredManifests = () => {
|
|
5902
|
-
|
|
5930
|
+
getRegisteredManifests = (cwd = getTradejsProjectCwd()) => {
|
|
5931
|
+
const { state } = getStrategyRegistryState(cwd);
|
|
5932
|
+
return [...state.strategyManifestsMap.values()];
|
|
5903
5933
|
};
|
|
5904
|
-
getStrategyManifest = (name) => {
|
|
5905
|
-
|
|
5934
|
+
getStrategyManifest = (name, cwd = getTradejsProjectCwd()) => {
|
|
5935
|
+
if (!name) {
|
|
5936
|
+
return void 0;
|
|
5937
|
+
}
|
|
5938
|
+
const { state } = getStrategyRegistryState(cwd);
|
|
5939
|
+
return state.strategyManifestsMap.get(name);
|
|
5906
5940
|
};
|
|
5907
|
-
isKnownStrategy = (name) => {
|
|
5908
|
-
|
|
5941
|
+
isKnownStrategy = (name, cwd = getTradejsProjectCwd()) => {
|
|
5942
|
+
const { state } = getStrategyRegistryState(cwd);
|
|
5943
|
+
return state.strategyCreators.has(name);
|
|
5909
5944
|
};
|
|
5910
|
-
registerStrategyEntries = (entries) => {
|
|
5911
|
-
|
|
5945
|
+
registerStrategyEntries = (entries, cwd = getTradejsProjectCwd()) => {
|
|
5946
|
+
const { state } = getStrategyRegistryState(cwd);
|
|
5947
|
+
registerEntries(entries, "runtime", state);
|
|
5912
5948
|
};
|
|
5913
|
-
resetStrategyRegistryCache = () => {
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5949
|
+
resetStrategyRegistryCache = (cwd) => {
|
|
5950
|
+
const normalizedCwd = String(cwd ?? "").trim();
|
|
5951
|
+
if (!normalizedCwd) {
|
|
5952
|
+
registryStateByProjectRoot.clear();
|
|
5953
|
+
(0, import_indicators.resetIndicatorRegistryCache)();
|
|
5954
|
+
return;
|
|
5955
|
+
}
|
|
5956
|
+
const projectRoot = getTradejsProjectCwd(normalizedCwd);
|
|
5957
|
+
registryStateByProjectRoot.delete(projectRoot);
|
|
5958
|
+
(0, import_indicators.resetIndicatorRegistryCache)(projectRoot);
|
|
5918
5959
|
};
|
|
5919
5960
|
strategies = new Proxy(
|
|
5920
5961
|
{},
|
|
@@ -5923,10 +5964,10 @@ var init_manifests = __esm({
|
|
|
5923
5964
|
if (typeof property !== "string") {
|
|
5924
5965
|
return void 0;
|
|
5925
5966
|
}
|
|
5926
|
-
return strategyCreators.get(property);
|
|
5967
|
+
return getStrategyRegistryState().state.strategyCreators.get(property);
|
|
5927
5968
|
},
|
|
5928
5969
|
ownKeys: () => {
|
|
5929
|
-
return [...strategyCreators.keys()];
|
|
5970
|
+
return [...getStrategyRegistryState().state.strategyCreators.keys()];
|
|
5930
5971
|
},
|
|
5931
5972
|
getOwnPropertyDescriptor: () => ({
|
|
5932
5973
|
enumerable: true,
|
|
@@ -6399,6 +6440,7 @@ var buildMlPayload = (payload) => {
|
|
|
6399
6440
|
};
|
|
6400
6441
|
|
|
6401
6442
|
// src/strategyHelpers/runtime.ts
|
|
6443
|
+
init_tradejsConfig();
|
|
6402
6444
|
var formatAiError = (err) => {
|
|
6403
6445
|
const error = err;
|
|
6404
6446
|
const safeJson = (value) => {
|
|
@@ -6440,7 +6482,8 @@ var enrichSignalWithMl = async ({
|
|
|
6440
6482
|
const mlResult = await (0, import_ml2.fetchMlThreshold)({
|
|
6441
6483
|
strategy,
|
|
6442
6484
|
features,
|
|
6443
|
-
threshold: ml.mlThreshold
|
|
6485
|
+
threshold: ml.mlThreshold,
|
|
6486
|
+
projectRoot: getTradejsProjectCwd()
|
|
6444
6487
|
});
|
|
6445
6488
|
if (mlResult) {
|
|
6446
6489
|
signal.ml = mlResult;
|
|
@@ -6518,20 +6561,8 @@ var executeEntryOrder = async ({
|
|
|
6518
6561
|
};
|
|
6519
6562
|
|
|
6520
6563
|
// src/pine.ts
|
|
6521
|
-
var pine_exports = {};
|
|
6522
|
-
__export(pine_exports, {
|
|
6523
|
-
createLoadPineScript: () => createLoadPineScript,
|
|
6524
|
-
loadPineScript: () => loadPineScript,
|
|
6525
|
-
runPineScript: () => runPineScript
|
|
6526
|
-
});
|
|
6527
6564
|
var import_node_fs = __toESM(require("fs"));
|
|
6528
6565
|
var import_node_path = __toESM(require("path"));
|
|
6529
|
-
__reExport(pine_exports, require("@tradejs/core/pine"));
|
|
6530
|
-
var loadPinets = () => {
|
|
6531
|
-
const resolvedPath = require.resolve("pinets");
|
|
6532
|
-
const cjsPath = resolvedPath.includes("pinets.min.browser") ? resolvedPath.replace(/pinets\.min\.browser(\.es)?\.js$/, "pinets.min.cjs") : resolvedPath;
|
|
6533
|
-
return require(cjsPath);
|
|
6534
|
-
};
|
|
6535
6566
|
var loadPineScript = (filePath, fallback = "") => {
|
|
6536
6567
|
const resolvedPath = String(filePath || "").trim();
|
|
6537
6568
|
if (!resolvedPath) {
|
|
@@ -6554,62 +6585,10 @@ var createLoadPineScript = (baseDir) => {
|
|
|
6554
6585
|
return loadPineScript(resolvedPath, fallback);
|
|
6555
6586
|
};
|
|
6556
6587
|
};
|
|
6557
|
-
var MINUTE_MS = 6e4;
|
|
6558
|
-
var normalizeTimestampMs = (timestamp) => timestamp < 1e12 ? timestamp * 1e3 : timestamp;
|
|
6559
|
-
var resolveCandleDuration = (candles) => {
|
|
6560
|
-
if (candles.length < 2) {
|
|
6561
|
-
return MINUTE_MS;
|
|
6562
|
-
}
|
|
6563
|
-
const first = normalizeTimestampMs(candles[0].timestamp);
|
|
6564
|
-
const second = normalizeTimestampMs(candles[1].timestamp);
|
|
6565
|
-
const duration = Math.max(second - first, MINUTE_MS);
|
|
6566
|
-
return Number.isFinite(duration) && duration > 0 ? duration : MINUTE_MS;
|
|
6567
|
-
};
|
|
6568
|
-
var toPineRuntimeCandles = (candles) => {
|
|
6569
|
-
const candleDuration = resolveCandleDuration(candles);
|
|
6570
|
-
return candles.map((candle) => {
|
|
6571
|
-
const openTime = normalizeTimestampMs(candle.timestamp);
|
|
6572
|
-
return {
|
|
6573
|
-
open: Number(candle.open),
|
|
6574
|
-
high: Number(candle.high),
|
|
6575
|
-
low: Number(candle.low),
|
|
6576
|
-
close: Number(candle.close),
|
|
6577
|
-
volume: Number(candle.volume ?? 0),
|
|
6578
|
-
openTime,
|
|
6579
|
-
closeTime: openTime + candleDuration
|
|
6580
|
-
};
|
|
6581
|
-
});
|
|
6582
|
-
};
|
|
6583
|
-
var runPineScript = async ({
|
|
6584
|
-
candles,
|
|
6585
|
-
script,
|
|
6586
|
-
symbol = "SYMBOL",
|
|
6587
|
-
timeframe = "15",
|
|
6588
|
-
inputs = {},
|
|
6589
|
-
limit
|
|
6590
|
-
}) => {
|
|
6591
|
-
const { PineTS, Indicator } = loadPinets();
|
|
6592
|
-
const trimmedScript = String(script || "").trim();
|
|
6593
|
-
if (!trimmedScript) {
|
|
6594
|
-
throw new Error("Pine script is empty");
|
|
6595
|
-
}
|
|
6596
|
-
if (!Array.isArray(candles) || candles.length === 0) {
|
|
6597
|
-
throw new Error("No candles provided for Pine script execution");
|
|
6598
|
-
}
|
|
6599
|
-
const pineCandles = toPineRuntimeCandles(candles);
|
|
6600
|
-
const pine = new PineTS(
|
|
6601
|
-
pineCandles,
|
|
6602
|
-
symbol,
|
|
6603
|
-
timeframe,
|
|
6604
|
-
Math.max(1, limit ?? pineCandles.length)
|
|
6605
|
-
);
|
|
6606
|
-
const indicator = new Indicator(trimmedScript, inputs);
|
|
6607
|
-
const context = await pine.run(indicator);
|
|
6608
|
-
return context;
|
|
6609
|
-
};
|
|
6610
6588
|
|
|
6611
6589
|
// src/strategyRuntime.ts
|
|
6612
6590
|
init_manifests();
|
|
6591
|
+
init_tradejsConfig();
|
|
6613
6592
|
|
|
6614
6593
|
// src/strategyHelpers/config.ts
|
|
6615
6594
|
var import_lodash2 = __toESM(require_lodash());
|
|
@@ -6833,6 +6812,7 @@ var createStrategyRuntime = ({
|
|
|
6833
6812
|
manifest: staticManifest,
|
|
6834
6813
|
strategyDirectory
|
|
6835
6814
|
}) => {
|
|
6815
|
+
const projectRoot = getTradejsProjectCwd();
|
|
6836
6816
|
const resolveManifest = (name) => {
|
|
6837
6817
|
if (!name) {
|
|
6838
6818
|
return void 0;
|
|
@@ -6840,11 +6820,11 @@ var createStrategyRuntime = ({
|
|
|
6840
6820
|
if (staticManifest?.name === name) {
|
|
6841
6821
|
return staticManifest;
|
|
6842
6822
|
}
|
|
6843
|
-
return getStrategyManifest(name);
|
|
6823
|
+
return getStrategyManifest(name, projectRoot);
|
|
6844
6824
|
};
|
|
6845
6825
|
const loadPineScript2 = createLoadPineScript(
|
|
6846
6826
|
strategyDirectory ? import_node_path2.default.resolve(strategyDirectory) : import_node_path2.default.resolve(
|
|
6847
|
-
|
|
6827
|
+
projectRoot,
|
|
6848
6828
|
"packages",
|
|
6849
6829
|
"strategies",
|
|
6850
6830
|
"src",
|
|
@@ -6939,7 +6919,8 @@ var createStrategyRuntime = ({
|
|
|
6939
6919
|
btcData,
|
|
6940
6920
|
btcBinanceData,
|
|
6941
6921
|
btcCoinbaseData,
|
|
6942
|
-
periods: (0, import_strategies.buildDefaultIndicatorPeriods)(config)
|
|
6922
|
+
periods: (0, import_strategies.buildDefaultIndicatorPeriods)(config),
|
|
6923
|
+
pluginRegistryScope: projectRoot
|
|
6943
6924
|
});
|
|
6944
6925
|
const strategyApi = (0, import_strategies.createStrategyAPI)({
|
|
6945
6926
|
strategy: strategyName,
|
package/dist/strategies.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildMlPayload
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-H4HXW3EZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
require_lodash
|
|
6
6
|
} from "./chunk-GKDBAF3A.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createLoadPineScript
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7ICOZAKA.mjs";
|
|
10
10
|
import "./chunk-5YNMSWL3.mjs";
|
|
11
11
|
import {
|
|
12
12
|
MAX_AI_SERIES_POINTS,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
buildAiPayload,
|
|
16
16
|
buildAiSystemPrompt,
|
|
17
17
|
trimSeriesDeep
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-QDYCJ2OK.mjs";
|
|
19
19
|
import {
|
|
20
20
|
ensureIndicatorPluginsLoaded,
|
|
21
21
|
ensureStrategyPluginsLoaded,
|
|
@@ -28,8 +28,10 @@ import {
|
|
|
28
28
|
registerStrategyEntries,
|
|
29
29
|
resetStrategyRegistryCache,
|
|
30
30
|
strategies
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import
|
|
31
|
+
} from "./chunk-CK2PW4L5.mjs";
|
|
32
|
+
import {
|
|
33
|
+
getTradejsProjectCwd
|
|
34
|
+
} from "./chunk-3C76HVLA.mjs";
|
|
33
35
|
import {
|
|
34
36
|
__toESM
|
|
35
37
|
} from "./chunk-6DZX6EAA.mjs";
|
|
@@ -185,7 +187,8 @@ var enrichSignalWithMl = async ({
|
|
|
185
187
|
const mlResult = await fetchMlThreshold({
|
|
186
188
|
strategy,
|
|
187
189
|
features,
|
|
188
|
-
threshold: ml.mlThreshold
|
|
190
|
+
threshold: ml.mlThreshold,
|
|
191
|
+
projectRoot: getTradejsProjectCwd()
|
|
189
192
|
});
|
|
190
193
|
if (mlResult) {
|
|
191
194
|
signal.ml = mlResult;
|
|
@@ -203,7 +206,7 @@ var enrichSignalWithAi = async ({
|
|
|
203
206
|
return void 0;
|
|
204
207
|
}
|
|
205
208
|
try {
|
|
206
|
-
const { askAI: askAI2 } = await import("./ai-
|
|
209
|
+
const { askAI: askAI2 } = await import("./ai-MDMDKAEE.mjs");
|
|
207
210
|
const analysis = await askAI2(signal);
|
|
208
211
|
if (typeof analysis?.quality === "number") {
|
|
209
212
|
const normalizedQuality = Math.round(analysis.quality);
|
|
@@ -484,6 +487,7 @@ var createStrategyRuntime = ({
|
|
|
484
487
|
manifest: staticManifest,
|
|
485
488
|
strategyDirectory
|
|
486
489
|
}) => {
|
|
490
|
+
const projectRoot = getTradejsProjectCwd();
|
|
487
491
|
const resolveManifest = (name) => {
|
|
488
492
|
if (!name) {
|
|
489
493
|
return void 0;
|
|
@@ -491,11 +495,11 @@ var createStrategyRuntime = ({
|
|
|
491
495
|
if (staticManifest?.name === name) {
|
|
492
496
|
return staticManifest;
|
|
493
497
|
}
|
|
494
|
-
return getStrategyManifest(name);
|
|
498
|
+
return getStrategyManifest(name, projectRoot);
|
|
495
499
|
};
|
|
496
500
|
const loadPineScript = createLoadPineScript(
|
|
497
501
|
strategyDirectory ? path.resolve(strategyDirectory) : path.resolve(
|
|
498
|
-
|
|
502
|
+
projectRoot,
|
|
499
503
|
"packages",
|
|
500
504
|
"strategies",
|
|
501
505
|
"src",
|
|
@@ -590,7 +594,8 @@ var createStrategyRuntime = ({
|
|
|
590
594
|
btcData,
|
|
591
595
|
btcBinanceData,
|
|
592
596
|
btcCoinbaseData,
|
|
593
|
-
periods: buildDefaultIndicatorPeriods(config)
|
|
597
|
+
periods: buildDefaultIndicatorPeriods(config),
|
|
598
|
+
pluginRegistryScope: projectRoot
|
|
594
599
|
});
|
|
595
600
|
const strategyApi = createStrategyAPI({
|
|
596
601
|
strategy: strategyName,
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Node-only TradeJS runtime for strategies, backtests, Pine loading, and plugin registries.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tradejs",
|
|
7
|
+
"trading",
|
|
8
|
+
"backtesting",
|
|
9
|
+
"node",
|
|
10
|
+
"runtime",
|
|
11
|
+
"strategy",
|
|
12
|
+
"pine-script"
|
|
13
|
+
],
|
|
5
14
|
"files": [
|
|
6
15
|
"dist"
|
|
7
16
|
],
|
|
@@ -45,9 +54,9 @@
|
|
|
45
54
|
"dependencies": {
|
|
46
55
|
"@langchain/core": "^0.3.68",
|
|
47
56
|
"@langchain/openai": "^0.6.11",
|
|
48
|
-
"@tradejs/core": "^1.0.
|
|
49
|
-
"@tradejs/infra": "^1.0.
|
|
50
|
-
"@tradejs/types": "^1.0.
|
|
57
|
+
"@tradejs/core": "^1.0.3",
|
|
58
|
+
"@tradejs/infra": "^1.0.3",
|
|
59
|
+
"@tradejs/types": "^1.0.3",
|
|
51
60
|
"chalk": "4.1.2",
|
|
52
61
|
"ioredis": "5.8.0",
|
|
53
62
|
"pinets": "0.8.12",
|