@tradejs/node 1.0.8 → 1.0.10
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.d.mts +4 -1
- package/dist/ai.d.ts +4 -1
- package/dist/ai.js +601 -93
- package/dist/ai.mjs +5 -3
- package/dist/backtest.d.mts +26 -2
- package/dist/backtest.d.ts +26 -2
- package/dist/backtest.js +3368 -485
- package/dist/backtest.mjs +1839 -269
- package/dist/chunk-37VNDZVX.mjs +1040 -0
- package/dist/chunk-IUZML4RK.mjs +1136 -0
- package/dist/{chunk-WGOYR6AB.mjs → chunk-QVSMINLG.mjs} +1 -1
- package/dist/{chunk-JMDYEKIO.mjs → chunk-V3YMKE4I.mjs} +1 -1
- package/dist/{chunk-JU77QVJ3.mjs → chunk-WS5DYEVZ.mjs} +59 -5
- package/dist/cli.d.mts +13 -3
- package/dist/cli.d.ts +13 -3
- package/dist/cli.js +1016 -234
- package/dist/cli.mjs +338 -65
- package/dist/connectors.js +59 -5
- package/dist/connectors.mjs +2 -2
- package/dist/registry.js +59 -5
- package/dist/registry.mjs +2 -2
- package/dist/strategies.d.mts +29 -8
- package/dist/strategies.d.ts +29 -8
- package/dist/strategies.js +3417 -1285
- package/dist/strategies.mjs +892 -112
- package/package.json +6 -6
- package/dist/chunk-2JKX3DM7.mjs +0 -619
- package/dist/chunk-JRRG3YQG.mjs +0 -154
package/dist/connectors.js
CHANGED
|
@@ -50,7 +50,6 @@ var import_logger2 = require("@tradejs/infra/logger");
|
|
|
50
50
|
// src/tradejsConfig.ts
|
|
51
51
|
var import_fs = __toESM(require("fs"));
|
|
52
52
|
var import_path = __toESM(require("path"));
|
|
53
|
-
var import_module = require("module");
|
|
54
53
|
var import_url = require("url");
|
|
55
54
|
var import_config = require("@tradejs/core/config");
|
|
56
55
|
var import_logger = require("@tradejs/infra/logger");
|
|
@@ -66,6 +65,7 @@ var cachedByCwd = /* @__PURE__ */ new Map();
|
|
|
66
65
|
var announcedConfigFile = /* @__PURE__ */ new Set();
|
|
67
66
|
var tsNodeRegistered = false;
|
|
68
67
|
var tsconfigPathsRegisteredByCwd = /* @__PURE__ */ new Set();
|
|
68
|
+
var tsconfigPathMatchersByCwd = /* @__PURE__ */ new Map();
|
|
69
69
|
var getTradejsProjectCwd = (cwd) => {
|
|
70
70
|
const explicit = String(cwd ?? "").trim();
|
|
71
71
|
if (explicit) {
|
|
@@ -95,7 +95,14 @@ var normalizeConfig = (rawConfig) => {
|
|
|
95
95
|
...hooks ? { hooks } : {}
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
|
-
var
|
|
98
|
+
var getNodeCreateRequire = () => {
|
|
99
|
+
const builtinModule = process.getBuiltinModule?.("module");
|
|
100
|
+
if (typeof builtinModule?.createRequire === "function") {
|
|
101
|
+
return builtinModule.createRequire;
|
|
102
|
+
}
|
|
103
|
+
throw new TypeError("module.createRequire is not available");
|
|
104
|
+
};
|
|
105
|
+
var getRequireFn = (cwd = getTradejsProjectCwd()) => getNodeCreateRequire()(import_path.default.join(import_path.default.resolve(cwd), "__tradejs_loader__.js"));
|
|
99
106
|
var ensureTsNodeRegistered = async () => {
|
|
100
107
|
if (tsNodeRegistered) {
|
|
101
108
|
return;
|
|
@@ -105,8 +112,8 @@ var ensureTsNodeRegistered = async () => {
|
|
|
105
112
|
tsNode.register?.({
|
|
106
113
|
transpileOnly: true,
|
|
107
114
|
compilerOptions: {
|
|
108
|
-
module: "
|
|
109
|
-
moduleResolution: "
|
|
115
|
+
module: "Node16",
|
|
116
|
+
moduleResolution: "node16"
|
|
110
117
|
}
|
|
111
118
|
});
|
|
112
119
|
tsNodeRegistered = true;
|
|
@@ -133,6 +140,42 @@ var ensureTsconfigPathsRegistered = async (cwd = getTradejsProjectCwd()) => {
|
|
|
133
140
|
});
|
|
134
141
|
tsconfigPathsRegisteredByCwd.add(projectRoot);
|
|
135
142
|
};
|
|
143
|
+
var resolveTsconfigPathModule = async (moduleName, cwd = getTradejsProjectCwd()) => {
|
|
144
|
+
const projectRoot = getTradejsProjectCwd(cwd);
|
|
145
|
+
const cachedMatcher = tsconfigPathMatchersByCwd.get(projectRoot);
|
|
146
|
+
if (cachedMatcher) {
|
|
147
|
+
const resolved2 = cachedMatcher(moduleName);
|
|
148
|
+
return resolved2 || null;
|
|
149
|
+
}
|
|
150
|
+
const tsconfigPathsModule = await import("tsconfig-paths");
|
|
151
|
+
const loadConfig = tsconfigPathsModule.loadConfig;
|
|
152
|
+
const createMatchPath = tsconfigPathsModule.createMatchPath;
|
|
153
|
+
if (typeof loadConfig !== "function" || typeof createMatchPath !== "function") {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const loadedConfig = loadConfig(projectRoot);
|
|
157
|
+
if (loadedConfig.resultType !== "success") {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const matchPath = createMatchPath(
|
|
161
|
+
loadedConfig.absoluteBaseUrl,
|
|
162
|
+
loadedConfig.paths
|
|
163
|
+
);
|
|
164
|
+
const matcher = (requestedModule) => matchPath(requestedModule, void 0, import_fs.default.existsSync, [
|
|
165
|
+
".ts",
|
|
166
|
+
".tsx",
|
|
167
|
+
".mts",
|
|
168
|
+
".cts",
|
|
169
|
+
".js",
|
|
170
|
+
".jsx",
|
|
171
|
+
".mjs",
|
|
172
|
+
".cjs",
|
|
173
|
+
".json"
|
|
174
|
+
]) || "";
|
|
175
|
+
tsconfigPathMatchersByCwd.set(projectRoot, matcher);
|
|
176
|
+
const resolved = matcher(moduleName);
|
|
177
|
+
return resolved || null;
|
|
178
|
+
};
|
|
136
179
|
var toImportSpecifier = (moduleName) => {
|
|
137
180
|
if (moduleName.startsWith("file://")) {
|
|
138
181
|
return moduleName;
|
|
@@ -191,7 +234,18 @@ var importTradejsModule = async (moduleName, cwd = getTradejsProjectCwd()) => {
|
|
|
191
234
|
}
|
|
192
235
|
if (isBareModuleSpecifier(normalized)) {
|
|
193
236
|
await ensureTsconfigPathsRegistered(cwd);
|
|
194
|
-
|
|
237
|
+
try {
|
|
238
|
+
return requireFn(normalized);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
const resolvedByTsconfig = await resolveTsconfigPathModule(
|
|
241
|
+
normalized,
|
|
242
|
+
cwd
|
|
243
|
+
);
|
|
244
|
+
if (resolvedByTsconfig && resolvedByTsconfig !== normalized) {
|
|
245
|
+
return requireFn(resolvedByTsconfig);
|
|
246
|
+
}
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
195
249
|
}
|
|
196
250
|
try {
|
|
197
251
|
return await import(
|
package/dist/connectors.mjs
CHANGED
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
registerConnectorEntries,
|
|
11
11
|
resetConnectorRegistryCache,
|
|
12
12
|
resolveConnectorName
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-V3YMKE4I.mjs";
|
|
14
|
+
import "./chunk-WS5DYEVZ.mjs";
|
|
15
15
|
import "./chunk-6DZX6EAA.mjs";
|
|
16
16
|
export {
|
|
17
17
|
BUILTIN_CONNECTOR_NAMES,
|
package/dist/registry.js
CHANGED
|
@@ -51,7 +51,6 @@ var import_logger2 = require("@tradejs/infra/logger");
|
|
|
51
51
|
// src/tradejsConfig.ts
|
|
52
52
|
var import_fs = __toESM(require("fs"));
|
|
53
53
|
var import_path = __toESM(require("path"));
|
|
54
|
-
var import_module = require("module");
|
|
55
54
|
var import_url = require("url");
|
|
56
55
|
var import_config = require("@tradejs/core/config");
|
|
57
56
|
var import_logger = require("@tradejs/infra/logger");
|
|
@@ -67,6 +66,7 @@ var cachedByCwd = /* @__PURE__ */ new Map();
|
|
|
67
66
|
var announcedConfigFile = /* @__PURE__ */ new Set();
|
|
68
67
|
var tsNodeRegistered = false;
|
|
69
68
|
var tsconfigPathsRegisteredByCwd = /* @__PURE__ */ new Set();
|
|
69
|
+
var tsconfigPathMatchersByCwd = /* @__PURE__ */ new Map();
|
|
70
70
|
var getTradejsProjectCwd = (cwd) => {
|
|
71
71
|
const explicit = String(cwd ?? "").trim();
|
|
72
72
|
if (explicit) {
|
|
@@ -96,7 +96,14 @@ var normalizeConfig = (rawConfig) => {
|
|
|
96
96
|
...hooks ? { hooks } : {}
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
|
-
var
|
|
99
|
+
var getNodeCreateRequire = () => {
|
|
100
|
+
const builtinModule = process.getBuiltinModule?.("module");
|
|
101
|
+
if (typeof builtinModule?.createRequire === "function") {
|
|
102
|
+
return builtinModule.createRequire;
|
|
103
|
+
}
|
|
104
|
+
throw new TypeError("module.createRequire is not available");
|
|
105
|
+
};
|
|
106
|
+
var getRequireFn = (cwd = getTradejsProjectCwd()) => getNodeCreateRequire()(import_path.default.join(import_path.default.resolve(cwd), "__tradejs_loader__.js"));
|
|
100
107
|
var ensureTsNodeRegistered = async () => {
|
|
101
108
|
if (tsNodeRegistered) {
|
|
102
109
|
return;
|
|
@@ -106,8 +113,8 @@ var ensureTsNodeRegistered = async () => {
|
|
|
106
113
|
tsNode.register?.({
|
|
107
114
|
transpileOnly: true,
|
|
108
115
|
compilerOptions: {
|
|
109
|
-
module: "
|
|
110
|
-
moduleResolution: "
|
|
116
|
+
module: "Node16",
|
|
117
|
+
moduleResolution: "node16"
|
|
111
118
|
}
|
|
112
119
|
});
|
|
113
120
|
tsNodeRegistered = true;
|
|
@@ -134,6 +141,42 @@ var ensureTsconfigPathsRegistered = async (cwd = getTradejsProjectCwd()) => {
|
|
|
134
141
|
});
|
|
135
142
|
tsconfigPathsRegisteredByCwd.add(projectRoot);
|
|
136
143
|
};
|
|
144
|
+
var resolveTsconfigPathModule = async (moduleName, cwd = getTradejsProjectCwd()) => {
|
|
145
|
+
const projectRoot = getTradejsProjectCwd(cwd);
|
|
146
|
+
const cachedMatcher = tsconfigPathMatchersByCwd.get(projectRoot);
|
|
147
|
+
if (cachedMatcher) {
|
|
148
|
+
const resolved2 = cachedMatcher(moduleName);
|
|
149
|
+
return resolved2 || null;
|
|
150
|
+
}
|
|
151
|
+
const tsconfigPathsModule = await import("tsconfig-paths");
|
|
152
|
+
const loadConfig = tsconfigPathsModule.loadConfig;
|
|
153
|
+
const createMatchPath = tsconfigPathsModule.createMatchPath;
|
|
154
|
+
if (typeof loadConfig !== "function" || typeof createMatchPath !== "function") {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const loadedConfig = loadConfig(projectRoot);
|
|
158
|
+
if (loadedConfig.resultType !== "success") {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
const matchPath = createMatchPath(
|
|
162
|
+
loadedConfig.absoluteBaseUrl,
|
|
163
|
+
loadedConfig.paths
|
|
164
|
+
);
|
|
165
|
+
const matcher = (requestedModule) => matchPath(requestedModule, void 0, import_fs.default.existsSync, [
|
|
166
|
+
".ts",
|
|
167
|
+
".tsx",
|
|
168
|
+
".mts",
|
|
169
|
+
".cts",
|
|
170
|
+
".js",
|
|
171
|
+
".jsx",
|
|
172
|
+
".mjs",
|
|
173
|
+
".cjs",
|
|
174
|
+
".json"
|
|
175
|
+
]) || "";
|
|
176
|
+
tsconfigPathMatchersByCwd.set(projectRoot, matcher);
|
|
177
|
+
const resolved = matcher(moduleName);
|
|
178
|
+
return resolved || null;
|
|
179
|
+
};
|
|
137
180
|
var toImportSpecifier = (moduleName) => {
|
|
138
181
|
if (moduleName.startsWith("file://")) {
|
|
139
182
|
return moduleName;
|
|
@@ -192,7 +235,18 @@ var importTradejsModule = async (moduleName, cwd = getTradejsProjectCwd()) => {
|
|
|
192
235
|
}
|
|
193
236
|
if (isBareModuleSpecifier(normalized)) {
|
|
194
237
|
await ensureTsconfigPathsRegistered(cwd);
|
|
195
|
-
|
|
238
|
+
try {
|
|
239
|
+
return requireFn(normalized);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
const resolvedByTsconfig = await resolveTsconfigPathModule(
|
|
242
|
+
normalized,
|
|
243
|
+
cwd
|
|
244
|
+
);
|
|
245
|
+
if (resolvedByTsconfig && resolvedByTsconfig !== normalized) {
|
|
246
|
+
return requireFn(resolvedByTsconfig);
|
|
247
|
+
}
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
196
250
|
}
|
|
197
251
|
try {
|
|
198
252
|
return await import(
|
package/dist/registry.mjs
CHANGED
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
registerStrategyEntries,
|
|
12
12
|
resetStrategyRegistryCache,
|
|
13
13
|
strategies
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-QVSMINLG.mjs";
|
|
15
|
+
import "./chunk-WS5DYEVZ.mjs";
|
|
16
16
|
import "./chunk-6DZX6EAA.mjs";
|
|
17
17
|
export {
|
|
18
18
|
ensureIndicatorPluginsLoaded,
|
package/dist/strategies.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from '@tradejs/core/strategies';
|
|
2
|
-
export { DEFAULT_AI_MODEL, MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiPrompts, buildAiSystemPrompt, ensureAiStrategyPluginsLoaded, getDeterministicAiGateContext, getOpenRouterModelKwargs, resetAiRuntimeCache, runAiPrompt, runAiPromptLocal, trimSeriesDeep } from './ai.mjs';
|
|
2
|
+
export { DEFAULT_AI_MODEL, MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiPrompts, buildAiSystemPrompt, buildCompactAiIndicatorsSnapshot, ensureAiStrategyPluginsLoaded, getDeterministicAiGateContext, getOpenRouterModelKwargs, resetAiRuntimeCache, runAiPrompt, runAiPromptLocal, trimSeriesDeep } from './ai.mjs';
|
|
3
3
|
export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies } from './registry.mjs';
|
|
4
|
-
import { StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Connector, Tp, StrategyEntrySignalContext } from '@tradejs/types';
|
|
4
|
+
import { StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Connector, Tp, MarketFeatureInterval, StrategyEntrySignalContext } from '@tradejs/types';
|
|
5
5
|
import { TradejsConfigOnBarHook, TradejsConfigBeforeSignalsHook } from '@tradejs/core/config';
|
|
6
6
|
|
|
7
7
|
interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
|
|
@@ -10,8 +10,10 @@ interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
|
|
|
10
10
|
createCore: CreateStrategyCore<TConfig, any, any>;
|
|
11
11
|
manifest?: StrategyManifest;
|
|
12
12
|
strategyDirectory?: string;
|
|
13
|
+
detectorKey?: (config: TConfig) => string | undefined;
|
|
14
|
+
detectorNoSignalSkipReason?: string;
|
|
13
15
|
}
|
|
14
|
-
declare const createStrategyRuntime: <TConfig extends StrategyConfig>({ strategyName, defaults, createCore, manifest: staticManifest, strategyDirectory, }: CreateStrategyRuntimeParams<TConfig>) => StrategyCreator;
|
|
16
|
+
declare const createStrategyRuntime: <TConfig extends StrategyConfig>({ strategyName, defaults, createCore, manifest: staticManifest, strategyDirectory, detectorKey, detectorNoSignalSkipReason, }: CreateStrategyRuntimeParams<TConfig>) => StrategyCreator;
|
|
15
17
|
|
|
16
18
|
interface ResolveStrategyConfigParams<TConfig extends StrategyConfig> {
|
|
17
19
|
strategyName: string;
|
|
@@ -19,8 +21,9 @@ interface ResolveStrategyConfigParams<TConfig extends StrategyConfig> {
|
|
|
19
21
|
symbol: string;
|
|
20
22
|
baseConfig: Record<string, any>;
|
|
21
23
|
defaults: TConfig;
|
|
24
|
+
runtimeConfigId?: string;
|
|
22
25
|
}
|
|
23
|
-
declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategyName, userName, symbol, baseConfig, defaults, }: ResolveStrategyConfigParams<TConfig>) => Promise<{
|
|
26
|
+
declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategyName, userName, symbol, baseConfig, defaults, runtimeConfigId, }: ResolveStrategyConfigParams<TConfig>) => Promise<{
|
|
24
27
|
config: TConfig;
|
|
25
28
|
isConfigFromBacktest: boolean;
|
|
26
29
|
}>;
|
|
@@ -47,11 +50,28 @@ interface ExecuteEntryOrderParams {
|
|
|
47
50
|
timestamp: number;
|
|
48
51
|
takeProfits: Tp[];
|
|
49
52
|
stopLossPrice: number | null;
|
|
53
|
+
leverage?: number;
|
|
50
54
|
signal: Signal;
|
|
51
55
|
beforePlaceOrder?: () => Promise<void>;
|
|
52
56
|
recordRuntimeTrade?: boolean;
|
|
53
57
|
}
|
|
54
|
-
declare const executeEntryOrder: ({ connector, userName, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, recordRuntimeTrade, }: ExecuteEntryOrderParams) => Promise<number>;
|
|
58
|
+
declare const executeEntryOrder: ({ connector, userName, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, recordRuntimeTrade, leverage, }: ExecuteEntryOrderParams) => Promise<number>;
|
|
59
|
+
|
|
60
|
+
declare const enrichSignalWithBinanceMarketContext: (params: {
|
|
61
|
+
signal: Signal;
|
|
62
|
+
env: string;
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
interval?: MarketFeatureInterval;
|
|
65
|
+
breadthUniverse?: string;
|
|
66
|
+
maxAgeMs?: number;
|
|
67
|
+
}) => Promise<boolean>;
|
|
68
|
+
|
|
69
|
+
declare const enrichSignalWithCoinMarketCapContext: (params: {
|
|
70
|
+
signal: Signal;
|
|
71
|
+
env: string;
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
maxAgeMs?: number;
|
|
74
|
+
}) => Promise<boolean>;
|
|
55
75
|
|
|
56
76
|
type CloseOppositePositionsBeforeOpenOptions = {
|
|
57
77
|
connector: Connector;
|
|
@@ -67,9 +87,10 @@ declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCl
|
|
|
67
87
|
interface CreateMoveStopToBreakEvenOnBarHookParams {
|
|
68
88
|
isEnabled?: (config: StrategyConfig) => boolean;
|
|
69
89
|
triggerRiskMultiplier?: number;
|
|
90
|
+
stopProfitMultiplier?: number;
|
|
70
91
|
}
|
|
71
|
-
declare const createMoveStopToBreakEvenOnBarHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
72
|
-
declare const createMoveStopToBreakEvenAfterCoreDecisionHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
92
|
+
declare const createMoveStopToBreakEvenOnBarHook: ({ isEnabled, triggerRiskMultiplier, stopProfitMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
93
|
+
declare const createMoveStopToBreakEvenAfterCoreDecisionHook: ({ isEnabled, triggerRiskMultiplier, stopProfitMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
73
94
|
|
|
74
95
|
interface CreateCloseAllOnGlobalProfitBeforeSignalsHookParams {
|
|
75
96
|
getStrategyDefaultConfig?: (strategyName: string) => StrategyConfig | undefined;
|
|
@@ -77,4 +98,4 @@ interface CreateCloseAllOnGlobalProfitBeforeSignalsHookParams {
|
|
|
77
98
|
}
|
|
78
99
|
declare const createCloseAllOnGlobalProfitBeforeSignalsHook: ({ getStrategyDefaultConfig, profitRiskMultiplier, }?: CreateCloseAllOnGlobalProfitBeforeSignalsHookParams) => TradejsConfigBeforeSignalsHook;
|
|
79
100
|
|
|
80
|
-
export { closeOppositePositionsBeforeOpen, createCloseAllOnGlobalProfitBeforeSignalsHook, createCloseOppositeBeforePlaceOrderHook, createMoveStopToBreakEvenAfterCoreDecisionHook, createMoveStopToBreakEvenOnBarHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };
|
|
101
|
+
export { closeOppositePositionsBeforeOpen, createCloseAllOnGlobalProfitBeforeSignalsHook, createCloseOppositeBeforePlaceOrderHook, createMoveStopToBreakEvenAfterCoreDecisionHook, createMoveStopToBreakEvenOnBarHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithBinanceMarketContext, enrichSignalWithCoinMarketCapContext, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };
|
package/dist/strategies.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from '@tradejs/core/strategies';
|
|
2
|
-
export { DEFAULT_AI_MODEL, MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiPrompts, buildAiSystemPrompt, ensureAiStrategyPluginsLoaded, getDeterministicAiGateContext, getOpenRouterModelKwargs, resetAiRuntimeCache, runAiPrompt, runAiPromptLocal, trimSeriesDeep } from './ai.js';
|
|
2
|
+
export { DEFAULT_AI_MODEL, MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiPrompts, buildAiSystemPrompt, buildCompactAiIndicatorsSnapshot, ensureAiStrategyPluginsLoaded, getDeterministicAiGateContext, getOpenRouterModelKwargs, resetAiRuntimeCache, runAiPrompt, runAiPromptLocal, trimSeriesDeep } from './ai.js';
|
|
3
3
|
export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies } from './registry.js';
|
|
4
|
-
import { StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Connector, Tp, StrategyEntrySignalContext } from '@tradejs/types';
|
|
4
|
+
import { StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Connector, Tp, MarketFeatureInterval, StrategyEntrySignalContext } from '@tradejs/types';
|
|
5
5
|
import { TradejsConfigOnBarHook, TradejsConfigBeforeSignalsHook } from '@tradejs/core/config';
|
|
6
6
|
|
|
7
7
|
interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
|
|
@@ -10,8 +10,10 @@ interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
|
|
|
10
10
|
createCore: CreateStrategyCore<TConfig, any, any>;
|
|
11
11
|
manifest?: StrategyManifest;
|
|
12
12
|
strategyDirectory?: string;
|
|
13
|
+
detectorKey?: (config: TConfig) => string | undefined;
|
|
14
|
+
detectorNoSignalSkipReason?: string;
|
|
13
15
|
}
|
|
14
|
-
declare const createStrategyRuntime: <TConfig extends StrategyConfig>({ strategyName, defaults, createCore, manifest: staticManifest, strategyDirectory, }: CreateStrategyRuntimeParams<TConfig>) => StrategyCreator;
|
|
16
|
+
declare const createStrategyRuntime: <TConfig extends StrategyConfig>({ strategyName, defaults, createCore, manifest: staticManifest, strategyDirectory, detectorKey, detectorNoSignalSkipReason, }: CreateStrategyRuntimeParams<TConfig>) => StrategyCreator;
|
|
15
17
|
|
|
16
18
|
interface ResolveStrategyConfigParams<TConfig extends StrategyConfig> {
|
|
17
19
|
strategyName: string;
|
|
@@ -19,8 +21,9 @@ interface ResolveStrategyConfigParams<TConfig extends StrategyConfig> {
|
|
|
19
21
|
symbol: string;
|
|
20
22
|
baseConfig: Record<string, any>;
|
|
21
23
|
defaults: TConfig;
|
|
24
|
+
runtimeConfigId?: string;
|
|
22
25
|
}
|
|
23
|
-
declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategyName, userName, symbol, baseConfig, defaults, }: ResolveStrategyConfigParams<TConfig>) => Promise<{
|
|
26
|
+
declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategyName, userName, symbol, baseConfig, defaults, runtimeConfigId, }: ResolveStrategyConfigParams<TConfig>) => Promise<{
|
|
24
27
|
config: TConfig;
|
|
25
28
|
isConfigFromBacktest: boolean;
|
|
26
29
|
}>;
|
|
@@ -47,11 +50,28 @@ interface ExecuteEntryOrderParams {
|
|
|
47
50
|
timestamp: number;
|
|
48
51
|
takeProfits: Tp[];
|
|
49
52
|
stopLossPrice: number | null;
|
|
53
|
+
leverage?: number;
|
|
50
54
|
signal: Signal;
|
|
51
55
|
beforePlaceOrder?: () => Promise<void>;
|
|
52
56
|
recordRuntimeTrade?: boolean;
|
|
53
57
|
}
|
|
54
|
-
declare const executeEntryOrder: ({ connector, userName, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, recordRuntimeTrade, }: ExecuteEntryOrderParams) => Promise<number>;
|
|
58
|
+
declare const executeEntryOrder: ({ connector, userName, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, recordRuntimeTrade, leverage, }: ExecuteEntryOrderParams) => Promise<number>;
|
|
59
|
+
|
|
60
|
+
declare const enrichSignalWithBinanceMarketContext: (params: {
|
|
61
|
+
signal: Signal;
|
|
62
|
+
env: string;
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
interval?: MarketFeatureInterval;
|
|
65
|
+
breadthUniverse?: string;
|
|
66
|
+
maxAgeMs?: number;
|
|
67
|
+
}) => Promise<boolean>;
|
|
68
|
+
|
|
69
|
+
declare const enrichSignalWithCoinMarketCapContext: (params: {
|
|
70
|
+
signal: Signal;
|
|
71
|
+
env: string;
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
maxAgeMs?: number;
|
|
74
|
+
}) => Promise<boolean>;
|
|
55
75
|
|
|
56
76
|
type CloseOppositePositionsBeforeOpenOptions = {
|
|
57
77
|
connector: Connector;
|
|
@@ -67,9 +87,10 @@ declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCl
|
|
|
67
87
|
interface CreateMoveStopToBreakEvenOnBarHookParams {
|
|
68
88
|
isEnabled?: (config: StrategyConfig) => boolean;
|
|
69
89
|
triggerRiskMultiplier?: number;
|
|
90
|
+
stopProfitMultiplier?: number;
|
|
70
91
|
}
|
|
71
|
-
declare const createMoveStopToBreakEvenOnBarHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
72
|
-
declare const createMoveStopToBreakEvenAfterCoreDecisionHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
92
|
+
declare const createMoveStopToBreakEvenOnBarHook: ({ isEnabled, triggerRiskMultiplier, stopProfitMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
93
|
+
declare const createMoveStopToBreakEvenAfterCoreDecisionHook: ({ isEnabled, triggerRiskMultiplier, stopProfitMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
|
|
73
94
|
|
|
74
95
|
interface CreateCloseAllOnGlobalProfitBeforeSignalsHookParams {
|
|
75
96
|
getStrategyDefaultConfig?: (strategyName: string) => StrategyConfig | undefined;
|
|
@@ -77,4 +98,4 @@ interface CreateCloseAllOnGlobalProfitBeforeSignalsHookParams {
|
|
|
77
98
|
}
|
|
78
99
|
declare const createCloseAllOnGlobalProfitBeforeSignalsHook: ({ getStrategyDefaultConfig, profitRiskMultiplier, }?: CreateCloseAllOnGlobalProfitBeforeSignalsHookParams) => TradejsConfigBeforeSignalsHook;
|
|
79
100
|
|
|
80
|
-
export { closeOppositePositionsBeforeOpen, createCloseAllOnGlobalProfitBeforeSignalsHook, createCloseOppositeBeforePlaceOrderHook, createMoveStopToBreakEvenAfterCoreDecisionHook, createMoveStopToBreakEvenOnBarHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };
|
|
101
|
+
export { closeOppositePositionsBeforeOpen, createCloseAllOnGlobalProfitBeforeSignalsHook, createCloseOppositeBeforePlaceOrderHook, createMoveStopToBreakEvenAfterCoreDecisionHook, createMoveStopToBreakEvenOnBarHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithBinanceMarketContext, enrichSignalWithCoinMarketCapContext, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };
|