@tradejs/node 1.0.4 → 1.0.6
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/README.md +1 -1
- package/dist/ai.d.mts +31 -0
- package/dist/ai.d.ts +31 -0
- package/dist/ai.js +926 -0
- package/dist/ai.mjs +35 -0
- package/dist/backtest.js +408 -5687
- package/dist/backtest.mjs +331 -175
- package/dist/chunk-72FKXJ2I.mjs +473 -0
- package/dist/{chunk-P2ZUWONT.mjs → chunk-CGJ2UU6H.mjs} +1 -1
- package/dist/{chunk-ZY6ULOWK.mjs → chunk-EOZSJKUM.mjs} +1 -1
- package/dist/{chunk-7ICOZAKA.mjs → chunk-H6LIYHU4.mjs} +29 -11
- package/dist/{chunk-RBE4PZER.mjs → chunk-PQH5PAFC.mjs} +1 -1
- package/dist/chunk-SCMBUEGK.mjs +22 -0
- package/dist/{chunk-CIY64D57.mjs → chunk-XW5L327F.mjs} +1 -1
- package/dist/cli.d.mts +4 -4
- package/dist/cli.d.ts +4 -4
- package/dist/cli.js +1179 -207
- package/dist/cli.mjs +652 -147
- package/dist/connectors.js +1 -1
- package/dist/connectors.mjs +2 -2
- package/dist/constants.js +10 -1
- package/dist/constants.mjs +1 -1
- package/dist/pine.d.mts +10 -6
- package/dist/pine.d.ts +10 -6
- package/dist/pine.js +40 -18
- package/dist/pine.mjs +21 -13
- package/dist/registry.js +1 -1
- package/dist/registry.mjs +2 -2
- package/dist/strategies.d.mts +6 -12
- package/dist/strategies.d.ts +6 -12
- package/dist/strategies.js +426 -83
- package/dist/strategies.mjs +200 -34
- package/package.json +18 -5
- package/dist/ai-G7ATN4YL.mjs +0 -19
- package/dist/chunk-4ZPGZWO7.mjs +0 -13
- package/dist/chunk-LMAKIC3C.mjs +0 -294
package/dist/connectors.js
CHANGED
|
@@ -258,7 +258,7 @@ var loadTradejsConfig = async (cwd = getTradejsProjectCwd()) => {
|
|
|
258
258
|
cachedByCwd.set(cwd, config);
|
|
259
259
|
if (!announcedConfigFile.has(configFilePath)) {
|
|
260
260
|
announcedConfigFile.add(configFilePath);
|
|
261
|
-
import_logger.logger.log("
|
|
261
|
+
import_logger.logger.log("debug", "Loaded TradeJS config: %s", configFilePath);
|
|
262
262
|
}
|
|
263
263
|
return config;
|
|
264
264
|
} catch (error) {
|
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-XW5L327F.mjs";
|
|
14
|
+
import "./chunk-CGJ2UU6H.mjs";
|
|
15
15
|
import "./chunk-6DZX6EAA.mjs";
|
|
16
16
|
export {
|
|
17
17
|
BUILTIN_CONNECTOR_NAMES,
|
package/dist/constants.js
CHANGED
|
@@ -27,7 +27,16 @@ __export(constants_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(constants_exports);
|
|
29
29
|
var { NODE_ENV } = process.env;
|
|
30
|
-
var
|
|
30
|
+
var getPositiveIntegerEnv = (name, fallback) => {
|
|
31
|
+
const rawValue = process.env[name];
|
|
32
|
+
const parsedValue = Number(rawValue);
|
|
33
|
+
return Number.isInteger(parsedValue) && parsedValue > 0 ? parsedValue : fallback;
|
|
34
|
+
};
|
|
35
|
+
var DEFAULT_KLINE_CONCURRENCY_LIMIT = NODE_ENV === "production" ? 1 : 10;
|
|
36
|
+
var KLINE_CONCURRENCY_LIMIT = getPositiveIntegerEnv(
|
|
37
|
+
"KLINE_CONCURRENCY_LIMIT",
|
|
38
|
+
DEFAULT_KLINE_CONCURRENCY_LIMIT
|
|
39
|
+
);
|
|
31
40
|
var TG_CONCURRENCY_LIMIT = 3;
|
|
32
41
|
var AI_CONCURRENCY_LIMIT = 3;
|
|
33
42
|
var SCREENSHOT_CONCURRENCY_LIMIT = NODE_ENV === "production" ? 1 : 2;
|
package/dist/constants.mjs
CHANGED
package/dist/pine.d.mts
CHANGED
|
@@ -22,11 +22,15 @@ interface RunPineScriptParams {
|
|
|
22
22
|
limit?: number;
|
|
23
23
|
}
|
|
24
24
|
declare const getPinePlotSeries: (context: PineContextLike, plotName: string) => PinePlotPoint[];
|
|
25
|
-
declare const
|
|
26
|
-
declare const
|
|
27
|
-
declare const
|
|
28
|
-
declare const
|
|
29
|
-
declare const
|
|
25
|
+
declare const getLatestPineRawPlotValue: (context: PineContextLike, plotName: string) => unknown;
|
|
26
|
+
declare const getLatestPineNumberPlotValue: (context: PineContextLike, plotName: string) => number | null;
|
|
27
|
+
declare const getLatestPineBooleanPlotValue: (context: PineContextLike, plotName: string) => boolean;
|
|
28
|
+
declare const getLatestPineNumberPlotValues: <TPlotName extends string>(context: PineContextLike, plotNames: readonly TPlotName[]) => Record<TPlotName, number | null>;
|
|
29
|
+
declare const getLatestPineBooleanPlotValues: <TPlotName extends string>(context: PineContextLike, plotNames: readonly TPlotName[]) => Record<TPlotName, boolean>;
|
|
30
|
+
declare const toFiniteNumber: (value: unknown) => number | undefined;
|
|
31
|
+
declare const toPineBoolean: (value: unknown) => boolean;
|
|
32
|
+
declare const loadPineScriptFile: (filePath: string, fallback?: string) => string;
|
|
33
|
+
declare const createPineScriptLoader: (baseDir: string) => ((fileNameOrPath: string, fallback?: string) => string);
|
|
30
34
|
declare const runPineScript: ({ candles, script, symbol, timeframe, inputs, limit, }: RunPineScriptParams) => Promise<PineContextLike>;
|
|
31
35
|
|
|
32
|
-
export { type PineContextLike, type PinePlotPoint, type RunPineScriptParams,
|
|
36
|
+
export { type PineContextLike, type PinePlotPoint, type RunPineScriptParams, createPineScriptLoader, getLatestPineBooleanPlotValue, getLatestPineBooleanPlotValues, getLatestPineNumberPlotValue, getLatestPineNumberPlotValues, getLatestPineRawPlotValue, getPinePlotSeries, loadPineScriptFile, runPineScript, toFiniteNumber, toPineBoolean };
|
package/dist/pine.d.ts
CHANGED
|
@@ -22,11 +22,15 @@ interface RunPineScriptParams {
|
|
|
22
22
|
limit?: number;
|
|
23
23
|
}
|
|
24
24
|
declare const getPinePlotSeries: (context: PineContextLike, plotName: string) => PinePlotPoint[];
|
|
25
|
-
declare const
|
|
26
|
-
declare const
|
|
27
|
-
declare const
|
|
28
|
-
declare const
|
|
29
|
-
declare const
|
|
25
|
+
declare const getLatestPineRawPlotValue: (context: PineContextLike, plotName: string) => unknown;
|
|
26
|
+
declare const getLatestPineNumberPlotValue: (context: PineContextLike, plotName: string) => number | null;
|
|
27
|
+
declare const getLatestPineBooleanPlotValue: (context: PineContextLike, plotName: string) => boolean;
|
|
28
|
+
declare const getLatestPineNumberPlotValues: <TPlotName extends string>(context: PineContextLike, plotNames: readonly TPlotName[]) => Record<TPlotName, number | null>;
|
|
29
|
+
declare const getLatestPineBooleanPlotValues: <TPlotName extends string>(context: PineContextLike, plotNames: readonly TPlotName[]) => Record<TPlotName, boolean>;
|
|
30
|
+
declare const toFiniteNumber: (value: unknown) => number | undefined;
|
|
31
|
+
declare const toPineBoolean: (value: unknown) => boolean;
|
|
32
|
+
declare const loadPineScriptFile: (filePath: string, fallback?: string) => string;
|
|
33
|
+
declare const createPineScriptLoader: (baseDir: string) => ((fileNameOrPath: string, fallback?: string) => string);
|
|
30
34
|
declare const runPineScript: ({ candles, script, symbol, timeframe, inputs, limit, }: RunPineScriptParams) => Promise<PineContextLike>;
|
|
31
35
|
|
|
32
|
-
export { type PineContextLike, type PinePlotPoint, type RunPineScriptParams,
|
|
36
|
+
export { type PineContextLike, type PinePlotPoint, type RunPineScriptParams, createPineScriptLoader, getLatestPineBooleanPlotValue, getLatestPineBooleanPlotValues, getLatestPineNumberPlotValue, getLatestPineNumberPlotValues, getLatestPineRawPlotValue, getPinePlotSeries, loadPineScriptFile, runPineScript, toFiniteNumber, toPineBoolean };
|
package/dist/pine.js
CHANGED
|
@@ -30,13 +30,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/pine.ts
|
|
31
31
|
var pine_exports = {};
|
|
32
32
|
__export(pine_exports, {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
createPineScriptLoader: () => createPineScriptLoader,
|
|
34
|
+
getLatestPineBooleanPlotValue: () => getLatestPineBooleanPlotValue,
|
|
35
|
+
getLatestPineBooleanPlotValues: () => getLatestPineBooleanPlotValues,
|
|
36
|
+
getLatestPineNumberPlotValue: () => getLatestPineNumberPlotValue,
|
|
37
|
+
getLatestPineNumberPlotValues: () => getLatestPineNumberPlotValues,
|
|
38
|
+
getLatestPineRawPlotValue: () => getLatestPineRawPlotValue,
|
|
37
39
|
getPinePlotSeries: () => getPinePlotSeries,
|
|
38
|
-
|
|
39
|
-
runPineScript: () => runPineScript
|
|
40
|
+
loadPineScriptFile: () => loadPineScriptFile,
|
|
41
|
+
runPineScript: () => runPineScript,
|
|
42
|
+
toFiniteNumber: () => toFiniteNumber,
|
|
43
|
+
toPineBoolean: () => toPineBoolean
|
|
40
44
|
});
|
|
41
45
|
module.exports = __toCommonJS(pine_exports);
|
|
42
46
|
var import_node_fs = __toESM(require("fs"));
|
|
@@ -47,18 +51,32 @@ var getPinePlotSeries = (context, plotName) => {
|
|
|
47
51
|
const data = context?.plots?.[name]?.data;
|
|
48
52
|
return Array.isArray(data) ? data : [];
|
|
49
53
|
};
|
|
50
|
-
var
|
|
54
|
+
var getLatestPineRawPlotValue = (context, plotName) => {
|
|
51
55
|
const series = getPinePlotSeries(context, plotName);
|
|
52
56
|
if (!series.length) return void 0;
|
|
53
57
|
return series[series.length - 1]?.value;
|
|
54
58
|
};
|
|
55
|
-
var
|
|
59
|
+
var getLatestPineNumberPlotValue = (context, plotName) => toFiniteNumber(getLatestPineRawPlotValue(context, plotName)) ?? null;
|
|
60
|
+
var getLatestPineBooleanPlotValue = (context, plotName) => toPineBoolean(getLatestPineRawPlotValue(context, plotName));
|
|
61
|
+
var getLatestPineNumberPlotValues = (context, plotNames) => Object.fromEntries(
|
|
62
|
+
plotNames.map((plotName) => [
|
|
63
|
+
plotName,
|
|
64
|
+
getLatestPineNumberPlotValue(context, plotName)
|
|
65
|
+
])
|
|
66
|
+
);
|
|
67
|
+
var getLatestPineBooleanPlotValues = (context, plotNames) => Object.fromEntries(
|
|
68
|
+
plotNames.map((plotName) => [
|
|
69
|
+
plotName,
|
|
70
|
+
getLatestPineBooleanPlotValue(context, plotName)
|
|
71
|
+
])
|
|
72
|
+
);
|
|
73
|
+
var toFiniteNumber = (value) => {
|
|
56
74
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
57
75
|
return void 0;
|
|
58
76
|
}
|
|
59
77
|
return value;
|
|
60
78
|
};
|
|
61
|
-
var
|
|
79
|
+
var toPineBoolean = (value) => {
|
|
62
80
|
if (typeof value === "boolean") return value;
|
|
63
81
|
if (typeof value === "number") return Number.isFinite(value) && value !== 0;
|
|
64
82
|
return false;
|
|
@@ -68,7 +86,7 @@ var loadPinets = () => {
|
|
|
68
86
|
const cjsPath = resolvedPath.includes("pinets.min.browser") ? resolvedPath.replace(/pinets\.min\.browser(\.es)?\.js$/, "pinets.min.cjs") : resolvedPath;
|
|
69
87
|
return require(cjsPath);
|
|
70
88
|
};
|
|
71
|
-
var
|
|
89
|
+
var loadPineScriptFile = (filePath, fallback = "") => {
|
|
72
90
|
const resolvedPath = String(filePath || "").trim();
|
|
73
91
|
if (!resolvedPath) {
|
|
74
92
|
return fallback;
|
|
@@ -79,7 +97,7 @@ var loadPineScript = (filePath, fallback = "") => {
|
|
|
79
97
|
return fallback;
|
|
80
98
|
}
|
|
81
99
|
};
|
|
82
|
-
var
|
|
100
|
+
var createPineScriptLoader = (baseDir) => {
|
|
83
101
|
const resolvedBaseDir = import_node_path.default.resolve(baseDir);
|
|
84
102
|
return (fileNameOrPath, fallback = "") => {
|
|
85
103
|
const rawPath = String(fileNameOrPath || "").trim();
|
|
@@ -87,7 +105,7 @@ var createLoadPineScript = (baseDir) => {
|
|
|
87
105
|
return fallback;
|
|
88
106
|
}
|
|
89
107
|
const resolvedPath = import_node_path.default.isAbsolute(rawPath) ? rawPath : import_node_path.default.resolve(resolvedBaseDir, rawPath);
|
|
90
|
-
return
|
|
108
|
+
return loadPineScriptFile(resolvedPath, fallback);
|
|
91
109
|
};
|
|
92
110
|
};
|
|
93
111
|
var MINUTE_MS = 6e4;
|
|
@@ -145,11 +163,15 @@ var runPineScript = async ({
|
|
|
145
163
|
};
|
|
146
164
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
165
|
0 && (module.exports = {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
166
|
+
createPineScriptLoader,
|
|
167
|
+
getLatestPineBooleanPlotValue,
|
|
168
|
+
getLatestPineBooleanPlotValues,
|
|
169
|
+
getLatestPineNumberPlotValue,
|
|
170
|
+
getLatestPineNumberPlotValues,
|
|
171
|
+
getLatestPineRawPlotValue,
|
|
152
172
|
getPinePlotSeries,
|
|
153
|
-
|
|
154
|
-
runPineScript
|
|
173
|
+
loadPineScriptFile,
|
|
174
|
+
runPineScript,
|
|
175
|
+
toFiniteNumber,
|
|
176
|
+
toPineBoolean
|
|
155
177
|
});
|
package/dist/pine.mjs
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
createPineScriptLoader,
|
|
3
|
+
getLatestPineBooleanPlotValue,
|
|
4
|
+
getLatestPineBooleanPlotValues,
|
|
5
|
+
getLatestPineNumberPlotValue,
|
|
6
|
+
getLatestPineNumberPlotValues,
|
|
7
|
+
getLatestPineRawPlotValue,
|
|
6
8
|
getPinePlotSeries,
|
|
7
|
-
|
|
8
|
-
runPineScript
|
|
9
|
-
|
|
9
|
+
loadPineScriptFile,
|
|
10
|
+
runPineScript,
|
|
11
|
+
toFiniteNumber,
|
|
12
|
+
toPineBoolean
|
|
13
|
+
} from "./chunk-H6LIYHU4.mjs";
|
|
10
14
|
import "./chunk-6DZX6EAA.mjs";
|
|
11
15
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
createPineScriptLoader,
|
|
17
|
+
getLatestPineBooleanPlotValue,
|
|
18
|
+
getLatestPineBooleanPlotValues,
|
|
19
|
+
getLatestPineNumberPlotValue,
|
|
20
|
+
getLatestPineNumberPlotValues,
|
|
21
|
+
getLatestPineRawPlotValue,
|
|
16
22
|
getPinePlotSeries,
|
|
17
|
-
|
|
18
|
-
runPineScript
|
|
23
|
+
loadPineScriptFile,
|
|
24
|
+
runPineScript,
|
|
25
|
+
toFiniteNumber,
|
|
26
|
+
toPineBoolean
|
|
19
27
|
};
|
package/dist/registry.js
CHANGED
|
@@ -259,7 +259,7 @@ var loadTradejsConfig = async (cwd = getTradejsProjectCwd()) => {
|
|
|
259
259
|
cachedByCwd.set(cwd, config);
|
|
260
260
|
if (!announcedConfigFile.has(configFilePath)) {
|
|
261
261
|
announcedConfigFile.add(configFilePath);
|
|
262
|
-
import_logger.logger.log("
|
|
262
|
+
import_logger.logger.log("debug", "Loaded TradeJS config: %s", configFilePath);
|
|
263
263
|
}
|
|
264
264
|
return config;
|
|
265
265
|
} catch (error) {
|
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-EOZSJKUM.mjs";
|
|
15
|
+
import "./chunk-CGJ2UU6H.mjs";
|
|
16
16
|
import "./chunk-6DZX6EAA.mjs";
|
|
17
17
|
export {
|
|
18
18
|
ensureIndicatorPluginsLoaded,
|
package/dist/strategies.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Connector, StrategyEntrySignalContext,
|
|
1
|
+
import { Connector, StrategyEntrySignalContext, StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Tp } from '@tradejs/types';
|
|
2
2
|
export * from '@tradejs/core/strategies';
|
|
3
|
+
export { DEFAULT_AI_MODEL, MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiPrompts, buildAiSystemPrompt, ensureAiStrategyPluginsLoaded, getDeterministicAiGateContext, getOpenRouterModelKwargs, resetAiRuntimeCache, runAiPrompt, runAiPromptLocal, trimSeriesDeep } from './ai.mjs';
|
|
3
4
|
export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies } from './registry.mjs';
|
|
4
5
|
|
|
5
6
|
type CloseOppositePositionsBeforeOpenOptions = {
|
|
@@ -8,14 +9,6 @@ type CloseOppositePositionsBeforeOpenOptions = {
|
|
|
8
9
|
};
|
|
9
10
|
declare const closeOppositePositionsBeforeOpen: ({ connector, entryContext, }: CloseOppositePositionsBeforeOpenOptions) => Promise<void>;
|
|
10
11
|
|
|
11
|
-
declare const MAX_AI_SERIES_POINTS = 5;
|
|
12
|
-
declare const trimSeriesDeep: (value: any) => any;
|
|
13
|
-
|
|
14
|
-
declare const buildAiSystemPrompt: (signal?: Signal) => string;
|
|
15
|
-
declare const buildAiPayload: (signal: Signal) => AiPayload;
|
|
16
|
-
declare const buildAiHumanPrompt: (signal: Signal, payload?: AiPayload) => string;
|
|
17
|
-
declare const askAI: (signal: Signal) => Promise<Partial<SignalAnalysis>>;
|
|
18
|
-
|
|
19
12
|
interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
|
|
20
13
|
strategyName: string;
|
|
21
14
|
defaults: TConfig;
|
|
@@ -39,6 +32,7 @@ declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategy
|
|
|
39
32
|
|
|
40
33
|
interface EnrichSignalWithMlAiParams {
|
|
41
34
|
signal: Signal;
|
|
35
|
+
userName?: string;
|
|
42
36
|
symbol: string;
|
|
43
37
|
direction: Direction;
|
|
44
38
|
env: string;
|
|
@@ -46,8 +40,8 @@ interface EnrichSignalWithMlAiParams {
|
|
|
46
40
|
ai?: StrategyRuntimeAiOptions;
|
|
47
41
|
}
|
|
48
42
|
declare const enrichSignalWithMl: ({ signal, env, ml, }: Pick<EnrichSignalWithMlAiParams, "signal" | "env" | "ml">) => Promise<void>;
|
|
49
|
-
declare const enrichSignalWithAi: ({ signal, symbol, direction, env, ai, }: Pick<EnrichSignalWithMlAiParams, "signal" | "symbol" | "direction" | "env" | "ai">) => Promise<number | undefined>;
|
|
50
|
-
declare const enrichSignalWithMlAi: ({ signal, symbol, direction, env, ml, ai, }: EnrichSignalWithMlAiParams) => Promise<number | undefined>;
|
|
43
|
+
declare const enrichSignalWithAi: ({ signal, symbol, userName, direction, env, ai, }: Pick<EnrichSignalWithMlAiParams, "signal" | "userName" | "symbol" | "direction" | "env" | "ai">) => Promise<number | undefined>;
|
|
44
|
+
declare const enrichSignalWithMlAi: ({ signal, userName, symbol, direction, env, ml, ai, }: EnrichSignalWithMlAiParams) => Promise<number | undefined>;
|
|
51
45
|
interface ExecuteEntryOrderParams {
|
|
52
46
|
connector: Connector;
|
|
53
47
|
symbol: string;
|
|
@@ -68,4 +62,4 @@ interface CreateCloseOppositeBeforePlaceOrderHookParams {
|
|
|
68
62
|
}
|
|
69
63
|
declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCloseOppositeBeforePlaceOrderHookParams) => BeforePlaceOrderHook;
|
|
70
64
|
|
|
71
|
-
export {
|
|
65
|
+
export { closeOppositePositionsBeforeOpen, createCloseOppositeBeforePlaceOrderHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };
|
package/dist/strategies.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Connector, StrategyEntrySignalContext,
|
|
1
|
+
import { Connector, StrategyEntrySignalContext, StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Tp } from '@tradejs/types';
|
|
2
2
|
export * from '@tradejs/core/strategies';
|
|
3
|
+
export { DEFAULT_AI_MODEL, MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiPrompts, buildAiSystemPrompt, ensureAiStrategyPluginsLoaded, getDeterministicAiGateContext, getOpenRouterModelKwargs, resetAiRuntimeCache, runAiPrompt, runAiPromptLocal, trimSeriesDeep } from './ai.js';
|
|
3
4
|
export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies } from './registry.js';
|
|
4
5
|
|
|
5
6
|
type CloseOppositePositionsBeforeOpenOptions = {
|
|
@@ -8,14 +9,6 @@ type CloseOppositePositionsBeforeOpenOptions = {
|
|
|
8
9
|
};
|
|
9
10
|
declare const closeOppositePositionsBeforeOpen: ({ connector, entryContext, }: CloseOppositePositionsBeforeOpenOptions) => Promise<void>;
|
|
10
11
|
|
|
11
|
-
declare const MAX_AI_SERIES_POINTS = 5;
|
|
12
|
-
declare const trimSeriesDeep: (value: any) => any;
|
|
13
|
-
|
|
14
|
-
declare const buildAiSystemPrompt: (signal?: Signal) => string;
|
|
15
|
-
declare const buildAiPayload: (signal: Signal) => AiPayload;
|
|
16
|
-
declare const buildAiHumanPrompt: (signal: Signal, payload?: AiPayload) => string;
|
|
17
|
-
declare const askAI: (signal: Signal) => Promise<Partial<SignalAnalysis>>;
|
|
18
|
-
|
|
19
12
|
interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
|
|
20
13
|
strategyName: string;
|
|
21
14
|
defaults: TConfig;
|
|
@@ -39,6 +32,7 @@ declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategy
|
|
|
39
32
|
|
|
40
33
|
interface EnrichSignalWithMlAiParams {
|
|
41
34
|
signal: Signal;
|
|
35
|
+
userName?: string;
|
|
42
36
|
symbol: string;
|
|
43
37
|
direction: Direction;
|
|
44
38
|
env: string;
|
|
@@ -46,8 +40,8 @@ interface EnrichSignalWithMlAiParams {
|
|
|
46
40
|
ai?: StrategyRuntimeAiOptions;
|
|
47
41
|
}
|
|
48
42
|
declare const enrichSignalWithMl: ({ signal, env, ml, }: Pick<EnrichSignalWithMlAiParams, "signal" | "env" | "ml">) => Promise<void>;
|
|
49
|
-
declare const enrichSignalWithAi: ({ signal, symbol, direction, env, ai, }: Pick<EnrichSignalWithMlAiParams, "signal" | "symbol" | "direction" | "env" | "ai">) => Promise<number | undefined>;
|
|
50
|
-
declare const enrichSignalWithMlAi: ({ signal, symbol, direction, env, ml, ai, }: EnrichSignalWithMlAiParams) => Promise<number | undefined>;
|
|
43
|
+
declare const enrichSignalWithAi: ({ signal, symbol, userName, direction, env, ai, }: Pick<EnrichSignalWithMlAiParams, "signal" | "userName" | "symbol" | "direction" | "env" | "ai">) => Promise<number | undefined>;
|
|
44
|
+
declare const enrichSignalWithMlAi: ({ signal, userName, symbol, direction, env, ml, ai, }: EnrichSignalWithMlAiParams) => Promise<number | undefined>;
|
|
51
45
|
interface ExecuteEntryOrderParams {
|
|
52
46
|
connector: Connector;
|
|
53
47
|
symbol: string;
|
|
@@ -68,4 +62,4 @@ interface CreateCloseOppositeBeforePlaceOrderHookParams {
|
|
|
68
62
|
}
|
|
69
63
|
declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCloseOppositeBeforePlaceOrderHookParams) => BeforePlaceOrderHook;
|
|
70
64
|
|
|
71
|
-
export {
|
|
65
|
+
export { closeOppositePositionsBeforeOpen, createCloseOppositeBeforePlaceOrderHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };
|