@backtest-kit/cli 7.1.0 → 7.3.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,21 @@
1
+ **ℹ️ Signal Info**
2
+
3
+ **Symbol:** `{{symbol}}` ({{data.position}})
4
+ **Current:** `{{currentPrice}}`
5
+ **Entry:** `{{data.priceOpen}}`
6
+ **Orig Entry:** `{{data.originalPriceOpen}}`
7
+ **DCA Entries:** `{{data.totalEntries}}`
8
+ **Partials Done:** `{{data.totalPartials}}`
9
+ **Take Profit:** `{{data.priceTakeProfit}}`
10
+ **Stop Loss:** `{{data.priceStopLoss}}`
11
+ **Orig TP:** `{{data.originalPriceTakeProfit}}`
12
+ **Orig SL:** `{{data.originalPriceStopLoss}}`
13
+ **PnL:** {{data.pnl.pnlPercentage}}% ({{data.pnl.pnlCost}} / {{data.pnl.pnlEntries}})
14
+ **Peak Profit:** {{data.peakProfit.pnlPercentage}}% ({{data.peakProfit.pnlCost}} / {{data.peakProfit.pnlEntries}})
15
+ **Max Drawdown:** {{data.maxDrawdown.pnlPercentage}}% ({{data.maxDrawdown.pnlCost}} / {{data.maxDrawdown.pnlEntries}})
16
+ **Signal ID:** `{{data.id}}`
17
+ **Time:** `{{timestamp}}`
18
+
19
+ {{#backtest}}
20
+ _🧪 Backtest_
21
+ {{/backtest}}
@@ -13,6 +13,8 @@
13
13
  **DCA Entries:** `{{totalEntries}}`
14
14
  **Partials Done:** `{{totalPartials}}`
15
15
  **PnL:** {{pnl.pnlPercentage}}% ({{pnl.pnlCost}} / {{pnl.pnlEntries}})
16
+ **Peak Profit:** {{peakProfit.pnlPercentage}}% ({{peakProfit.pnlCost}} / {{peakProfit.pnlEntries}})
17
+ **Max Drawdown:** {{maxDrawdown.pnlPercentage}}% ({{maxDrawdown.pnlCost}} / {{maxDrawdown.pnlEntries}})
16
18
  **Signal ID:** `{{signalId}}`
17
19
  **Time:** `{{timestamp}}`
18
20
 
@@ -12,6 +12,8 @@
12
12
  **DCA Entries:** `{{totalEntries}}`
13
13
  **Partials Done:** `{{totalPartials}}`
14
14
  **PnL:** {{pnl.pnlPercentage}}% ({{pnl.pnlCost}} / {{pnl.pnlEntries}})
15
+ **Peak Profit:** {{peakProfit.pnlPercentage}}% ({{peakProfit.pnlCost}} / {{peakProfit.pnlEntries}})
16
+ **Max Drawdown:** {{maxDrawdown.pnlPercentage}}% ({{maxDrawdown.pnlCost}} / {{maxDrawdown.pnlEntries}})
15
17
  **Signal ID:** `{{signalId}}`
16
18
  **Time:** `{{timestamp}}`
17
19
 
@@ -12,6 +12,8 @@
12
12
  **DCA Entries:** `{{totalEntries}}`
13
13
  **Partials Done:** `{{totalPartials}}`
14
14
  **PnL:** {{pnl.pnlPercentage}}% ({{pnl.pnlCost}} / {{pnl.pnlEntries}})
15
+ **Peak Profit:** {{peakProfit.pnlPercentage}}% ({{peakProfit.pnlCost}} / {{peakProfit.pnlEntries}})
16
+ **Max Drawdown:** {{maxDrawdown.pnlPercentage}}% ({{maxDrawdown.pnlCost}} / {{maxDrawdown.pnlEntries}})
15
17
  **Signal ID:** `{{signalId}}`
16
18
  **Time:** `{{timestamp}}`
17
19
 
package/types.d.ts CHANGED
@@ -1,5 +1,11 @@
1
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';
2
+ import * as BacktestKit from 'backtest-kit';
3
+ import { CandleInterval, TrailingTakeCommit, TrailingStopCommit, BreakevenCommit, PartialProfitCommit, PartialLossCommit, IStrategyTickResultScheduled, IStrategyTickResultCancelled, IStrategyTickResultOpened, IStrategyTickResultClosed, RiskContract, AverageBuyCommit, SignalOpenContract, SignalCloseContract, CancelScheduledCommit, ClosePendingCommit, SignalInfoContract } from 'backtest-kit';
4
+ import * as BacktestKitUi from '@backtest-kit/ui';
5
+ import * as BacktestKitGraph from '@backtest-kit/graph';
6
+ import * as BacktestKitOllama from '@backtest-kit/ollama';
7
+ import * as BacktestKitPinets from '@backtest-kit/pinets';
8
+ import * as BacktestKitSignals from '@backtest-kit/signals';
3
9
  import { Input } from 'telegraf';
4
10
 
5
11
  interface ILogger {
@@ -21,6 +27,7 @@ declare class LoggerService implements ILogger {
21
27
  declare class PaperMainService {
22
28
  private loggerService;
23
29
  private resolveService;
30
+ private configService;
24
31
  private exchangeSchemaService;
25
32
  private symbolSchemaService;
26
33
  private frontendProviderService;
@@ -32,13 +39,20 @@ declare class PaperMainService {
32
39
  strategy: string;
33
40
  exchange: string;
34
41
  verbose: boolean;
35
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
36
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
42
+ }) => Promise<void>) & functools_kit.ISingleshotClearable<(payload: {
43
+ entryPoint: string;
44
+ symbol: string;
45
+ strategy: string;
46
+ exchange: string;
47
+ verbose: boolean;
48
+ }) => Promise<void>>;
49
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
37
50
  }
38
51
 
39
52
  declare class LiveMainService {
40
53
  private loggerService;
41
54
  private resolveService;
55
+ private configService;
42
56
  private exchangeSchemaService;
43
57
  private symbolSchemaService;
44
58
  private frontendProviderService;
@@ -50,13 +64,20 @@ declare class LiveMainService {
50
64
  strategy: string;
51
65
  exchange: string;
52
66
  verbose: boolean;
53
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
54
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
67
+ }) => Promise<void>) & functools_kit.ISingleshotClearable<(payload: {
68
+ entryPoint: string;
69
+ symbol: string;
70
+ strategy: string;
71
+ exchange: string;
72
+ verbose: boolean;
73
+ }) => Promise<void>>;
74
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
55
75
  }
56
76
 
57
77
  declare class BacktestMainService {
58
78
  private loggerService;
59
79
  private resolveService;
80
+ private configService;
60
81
  private exchangeSchemaService;
61
82
  private frameSchemaService;
62
83
  private symbolSchemaService;
@@ -73,13 +94,23 @@ declare class BacktestMainService {
73
94
  cacheInterval: string[];
74
95
  verbose: boolean;
75
96
  noCache: boolean;
76
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
77
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
97
+ }) => Promise<void>) & functools_kit.ISingleshotClearable<(payload: {
98
+ entryPoint: string;
99
+ symbol: string;
100
+ strategy: string;
101
+ exchange: string;
102
+ frame: string;
103
+ cacheInterval: string[];
104
+ verbose: boolean;
105
+ noCache: boolean;
106
+ }) => Promise<void>>;
107
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
78
108
  }
79
109
 
80
110
  declare class WalkerMainService {
81
111
  private loggerService;
82
112
  private resolveService;
113
+ private configService;
83
114
  private exchangeSchemaService;
84
115
  private symbolSchemaService;
85
116
  private cacheLogicService;
@@ -93,27 +124,36 @@ declare class WalkerMainService {
93
124
  markdown: boolean;
94
125
  verbose: boolean;
95
126
  noCache: boolean;
96
- }) => Promise<void>) & functools_kit.ISingleshotClearable;
97
- connect: (() => Promise<void>) & functools_kit.ISingleshotClearable;
127
+ }) => Promise<void>) & functools_kit.ISingleshotClearable<(payload: {
128
+ entryPoints: string[];
129
+ symbol: string;
130
+ output: string;
131
+ cacheInterval: CandleInterval[];
132
+ json: boolean;
133
+ markdown: boolean;
134
+ verbose: boolean;
135
+ noCache: boolean;
136
+ }) => Promise<void>>;
137
+ connect: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
98
138
  }
99
139
 
100
140
  declare class ExchangeSchemaService {
101
141
  readonly loggerService: LoggerService;
102
- addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
142
+ addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
103
143
  }
104
144
 
105
145
  declare class FrameSchemaService {
106
146
  readonly loggerService: LoggerService;
107
- addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
147
+ addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
108
148
  }
109
149
 
110
- declare class LoaderService {
111
- private readonly babelService;
112
- private readonly loggerService;
113
- private readonly resolveService;
114
- private getInstance;
115
- import: (filePath: string, basePath?: string) => any;
116
- check: (filePath: string, basePath?: string) => Promise<boolean>;
150
+ interface IBabel {
151
+ transpile(code: string): string;
152
+ }
153
+
154
+ declare class BabelService implements IBabel {
155
+ readonly loggerService: LoggerService;
156
+ transpile: (code: string) => any;
117
157
  }
118
158
 
119
159
  interface IResolve {
@@ -124,13 +164,59 @@ interface IResolve {
124
164
  PROJECT_ROOT_DIR: string;
125
165
  }
126
166
 
167
+ interface ILoaderParams {
168
+ path: string;
169
+ logger: ILogger;
170
+ babel: IBabel;
171
+ resolve: IResolve;
172
+ }
173
+ interface ILoader {
174
+ import(filePath: string): any;
175
+ check(filePath: string): boolean;
176
+ }
177
+
178
+ declare const BacktestKitCli: {};
179
+ declare global {
180
+ interface Window {
181
+ BacktestKit: typeof BacktestKit;
182
+ BacktestKitCli: typeof BacktestKitCli;
183
+ BacktestKitUi: typeof BacktestKitUi;
184
+ BacktestKitGraph: typeof BacktestKitGraph;
185
+ BacktestKitOllama: typeof BacktestKitOllama;
186
+ BacktestKitPinets: typeof BacktestKitPinets;
187
+ BacktestKitSignals: typeof BacktestKitSignals;
188
+ }
189
+ }
190
+ declare class ClientLoader implements ILoader {
191
+ readonly params: ILoaderParams;
192
+ __filename: string;
193
+ __dirname: string;
194
+ baseRequire: (() => NodeRequire) & functools_kit.ISingleshotClearable<() => NodeRequire>;
195
+ constructor(params: ILoaderParams);
196
+ fork(basePath: string): ClientLoader;
197
+ import(filePath: string, seen?: Set<string>): any;
198
+ check(filePath: string): boolean;
199
+ }
200
+
201
+ declare class LoaderService {
202
+ readonly babelService: BabelService;
203
+ readonly loggerService: LoggerService;
204
+ readonly resolveService: ResolveService;
205
+ getInstance: ((basePath: string) => ClientLoader) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientLoader>;
206
+ import: (filePath: string, basePath?: string) => any;
207
+ check: (filePath: string, basePath?: string) => Promise<boolean>;
208
+ init: (() => void) & functools_kit.ISingleshotClearable<() => void>;
209
+ }
210
+
127
211
  declare class ResolveService implements IResolve {
128
212
  readonly loggerService: LoggerService;
129
213
  readonly loaderService: LoaderService;
130
214
  readonly DEFAULT_TEMPLATE_DIR: string;
131
215
  readonly DEFAULT_MODULES_DIR: string;
216
+ readonly DEFAULT_CONFIG_DIR: string;
132
217
  readonly OVERRIDE_TEMPLATE_DIR: string;
133
218
  readonly OVERRIDE_MODULES_DIR: string;
219
+ readonly OVERRIDE_CONFIG_DIR: string;
134
220
  readonly PROJECT_ROOT_DIR: string;
135
221
  getIsLaunched: () => boolean;
136
222
  attachPine: (pinePath: string) => Promise<string>;
@@ -141,28 +227,41 @@ declare class ResolveService implements IResolve {
141
227
  declare class ErrorService {
142
228
  handleGlobalError: (error: Error) => Promise<void>;
143
229
  private _listenForError;
144
- protected init: (() => void) & functools_kit.ISingleshotClearable;
230
+ protected init: (() => void) & functools_kit.ISingleshotClearable<() => void>;
145
231
  }
146
232
 
147
233
  declare class SymbolSchemaService {
148
234
  readonly loggerService: LoggerService;
149
- addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable;
235
+ addSchema: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
236
+ }
237
+
238
+ type ModuleExports = {
239
+ [key: string]: any;
240
+ default?: any;
241
+ };
242
+
243
+ declare class ConfigConnectionService {
244
+ readonly loggerService: LoggerService;
245
+ readonly resolveService: ResolveService;
246
+ readonly loaderService: LoaderService;
247
+ loadConfig: (fileName: string) => Promise<ModuleExports>;
150
248
  }
151
249
 
152
250
  declare class FrontendProviderService {
153
- private readonly loggerService;
154
- private readonly resolveService;
155
- enable: (() => () => void) & functools_kit.ISingleshotClearable;
251
+ readonly loggerService: LoggerService;
252
+ readonly resolveService: ResolveService;
253
+ readonly configConnectionService: ConfigConnectionService;
254
+ enable: (() => () => void) & functools_kit.ISingleshotClearable<() => () => void>;
156
255
  disable: () => void;
157
- connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable;
256
+ connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable<() => Promise<() => void>>;
158
257
  }
159
258
 
160
259
  declare class TelegramProviderService {
161
260
  private readonly loggerService;
162
261
  private readonly telegramLogicService;
163
- enable: (() => () => void) & functools_kit.ISingleshotClearable;
262
+ enable: (() => () => void) & functools_kit.ISingleshotClearable<() => () => void>;
164
263
  disable: () => void;
165
- connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable;
264
+ connect: (() => Promise<() => void>) & functools_kit.ISingleshotClearable<() => Promise<() => void>>;
166
265
  }
167
266
 
168
267
  declare class CacheLogicService {
@@ -212,9 +311,10 @@ declare class TelegramLogicService {
212
311
  private notifyAverageBuy;
213
312
  private notifySignalOpen;
214
313
  private notifySignalClose;
314
+ private notifySignalInfo;
215
315
  private notifyCancelScheduled;
216
316
  private notifyClosePending;
217
- connect: (() => () => void) & functools_kit.ISingleshotClearable;
317
+ connect: (() => () => void) & functools_kit.ISingleshotClearable<() => () => void>;
218
318
  }
219
319
 
220
320
  declare class TelegramTemplateService {
@@ -235,6 +335,7 @@ declare class TelegramTemplateService {
235
335
  getSignalCloseMarkdown: (event: SignalCloseContract) => Promise<string>;
236
336
  getCancelScheduledMarkdown: (event: CancelScheduledCommit) => Promise<string>;
237
337
  getClosePendingMarkdown: (event: ClosePendingCommit) => Promise<string>;
338
+ getSignalInfoMarkdown: (event: SignalInfoContract) => Promise<string>;
238
339
  }
239
340
 
240
341
  declare class ModuleConnectionService {
@@ -244,13 +345,25 @@ declare class ModuleConnectionService {
244
345
  loadModule: (fileName: string) => Promise<boolean>;
245
346
  }
246
347
 
247
- interface IBabel {
248
- transpile(code: string): string;
348
+ interface NotificationConfig {
349
+ signal: boolean;
350
+ risk: boolean;
351
+ info: boolean;
352
+ breakeven: boolean;
353
+ common_error: boolean;
354
+ critical_error: boolean;
355
+ validation_error: boolean;
356
+ partial_loss: boolean;
357
+ partial_profit: boolean;
358
+ signal_sync: boolean;
359
+ strategy_commit: boolean;
249
360
  }
250
361
 
251
- declare class BabelService implements IBabel {
362
+ declare class ConfigService {
252
363
  readonly loggerService: LoggerService;
253
- transpile: (code: string) => any;
364
+ readonly configConnectionService: ConfigConnectionService;
365
+ getNotificationConfig: (() => NotificationConfig) & functools_kit.ISingleshotClearable<() => NotificationConfig>;
366
+ waitForInit: (() => Promise<void>) & functools_kit.ISingleshotClearable<() => Promise<void>>;
254
367
  }
255
368
 
256
369
  declare const cli: {
@@ -268,26 +381,23 @@ declare const cli: {
268
381
  paperMainService: PaperMainService;
269
382
  liveMainService: LiveMainService;
270
383
  moduleConnectionService: ModuleConnectionService;
271
- errorService: ErrorService;
272
- loggerService: LoggerService;
384
+ configConnectionService: ConfigConnectionService;
273
385
  resolveService: ResolveService;
274
386
  loaderService: LoaderService;
387
+ configService: ConfigService;
275
388
  babelService: BabelService;
389
+ errorService: ErrorService;
390
+ loggerService: LoggerService;
276
391
  telegramApiService: TelegramApiService;
277
392
  quickchartApiService: QuickchartApiService;
278
393
  };
279
394
 
280
395
  declare class SetupUtils {
281
- enable: (() => void) & functools_kit.ISingleshotClearable;
396
+ enable: (() => void) & functools_kit.ISingleshotClearable<() => void>;
282
397
  clear: () => void;
283
398
  }
284
399
  declare const Setup: SetupUtils;
285
400
 
286
- interface ILoader {
287
- import(filePath: string): any;
288
- check(filePath: string): boolean;
289
- }
290
-
291
401
  declare enum ExchangeName {
292
402
  DefaultExchange = "default_exchange"
293
403
  }