@tradejs/node 1.0.0

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.
@@ -0,0 +1,71 @@
1
+ import { Connector, StrategyEntrySignalContext, Signal, SignalAnalysis, AiPayload, StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Tp } from '@tradejs/types';
2
+ export * from '@tradejs/core/strategies';
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>>;
18
+
19
+ interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
20
+ strategyName: string;
21
+ defaults: TConfig;
22
+ createCore: CreateStrategyCore<TConfig, any, any>;
23
+ manifest?: StrategyManifest;
24
+ strategyDirectory?: string;
25
+ }
26
+ declare const createStrategyRuntime: <TConfig extends StrategyConfig>({ strategyName, defaults, createCore, manifest: staticManifest, strategyDirectory, }: CreateStrategyRuntimeParams<TConfig>) => StrategyCreator;
27
+
28
+ interface ResolveStrategyConfigParams<TConfig extends StrategyConfig> {
29
+ strategyName: string;
30
+ userName: string;
31
+ symbol: string;
32
+ baseConfig: Record<string, any>;
33
+ defaults: TConfig;
34
+ }
35
+ declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategyName, userName, symbol, baseConfig, defaults, }: ResolveStrategyConfigParams<TConfig>) => Promise<{
36
+ config: TConfig;
37
+ isConfigFromBacktest: boolean;
38
+ }>;
39
+
40
+ interface EnrichSignalWithMlAiParams {
41
+ signal: Signal;
42
+ symbol: string;
43
+ direction: Direction;
44
+ env: string;
45
+ ml?: StrategyRuntimeMlOptions;
46
+ ai?: StrategyRuntimeAiOptions;
47
+ }
48
+ 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>;
51
+ interface ExecuteEntryOrderParams {
52
+ connector: Connector;
53
+ symbol: string;
54
+ direction: Direction;
55
+ qty: number;
56
+ currentPrice: number;
57
+ timestamp: number;
58
+ takeProfits: Tp[];
59
+ stopLossPrice: number | null;
60
+ signal: Signal;
61
+ beforePlaceOrder?: () => Promise<void>;
62
+ }
63
+ declare const executeEntryOrder: ({ connector, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, }: ExecuteEntryOrderParams) => Promise<number>;
64
+
65
+ type BeforePlaceOrderHook = NonNullable<NonNullable<StrategyManifest['hooks']>['beforePlaceOrder']>;
66
+ interface CreateCloseOppositeBeforePlaceOrderHookParams {
67
+ isEnabled: (config: StrategyConfig) => boolean;
68
+ }
69
+ declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCloseOppositeBeforePlaceOrderHookParams) => BeforePlaceOrderHook;
70
+
71
+ export { MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiSystemPrompt, closeOppositePositionsBeforeOpen, createCloseOppositeBeforePlaceOrderHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig, trimSeriesDeep };
@@ -0,0 +1,71 @@
1
+ import { Connector, StrategyEntrySignalContext, Signal, SignalAnalysis, AiPayload, StrategyConfig, CreateStrategyCore, StrategyManifest, StrategyCreator, Direction, StrategyRuntimeMlOptions, StrategyRuntimeAiOptions, Tp } from '@tradejs/types';
2
+ export * from '@tradejs/core/strategies';
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>>;
18
+
19
+ interface CreateStrategyRuntimeParams<TConfig extends StrategyConfig> {
20
+ strategyName: string;
21
+ defaults: TConfig;
22
+ createCore: CreateStrategyCore<TConfig, any, any>;
23
+ manifest?: StrategyManifest;
24
+ strategyDirectory?: string;
25
+ }
26
+ declare const createStrategyRuntime: <TConfig extends StrategyConfig>({ strategyName, defaults, createCore, manifest: staticManifest, strategyDirectory, }: CreateStrategyRuntimeParams<TConfig>) => StrategyCreator;
27
+
28
+ interface ResolveStrategyConfigParams<TConfig extends StrategyConfig> {
29
+ strategyName: string;
30
+ userName: string;
31
+ symbol: string;
32
+ baseConfig: Record<string, any>;
33
+ defaults: TConfig;
34
+ }
35
+ declare const resolveStrategyConfig: <TConfig extends StrategyConfig>({ strategyName, userName, symbol, baseConfig, defaults, }: ResolveStrategyConfigParams<TConfig>) => Promise<{
36
+ config: TConfig;
37
+ isConfigFromBacktest: boolean;
38
+ }>;
39
+
40
+ interface EnrichSignalWithMlAiParams {
41
+ signal: Signal;
42
+ symbol: string;
43
+ direction: Direction;
44
+ env: string;
45
+ ml?: StrategyRuntimeMlOptions;
46
+ ai?: StrategyRuntimeAiOptions;
47
+ }
48
+ 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>;
51
+ interface ExecuteEntryOrderParams {
52
+ connector: Connector;
53
+ symbol: string;
54
+ direction: Direction;
55
+ qty: number;
56
+ currentPrice: number;
57
+ timestamp: number;
58
+ takeProfits: Tp[];
59
+ stopLossPrice: number | null;
60
+ signal: Signal;
61
+ beforePlaceOrder?: () => Promise<void>;
62
+ }
63
+ declare const executeEntryOrder: ({ connector, symbol, direction, qty, currentPrice, timestamp, takeProfits, stopLossPrice, signal, beforePlaceOrder, }: ExecuteEntryOrderParams) => Promise<number>;
64
+
65
+ type BeforePlaceOrderHook = NonNullable<NonNullable<StrategyManifest['hooks']>['beforePlaceOrder']>;
66
+ interface CreateCloseOppositeBeforePlaceOrderHookParams {
67
+ isEnabled: (config: StrategyConfig) => boolean;
68
+ }
69
+ declare const createCloseOppositeBeforePlaceOrderHook: ({ isEnabled, }: CreateCloseOppositeBeforePlaceOrderHookParams) => BeforePlaceOrderHook;
70
+
71
+ export { MAX_AI_SERIES_POINTS, askAI, buildAiHumanPrompt, buildAiPayload, buildAiSystemPrompt, closeOppositePositionsBeforeOpen, createCloseOppositeBeforePlaceOrderHook, createStrategyRuntime, enrichSignalWithAi, enrichSignalWithMl, enrichSignalWithMlAi, executeEntryOrder, resolveStrategyConfig, trimSeriesDeep };