@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.
- package/dist/ai.js +0 -1
- package/dist/ai.mjs +1 -1
- package/dist/backtest.js +99 -82
- package/dist/backtest.mjs +2 -2
- package/dist/{chunk-B6X2HEGL.mjs → chunk-6PIVDS4M.mjs} +6 -6
- package/dist/{chunk-C3KRBNUR.mjs → chunk-IKRSNRP6.mjs} +58 -31
- package/dist/chunk-NQO2MFP6.mjs +552 -0
- package/dist/cli.js +108 -91
- package/dist/cli.mjs +1 -1
- package/dist/registry.js +86 -65
- package/dist/registry.mjs +2 -2
- package/dist/runtimeDashboard.js +420 -216
- package/dist/runtimeDashboard.mjs +9 -9
- package/dist/runtimeStrategies.d.mts +66 -6
- package/dist/runtimeStrategies.d.ts +66 -6
- package/dist/runtimeStrategies.js +450 -218
- package/dist/runtimeStrategies.mjs +11 -3
- package/dist/strategies.js +97 -76
- package/dist/strategies.mjs +2 -2
- package/package.json +14 -8
- package/dist/chunk-7BAL7EN3.mjs +0 -345
package/dist/ai.js
CHANGED
|
@@ -624,7 +624,6 @@ var buildAiMarketContext = (signal) => ({
|
|
|
624
624
|
|
|
625
625
|
// src/strategy/manifests.ts
|
|
626
626
|
var import_indicators = require("@tradejs/core/indicators");
|
|
627
|
-
var import_logger2 = require("@tradejs/infra/logger");
|
|
628
627
|
|
|
629
628
|
// src/tradejsConfig.ts
|
|
630
629
|
var import_path = __toESM(require("path"));
|
package/dist/ai.mjs
CHANGED
package/dist/backtest.js
CHANGED
|
@@ -47,15 +47,15 @@ var import_indicators3 = require("@tradejs/core/indicators");
|
|
|
47
47
|
var import_constants9 = require("@tradejs/core/constants");
|
|
48
48
|
var import_strategies7 = require("@tradejs/core/strategies");
|
|
49
49
|
var import_time3 = require("@tradejs/core/time");
|
|
50
|
-
var
|
|
50
|
+
var import_logger14 = require("@tradejs/infra/logger");
|
|
51
51
|
|
|
52
52
|
// src/strategyRuntime.ts
|
|
53
53
|
var import_constants5 = require("@tradejs/core/constants");
|
|
54
54
|
var import_strategies6 = require("@tradejs/core/strategies");
|
|
55
|
-
var
|
|
55
|
+
var import_logger10 = require("@tradejs/infra/logger");
|
|
56
56
|
|
|
57
57
|
// src/strategyHelpers/runtime.ts
|
|
58
|
-
var
|
|
58
|
+
var import_logger8 = require("@tradejs/infra/logger");
|
|
59
59
|
var import_constants3 = require("@tradejs/core/constants");
|
|
60
60
|
var import_ml2 = require("@tradejs/infra/ml");
|
|
61
61
|
|
|
@@ -637,7 +637,6 @@ var buildAiMarketContext = (signal) => ({
|
|
|
637
637
|
|
|
638
638
|
// src/strategy/manifests.ts
|
|
639
639
|
var import_indicators = require("@tradejs/core/indicators");
|
|
640
|
-
var import_logger2 = require("@tradejs/infra/logger");
|
|
641
640
|
|
|
642
641
|
// src/tradejsConfig.ts
|
|
643
642
|
var import_fs = __toESM(require("fs"));
|
|
@@ -990,21 +989,34 @@ var extractIndicatorPluginDefinition = (moduleExport) => {
|
|
|
990
989
|
);
|
|
991
990
|
return indicatorEntries ? { indicatorEntries } : null;
|
|
992
991
|
};
|
|
993
|
-
var
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
992
|
+
var validateStrategyEntries = (moduleName, entries, state) => {
|
|
993
|
+
const issues = [];
|
|
994
|
+
const names = /* @__PURE__ */ new Set();
|
|
995
|
+
entries.forEach((entry, index) => {
|
|
996
|
+
const entryPath = `${moduleName}.strategyEntries[${index}]`;
|
|
997
|
+
const strategyName = entry?.manifest?.name;
|
|
998
|
+
if (typeof strategyName !== "string" || !strategyName.trim()) {
|
|
999
|
+
issues.push(`${entryPath}: manifest.name is required`);
|
|
1000
|
+
} else if (names.has(strategyName) || state.strategyEntriesMap.has(strategyName)) {
|
|
1001
|
+
issues.push(`${entryPath}: duplicate strategy ${strategyName}`);
|
|
1002
|
+
} else {
|
|
1003
|
+
names.add(strategyName);
|
|
999
1004
|
}
|
|
1000
|
-
if (
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
);
|
|
1006
|
-
continue;
|
|
1005
|
+
if (!entry || typeof entry !== "object" || !entry.defaults || typeof entry.defaults !== "object" || Array.isArray(entry.defaults)) {
|
|
1006
|
+
issues.push(`${entryPath}: defaults must be an object`);
|
|
1007
|
+
}
|
|
1008
|
+
if (typeof entry?.parseConfig !== "function") {
|
|
1009
|
+
issues.push(`${entryPath}: parseConfig is required`);
|
|
1007
1010
|
}
|
|
1011
|
+
if (typeof entry?.createCore !== "function") {
|
|
1012
|
+
issues.push(`${entryPath}: createCore is required`);
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
return issues;
|
|
1016
|
+
};
|
|
1017
|
+
var registerEntries = (entries, source, state) => {
|
|
1018
|
+
for (const entry of entries) {
|
|
1019
|
+
const strategyName = entry.manifest.name;
|
|
1008
1020
|
state.strategyManifestsMap.set(strategyName, entry.manifest);
|
|
1009
1021
|
state.strategyEntriesMap.set(strategyName, entry);
|
|
1010
1022
|
state.strategySourcesMap.set(strategyName, source);
|
|
@@ -1061,6 +1073,7 @@ var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
|
|
|
1061
1073
|
if (!pluginModuleNames.length) {
|
|
1062
1074
|
return;
|
|
1063
1075
|
}
|
|
1076
|
+
const issues = [];
|
|
1064
1077
|
for (const moduleName of pluginModuleNames) {
|
|
1065
1078
|
try {
|
|
1066
1079
|
const resolvedModuleName = resolvePluginModuleSpecifier(
|
|
@@ -1074,24 +1087,30 @@ var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
|
|
|
1074
1087
|
if (strategySet.has(moduleName)) {
|
|
1075
1088
|
const pluginDefinition = extractStrategyPluginDefinition(moduleExport);
|
|
1076
1089
|
if (!pluginDefinition) {
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
moduleName
|
|
1090
|
+
issues.push(
|
|
1091
|
+
`${moduleName}: export { strategyEntries } is missing`
|
|
1080
1092
|
);
|
|
1081
1093
|
} else {
|
|
1082
|
-
|
|
1083
|
-
pluginDefinition.strategyEntries,
|
|
1094
|
+
const entryIssues = validateStrategyEntries(
|
|
1084
1095
|
moduleName,
|
|
1096
|
+
pluginDefinition.strategyEntries,
|
|
1085
1097
|
state
|
|
1086
1098
|
);
|
|
1099
|
+
issues.push(...entryIssues);
|
|
1100
|
+
if (entryIssues.length === 0) {
|
|
1101
|
+
registerEntries(
|
|
1102
|
+
pluginDefinition.strategyEntries,
|
|
1103
|
+
moduleName,
|
|
1104
|
+
state
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
1087
1107
|
}
|
|
1088
1108
|
}
|
|
1089
1109
|
if (indicatorSet.has(moduleName)) {
|
|
1090
1110
|
const indicatorPluginDefinition = extractIndicatorPluginDefinition(moduleExport);
|
|
1091
1111
|
if (!indicatorPluginDefinition) {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
moduleName
|
|
1112
|
+
issues.push(
|
|
1113
|
+
`${moduleName}: export { indicatorEntries } is missing`
|
|
1095
1114
|
);
|
|
1096
1115
|
} else {
|
|
1097
1116
|
(0, import_indicators.registerIndicatorEntries)(
|
|
@@ -1102,19 +1121,17 @@ var ensureStrategyPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
|
|
|
1102
1121
|
}
|
|
1103
1122
|
}
|
|
1104
1123
|
if (!strategySet.has(moduleName) && !indicatorSet.has(moduleName)) {
|
|
1105
|
-
|
|
1106
|
-
'Skip plugin "%s": no strategy/indicator sections requested in config',
|
|
1107
|
-
moduleName
|
|
1108
|
-
);
|
|
1124
|
+
issues.push(`${moduleName}: plugin is not declared in config`);
|
|
1109
1125
|
}
|
|
1110
1126
|
} catch (error) {
|
|
1111
|
-
|
|
1112
|
-
'Failed to load plugin "%s": %s',
|
|
1113
|
-
moduleName,
|
|
1114
|
-
String(error)
|
|
1115
|
-
);
|
|
1127
|
+
issues.push(`${moduleName}: failed to import: ${String(error)}`);
|
|
1116
1128
|
}
|
|
1117
1129
|
}
|
|
1130
|
+
if (issues.length > 0) {
|
|
1131
|
+
throw new Error(
|
|
1132
|
+
["Invalid TradeJS plugin catalog:", ...issues].join("\n")
|
|
1133
|
+
);
|
|
1134
|
+
}
|
|
1118
1135
|
})();
|
|
1119
1136
|
}
|
|
1120
1137
|
await state.pluginsLoadPromise;
|
|
@@ -1771,7 +1788,7 @@ var import_node_crypto = require("crypto");
|
|
|
1771
1788
|
var import_constants = require("@tradejs/core/constants");
|
|
1772
1789
|
var import_time = require("@tradejs/core/time");
|
|
1773
1790
|
var import_trade = require("@tradejs/core/trade");
|
|
1774
|
-
var
|
|
1791
|
+
var import_logger2 = require("@tradejs/infra/logger");
|
|
1775
1792
|
var import_redis2 = require("@tradejs/infra/redis");
|
|
1776
1793
|
var now = () => Date.now();
|
|
1777
1794
|
var toRandomOrderSuffix = () => (0, import_node_crypto.randomUUID)().replace(/-/g, "").slice(0, 12).toLowerCase();
|
|
@@ -1830,7 +1847,7 @@ var recordRuntimeTradeOpen = async (params) => {
|
|
|
1830
1847
|
)
|
|
1831
1848
|
]);
|
|
1832
1849
|
} catch (error) {
|
|
1833
|
-
|
|
1850
|
+
import_logger2.logger.error(
|
|
1834
1851
|
"runtime trade open journal failed: %s %s",
|
|
1835
1852
|
record.symbol,
|
|
1836
1853
|
error?.message || String(error)
|
|
@@ -1897,7 +1914,7 @@ var recordRuntimeTradeIncrease = async (params) => {
|
|
|
1897
1914
|
)
|
|
1898
1915
|
]);
|
|
1899
1916
|
} catch (error) {
|
|
1900
|
-
|
|
1917
|
+
import_logger2.logger.error(
|
|
1901
1918
|
"runtime trade increase journal failed: %s %s",
|
|
1902
1919
|
symbol,
|
|
1903
1920
|
error?.message || String(error)
|
|
@@ -2004,7 +2021,7 @@ var markRuntimeTradeClosed = async (params) => {
|
|
|
2004
2021
|
)
|
|
2005
2022
|
]);
|
|
2006
2023
|
} catch (error) {
|
|
2007
|
-
|
|
2024
|
+
import_logger2.logger.error(
|
|
2008
2025
|
"runtime trade close journal failed: %s %s",
|
|
2009
2026
|
symbol,
|
|
2010
2027
|
error?.message || String(error)
|
|
@@ -2014,11 +2031,11 @@ var markRuntimeTradeClosed = async (params) => {
|
|
|
2014
2031
|
};
|
|
2015
2032
|
|
|
2016
2033
|
// src/strategyHelpers/marketContextStages.ts
|
|
2017
|
-
var
|
|
2034
|
+
var import_logger7 = require("@tradejs/infra/logger");
|
|
2018
2035
|
|
|
2019
2036
|
// src/strategyHelpers/binanceMarketContext.ts
|
|
2020
2037
|
var import_marketContext = require("@tradejs/infra/timescale/marketContext");
|
|
2021
|
-
var
|
|
2038
|
+
var import_logger3 = require("@tradejs/infra/logger");
|
|
2022
2039
|
var import_strategies = require("@tradejs/core/strategies");
|
|
2023
2040
|
|
|
2024
2041
|
// src/binanceBreadthUniverses.ts
|
|
@@ -2614,7 +2631,7 @@ var enrichSignalWithBinanceMarketContext = async (params) => {
|
|
|
2614
2631
|
throw error;
|
|
2615
2632
|
}
|
|
2616
2633
|
binanceMarketContextUnavailable = true;
|
|
2617
|
-
|
|
2634
|
+
import_logger3.logger.warn(
|
|
2618
2635
|
"Binance market context disabled after Timescale read failure: %s",
|
|
2619
2636
|
String(error)
|
|
2620
2637
|
);
|
|
@@ -2624,7 +2641,7 @@ var enrichSignalWithBinanceMarketContext = async (params) => {
|
|
|
2624
2641
|
|
|
2625
2642
|
// src/strategyHelpers/coinMarketCapContext.ts
|
|
2626
2643
|
var import_strategies2 = require("@tradejs/core/strategies");
|
|
2627
|
-
var
|
|
2644
|
+
var import_logger4 = require("@tradejs/infra/logger");
|
|
2628
2645
|
var import_marketContext2 = require("@tradejs/infra/timescale/marketContext");
|
|
2629
2646
|
var DEFAULT_MAX_AGE_MS = 48 * 60 * 6e4;
|
|
2630
2647
|
var SOURCE_GLOBAL_DAILY = "coinmarketcap_global";
|
|
@@ -3113,7 +3130,7 @@ var enrichSignalWithCoinMarketCapContext = async (params) => {
|
|
|
3113
3130
|
throw error;
|
|
3114
3131
|
}
|
|
3115
3132
|
coinMarketCapContextUnavailable = true;
|
|
3116
|
-
|
|
3133
|
+
import_logger4.logger.warn(
|
|
3117
3134
|
"CoinMarketCap context disabled after Timescale read failure: %s",
|
|
3118
3135
|
String(error)
|
|
3119
3136
|
);
|
|
@@ -3127,7 +3144,7 @@ var import_data = require("@tradejs/core/data");
|
|
|
3127
3144
|
var import_strategies3 = require("@tradejs/core/strategies");
|
|
3128
3145
|
var import_constants2 = require("@tradejs/core/constants");
|
|
3129
3146
|
var import_derivatives = require("@tradejs/infra/timescale/derivatives");
|
|
3130
|
-
var
|
|
3147
|
+
var import_logger5 = require("@tradejs/infra/logger");
|
|
3131
3148
|
var STORED_INTERVALS = ["15m", "1h"];
|
|
3132
3149
|
var CONTEXT_INTERVALS = ["15m", "1h"];
|
|
3133
3150
|
var DEFAULT_LOOKBACK_HOURS = 48;
|
|
@@ -3359,7 +3376,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
|
|
|
3359
3376
|
throw error;
|
|
3360
3377
|
}
|
|
3361
3378
|
derivativesContextUnavailable = true;
|
|
3362
|
-
|
|
3379
|
+
import_logger5.logger.warn(
|
|
3363
3380
|
"Derivatives context disabled after Timescale read failure: %s",
|
|
3364
3381
|
String(error)
|
|
3365
3382
|
);
|
|
@@ -3371,7 +3388,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
|
|
|
3371
3388
|
var import_data2 = require("@tradejs/core/data");
|
|
3372
3389
|
var import_strategies4 = require("@tradejs/core/strategies");
|
|
3373
3390
|
var import_hyperliquidWhales2 = require("@tradejs/infra/timescale/hyperliquidWhales");
|
|
3374
|
-
var
|
|
3391
|
+
var import_logger6 = require("@tradejs/infra/logger");
|
|
3375
3392
|
|
|
3376
3393
|
// src/hyperliquidWhaleUniverse.ts
|
|
3377
3394
|
var import_node_crypto3 = require("crypto");
|
|
@@ -3891,7 +3908,7 @@ var loadHyperliquidWhaleFlowContext = async (params) => {
|
|
|
3891
3908
|
throw error;
|
|
3892
3909
|
}
|
|
3893
3910
|
hyperliquidWhaleContextUnavailable = true;
|
|
3894
|
-
|
|
3911
|
+
import_logger6.logger.warn(
|
|
3895
3912
|
"Hyperliquid whale context disabled after Timescale read failure: %s",
|
|
3896
3913
|
String(error)
|
|
3897
3914
|
);
|
|
@@ -3974,7 +3991,7 @@ var runMarketContextStage = async ({
|
|
|
3974
3991
|
elapsedMs: Date.now() - startedAt
|
|
3975
3992
|
};
|
|
3976
3993
|
if (status === "timed_out") {
|
|
3977
|
-
|
|
3994
|
+
import_logger7.logger.warn(
|
|
3978
3995
|
"Market context stage timed out: %s after %sms",
|
|
3979
3996
|
stage,
|
|
3980
3997
|
result.elapsedMs
|
|
@@ -4164,7 +4181,7 @@ var enrichSignalWithAi = async ({
|
|
|
4164
4181
|
signal.aiAnalysis = analysis;
|
|
4165
4182
|
return resolveAiQuality(analysis, direction);
|
|
4166
4183
|
} catch (err) {
|
|
4167
|
-
|
|
4184
|
+
import_logger8.logger.error("AI analysis error: %s %s", symbol, formatAiError(err));
|
|
4168
4185
|
}
|
|
4169
4186
|
return void 0;
|
|
4170
4187
|
};
|
|
@@ -4199,7 +4216,7 @@ var getOrderArrivalSnapshot = async ({
|
|
|
4199
4216
|
spreadBps
|
|
4200
4217
|
};
|
|
4201
4218
|
} catch (error) {
|
|
4202
|
-
|
|
4219
|
+
import_logger8.logger.warn(
|
|
4203
4220
|
"runtime order arrival snapshot failed: %s %s",
|
|
4204
4221
|
symbol,
|
|
4205
4222
|
error?.message || String(error)
|
|
@@ -4428,7 +4445,7 @@ var executeEntryOrder = async ({
|
|
|
4428
4445
|
deploymentId: signal.deploymentId,
|
|
4429
4446
|
policyProfileId: signal.policyProfileId,
|
|
4430
4447
|
runtimeConfigId: signal.runtimeConfigId,
|
|
4431
|
-
|
|
4448
|
+
strategyRevision: signal.strategyRevision,
|
|
4432
4449
|
runtimeLineage: signal.runtimeLineage,
|
|
4433
4450
|
...signal.aiAnalysis ? { aiAnalysis: signal.aiAnalysis } : {}
|
|
4434
4451
|
});
|
|
@@ -4980,7 +4997,7 @@ var canUseSharedReplayState = ({
|
|
|
4980
4997
|
}) => (env === "BACKTEST" || env === "PARITY") && Boolean(sharedReplayKey);
|
|
4981
4998
|
|
|
4982
4999
|
// src/strategy/runtimeExecution.ts
|
|
4983
|
-
var
|
|
5000
|
+
var import_logger9 = require("@tradejs/infra/logger");
|
|
4984
5001
|
var import_types = require("@tradejs/types");
|
|
4985
5002
|
var buildExitOrderSignal = ({
|
|
4986
5003
|
strategyName,
|
|
@@ -5032,7 +5049,7 @@ var handleExitDecision = async ({
|
|
|
5032
5049
|
deploymentId: connector.deploymentId
|
|
5033
5050
|
});
|
|
5034
5051
|
if (!activeTrade) {
|
|
5035
|
-
|
|
5052
|
+
import_logger9.logger.warn(
|
|
5036
5053
|
"[%s] blocked closePosition for untracked runtime position: %s",
|
|
5037
5054
|
strategyName ?? "unknown",
|
|
5038
5055
|
symbol
|
|
@@ -5040,7 +5057,7 @@ var handleExitDecision = async ({
|
|
|
5040
5057
|
return "CLOSE_BLOCKED_BY_UNTRACKED_POSITION";
|
|
5041
5058
|
}
|
|
5042
5059
|
if (!strategyName || activeTrade.strategy !== strategyName) {
|
|
5043
|
-
|
|
5060
|
+
import_logger9.logger.warn(
|
|
5044
5061
|
"[%s] blocked closePosition for foreign runtime position: %s ownedBy=%s",
|
|
5045
5062
|
strategyName ?? "unknown",
|
|
5046
5063
|
symbol,
|
|
@@ -5092,7 +5109,7 @@ var handleExitDecision = async ({
|
|
|
5092
5109
|
exitType: closedTrade?.exitType ?? "exit"
|
|
5093
5110
|
});
|
|
5094
5111
|
} catch (notificationError) {
|
|
5095
|
-
|
|
5112
|
+
import_logger9.logger.error(
|
|
5096
5113
|
"runtime close notification error: %s %s",
|
|
5097
5114
|
symbol,
|
|
5098
5115
|
notificationError
|
|
@@ -5106,7 +5123,7 @@ var handleExitDecision = async ({
|
|
|
5106
5123
|
decision,
|
|
5107
5124
|
market
|
|
5108
5125
|
});
|
|
5109
|
-
|
|
5126
|
+
import_logger9.logger.error("close order error: %s %s", symbol, err);
|
|
5110
5127
|
return "ORDER_ERROR";
|
|
5111
5128
|
}
|
|
5112
5129
|
return decision.code;
|
|
@@ -5133,7 +5150,7 @@ var handleProtectDecision = async ({
|
|
|
5133
5150
|
decision,
|
|
5134
5151
|
market
|
|
5135
5152
|
});
|
|
5136
|
-
|
|
5153
|
+
import_logger9.logger.error("protect position error: %s %s", symbol, err);
|
|
5137
5154
|
return "ORDER_ERROR";
|
|
5138
5155
|
}
|
|
5139
5156
|
return decision.code;
|
|
@@ -5296,9 +5313,9 @@ var executeEntryDecision = async ({
|
|
|
5296
5313
|
market
|
|
5297
5314
|
});
|
|
5298
5315
|
if (err?.message === import_types.BACKTEST_WARNING_CODES.TAKE_PROFIT_CROSSED_BEFORE_ENTRY) {
|
|
5299
|
-
|
|
5316
|
+
import_logger9.logger.warn("order warning: %s %s", symbol, err);
|
|
5300
5317
|
} else {
|
|
5301
|
-
|
|
5318
|
+
import_logger9.logger.error("order error: %s %s", symbol, err);
|
|
5302
5319
|
}
|
|
5303
5320
|
return signal ?? "ORDER_ERROR";
|
|
5304
5321
|
}
|
|
@@ -5339,7 +5356,7 @@ var createStrategyRuntime = ({
|
|
|
5339
5356
|
deploymentId: requestedDeploymentId,
|
|
5340
5357
|
policyProfileId,
|
|
5341
5358
|
runtimeConfigId,
|
|
5342
|
-
|
|
5359
|
+
strategyRevision,
|
|
5343
5360
|
entriesPaused = false,
|
|
5344
5361
|
runtimeLineage,
|
|
5345
5362
|
runtimeConfigSnapshot,
|
|
@@ -5452,7 +5469,7 @@ var createStrategyRuntime = ({
|
|
|
5452
5469
|
try {
|
|
5453
5470
|
await projectHook(errorParams);
|
|
5454
5471
|
} catch (hookError) {
|
|
5455
|
-
|
|
5472
|
+
import_logger10.logger.error(
|
|
5456
5473
|
"project hook onRuntimeError failed: %s %s",
|
|
5457
5474
|
strategyName,
|
|
5458
5475
|
hookError
|
|
@@ -5466,7 +5483,7 @@ var createStrategyRuntime = ({
|
|
|
5466
5483
|
try {
|
|
5467
5484
|
await onRuntimeError(errorParams);
|
|
5468
5485
|
} catch (hookError) {
|
|
5469
|
-
|
|
5486
|
+
import_logger10.logger.error(
|
|
5470
5487
|
"runtime hook onRuntimeError failed: %s %s",
|
|
5471
5488
|
strategyName,
|
|
5472
5489
|
hookError
|
|
@@ -5480,7 +5497,7 @@ var createStrategyRuntime = ({
|
|
|
5480
5497
|
try {
|
|
5481
5498
|
return await hook(params);
|
|
5482
5499
|
} catch (error) {
|
|
5483
|
-
|
|
5500
|
+
import_logger10.logger.error(
|
|
5484
5501
|
'strategy hook "%s" failed for %s: %s',
|
|
5485
5502
|
stage,
|
|
5486
5503
|
strategyName,
|
|
@@ -6011,8 +6028,8 @@ var createStrategyRuntime = ({
|
|
|
6011
6028
|
signal.signalId = `${signal.signalId}:${runtimeConfigId}`;
|
|
6012
6029
|
}
|
|
6013
6030
|
}
|
|
6014
|
-
if (
|
|
6015
|
-
signal.
|
|
6031
|
+
if (strategyRevision) {
|
|
6032
|
+
signal.strategyRevision = strategyRevision;
|
|
6016
6033
|
}
|
|
6017
6034
|
if (decisionHookCtx.policyProfileId) {
|
|
6018
6035
|
signal.policyProfileId = decisionHookCtx.policyProfileId;
|
|
@@ -6125,7 +6142,7 @@ var createStrategyRuntime = ({
|
|
|
6125
6142
|
if (signal) {
|
|
6126
6143
|
signal.orderStatus = "skipped";
|
|
6127
6144
|
signal.orderSkipReason = skipReason;
|
|
6128
|
-
signal.
|
|
6145
|
+
signal.strategyRevision = strategyRevision;
|
|
6129
6146
|
}
|
|
6130
6147
|
return signal ?? skipReason;
|
|
6131
6148
|
}
|
|
@@ -6237,10 +6254,10 @@ var createStrategyRuntime = ({
|
|
|
6237
6254
|
setStrategyRuntimeFactory(createStrategyRuntime);
|
|
6238
6255
|
|
|
6239
6256
|
// src/connectorsRegistry.ts
|
|
6240
|
-
var
|
|
6257
|
+
var import_logger13 = require("@tradejs/infra/logger");
|
|
6241
6258
|
|
|
6242
6259
|
// src/connectorRuntime.ts
|
|
6243
|
-
var
|
|
6260
|
+
var import_logger12 = require("@tradejs/infra/logger");
|
|
6244
6261
|
var import_tradingAccounts = require("@tradejs/infra/tradingAccounts");
|
|
6245
6262
|
|
|
6246
6263
|
// src/timescaleCachedKline.ts
|
|
@@ -6248,7 +6265,7 @@ var import_constants6 = require("@tradejs/core/constants");
|
|
|
6248
6265
|
var import_data4 = require("@tradejs/core/data");
|
|
6249
6266
|
var import_time2 = require("@tradejs/core/time");
|
|
6250
6267
|
var import_async = require("@tradejs/core/async");
|
|
6251
|
-
var
|
|
6268
|
+
var import_logger11 = require("@tradejs/infra/logger");
|
|
6252
6269
|
var import_candles = require("@tradejs/infra/timescale/candles");
|
|
6253
6270
|
var DEFAULT_LIMIT = 1e3;
|
|
6254
6271
|
var DEFAULT_CACHE_FALLBACK_WINDOW = 1e3;
|
|
@@ -6362,7 +6379,7 @@ var createTimescaleCachedKline = ({
|
|
|
6362
6379
|
}) => {
|
|
6363
6380
|
const intMinutes = intervalToMinutes(interval);
|
|
6364
6381
|
if (!intMinutes) {
|
|
6365
|
-
|
|
6382
|
+
import_logger11.logger.log("error", "refreshTail: invalid interval %s", interval);
|
|
6366
6383
|
return;
|
|
6367
6384
|
}
|
|
6368
6385
|
const intervalMs = intervalMsOf(intMinutes);
|
|
@@ -6393,7 +6410,7 @@ var createTimescaleCachedKline = ({
|
|
|
6393
6410
|
}) => {
|
|
6394
6411
|
const intMinutes = intervalToMinutes(interval);
|
|
6395
6412
|
if (!intMinutes) {
|
|
6396
|
-
|
|
6413
|
+
import_logger11.logger.log("error", "kline: invalid interval %s", interval);
|
|
6397
6414
|
return [];
|
|
6398
6415
|
}
|
|
6399
6416
|
if (defaultStart !== void 0 && defaultEnd !== void 0 && defaultEnd <= defaultStart) {
|
|
@@ -6502,7 +6519,7 @@ var createTimescaleCachedKline = ({
|
|
|
6502
6519
|
if (warmOnly) {
|
|
6503
6520
|
if (isTimescaleFallbackMode) {
|
|
6504
6521
|
isTimescaleFallbackMode = false;
|
|
6505
|
-
|
|
6522
|
+
import_logger11.logger.log("info", "TimescaleDB connection restored for kline cache");
|
|
6506
6523
|
}
|
|
6507
6524
|
return [];
|
|
6508
6525
|
}
|
|
@@ -6514,13 +6531,13 @@ var createTimescaleCachedKline = ({
|
|
|
6514
6531
|
);
|
|
6515
6532
|
if (isTimescaleFallbackMode) {
|
|
6516
6533
|
isTimescaleFallbackMode = false;
|
|
6517
|
-
|
|
6534
|
+
import_logger11.logger.log("info", "TimescaleDB connection restored for kline cache");
|
|
6518
6535
|
}
|
|
6519
6536
|
return rowsToKline(dbData);
|
|
6520
6537
|
} catch (error) {
|
|
6521
6538
|
if (!isTimescaleFallbackMode) {
|
|
6522
6539
|
isTimescaleFallbackMode = true;
|
|
6523
|
-
|
|
6540
|
+
import_logger11.logger.log(
|
|
6524
6541
|
"warn",
|
|
6525
6542
|
"TimescaleDB unavailable for %s %s: %s. Falling back to exchange API.",
|
|
6526
6543
|
symbol,
|
|
@@ -6544,7 +6561,7 @@ var createTimescaleCachedKline = ({
|
|
|
6544
6561
|
|
|
6545
6562
|
// src/connectorRuntime.ts
|
|
6546
6563
|
var connectorRuntime = {
|
|
6547
|
-
logger:
|
|
6564
|
+
logger: import_logger12.logger,
|
|
6548
6565
|
resolveTradingAccount: import_tradingAccounts.resolveTradingAccount,
|
|
6549
6566
|
createCachedKline: createTimescaleCachedKline
|
|
6550
6567
|
};
|
|
@@ -6605,7 +6622,7 @@ var normalizeProviders = (providers, connectorName) => {
|
|
|
6605
6622
|
var registerProvider = (provider, connectorName, source, providerToConnectorName) => {
|
|
6606
6623
|
const existing = providerToConnectorName.get(provider);
|
|
6607
6624
|
if (existing && existing !== connectorName) {
|
|
6608
|
-
|
|
6625
|
+
import_logger13.logger.warn(
|
|
6609
6626
|
'Skip duplicate connector provider "%s" from %s: already mapped to %s',
|
|
6610
6627
|
provider,
|
|
6611
6628
|
source,
|
|
@@ -6618,11 +6635,11 @@ var registerProvider = (provider, connectorName, source, providerToConnectorName
|
|
|
6618
6635
|
var registerEntry = (entry, source, state) => {
|
|
6619
6636
|
const connectorName = String(entry?.name ?? "").trim();
|
|
6620
6637
|
if (!connectorName) {
|
|
6621
|
-
|
|
6638
|
+
import_logger13.logger.warn("Skip connector entry without name from %s", source);
|
|
6622
6639
|
return;
|
|
6623
6640
|
}
|
|
6624
6641
|
if (typeof entry.creator !== "function") {
|
|
6625
|
-
|
|
6642
|
+
import_logger13.logger.warn(
|
|
6626
6643
|
'Skip connector entry "%s" from %s: creator must be a function',
|
|
6627
6644
|
connectorName,
|
|
6628
6645
|
source
|
|
@@ -6634,7 +6651,7 @@ var registerEntry = (entry, source, state) => {
|
|
|
6634
6651
|
state.connectorCreators
|
|
6635
6652
|
);
|
|
6636
6653
|
if (existingByName) {
|
|
6637
|
-
|
|
6654
|
+
import_logger13.logger.warn(
|
|
6638
6655
|
'Skip duplicate connector "%s" from %s: already registered as %s',
|
|
6639
6656
|
connectorName,
|
|
6640
6657
|
source,
|
|
@@ -6709,7 +6726,7 @@ var ensureConnectorPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
|
|
|
6709
6726
|
);
|
|
6710
6727
|
const pluginDefinition = extractConnectorPluginDefinition(moduleExport);
|
|
6711
6728
|
if (!pluginDefinition) {
|
|
6712
|
-
|
|
6729
|
+
import_logger13.logger.warn(
|
|
6713
6730
|
'Skip connector plugin "%s": export { connectorEntries } is missing',
|
|
6714
6731
|
moduleName
|
|
6715
6732
|
);
|
|
@@ -6717,7 +6734,7 @@ var ensureConnectorPluginsLoaded = async (cwd = getTradejsProjectCwd()) => {
|
|
|
6717
6734
|
}
|
|
6718
6735
|
registerEntries2(pluginDefinition.connectorEntries, moduleName, state);
|
|
6719
6736
|
} catch (error) {
|
|
6720
|
-
|
|
6737
|
+
import_logger13.logger.warn(
|
|
6721
6738
|
'Failed to load connector plugin "%s": %s',
|
|
6722
6739
|
moduleName,
|
|
6723
6740
|
String(error)
|
|
@@ -8615,7 +8632,7 @@ var prepareTestingData = async (params) => {
|
|
|
8615
8632
|
throw new Error(`Unknown connector: ${connectorName}`);
|
|
8616
8633
|
}
|
|
8617
8634
|
if (!binanceConnector || !coinbaseConnector) {
|
|
8618
|
-
|
|
8635
|
+
import_logger14.logger.warn(
|
|
8619
8636
|
"Binance/Coinbase connectors are unavailable. Reusing %s for BTC references.",
|
|
8620
8637
|
connectorName
|
|
8621
8638
|
);
|
package/dist/backtest.mjs
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
buildMlPayload,
|
|
7
7
|
enrichSignalWithMarketContextStages
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6PIVDS4M.mjs";
|
|
9
9
|
import {
|
|
10
10
|
buildAiPayload,
|
|
11
11
|
getStrategyCreator
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IKRSNRP6.mjs";
|
|
13
13
|
import {
|
|
14
14
|
getTradejsProjectCwd
|
|
15
15
|
} from "./chunk-LZDXRXIU.mjs";
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
resolveStrategyPolicyProfile,
|
|
6
6
|
runAiPromptLocal,
|
|
7
7
|
setStrategyRuntimeFactory
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IKRSNRP6.mjs";
|
|
9
9
|
import {
|
|
10
10
|
getTradejsProjectCwd,
|
|
11
11
|
loadTradejsConfig
|
|
@@ -2774,7 +2774,7 @@ var executeEntryOrder = async ({
|
|
|
2774
2774
|
deploymentId: signal.deploymentId,
|
|
2775
2775
|
policyProfileId: signal.policyProfileId,
|
|
2776
2776
|
runtimeConfigId: signal.runtimeConfigId,
|
|
2777
|
-
|
|
2777
|
+
strategyRevision: signal.strategyRevision,
|
|
2778
2778
|
runtimeLineage: signal.runtimeLineage,
|
|
2779
2779
|
...signal.aiAnalysis ? { aiAnalysis: signal.aiAnalysis } : {}
|
|
2780
2780
|
});
|
|
@@ -3703,7 +3703,7 @@ var createStrategyRuntime = ({
|
|
|
3703
3703
|
deploymentId: requestedDeploymentId,
|
|
3704
3704
|
policyProfileId,
|
|
3705
3705
|
runtimeConfigId,
|
|
3706
|
-
|
|
3706
|
+
strategyRevision,
|
|
3707
3707
|
entriesPaused = false,
|
|
3708
3708
|
runtimeLineage,
|
|
3709
3709
|
runtimeConfigSnapshot,
|
|
@@ -4375,8 +4375,8 @@ var createStrategyRuntime = ({
|
|
|
4375
4375
|
signal.signalId = `${signal.signalId}:${runtimeConfigId}`;
|
|
4376
4376
|
}
|
|
4377
4377
|
}
|
|
4378
|
-
if (
|
|
4379
|
-
signal.
|
|
4378
|
+
if (strategyRevision) {
|
|
4379
|
+
signal.strategyRevision = strategyRevision;
|
|
4380
4380
|
}
|
|
4381
4381
|
if (decisionHookCtx.policyProfileId) {
|
|
4382
4382
|
signal.policyProfileId = decisionHookCtx.policyProfileId;
|
|
@@ -4489,7 +4489,7 @@ var createStrategyRuntime = ({
|
|
|
4489
4489
|
if (signal) {
|
|
4490
4490
|
signal.orderStatus = "skipped";
|
|
4491
4491
|
signal.orderSkipReason = skipReason;
|
|
4492
|
-
signal.
|
|
4492
|
+
signal.strategyRevision = strategyRevision;
|
|
4493
4493
|
}
|
|
4494
4494
|
return signal ?? skipReason;
|
|
4495
4495
|
}
|