@backtest-kit/cli 6.4.0 → 6.5.1

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/build/index.cjs CHANGED
@@ -772,7 +772,22 @@ class WalkerMainService {
772
772
  this.run = functoolsKit.singleshot(async (payload) => {
773
773
  this.loggerService.log("walkerMainService run", { payload });
774
774
  const strategyMap = new Map();
775
+ const cwd = process.cwd();
775
776
  for (const entryPoint of payload.entryPoints) {
777
+ process.chdir(cwd);
778
+ const absolutePath = path.resolve(entryPoint);
779
+ await fs$1.access(absolutePath, fs.constants.F_OK | fs.constants.R_OK);
780
+ const moduleRoot = path.dirname(absolutePath);
781
+ process.chdir(moduleRoot);
782
+ {
783
+ Setup.clear();
784
+ Setup.enable();
785
+ }
786
+ {
787
+ cwd !== moduleRoot && BacktestKit.Log.useJsonl();
788
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
789
+ dotenv.config({ path: path.join(moduleRoot, '.env'), override: true, quiet: true });
790
+ }
776
791
  await this.resolveService.attachStrategy(entryPoint);
777
792
  for (const { strategyName } of await BacktestKit.listStrategySchema()) {
778
793
  if (strategyMap.has(strategyName)) {
@@ -780,6 +795,7 @@ class WalkerMainService {
780
795
  }
781
796
  strategyMap.set(strategyName, entryPoint);
782
797
  }
798
+ BacktestKit.Cache.clear();
783
799
  }
784
800
  await this.moduleConnectionService.loadModule("./walker.module");
785
801
  {
@@ -816,7 +832,6 @@ class WalkerMainService {
816
832
  if (!frameName) {
817
833
  throw new Error("Frame name is required");
818
834
  }
819
- const cwd = process.cwd();
820
835
  const self = this;
821
836
  const callbacks = {
822
837
  async onStrategyStart(strategyName) {
@@ -824,14 +839,15 @@ class WalkerMainService {
824
839
  if (!entryPoint) {
825
840
  return;
826
841
  }
842
+ process.chdir(cwd);
843
+ const absolutePath = path.resolve(entryPoint);
844
+ const moduleRoot = path.dirname(absolutePath);
845
+ process.chdir(moduleRoot);
827
846
  {
828
847
  Setup.clear();
829
848
  Setup.enable();
830
849
  }
831
- const absolutePath = path.resolve(entryPoint);
832
- const moduleRoot = path.dirname(absolutePath);
833
850
  {
834
- process.chdir(moduleRoot);
835
851
  cwd !== moduleRoot && BacktestKit.Log.useJsonl();
836
852
  dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
837
853
  dotenv.config({ path: path.join(moduleRoot, '.env'), override: true, quiet: true });
@@ -2452,6 +2468,9 @@ class SetupUtils {
2452
2468
  BacktestKit.NotificationLive.clear();
2453
2469
  BacktestKit.NotificationBacktest.clear();
2454
2470
  }
2471
+ {
2472
+ BacktestKit.Cache.clear();
2473
+ }
2455
2474
  };
2456
2475
  }
2457
2476
  }
@@ -2505,7 +2524,7 @@ const main$b = async () => {
2505
2524
  if (MODES.some((mode) => values[mode])) {
2506
2525
  return;
2507
2526
  }
2508
- process.stdout.write(`@backtest-kit/cli ${"6.3.0"}\n`);
2527
+ process.stdout.write(`@backtest-kit/cli ${"6.5.1"}\n`);
2509
2528
  process.stdout.write("\n");
2510
2529
  process.stdout.write(`Run with --help to see available commands.\n`);
2511
2530
  process.stdout.write("\n");
@@ -3073,7 +3092,7 @@ const main$1 = async () => {
3073
3092
  if (!values.help) {
3074
3093
  return;
3075
3094
  }
3076
- process.stdout.write(`@backtest-kit/cli ${"6.3.0"}\n\n`);
3095
+ process.stdout.write(`@backtest-kit/cli ${"6.5.1"}\n\n`);
3077
3096
  process.stdout.write(HELP_TEXT);
3078
3097
  process.exit(0);
3079
3098
  };
@@ -3087,7 +3106,7 @@ const main = async () => {
3087
3106
  if (!values.version) {
3088
3107
  return;
3089
3108
  }
3090
- process.stdout.write(`@backtest-kit/cli ${"6.3.0"}\n`);
3109
+ process.stdout.write(`@backtest-kit/cli ${"6.5.1"}\n`);
3091
3110
  process.exit(0);
3092
3111
  };
3093
3112
  main();
package/build/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import * as BacktestKit from 'backtest-kit';
3
- import { Log, listExchangeSchema, addExchangeSchema, roundTicks, listFrameSchema, addFrameSchema, listenDoneLive, listenDoneBacktest, shutdown, listenSignal, listStrategySchema, overrideExchangeSchema, Backtest, alignToInterval, addWalkerSchema, overrideWalkerSchema, Walker, listenDoneWalker, Live, getCandles, checkCandles, warmCandles, listenRisk, listenStrategyCommit, listenSync, Storage, Notification, Markdown, Report, Dump, Memory, StorageLive, StorageBacktest, NotificationLive, NotificationBacktest, PersistSignalAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistPartialAdapter, PersistBreakevenAdapter, PersistCandleAdapter, PersistStorageAdapter, PersistNotificationAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, setConfig, Exchange } from 'backtest-kit';
3
+ import { Log, listExchangeSchema, addExchangeSchema, roundTicks, listFrameSchema, addFrameSchema, listenDoneLive, listenDoneBacktest, shutdown, listenSignal, listStrategySchema, overrideExchangeSchema, Backtest, Cache, alignToInterval, addWalkerSchema, overrideWalkerSchema, Walker, listenDoneWalker, Live, getCandles, checkCandles, warmCandles, listenRisk, listenStrategyCommit, listenSync, Storage, Notification, Markdown, Report, Dump, Memory, StorageLive, StorageBacktest, NotificationLive, NotificationBacktest, PersistSignalAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistPartialAdapter, PersistBreakevenAdapter, PersistCandleAdapter, PersistStorageAdapter, PersistNotificationAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, setConfig, Exchange } from 'backtest-kit';
4
4
  import { getErrorMessage, errorData, singleshot, str, BehaviorSubject, compose, createAwaiter, execpool, queued, sleep, randomString, TIMEOUT_SYMBOL, typo, retry, trycatch, memoize } from 'functools-kit';
5
5
  import fs, { constants } from 'fs';
6
6
  import * as stackTrace from 'stack-trace';
@@ -747,7 +747,22 @@ class WalkerMainService {
747
747
  this.run = singleshot(async (payload) => {
748
748
  this.loggerService.log("walkerMainService run", { payload });
749
749
  const strategyMap = new Map();
750
+ const cwd = process.cwd();
750
751
  for (const entryPoint of payload.entryPoints) {
752
+ process.chdir(cwd);
753
+ const absolutePath = path.resolve(entryPoint);
754
+ await access(absolutePath, constants.F_OK | constants.R_OK);
755
+ const moduleRoot = path.dirname(absolutePath);
756
+ process.chdir(moduleRoot);
757
+ {
758
+ Setup.clear();
759
+ Setup.enable();
760
+ }
761
+ {
762
+ cwd !== moduleRoot && Log.useJsonl();
763
+ dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
764
+ dotenv.config({ path: path.join(moduleRoot, '.env'), override: true, quiet: true });
765
+ }
751
766
  await this.resolveService.attachStrategy(entryPoint);
752
767
  for (const { strategyName } of await listStrategySchema()) {
753
768
  if (strategyMap.has(strategyName)) {
@@ -755,6 +770,7 @@ class WalkerMainService {
755
770
  }
756
771
  strategyMap.set(strategyName, entryPoint);
757
772
  }
773
+ Cache.clear();
758
774
  }
759
775
  await this.moduleConnectionService.loadModule("./walker.module");
760
776
  {
@@ -791,7 +807,6 @@ class WalkerMainService {
791
807
  if (!frameName) {
792
808
  throw new Error("Frame name is required");
793
809
  }
794
- const cwd = process.cwd();
795
810
  const self = this;
796
811
  const callbacks = {
797
812
  async onStrategyStart(strategyName) {
@@ -799,14 +814,15 @@ class WalkerMainService {
799
814
  if (!entryPoint) {
800
815
  return;
801
816
  }
817
+ process.chdir(cwd);
818
+ const absolutePath = path.resolve(entryPoint);
819
+ const moduleRoot = path.dirname(absolutePath);
820
+ process.chdir(moduleRoot);
802
821
  {
803
822
  Setup.clear();
804
823
  Setup.enable();
805
824
  }
806
- const absolutePath = path.resolve(entryPoint);
807
- const moduleRoot = path.dirname(absolutePath);
808
825
  {
809
- process.chdir(moduleRoot);
810
826
  cwd !== moduleRoot && Log.useJsonl();
811
827
  dotenv.config({ path: path.join(cwd, '.env'), override: true, quiet: true });
812
828
  dotenv.config({ path: path.join(moduleRoot, '.env'), override: true, quiet: true });
@@ -2423,6 +2439,9 @@ class SetupUtils {
2423
2439
  NotificationLive.clear();
2424
2440
  NotificationBacktest.clear();
2425
2441
  }
2442
+ {
2443
+ Cache.clear();
2444
+ }
2426
2445
  };
2427
2446
  }
2428
2447
  }
@@ -2476,7 +2495,7 @@ const main$b = async () => {
2476
2495
  if (MODES.some((mode) => values[mode])) {
2477
2496
  return;
2478
2497
  }
2479
- process.stdout.write(`@backtest-kit/cli ${"6.3.0"}\n`);
2498
+ process.stdout.write(`@backtest-kit/cli ${"6.5.1"}\n`);
2480
2499
  process.stdout.write("\n");
2481
2500
  process.stdout.write(`Run with --help to see available commands.\n`);
2482
2501
  process.stdout.write("\n");
@@ -3044,7 +3063,7 @@ const main$1 = async () => {
3044
3063
  if (!values.help) {
3045
3064
  return;
3046
3065
  }
3047
- process.stdout.write(`@backtest-kit/cli ${"6.3.0"}\n\n`);
3066
+ process.stdout.write(`@backtest-kit/cli ${"6.5.1"}\n\n`);
3048
3067
  process.stdout.write(HELP_TEXT);
3049
3068
  process.exit(0);
3050
3069
  };
@@ -3058,7 +3077,7 @@ const main = async () => {
3058
3077
  if (!values.version) {
3059
3078
  return;
3060
3079
  }
3061
- process.stdout.write(`@backtest-kit/cli ${"6.3.0"}\n`);
3080
+ process.stdout.write(`@backtest-kit/cli ${"6.5.1"}\n`);
3062
3081
  process.exit(0);
3063
3082
  };
3064
3083
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/cli",
3
- "version": "6.4.0",
3
+ "version": "6.5.1",
4
4
  "description": "Zero-boilerplate CLI runner for backtest-kit strategies. Run backtests, paper trading, and live bots with candle cache warming, web dashboard, and Telegram notifications — no setup code required.",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -61,11 +61,11 @@
61
61
  "devDependencies": {
62
62
  "@babel/plugin-transform-modules-umd": "7.27.1",
63
63
  "@babel/standalone": "7.29.1",
64
- "@backtest-kit/ui": "6.4.0",
65
- "@backtest-kit/graph": "6.4.0",
66
- "@backtest-kit/ollama": "6.4.0",
67
- "@backtest-kit/pinets": "6.4.0",
68
- "@backtest-kit/signals": "6.4.0",
64
+ "@backtest-kit/ui": "6.5.0",
65
+ "@backtest-kit/graph": "6.5.0",
66
+ "@backtest-kit/ollama": "6.5.0",
67
+ "@backtest-kit/pinets": "6.5.0",
68
+ "@backtest-kit/signals": "6.5.0",
69
69
  "@rollup/plugin-replace": "6.0.3",
70
70
  "@rollup/plugin-typescript": "11.1.6",
71
71
  "@types/image-size": "0.7.0",
@@ -73,7 +73,7 @@
73
73
  "@types/mustache": "4.2.6",
74
74
  "@types/node": "22.9.0",
75
75
  "@types/stack-trace": "0.0.33",
76
- "backtest-kit": "6.4.0",
76
+ "backtest-kit": "6.5.0",
77
77
  "glob": "11.0.1",
78
78
  "markdown-it": "14.1.1",
79
79
  "rimraf": "6.0.1",
@@ -88,12 +88,12 @@
88
88
  "peerDependencies": {
89
89
  "@babel/plugin-transform-modules-umd": "^7.27.1",
90
90
  "@babel/standalone": "^7.29.1",
91
- "@backtest-kit/ui": "^6.4.0",
92
- "@backtest-kit/graph": "^6.4.0",
93
- "@backtest-kit/ollama": "^6.4.0",
94
- "@backtest-kit/pinets": "^6.4.0",
95
- "@backtest-kit/signals": "^6.4.0",
96
- "backtest-kit": "^6.4.0",
91
+ "@backtest-kit/ui": "^6.5.0",
92
+ "@backtest-kit/graph": "^6.5.0",
93
+ "@backtest-kit/ollama": "^6.5.0",
94
+ "@backtest-kit/pinets": "^6.5.0",
95
+ "@backtest-kit/signals": "^6.5.0",
96
+ "backtest-kit": "^6.5.0",
97
97
  "markdown-it": "^14.1.1",
98
98
  "typescript": "^5.0.0"
99
99
  },
@@ -12,12 +12,12 @@
12
12
  "license": "ISC",
13
13
  "type": "commonjs",
14
14
  "dependencies": {
15
- "@backtest-kit/cli": "^6.2.1",
16
- "@backtest-kit/graph": "^6.2.0",
17
- "@backtest-kit/pinets": "^6.2.0",
18
- "@backtest-kit/ui": "^6.2.0",
15
+ "@backtest-kit/cli": "^6.5.0",
16
+ "@backtest-kit/graph": "^6.5.0",
17
+ "@backtest-kit/pinets": "^6.5.0",
18
+ "@backtest-kit/ui": "^6.5.0",
19
19
  "agent-swarm-kit": "^1.3.0",
20
- "backtest-kit": "^6.2.0",
20
+ "backtest-kit": "^6.5.0",
21
21
  "functools-kit": "^1.0.95",
22
22
  "garch": "^1.2.3",
23
23
  "get-moment-stamp": "^1.1.2",
package/types.d.ts CHANGED
@@ -1,297 +1,297 @@
1
- import * as functools_kit from 'functools-kit';
2
- import { CandleInterval, TrailingTakeCommit, TrailingStopCommit, BreakevenCommit, PartialProfitCommit, PartialLossCommit, IStrategyTickResultScheduled, IStrategyTickResultCancelled, IStrategyTickResultOpened, IStrategyTickResultClosed, RiskContract, AverageBuyCommit, SignalOpenContract, SignalCloseContract, CancelScheduledCommit, ClosePendingCommit } from 'backtest-kit';
3
- import { Input } from 'telegraf';
4
-
5
- interface ILogger {
6
- log(topic: string, ...args: any[]): void;
7
- debug(topic: string, ...args: any[]): void;
8
- info(topic: string, ...args: any[]): void;
9
- warn(topic: string, ...args: any[]): void;
10
- }
11
-
12
- declare class LoggerService implements ILogger {
13
- private _commonLogger;
14
- log: (topic: string, ...args: any[]) => Promise<void>;
15
- debug: (topic: string, ...args: any[]) => Promise<void>;
16
- info: (topic: string, ...args: any[]) => Promise<void>;
17
- warn: (topic: string, ...args: any[]) => Promise<void>;
18
- setLogger: (logger: ILogger) => void;
19
- }
20
-
21
- declare class PaperMainService {
22
- private loggerService;
23
- private resolveService;
24
- private exchangeSchemaService;
25
- private symbolSchemaService;
26
- private frontendProviderService;
27
- private telegramProviderService;
28
- private moduleConnectionService;
29
- run: ((payload: {
30
- entryPoint: string;
31
- symbol: string;
32
- strategy: string;
33
- exchange: string;
34
- verbose: boolean;
35
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
36
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
37
- }
38
-
39
- declare class LiveMainService {
40
- private loggerService;
41
- private resolveService;
42
- private exchangeSchemaService;
43
- private symbolSchemaService;
44
- private frontendProviderService;
45
- private telegramProviderService;
46
- private moduleConnectionService;
47
- run: ((payload: {
48
- entryPoint: string;
49
- symbol: string;
50
- strategy: string;
51
- exchange: string;
52
- verbose: boolean;
53
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
54
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
55
- }
56
-
57
- declare class BacktestMainService {
58
- private loggerService;
59
- private resolveService;
60
- private exchangeSchemaService;
61
- private frameSchemaService;
62
- private symbolSchemaService;
63
- private cacheLogicService;
64
- private frontendProviderService;
65
- private telegramProviderService;
66
- private moduleConnectionService;
67
- run: ((payload: {
68
- entryPoint: string;
69
- symbol: string;
70
- strategy: string;
71
- exchange: string;
72
- frame: string;
73
- cacheInterval: string[];
74
- verbose: boolean;
75
- noCache: boolean;
76
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
77
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
78
- }
79
-
80
- declare class WalkerMainService {
81
- private loggerService;
82
- private resolveService;
83
- private exchangeSchemaService;
84
- private symbolSchemaService;
85
- private cacheLogicService;
86
- private moduleConnectionService;
87
- run: ((payload: {
88
- entryPoints: string[];
89
- symbol: string;
90
- output: string;
91
- cacheInterval: CandleInterval[];
92
- json: boolean;
93
- markdown: boolean;
94
- verbose: boolean;
95
- noCache: boolean;
96
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
97
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
98
- }
99
-
100
- declare class ExchangeSchemaService {
101
- readonly loggerService: LoggerService;
102
- addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
103
- }
104
-
105
- declare class FrameSchemaService {
106
- readonly loggerService: LoggerService;
107
- addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
108
- }
109
-
110
- declare class LoaderService {
111
- private readonly babelService;
112
- private readonly loggerService;
113
- private getInstance;
114
- import: (filePath: string, basePath?: string) => any;
115
- check: (filePath: string, basePath?: string) => Promise<boolean>;
116
- }
117
-
118
- declare class ResolveService {
119
- readonly loggerService: LoggerService;
120
- readonly loaderService: LoaderService;
121
- readonly DEFAULT_TEMPLATE_DIR: string;
122
- readonly DEFAULT_MODULES_DIR: string;
123
- readonly OVERRIDE_TEMPLATE_DIR: string;
124
- readonly OVERRIDE_MODULES_DIR: string;
125
- getIsLaunched: () => boolean;
126
- attachPine: (pinePath: string) => Promise<string>;
127
- attachStrategy: (jsPath: string) => Promise<void>;
128
- attachJavascript: (jsPath: string) => Promise<void>;
129
- }
130
-
131
- declare class ErrorService {
132
- handleGlobalError: (error: Error) => Promise<void>;
133
- private _listenForError;
134
- protected init: (() => void) & functools_kit.ISingleshotClearable;
135
- }
136
-
137
- declare class SymbolSchemaService {
138
- readonly loggerService: LoggerService;
139
- addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
140
- }
141
-
142
- declare class FrontendProviderService {
143
- private readonly loggerService;
144
- enable: (() => () => void) & functools_kit.ISingleshotClearable;
145
- disable: () => void;
146
- connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable;
147
- }
148
-
149
- declare class TelegramProviderService {
150
- private readonly loggerService;
151
- private readonly telegramLogicService;
152
- enable: (() => () => void) & functools_kit.ISingleshotClearable;
153
- disable: () => void;
154
- connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable;
155
- }
156
-
157
- declare class CacheLogicService {
158
- private readonly loggerService;
159
- execute: (intervalList: CandleInterval[], dto: {
160
- symbol: string;
161
- frameName: string;
162
- exchangeName: string;
163
- }) => Promise<void>;
164
- }
165
-
166
- type InputFile = ReturnType<typeof Input.fromReadableStream>;
167
- type Image = string | InputFile;
168
- declare class TelegramApiService {
169
- publish: (channel: string, msg: string, images?: Image[]) => Promise<"Message scheduled for publication" | "Message published successfully">;
170
- }
171
-
172
- declare class QuickchartApiService {
173
- readonly loggerService: LoggerService;
174
- getChart: (symbol: string, interval: string) => Promise<Buffer<ArrayBufferLike>>;
175
- }
176
-
177
- declare class TelegramWebService {
178
- private readonly loggerService;
179
- private readonly telegramApiService;
180
- private readonly quickchartApiService;
181
- publishNotify: (dto: {
182
- symbol: string;
183
- markdown: string;
184
- }) => Promise<void>;
185
- }
186
-
187
- declare class TelegramLogicService {
188
- private readonly loggerService;
189
- private readonly telegramTemplateService;
190
- private readonly telegramWebService;
191
- private notifyTrailingTake;
192
- private notifyTrailingStop;
193
- private notifyBreakeven;
194
- private notifyPartialProfit;
195
- private notifyPartialLoss;
196
- private notifyScheduled;
197
- private notifyCancelled;
198
- private notifyOpened;
199
- private notifyClosed;
200
- private notifyRisk;
201
- private notifyAverageBuy;
202
- private notifySignalOpen;
203
- private notifySignalClose;
204
- private notifyCancelScheduled;
205
- private notifyClosePending;
206
- connect: (() => () => void) & functools_kit.ISingleshotClearable;
207
- }
208
-
209
- declare class TelegramTemplateService {
210
- readonly loggerService: LoggerService;
211
- readonly resolveService: ResolveService;
212
- getTrailingTakeMarkdown: (event: TrailingTakeCommit) => Promise<string>;
213
- getTrailingStopMarkdown: (event: TrailingStopCommit) => Promise<string>;
214
- getBreakevenMarkdown: (event: BreakevenCommit) => Promise<string>;
215
- getPartialProfitMarkdown: (event: PartialProfitCommit) => Promise<string>;
216
- getPartialLossMarkdown: (event: PartialLossCommit) => Promise<string>;
217
- getScheduledMarkdown: (event: IStrategyTickResultScheduled) => Promise<string>;
218
- getCancelledMarkdown: (event: IStrategyTickResultCancelled) => Promise<string>;
219
- getOpenedMarkdown: (event: IStrategyTickResultOpened) => Promise<string>;
220
- getClosedMarkdown: (event: IStrategyTickResultClosed) => Promise<string>;
221
- getRiskMarkdown: (event: RiskContract) => Promise<string>;
222
- getAverageBuyMarkdown: (event: AverageBuyCommit) => Promise<string>;
223
- getSignalOpenMarkdown: (event: SignalOpenContract) => Promise<string>;
224
- getSignalCloseMarkdown: (event: SignalCloseContract) => Promise<string>;
225
- getCancelScheduledMarkdown: (event: CancelScheduledCommit) => Promise<string>;
226
- getClosePendingMarkdown: (event: ClosePendingCommit) => Promise<string>;
227
- }
228
-
229
- declare class ModuleConnectionService {
230
- readonly loggerService: LoggerService;
231
- readonly resolveService: ResolveService;
232
- readonly loaderService: LoaderService;
233
- loadModule: (fileName: string) => Promise<boolean>;
234
- }
235
-
236
- interface IBabel {
237
- transpile(code: string): string;
238
- }
239
-
240
- declare class BabelService implements IBabel {
241
- readonly loggerService: LoggerService;
242
- transpile: (code: string) => any;
243
- }
244
-
245
- declare const cli: {
246
- telegramTemplateService: TelegramTemplateService;
247
- telegramWebService: TelegramWebService;
248
- frontendProviderService: FrontendProviderService;
249
- telegramProviderService: TelegramProviderService;
250
- exchangeSchemaService: ExchangeSchemaService;
251
- symbolSchemaService: SymbolSchemaService;
252
- frameSchemaService: FrameSchemaService;
253
- cacheLogicService: CacheLogicService;
254
- telegramLogicService: TelegramLogicService;
255
- backtestMainService: BacktestMainService;
256
- walkerMainService: WalkerMainService;
257
- paperMainService: PaperMainService;
258
- liveMainService: LiveMainService;
259
- moduleConnectionService: ModuleConnectionService;
260
- errorService: ErrorService;
261
- loggerService: LoggerService;
262
- resolveService: ResolveService;
263
- loaderService: LoaderService;
264
- babelService: BabelService;
265
- telegramApiService: TelegramApiService;
266
- quickchartApiService: QuickchartApiService;
267
- };
268
-
269
- declare class SetupUtils {
270
- enable: (() => void) & functools_kit.ISingleshotClearable;
271
- clear: () => void;
272
- }
273
- declare const Setup: SetupUtils;
274
-
275
- interface ILoader {
276
- import(filePath: string): any;
277
- check(filePath: string): boolean;
278
- }
279
-
280
- declare enum ExchangeName {
281
- DefaultExchange = "default_exchange"
282
- }
283
-
284
- declare enum FrameName {
285
- DefaultFrame = "default_frame"
286
- }
287
-
288
- declare function setLogger(logger: ILogger): void;
289
-
290
- type PayloadBacktest = Parameters<typeof cli.backtestMainService.run>[0];
291
- type PayloadPaper = Parameters<typeof cli.paperMainService.run>[0];
292
- type PayloadLive = Parameters<typeof cli.liveMainService.run>[0];
293
- type Mode = "backtest" | "live" | "paper";
294
- type Args = Partial<PayloadBacktest> | Partial<PayloadPaper> | Partial<PayloadLive>;
295
- declare function run(mode: Mode, args: Args): Promise<void>;
296
-
297
- export { ExchangeName, FrameName, type IBabel, type ILoader, type ILogger, Setup, cli, run, setLogger };
1
+ import * as functools_kit from 'functools-kit';
2
+ import { CandleInterval, TrailingTakeCommit, TrailingStopCommit, BreakevenCommit, PartialProfitCommit, PartialLossCommit, IStrategyTickResultScheduled, IStrategyTickResultCancelled, IStrategyTickResultOpened, IStrategyTickResultClosed, RiskContract, AverageBuyCommit, SignalOpenContract, SignalCloseContract, CancelScheduledCommit, ClosePendingCommit } from 'backtest-kit';
3
+ import { Input } from 'telegraf';
4
+
5
+ interface ILogger {
6
+ log(topic: string, ...args: any[]): void;
7
+ debug(topic: string, ...args: any[]): void;
8
+ info(topic: string, ...args: any[]): void;
9
+ warn(topic: string, ...args: any[]): void;
10
+ }
11
+
12
+ declare class LoggerService implements ILogger {
13
+ private _commonLogger;
14
+ log: (topic: string, ...args: any[]) => Promise<void>;
15
+ debug: (topic: string, ...args: any[]) => Promise<void>;
16
+ info: (topic: string, ...args: any[]) => Promise<void>;
17
+ warn: (topic: string, ...args: any[]) => Promise<void>;
18
+ setLogger: (logger: ILogger) => void;
19
+ }
20
+
21
+ declare class PaperMainService {
22
+ private loggerService;
23
+ private resolveService;
24
+ private exchangeSchemaService;
25
+ private symbolSchemaService;
26
+ private frontendProviderService;
27
+ private telegramProviderService;
28
+ private moduleConnectionService;
29
+ run: ((payload: {
30
+ entryPoint: string;
31
+ symbol: string;
32
+ strategy: string;
33
+ exchange: string;
34
+ verbose: boolean;
35
+ }) => Promise<void>) & functools_kit.ISingleshotClearable;
36
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
37
+ }
38
+
39
+ declare class LiveMainService {
40
+ private loggerService;
41
+ private resolveService;
42
+ private exchangeSchemaService;
43
+ private symbolSchemaService;
44
+ private frontendProviderService;
45
+ private telegramProviderService;
46
+ private moduleConnectionService;
47
+ run: ((payload: {
48
+ entryPoint: string;
49
+ symbol: string;
50
+ strategy: string;
51
+ exchange: string;
52
+ verbose: boolean;
53
+ }) => Promise<void>) & functools_kit.ISingleshotClearable;
54
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
55
+ }
56
+
57
+ declare class BacktestMainService {
58
+ private loggerService;
59
+ private resolveService;
60
+ private exchangeSchemaService;
61
+ private frameSchemaService;
62
+ private symbolSchemaService;
63
+ private cacheLogicService;
64
+ private frontendProviderService;
65
+ private telegramProviderService;
66
+ private moduleConnectionService;
67
+ run: ((payload: {
68
+ entryPoint: string;
69
+ symbol: string;
70
+ strategy: string;
71
+ exchange: string;
72
+ frame: string;
73
+ cacheInterval: string[];
74
+ verbose: boolean;
75
+ noCache: boolean;
76
+ }) => Promise<void>) & functools_kit.ISingleshotClearable;
77
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
78
+ }
79
+
80
+ declare class WalkerMainService {
81
+ private loggerService;
82
+ private resolveService;
83
+ private exchangeSchemaService;
84
+ private symbolSchemaService;
85
+ private cacheLogicService;
86
+ private moduleConnectionService;
87
+ run: ((payload: {
88
+ entryPoints: string[];
89
+ symbol: string;
90
+ output: string;
91
+ cacheInterval: CandleInterval[];
92
+ json: boolean;
93
+ markdown: boolean;
94
+ verbose: boolean;
95
+ noCache: boolean;
96
+ }) => Promise<void>) & functools_kit.ISingleshotClearable;
97
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
98
+ }
99
+
100
+ declare class ExchangeSchemaService {
101
+ readonly loggerService: LoggerService;
102
+ addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
103
+ }
104
+
105
+ declare class FrameSchemaService {
106
+ readonly loggerService: LoggerService;
107
+ addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
108
+ }
109
+
110
+ declare class LoaderService {
111
+ private readonly babelService;
112
+ private readonly loggerService;
113
+ private getInstance;
114
+ import: (filePath: string, basePath?: string) => any;
115
+ check: (filePath: string, basePath?: string) => Promise<boolean>;
116
+ }
117
+
118
+ declare class ResolveService {
119
+ readonly loggerService: LoggerService;
120
+ readonly loaderService: LoaderService;
121
+ readonly DEFAULT_TEMPLATE_DIR: string;
122
+ readonly DEFAULT_MODULES_DIR: string;
123
+ readonly OVERRIDE_TEMPLATE_DIR: string;
124
+ readonly OVERRIDE_MODULES_DIR: string;
125
+ getIsLaunched: () => boolean;
126
+ attachPine: (pinePath: string) => Promise<string>;
127
+ attachStrategy: (jsPath: string) => Promise<void>;
128
+ attachJavascript: (jsPath: string) => Promise<void>;
129
+ }
130
+
131
+ declare class ErrorService {
132
+ handleGlobalError: (error: Error) => Promise<void>;
133
+ private _listenForError;
134
+ protected init: (() => void) & functools_kit.ISingleshotClearable;
135
+ }
136
+
137
+ declare class SymbolSchemaService {
138
+ readonly loggerService: LoggerService;
139
+ addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
140
+ }
141
+
142
+ declare class FrontendProviderService {
143
+ private readonly loggerService;
144
+ enable: (() => () => void) & functools_kit.ISingleshotClearable;
145
+ disable: () => void;
146
+ connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable;
147
+ }
148
+
149
+ declare class TelegramProviderService {
150
+ private readonly loggerService;
151
+ private readonly telegramLogicService;
152
+ enable: (() => () => void) & functools_kit.ISingleshotClearable;
153
+ disable: () => void;
154
+ connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable;
155
+ }
156
+
157
+ declare class CacheLogicService {
158
+ private readonly loggerService;
159
+ execute: (intervalList: CandleInterval[], dto: {
160
+ symbol: string;
161
+ frameName: string;
162
+ exchangeName: string;
163
+ }) => Promise<void>;
164
+ }
165
+
166
+ type InputFile = ReturnType<typeof Input.fromReadableStream>;
167
+ type Image = string | InputFile;
168
+ declare class TelegramApiService {
169
+ publish: (channel: string, msg: string, images?: Image[]) => Promise<"Message scheduled for publication" | "Message published successfully">;
170
+ }
171
+
172
+ declare class QuickchartApiService {
173
+ readonly loggerService: LoggerService;
174
+ getChart: (symbol: string, interval: string) => Promise<Buffer<ArrayBufferLike>>;
175
+ }
176
+
177
+ declare class TelegramWebService {
178
+ private readonly loggerService;
179
+ private readonly telegramApiService;
180
+ private readonly quickchartApiService;
181
+ publishNotify: (dto: {
182
+ symbol: string;
183
+ markdown: string;
184
+ }) => Promise<void>;
185
+ }
186
+
187
+ declare class TelegramLogicService {
188
+ private readonly loggerService;
189
+ private readonly telegramTemplateService;
190
+ private readonly telegramWebService;
191
+ private notifyTrailingTake;
192
+ private notifyTrailingStop;
193
+ private notifyBreakeven;
194
+ private notifyPartialProfit;
195
+ private notifyPartialLoss;
196
+ private notifyScheduled;
197
+ private notifyCancelled;
198
+ private notifyOpened;
199
+ private notifyClosed;
200
+ private notifyRisk;
201
+ private notifyAverageBuy;
202
+ private notifySignalOpen;
203
+ private notifySignalClose;
204
+ private notifyCancelScheduled;
205
+ private notifyClosePending;
206
+ connect: (() => () => void) & functools_kit.ISingleshotClearable;
207
+ }
208
+
209
+ declare class TelegramTemplateService {
210
+ readonly loggerService: LoggerService;
211
+ readonly resolveService: ResolveService;
212
+ getTrailingTakeMarkdown: (event: TrailingTakeCommit) => Promise<string>;
213
+ getTrailingStopMarkdown: (event: TrailingStopCommit) => Promise<string>;
214
+ getBreakevenMarkdown: (event: BreakevenCommit) => Promise<string>;
215
+ getPartialProfitMarkdown: (event: PartialProfitCommit) => Promise<string>;
216
+ getPartialLossMarkdown: (event: PartialLossCommit) => Promise<string>;
217
+ getScheduledMarkdown: (event: IStrategyTickResultScheduled) => Promise<string>;
218
+ getCancelledMarkdown: (event: IStrategyTickResultCancelled) => Promise<string>;
219
+ getOpenedMarkdown: (event: IStrategyTickResultOpened) => Promise<string>;
220
+ getClosedMarkdown: (event: IStrategyTickResultClosed) => Promise<string>;
221
+ getRiskMarkdown: (event: RiskContract) => Promise<string>;
222
+ getAverageBuyMarkdown: (event: AverageBuyCommit) => Promise<string>;
223
+ getSignalOpenMarkdown: (event: SignalOpenContract) => Promise<string>;
224
+ getSignalCloseMarkdown: (event: SignalCloseContract) => Promise<string>;
225
+ getCancelScheduledMarkdown: (event: CancelScheduledCommit) => Promise<string>;
226
+ getClosePendingMarkdown: (event: ClosePendingCommit) => Promise<string>;
227
+ }
228
+
229
+ declare class ModuleConnectionService {
230
+ readonly loggerService: LoggerService;
231
+ readonly resolveService: ResolveService;
232
+ readonly loaderService: LoaderService;
233
+ loadModule: (fileName: string) => Promise<boolean>;
234
+ }
235
+
236
+ interface IBabel {
237
+ transpile(code: string): string;
238
+ }
239
+
240
+ declare class BabelService implements IBabel {
241
+ readonly loggerService: LoggerService;
242
+ transpile: (code: string) => any;
243
+ }
244
+
245
+ declare const cli: {
246
+ telegramTemplateService: TelegramTemplateService;
247
+ telegramWebService: TelegramWebService;
248
+ frontendProviderService: FrontendProviderService;
249
+ telegramProviderService: TelegramProviderService;
250
+ exchangeSchemaService: ExchangeSchemaService;
251
+ symbolSchemaService: SymbolSchemaService;
252
+ frameSchemaService: FrameSchemaService;
253
+ cacheLogicService: CacheLogicService;
254
+ telegramLogicService: TelegramLogicService;
255
+ backtestMainService: BacktestMainService;
256
+ walkerMainService: WalkerMainService;
257
+ paperMainService: PaperMainService;
258
+ liveMainService: LiveMainService;
259
+ moduleConnectionService: ModuleConnectionService;
260
+ errorService: ErrorService;
261
+ loggerService: LoggerService;
262
+ resolveService: ResolveService;
263
+ loaderService: LoaderService;
264
+ babelService: BabelService;
265
+ telegramApiService: TelegramApiService;
266
+ quickchartApiService: QuickchartApiService;
267
+ };
268
+
269
+ declare class SetupUtils {
270
+ enable: (() => void) & functools_kit.ISingleshotClearable;
271
+ clear: () => void;
272
+ }
273
+ declare const Setup: SetupUtils;
274
+
275
+ interface ILoader {
276
+ import(filePath: string): any;
277
+ check(filePath: string): boolean;
278
+ }
279
+
280
+ declare enum ExchangeName {
281
+ DefaultExchange = "default_exchange"
282
+ }
283
+
284
+ declare enum FrameName {
285
+ DefaultFrame = "default_frame"
286
+ }
287
+
288
+ declare function setLogger(logger: ILogger): void;
289
+
290
+ type PayloadBacktest = Parameters<typeof cli.backtestMainService.run>[0];
291
+ type PayloadPaper = Parameters<typeof cli.paperMainService.run>[0];
292
+ type PayloadLive = Parameters<typeof cli.liveMainService.run>[0];
293
+ type Mode = "backtest" | "live" | "paper";
294
+ type Args = Partial<PayloadBacktest> | Partial<PayloadPaper> | Partial<PayloadLive>;
295
+ declare function run(mode: Mode, args: Args): Promise<void>;
296
+
297
+ export { ExchangeName, FrameName, type IBabel, type ILoader, type ILogger, Setup, cli, run, setLogger };