@tradejs/node 1.0.5 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,6 +52,7 @@ var import_fs = __toESM(require("fs"));
52
52
  var import_path = __toESM(require("path"));
53
53
  var import_module = require("module");
54
54
  var import_url = require("url");
55
+ var import_config = require("@tradejs/core/config");
55
56
  var import_logger = require("@tradejs/infra/logger");
56
57
  var CONFIG_FILE_NAMES = [
57
58
  "tradejs.config.ts",
@@ -84,10 +85,14 @@ var normalizeConfig = (rawConfig) => {
84
85
  const strategies = Array.isArray(config.strategies) ? config.strategies.map((value) => String(value || "").trim()).filter(Boolean) : [];
85
86
  const indicators = Array.isArray(config.indicators) ? config.indicators.map((value) => String(value || "").trim()).filter(Boolean) : [];
86
87
  const connectors = Array.isArray(config.connectors) ? config.connectors.map((value) => String(value || "").trim()).filter(Boolean) : [];
88
+ const hooks = (0, import_config.normalizeTradejsConfigHooks)(
89
+ config.hooks
90
+ );
87
91
  return {
88
92
  strategies,
89
93
  indicators,
90
- connectors
94
+ connectors,
95
+ ...hooks ? { hooks } : {}
91
96
  };
92
97
  };
93
98
  var getRequireFn = (cwd = getTradejsProjectCwd()) => (0, import_module.createRequire)(import_path.default.join(import_path.default.resolve(cwd), "__tradejs_loader__.js"));
@@ -258,7 +263,7 @@ var loadTradejsConfig = async (cwd = getTradejsProjectCwd()) => {
258
263
  cachedByCwd.set(cwd, config);
259
264
  if (!announcedConfigFile.has(configFilePath)) {
260
265
  announcedConfigFile.add(configFilePath);
261
- import_logger.logger.log("info", "Loaded TradeJS config: %s", configFilePath);
266
+ import_logger.logger.log("debug", "Loaded TradeJS config: %s", configFilePath);
262
267
  }
263
268
  return config;
264
269
  } catch (error) {
@@ -10,8 +10,8 @@ import {
10
10
  registerConnectorEntries,
11
11
  resetConnectorRegistryCache,
12
12
  resolveConnectorName
13
- } from "./chunk-CIY64D57.mjs";
14
- import "./chunk-P2ZUWONT.mjs";
13
+ } from "./chunk-JMDYEKIO.mjs";
14
+ import "./chunk-JU77QVJ3.mjs";
15
15
  import "./chunk-6DZX6EAA.mjs";
16
16
  export {
17
17
  BUILTIN_CONNECTOR_NAMES,
package/dist/constants.js CHANGED
@@ -32,7 +32,7 @@ var getPositiveIntegerEnv = (name, fallback) => {
32
32
  const parsedValue = Number(rawValue);
33
33
  return Number.isInteger(parsedValue) && parsedValue > 0 ? parsedValue : fallback;
34
34
  };
35
- var DEFAULT_KLINE_CONCURRENCY_LIMIT = NODE_ENV === "production" ? 1 : 10;
35
+ var DEFAULT_KLINE_CONCURRENCY_LIMIT = NODE_ENV === "production" ? 5 : 10;
36
36
  var KLINE_CONCURRENCY_LIMIT = getPositiveIntegerEnv(
37
37
  "KLINE_CONCURRENCY_LIMIT",
38
38
  DEFAULT_KLINE_CONCURRENCY_LIMIT
@@ -3,7 +3,7 @@ import {
3
3
  KLINE_CONCURRENCY_LIMIT,
4
4
  SCREENSHOT_CONCURRENCY_LIMIT,
5
5
  TG_CONCURRENCY_LIMIT
6
- } from "./chunk-SCMBUEGK.mjs";
6
+ } from "./chunk-KMJQQ53K.mjs";
7
7
  import "./chunk-6DZX6EAA.mjs";
8
8
  export {
9
9
  AI_CONCURRENCY_LIMIT,
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 getLatestPinePlotValue: (context: PineContextLike, plotName: string) => unknown;
26
- declare const asFiniteNumber: (value: unknown) => number | undefined;
27
- declare const asPineBoolean: (value: unknown) => boolean;
28
- declare const loadPineScript: (filePath: string, fallback?: string) => string;
29
- declare const createLoadPineScript: (baseDir: string) => ((fileNameOrPath: string, fallback?: string) => string);
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, asFiniteNumber, asPineBoolean, createLoadPineScript, getLatestPinePlotValue, getPinePlotSeries, loadPineScript, runPineScript };
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 getLatestPinePlotValue: (context: PineContextLike, plotName: string) => unknown;
26
- declare const asFiniteNumber: (value: unknown) => number | undefined;
27
- declare const asPineBoolean: (value: unknown) => boolean;
28
- declare const loadPineScript: (filePath: string, fallback?: string) => string;
29
- declare const createLoadPineScript: (baseDir: string) => ((fileNameOrPath: string, fallback?: string) => string);
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, asFiniteNumber, asPineBoolean, createLoadPineScript, getLatestPinePlotValue, getPinePlotSeries, loadPineScript, runPineScript };
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
- asFiniteNumber: () => asFiniteNumber,
34
- asPineBoolean: () => asPineBoolean,
35
- createLoadPineScript: () => createLoadPineScript,
36
- getLatestPinePlotValue: () => getLatestPinePlotValue,
33
+ createPineScriptLoader: () => createPineScriptLoader,
34
+ getLatestPineBooleanPlotValue: () => getLatestPineBooleanPlotValue,
35
+ getLatestPineBooleanPlotValues: () => getLatestPineBooleanPlotValues,
36
+ getLatestPineNumberPlotValue: () => getLatestPineNumberPlotValue,
37
+ getLatestPineNumberPlotValues: () => getLatestPineNumberPlotValues,
38
+ getLatestPineRawPlotValue: () => getLatestPineRawPlotValue,
37
39
  getPinePlotSeries: () => getPinePlotSeries,
38
- loadPineScript: () => loadPineScript,
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 getLatestPinePlotValue = (context, plotName) => {
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 asFiniteNumber = (value) => {
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 asPineBoolean = (value) => {
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 loadPineScript = (filePath, fallback = "") => {
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 createLoadPineScript = (baseDir) => {
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 loadPineScript(resolvedPath, fallback);
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
- asFiniteNumber,
149
- asPineBoolean,
150
- createLoadPineScript,
151
- getLatestPinePlotValue,
166
+ createPineScriptLoader,
167
+ getLatestPineBooleanPlotValue,
168
+ getLatestPineBooleanPlotValues,
169
+ getLatestPineNumberPlotValue,
170
+ getLatestPineNumberPlotValues,
171
+ getLatestPineRawPlotValue,
152
172
  getPinePlotSeries,
153
- loadPineScript,
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
- asFiniteNumber,
3
- asPineBoolean,
4
- createLoadPineScript,
5
- getLatestPinePlotValue,
2
+ createPineScriptLoader,
3
+ getLatestPineBooleanPlotValue,
4
+ getLatestPineBooleanPlotValues,
5
+ getLatestPineNumberPlotValue,
6
+ getLatestPineNumberPlotValues,
7
+ getLatestPineRawPlotValue,
6
8
  getPinePlotSeries,
7
- loadPineScript,
8
- runPineScript
9
- } from "./chunk-7ICOZAKA.mjs";
9
+ loadPineScriptFile,
10
+ runPineScript,
11
+ toFiniteNumber,
12
+ toPineBoolean
13
+ } from "./chunk-H6LIYHU4.mjs";
10
14
  import "./chunk-6DZX6EAA.mjs";
11
15
  export {
12
- asFiniteNumber,
13
- asPineBoolean,
14
- createLoadPineScript,
15
- getLatestPinePlotValue,
16
+ createPineScriptLoader,
17
+ getLatestPineBooleanPlotValue,
18
+ getLatestPineBooleanPlotValues,
19
+ getLatestPineNumberPlotValue,
20
+ getLatestPineNumberPlotValues,
21
+ getLatestPineRawPlotValue,
16
22
  getPinePlotSeries,
17
- loadPineScript,
18
- runPineScript
23
+ loadPineScriptFile,
24
+ runPineScript,
25
+ toFiniteNumber,
26
+ toPineBoolean
19
27
  };
package/dist/registry.js CHANGED
@@ -53,6 +53,7 @@ var import_fs = __toESM(require("fs"));
53
53
  var import_path = __toESM(require("path"));
54
54
  var import_module = require("module");
55
55
  var import_url = require("url");
56
+ var import_config = require("@tradejs/core/config");
56
57
  var import_logger = require("@tradejs/infra/logger");
57
58
  var CONFIG_FILE_NAMES = [
58
59
  "tradejs.config.ts",
@@ -85,10 +86,14 @@ var normalizeConfig = (rawConfig) => {
85
86
  const strategies2 = Array.isArray(config.strategies) ? config.strategies.map((value) => String(value || "").trim()).filter(Boolean) : [];
86
87
  const indicators = Array.isArray(config.indicators) ? config.indicators.map((value) => String(value || "").trim()).filter(Boolean) : [];
87
88
  const connectors = Array.isArray(config.connectors) ? config.connectors.map((value) => String(value || "").trim()).filter(Boolean) : [];
89
+ const hooks = (0, import_config.normalizeTradejsConfigHooks)(
90
+ config.hooks
91
+ );
88
92
  return {
89
93
  strategies: strategies2,
90
94
  indicators,
91
- connectors
95
+ connectors,
96
+ ...hooks ? { hooks } : {}
92
97
  };
93
98
  };
94
99
  var getRequireFn = (cwd = getTradejsProjectCwd()) => (0, import_module.createRequire)(import_path.default.join(import_path.default.resolve(cwd), "__tradejs_loader__.js"));
@@ -259,7 +264,7 @@ var loadTradejsConfig = async (cwd = getTradejsProjectCwd()) => {
259
264
  cachedByCwd.set(cwd, config);
260
265
  if (!announcedConfigFile.has(configFilePath)) {
261
266
  announcedConfigFile.add(configFilePath);
262
- import_logger.logger.log("info", "Loaded TradeJS config: %s", configFilePath);
267
+ import_logger.logger.log("debug", "Loaded TradeJS config: %s", configFilePath);
263
268
  }
264
269
  return config;
265
270
  } catch (error) {
package/dist/registry.mjs CHANGED
@@ -11,8 +11,8 @@ import {
11
11
  registerStrategyEntries,
12
12
  resetStrategyRegistryCache,
13
13
  strategies
14
- } from "./chunk-ZY6ULOWK.mjs";
15
- import "./chunk-P2ZUWONT.mjs";
14
+ } from "./chunk-WGOYR6AB.mjs";
15
+ import "./chunk-JU77QVJ3.mjs";
16
16
  import "./chunk-6DZX6EAA.mjs";
17
17
  export {
18
18
  ensureIndicatorPluginsLoaded,
@@ -1,20 +1,8 @@
1
- import { Connector, StrategyEntrySignalContext, Signal, SignalAnalysis, AiPayload, StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Tp } from '@tradejs/types';
2
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';
3
3
  export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies } from './registry.mjs';
4
-
5
- type CloseOppositePositionsBeforeOpenOptions = {
6
- connector: Connector;
7
- entryContext: StrategyEntrySignalContext;
8
- };
9
- declare const closeOppositePositionsBeforeOpen: ({ connector, entryContext, }: CloseOppositePositionsBeforeOpenOptions) => Promise<void>;
10
-
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>>;
4
+ import { StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Connector, Tp, StrategyEntrySignalContext } from '@tradejs/types';
5
+ import { TradejsConfigOnBarHook, TradejsConfigBeforeSignalsHook } from '@tradejs/core/config';
18
6
 
19
7
  interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
20
8
  strategyName: string;
@@ -39,6 +27,7 @@ declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategy
39
27
 
40
28
  interface EnrichSignalWithMlAiParams {
41
29
  signal: Signal;
30
+ userName?: string;
42
31
  symbol: string;
43
32
  direction: Direction;
44
33
  env: string;
@@ -46,10 +35,11 @@ interface EnrichSignalWithMlAiParams {
46
35
  ai?: StrategyRuntimeAiOptions;
47
36
  }
48
37
  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>;
38
+ declare const enrichSignalWithAi: ({ signal, symbol, userName, direction, env, ai, }: Pick<EnrichSignalWithMlAiParams, "signal" | "userName" | "symbol" | "direction" | "env" | "ai">) => Promise<number | undefined>;
39
+ declare const enrichSignalWithMlAi: ({ signal, userName, symbol, direction, env, ml, ai, }: EnrichSignalWithMlAiParams) => Promise<number | undefined>;
51
40
  interface ExecuteEntryOrderParams {
52
41
  connector: Connector;
42
+ userName?: string;
53
43
  symbol: string;
54
44
  direction: Direction;
55
45
  qty: number;
@@ -59,13 +49,32 @@ interface ExecuteEntryOrderParams {
59
49
  stopLossPrice: number | null;
60
50
  signal: Signal;
61
51
  beforePlaceOrder?: () => Promise<void>;
52
+ recordRuntimeTrade?: boolean;
62
53
  }
63
- declare const executeEntryOrder: ({ connector, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, }: ExecuteEntryOrderParams) => Promise<number>;
54
+ declare const executeEntryOrder: ({ connector, userName, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, recordRuntimeTrade, }: ExecuteEntryOrderParams) => Promise<number>;
64
55
 
56
+ type CloseOppositePositionsBeforeOpenOptions = {
57
+ connector: Connector;
58
+ entryContext: StrategyEntrySignalContext;
59
+ };
65
60
  type BeforePlaceOrderHook = NonNullable<NonNullable<StrategyManifest['hooks']>['beforePlaceOrder']>;
66
61
  interface CreateCloseOppositeBeforePlaceOrderHookParams {
67
62
  isEnabled: (config: StrategyConfig) => boolean;
68
63
  }
64
+ declare const closeOppositePositionsBeforeOpen: ({ connector, entryContext, }: CloseOppositePositionsBeforeOpenOptions) => Promise<void>;
69
65
  declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCloseOppositeBeforePlaceOrderHookParams) => BeforePlaceOrderHook;
70
66
 
71
- export { MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiSystemPrompt, closeOppositePositionsBeforeOpen, createCloseOppositeBeforePlaceOrderHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig, trimSeriesDeep };
67
+ interface CreateMoveStopToBreakEvenOnBarHookParams {
68
+ isEnabled?: (config: StrategyConfig) => boolean;
69
+ triggerRiskMultiplier?: number;
70
+ }
71
+ declare const createMoveStopToBreakEvenOnBarHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
72
+ declare const createMoveStopToBreakEvenAfterCoreDecisionHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
73
+
74
+ interface CreateCloseAllOnGlobalProfitBeforeSignalsHookParams {
75
+ getStrategyDefaultConfig?: (strategyName: string) => StrategyConfig | undefined;
76
+ profitRiskMultiplier?: number;
77
+ }
78
+ declare const createCloseAllOnGlobalProfitBeforeSignalsHook: ({ getStrategyDefaultConfig, profitRiskMultiplier, }?: CreateCloseAllOnGlobalProfitBeforeSignalsHookParams) => TradejsConfigBeforeSignalsHook;
79
+
80
+ export { closeOppositePositionsBeforeOpen, createCloseAllOnGlobalProfitBeforeSignalsHook, createCloseOppositeBeforePlaceOrderHook, createMoveStopToBreakEvenAfterCoreDecisionHook, createMoveStopToBreakEvenOnBarHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };
@@ -1,20 +1,8 @@
1
- import { Connector, StrategyEntrySignalContext, Signal, SignalAnalysis, AiPayload, StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Tp } from '@tradejs/types';
2
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';
3
3
  export { ensureIndicatorPluginsLoaded, ensureStrategyPluginsLoaded, getAvailableStrategyNames, getRegisteredManifests, getRegisteredStrategies, getStrategyCreator, getStrategyManifest, isKnownStrategy, registerStrategyEntries, resetStrategyRegistryCache, strategies } from './registry.js';
4
-
5
- type CloseOppositePositionsBeforeOpenOptions = {
6
- connector: Connector;
7
- entryContext: StrategyEntrySignalContext;
8
- };
9
- declare const closeOppositePositionsBeforeOpen: ({ connector, entryContext, }: CloseOppositePositionsBeforeOpenOptions) => Promise<void>;
10
-
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>>;
4
+ import { StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Signal, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Connector, Tp, StrategyEntrySignalContext } from '@tradejs/types';
5
+ import { TradejsConfigOnBarHook, TradejsConfigBeforeSignalsHook } from '@tradejs/core/config';
18
6
 
19
7
  interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
20
8
  strategyName: string;
@@ -39,6 +27,7 @@ declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategy
39
27
 
40
28
  interface EnrichSignalWithMlAiParams {
41
29
  signal: Signal;
30
+ userName?: string;
42
31
  symbol: string;
43
32
  direction: Direction;
44
33
  env: string;
@@ -46,10 +35,11 @@ interface EnrichSignalWithMlAiParams {
46
35
  ai?: StrategyRuntimeAiOptions;
47
36
  }
48
37
  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>;
38
+ declare const enrichSignalWithAi: ({ signal, symbol, userName, direction, env, ai, }: Pick<EnrichSignalWithMlAiParams, "signal" | "userName" | "symbol" | "direction" | "env" | "ai">) => Promise<number | undefined>;
39
+ declare const enrichSignalWithMlAi: ({ signal, userName, symbol, direction, env, ml, ai, }: EnrichSignalWithMlAiParams) => Promise<number | undefined>;
51
40
  interface ExecuteEntryOrderParams {
52
41
  connector: Connector;
42
+ userName?: string;
53
43
  symbol: string;
54
44
  direction: Direction;
55
45
  qty: number;
@@ -59,13 +49,32 @@ interface ExecuteEntryOrderParams {
59
49
  stopLossPrice: number | null;
60
50
  signal: Signal;
61
51
  beforePlaceOrder?: () => Promise<void>;
52
+ recordRuntimeTrade?: boolean;
62
53
  }
63
- declare const executeEntryOrder: ({ connector, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, }: ExecuteEntryOrderParams) => Promise<number>;
54
+ declare const executeEntryOrder: ({ connector, userName, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, recordRuntimeTrade, }: ExecuteEntryOrderParams) => Promise<number>;
64
55
 
56
+ type CloseOppositePositionsBeforeOpenOptions = {
57
+ connector: Connector;
58
+ entryContext: StrategyEntrySignalContext;
59
+ };
65
60
  type BeforePlaceOrderHook = NonNullable<NonNullable<StrategyManifest['hooks']>['beforePlaceOrder']>;
66
61
  interface CreateCloseOppositeBeforePlaceOrderHookParams {
67
62
  isEnabled: (config: StrategyConfig) => boolean;
68
63
  }
64
+ declare const closeOppositePositionsBeforeOpen: ({ connector, entryContext, }: CloseOppositePositionsBeforeOpenOptions) => Promise<void>;
69
65
  declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCloseOppositeBeforePlaceOrderHookParams) => BeforePlaceOrderHook;
70
66
 
71
- export { MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiSystemPrompt, closeOppositePositionsBeforeOpen, createCloseOppositeBeforePlaceOrderHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig, trimSeriesDeep };
67
+ interface CreateMoveStopToBreakEvenOnBarHookParams {
68
+ isEnabled?: (config: StrategyConfig) => boolean;
69
+ triggerRiskMultiplier?: number;
70
+ }
71
+ declare const createMoveStopToBreakEvenOnBarHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
72
+ declare const createMoveStopToBreakEvenAfterCoreDecisionHook: ({ isEnabled, triggerRiskMultiplier, }?: CreateMoveStopToBreakEvenOnBarHookParams) => TradejsConfigOnBarHook;
73
+
74
+ interface CreateCloseAllOnGlobalProfitBeforeSignalsHookParams {
75
+ getStrategyDefaultConfig?: (strategyName: string) => StrategyConfig | undefined;
76
+ profitRiskMultiplier?: number;
77
+ }
78
+ declare const createCloseAllOnGlobalProfitBeforeSignalsHook: ({ getStrategyDefaultConfig, profitRiskMultiplier, }?: CreateCloseAllOnGlobalProfitBeforeSignalsHookParams) => TradejsConfigBeforeSignalsHook;
79
+
80
+ export { closeOppositePositionsBeforeOpen, createCloseAllOnGlobalProfitBeforeSignalsHook, createCloseOppositeBeforePlaceOrderHook, createMoveStopToBreakEvenAfterCoreDecisionHook, createMoveStopToBreakEvenOnBarHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig };