backtest-kit 1.0.3 → 1.0.4
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 +1197 -186
- package/build/index.mjs +1189 -187
- package/package.json +1 -1
- package/types.d.ts +264 -46
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import * as di_scoped from 'di-scoped';
|
|
2
2
|
import * as functools_kit from 'functools-kit';
|
|
3
3
|
|
|
4
|
-
interface IExecutionContext {
|
|
5
|
-
when: Date;
|
|
6
|
-
backtest: boolean;
|
|
7
|
-
}
|
|
8
|
-
declare const ExecutionContextService: (new () => {
|
|
9
|
-
readonly context: IExecutionContext;
|
|
10
|
-
}) & Omit<{
|
|
11
|
-
new (context: IExecutionContext): {
|
|
12
|
-
readonly context: IExecutionContext;
|
|
13
|
-
};
|
|
14
|
-
}, "prototype"> & di_scoped.IScopedClassRun<[context: IExecutionContext]>;
|
|
15
|
-
type TExecutionContextService = InstanceType<typeof ExecutionContextService>;
|
|
16
|
-
|
|
17
4
|
/**
|
|
18
5
|
* Interface representing a logging mechanism for the swarm system.
|
|
19
6
|
* Provides methods to record messages at different severity levels, used across components like agents, sessions, states, storage, swarms, history, embeddings, completions, and policies.
|
|
@@ -37,6 +24,22 @@ interface ILogger {
|
|
|
37
24
|
info(topic: string, ...args: any[]): void;
|
|
38
25
|
}
|
|
39
26
|
|
|
27
|
+
declare function setLogger(logger: ILogger): Promise<void>;
|
|
28
|
+
|
|
29
|
+
interface IExecutionContext {
|
|
30
|
+
symbol: string;
|
|
31
|
+
when: Date;
|
|
32
|
+
backtest: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare const ExecutionContextService: (new () => {
|
|
35
|
+
readonly context: IExecutionContext;
|
|
36
|
+
}) & Omit<{
|
|
37
|
+
new (context: IExecutionContext): {
|
|
38
|
+
readonly context: IExecutionContext;
|
|
39
|
+
};
|
|
40
|
+
}, "prototype"> & di_scoped.IScopedClassRun<[context: IExecutionContext]>;
|
|
41
|
+
type TExecutionContextService = InstanceType<typeof ExecutionContextService>;
|
|
42
|
+
|
|
40
43
|
type CandleInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "6h" | "8h";
|
|
41
44
|
interface ICandleData {
|
|
42
45
|
timestamp: number;
|
|
@@ -54,6 +57,7 @@ interface IExchangeCallbacks {
|
|
|
54
57
|
onCandleData: (symbol: string, interval: CandleInterval, since: Date, limit: number, data: ICandleData[]) => void;
|
|
55
58
|
}
|
|
56
59
|
interface IExchangeSchema {
|
|
60
|
+
exchangeName: ExchangeName;
|
|
57
61
|
getCandles: (symbol: string, interval: CandleInterval, since: Date, limit: number) => Promise<ICandleData[]>;
|
|
58
62
|
formatQuantity: (symbol: string, quantity: number) => Promise<string>;
|
|
59
63
|
formatPrice: (symbol: string, price: number) => Promise<string>;
|
|
@@ -61,13 +65,16 @@ interface IExchangeSchema {
|
|
|
61
65
|
}
|
|
62
66
|
interface IExchange {
|
|
63
67
|
getCandles: (symbol: string, interval: CandleInterval, limit: number) => Promise<ICandleData[]>;
|
|
68
|
+
getNextCandles: (symbol: string, interval: CandleInterval, limit: number) => Promise<ICandleData[]>;
|
|
64
69
|
formatQuantity: (symbol: string, quantity: number) => Promise<string>;
|
|
65
70
|
formatPrice: (symbol: string, price: number) => Promise<string>;
|
|
66
71
|
getAveragePrice: (symbol: string) => Promise<number>;
|
|
67
72
|
}
|
|
73
|
+
type ExchangeName = string;
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
type SignalInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h";
|
|
76
|
+
interface ISignalDto {
|
|
77
|
+
id?: string;
|
|
71
78
|
position: "long" | "short";
|
|
72
79
|
note: string;
|
|
73
80
|
priceOpen: number;
|
|
@@ -76,12 +83,17 @@ interface ISignalData {
|
|
|
76
83
|
minuteEstimatedTime: number;
|
|
77
84
|
timestamp: number;
|
|
78
85
|
}
|
|
86
|
+
interface ISignalRow extends ISignalDto {
|
|
87
|
+
id: string;
|
|
88
|
+
}
|
|
79
89
|
interface IStrategyCallbacks {
|
|
80
|
-
onOpen: (backtest: boolean, symbol: string, data:
|
|
81
|
-
onClose: (backtest: boolean, symbol: string, priceClose: number, data:
|
|
90
|
+
onOpen: (backtest: boolean, symbol: string, data: ISignalRow) => void;
|
|
91
|
+
onClose: (backtest: boolean, symbol: string, priceClose: number, data: ISignalRow) => void;
|
|
82
92
|
}
|
|
83
93
|
interface IStrategySchema {
|
|
84
|
-
|
|
94
|
+
strategyName: StrategyName;
|
|
95
|
+
interval: SignalInterval;
|
|
96
|
+
getSignal: (symbol: string) => Promise<ISignalDto | null>;
|
|
85
97
|
callbacks?: Partial<IStrategyCallbacks>;
|
|
86
98
|
}
|
|
87
99
|
type StrategyCloseReason = "time_expired" | "take_profit" | "stop_loss";
|
|
@@ -96,27 +108,51 @@ interface IStrategyTickResultIdle {
|
|
|
96
108
|
}
|
|
97
109
|
interface IStrategyTickResultOpened {
|
|
98
110
|
action: "opened";
|
|
99
|
-
signal:
|
|
111
|
+
signal: ISignalRow;
|
|
100
112
|
}
|
|
101
113
|
interface IStrategyTickResultActive {
|
|
102
114
|
action: "active";
|
|
103
|
-
signal:
|
|
115
|
+
signal: ISignalRow;
|
|
104
116
|
currentPrice: number;
|
|
105
117
|
}
|
|
106
118
|
interface IStrategyTickResultClosed {
|
|
107
119
|
action: "closed";
|
|
108
|
-
signal:
|
|
120
|
+
signal: ISignalRow;
|
|
109
121
|
currentPrice: number;
|
|
110
122
|
closeReason: StrategyCloseReason;
|
|
123
|
+
closeTimestamp: number;
|
|
111
124
|
pnl: IStrategyPnL;
|
|
112
125
|
}
|
|
113
126
|
type IStrategyTickResult = IStrategyTickResultIdle | IStrategyTickResultOpened | IStrategyTickResultActive | IStrategyTickResultClosed;
|
|
127
|
+
type IStrategyBacktestResult = IStrategyTickResultClosed;
|
|
114
128
|
interface IStrategy {
|
|
115
129
|
tick: (symbol: string) => Promise<IStrategyTickResult>;
|
|
130
|
+
backtest: (candles: ICandleData[]) => Promise<IStrategyBacktestResult>;
|
|
116
131
|
}
|
|
132
|
+
type StrategyName = string;
|
|
133
|
+
|
|
134
|
+
type FrameInterval = "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "6h" | "8h" | "12h" | "1d" | "3d";
|
|
135
|
+
interface IFrameParams extends IFrameSchema {
|
|
136
|
+
logger: ILogger;
|
|
137
|
+
}
|
|
138
|
+
interface IFrameCallbacks {
|
|
139
|
+
onTimeframe: (timeframe: Date[], startDate: Date, endDate: Date, interval: FrameInterval) => void;
|
|
140
|
+
}
|
|
141
|
+
interface IFrameSchema {
|
|
142
|
+
frameName: FrameName;
|
|
143
|
+
interval: FrameInterval;
|
|
144
|
+
startDate: Date;
|
|
145
|
+
endDate: Date;
|
|
146
|
+
callbacks?: Partial<IFrameCallbacks>;
|
|
147
|
+
}
|
|
148
|
+
interface IFrame {
|
|
149
|
+
getTimeframe: (symbol: string) => Promise<Date[]>;
|
|
150
|
+
}
|
|
151
|
+
type FrameName = string;
|
|
117
152
|
|
|
118
153
|
declare function addStrategy(strategySchema: IStrategySchema): void;
|
|
119
154
|
declare function addExchange(exchangeSchema: IExchangeSchema): void;
|
|
155
|
+
declare function addFrame(frameSchema: IFrameSchema): void;
|
|
120
156
|
|
|
121
157
|
interface IBacktestResult {
|
|
122
158
|
symbol: string;
|
|
@@ -145,9 +181,91 @@ declare function getCandles(symbol: string, interval: CandleInterval, limit: num
|
|
|
145
181
|
declare function getAveragePrice(symbol: string): Promise<number>;
|
|
146
182
|
declare function formatPrice(symbol: string, price: number): Promise<string>;
|
|
147
183
|
declare function formatQuantity(symbol: string, quantity: number): Promise<string>;
|
|
184
|
+
declare function getDate(): Promise<Date>;
|
|
185
|
+
declare function getMode(): Promise<"backtest" | "live">;
|
|
186
|
+
|
|
187
|
+
interface IMethodContext {
|
|
188
|
+
exchangeName: ExchangeName;
|
|
189
|
+
strategyName: StrategyName;
|
|
190
|
+
frameName: FrameName;
|
|
191
|
+
}
|
|
192
|
+
declare const MethodContextService: (new () => {
|
|
193
|
+
readonly context: IMethodContext;
|
|
194
|
+
}) & Omit<{
|
|
195
|
+
new (context: IMethodContext): {
|
|
196
|
+
readonly context: IMethodContext;
|
|
197
|
+
};
|
|
198
|
+
}, "prototype"> & di_scoped.IScopedClassRun<[context: IMethodContext]>;
|
|
199
|
+
|
|
200
|
+
declare const BASE_WAIT_FOR_INIT_SYMBOL: unique symbol;
|
|
201
|
+
interface ISignalData {
|
|
202
|
+
signalRow: ISignalRow | null;
|
|
203
|
+
}
|
|
204
|
+
type TPersistBase = InstanceType<typeof PersistBase>;
|
|
205
|
+
type TPersistBaseCtor<EntityName extends string = string, Entity extends IEntity = IEntity> = new (entityName: EntityName, baseDir: string) => IPersistBase<Entity>;
|
|
206
|
+
type EntityId = string | number;
|
|
207
|
+
interface IEntity {
|
|
208
|
+
}
|
|
209
|
+
interface IPersistBase<Entity extends IEntity = IEntity> {
|
|
210
|
+
waitForInit(initial: boolean): Promise<void>;
|
|
211
|
+
readValue(entityId: EntityId): Promise<Entity>;
|
|
212
|
+
hasValue(entityId: EntityId): Promise<boolean>;
|
|
213
|
+
writeValue(entityId: EntityId, entity: Entity): Promise<void>;
|
|
214
|
+
}
|
|
215
|
+
declare const PersistBase: {
|
|
216
|
+
new <EntityName extends string = string>(entityName: EntityName, baseDir?: string): {
|
|
217
|
+
_directory: string;
|
|
218
|
+
readonly entityName: EntityName;
|
|
219
|
+
readonly baseDir: string;
|
|
220
|
+
_getFilePath(entityId: EntityId): string;
|
|
221
|
+
waitForInit(initial: boolean): Promise<void>;
|
|
222
|
+
getCount(): Promise<number>;
|
|
223
|
+
readValue<T extends IEntity = IEntity>(entityId: EntityId): Promise<T>;
|
|
224
|
+
hasValue(entityId: EntityId): Promise<boolean>;
|
|
225
|
+
writeValue<T extends IEntity = IEntity>(entityId: EntityId, entity: T): Promise<void>;
|
|
226
|
+
removeValue(entityId: EntityId): Promise<void>;
|
|
227
|
+
removeAll(): Promise<void>;
|
|
228
|
+
values<T extends IEntity = IEntity>(): AsyncGenerator<T>;
|
|
229
|
+
keys(): AsyncGenerator<EntityId>;
|
|
230
|
+
filter<T extends IEntity = IEntity>(predicate: (value: T) => boolean): AsyncGenerator<T>;
|
|
231
|
+
take<T extends IEntity = IEntity>(total: number, predicate?: (value: T) => boolean): AsyncGenerator<T>;
|
|
232
|
+
[BASE_WAIT_FOR_INIT_SYMBOL]: (() => Promise<void>) & functools_kit.ISingleshotClearable;
|
|
233
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
declare class PersistSignalUtils {
|
|
237
|
+
private PersistSignalFactory;
|
|
238
|
+
private getSignalStorage;
|
|
239
|
+
usePersistSignalAdapter(Ctor: TPersistBaseCtor<StrategyName, ISignalData>): void;
|
|
240
|
+
readSignalData: (strategyName: StrategyName, symbol: string) => Promise<ISignalRow | null>;
|
|
241
|
+
writeSignalData: (signalRow: ISignalRow | null, strategyName: StrategyName, symbol: string) => Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
declare const PersistSignalAdaper: PersistSignalUtils;
|
|
244
|
+
|
|
245
|
+
declare class BacktestUtils {
|
|
246
|
+
run: (symbol: string, context: {
|
|
247
|
+
strategyName: string;
|
|
248
|
+
exchangeName: string;
|
|
249
|
+
frameName: string;
|
|
250
|
+
}) => AsyncGenerator<IStrategyTickResultClosed, void, unknown>;
|
|
251
|
+
}
|
|
252
|
+
declare const Backtest: BacktestUtils;
|
|
253
|
+
|
|
254
|
+
declare class LiveUtils {
|
|
255
|
+
run: (symbol: string, context: {
|
|
256
|
+
strategyName: string;
|
|
257
|
+
exchangeName: string;
|
|
258
|
+
frameName: string;
|
|
259
|
+
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
260
|
+
}
|
|
261
|
+
declare const Live: LiveUtils;
|
|
148
262
|
|
|
149
263
|
declare class LoggerService implements ILogger {
|
|
264
|
+
private readonly methodContextService;
|
|
265
|
+
private readonly executionContextService;
|
|
150
266
|
private _commonLogger;
|
|
267
|
+
private get methodContext();
|
|
268
|
+
private get executionContext();
|
|
151
269
|
log: (topic: string, ...args: any[]) => Promise<void>;
|
|
152
270
|
debug: (topic: string, ...args: any[]) => Promise<void>;
|
|
153
271
|
info: (topic: string, ...args: any[]) => Promise<void>;
|
|
@@ -157,72 +275,172 @@ declare class LoggerService implements ILogger {
|
|
|
157
275
|
declare class ClientExchange implements IExchange {
|
|
158
276
|
readonly params: IExchangeParams;
|
|
159
277
|
constructor(params: IExchangeParams);
|
|
160
|
-
getCandles
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
278
|
+
getCandles(symbol: string, interval: CandleInterval, limit: number): Promise<ICandleData[]>;
|
|
279
|
+
getNextCandles(symbol: string, interval: CandleInterval, limit: number): Promise<ICandleData[]>;
|
|
280
|
+
getAveragePrice(symbol: string): Promise<number>;
|
|
281
|
+
formatQuantity(symbol: string, quantity: number): Promise<string>;
|
|
282
|
+
formatPrice(symbol: string, price: number): Promise<string>;
|
|
164
283
|
}
|
|
165
284
|
|
|
166
285
|
declare class ExchangeConnectionService implements IExchange {
|
|
167
286
|
private readonly loggerService;
|
|
168
287
|
private readonly executionContextService;
|
|
169
288
|
private readonly exchangeSchemaService;
|
|
170
|
-
|
|
289
|
+
private readonly methodContextService;
|
|
290
|
+
getExchange: ((exchangeName: ExchangeName) => ClientExchange) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientExchange>;
|
|
171
291
|
getCandles: (symbol: string, interval: CandleInterval, limit: number) => Promise<ICandleData[]>;
|
|
292
|
+
getNextCandles: (symbol: string, interval: CandleInterval, limit: number) => Promise<ICandleData[]>;
|
|
172
293
|
getAveragePrice: (symbol: string) => Promise<number>;
|
|
173
294
|
formatPrice: (symbol: string, price: number) => Promise<string>;
|
|
174
295
|
formatQuantity: (symbol: string, quantity: number) => Promise<string>;
|
|
175
296
|
}
|
|
176
297
|
|
|
177
|
-
declare class ExchangeSchemaService {
|
|
178
|
-
private readonly loggerService;
|
|
179
|
-
private _exchangeSchema;
|
|
180
|
-
getSchema: () => IExchangeSchema;
|
|
181
|
-
addSchema: (exchangeSchema: IExchangeSchema) => void;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
declare class StrategySchemaService {
|
|
185
|
-
private readonly loggerService;
|
|
186
|
-
private _strategySchema;
|
|
187
|
-
getSchema: () => IStrategySchema;
|
|
188
|
-
addSchema: (strategySchema: IStrategySchema) => void;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
298
|
declare class StrategyConnectionService implements IStrategy {
|
|
192
299
|
private readonly loggerService;
|
|
193
300
|
private readonly executionContextService;
|
|
194
301
|
private readonly strategySchemaService;
|
|
195
302
|
private readonly exchangeConnectionService;
|
|
303
|
+
private readonly methodContextService;
|
|
196
304
|
private getStrategy;
|
|
197
|
-
tick: (
|
|
305
|
+
tick: () => Promise<IStrategyTickResult>;
|
|
306
|
+
backtest: (candles: ICandleData[]) => Promise<IStrategyBacktestResult>;
|
|
198
307
|
}
|
|
199
308
|
|
|
200
|
-
declare class
|
|
309
|
+
declare class ClientFrame implements IFrame {
|
|
310
|
+
readonly params: IFrameParams;
|
|
311
|
+
constructor(params: IFrameParams);
|
|
312
|
+
getTimeframe: ((symbol: string) => Promise<Date[]>) & functools_kit.ISingleshotClearable;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare class FrameConnectionService implements IFrame {
|
|
316
|
+
private readonly loggerService;
|
|
317
|
+
private readonly frameSchemaService;
|
|
318
|
+
private readonly methodContextService;
|
|
319
|
+
getFrame: ((frameName: FrameName) => ClientFrame) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientFrame>;
|
|
320
|
+
getTimeframe: (symbol: string) => Promise<Date[]>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class ExchangeGlobalService {
|
|
201
324
|
private readonly loggerService;
|
|
202
325
|
private readonly exchangeConnectionService;
|
|
203
326
|
getCandles: (symbol: string, interval: CandleInterval, limit: number, when: Date, backtest: boolean) => Promise<ICandleData[]>;
|
|
327
|
+
getNextCandles: (symbol: string, interval: CandleInterval, limit: number, when: Date, backtest: boolean) => Promise<ICandleData[]>;
|
|
204
328
|
getAveragePrice: (symbol: string, when: Date, backtest: boolean) => Promise<number>;
|
|
205
329
|
formatPrice: (symbol: string, price: number, when: Date, backtest: boolean) => Promise<string>;
|
|
206
330
|
formatQuantity: (symbol: string, quantity: number, when: Date, backtest: boolean) => Promise<string>;
|
|
207
331
|
}
|
|
208
332
|
|
|
209
|
-
declare class
|
|
333
|
+
declare class StrategyGlobalService {
|
|
210
334
|
private readonly loggerService;
|
|
211
335
|
private readonly strategyConnectionService;
|
|
212
336
|
tick: (symbol: string, when: Date, backtest: boolean) => Promise<IStrategyTickResult>;
|
|
337
|
+
backtest: (symbol: string, candles: ICandleData[], when: Date, backtest: boolean) => Promise<IStrategyBacktestResult>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare class FrameGlobalService {
|
|
341
|
+
private readonly loggerService;
|
|
342
|
+
private readonly frameConnectionService;
|
|
343
|
+
getTimeframe: (symbol: string) => Promise<Date[]>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare class ExchangeSchemaService {
|
|
347
|
+
readonly loggerService: LoggerService;
|
|
348
|
+
private _registry;
|
|
349
|
+
register: (key: ExchangeName, value: IExchangeSchema) => void;
|
|
350
|
+
override: (key: ExchangeName, value: Partial<IExchangeSchema>) => IExchangeSchema;
|
|
351
|
+
get: (key: ExchangeName) => IExchangeSchema;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
declare class StrategySchemaService {
|
|
355
|
+
readonly loggerService: LoggerService;
|
|
356
|
+
private _registry;
|
|
357
|
+
register: (key: StrategyName, value: IStrategySchema) => void;
|
|
358
|
+
override: (key: StrategyName, value: Partial<IStrategySchema>) => IStrategySchema;
|
|
359
|
+
get: (key: StrategyName) => IStrategySchema;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
declare class FrameSchemaService {
|
|
363
|
+
private _registry;
|
|
364
|
+
register(key: FrameName, value: IFrameSchema): void;
|
|
365
|
+
override(key: FrameName, value: Partial<IFrameSchema>): void;
|
|
366
|
+
get(key: FrameName): IFrameSchema;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
declare class BacktestLogicPrivateService {
|
|
370
|
+
private readonly loggerService;
|
|
371
|
+
private readonly strategyGlobalService;
|
|
372
|
+
private readonly exchangeGlobalService;
|
|
373
|
+
private readonly frameGlobalService;
|
|
374
|
+
run(symbol: string): AsyncGenerator<IStrategyTickResultClosed, void, unknown>;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare class LiveLogicPrivateService {
|
|
378
|
+
private readonly loggerService;
|
|
379
|
+
private readonly strategyGlobalService;
|
|
380
|
+
run(symbol: string): AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
declare class BacktestLogicPublicService {
|
|
384
|
+
private readonly loggerService;
|
|
385
|
+
private readonly backtestLogicPrivateService;
|
|
386
|
+
run: (symbol: string, context: {
|
|
387
|
+
strategyName: string;
|
|
388
|
+
exchangeName: string;
|
|
389
|
+
frameName: string;
|
|
390
|
+
}) => AsyncGenerator<IStrategyTickResultClosed, void, unknown>;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
declare class LiveLogicPublicService {
|
|
394
|
+
private readonly loggerService;
|
|
395
|
+
private readonly liveLogicPrivateService;
|
|
396
|
+
run: (symbol: string, context: {
|
|
397
|
+
strategyName: string;
|
|
398
|
+
exchangeName: string;
|
|
399
|
+
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
declare class LiveGlobalService {
|
|
403
|
+
private readonly loggerService;
|
|
404
|
+
private readonly liveLogicPublicService;
|
|
405
|
+
run: (symbol: string, context: {
|
|
406
|
+
strategyName: string;
|
|
407
|
+
exchangeName: string;
|
|
408
|
+
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
declare class BacktestGlobalService {
|
|
412
|
+
private readonly loggerService;
|
|
413
|
+
private readonly backtestLogicPublicService;
|
|
414
|
+
run: (symbol: string, context: {
|
|
415
|
+
strategyName: string;
|
|
416
|
+
exchangeName: string;
|
|
417
|
+
frameName: string;
|
|
418
|
+
}) => AsyncGenerator<IStrategyTickResultClosed, void, unknown>;
|
|
213
419
|
}
|
|
214
420
|
|
|
215
421
|
declare const backtest: {
|
|
216
|
-
|
|
217
|
-
|
|
422
|
+
backtestLogicPublicService: BacktestLogicPublicService;
|
|
423
|
+
liveLogicPublicService: LiveLogicPublicService;
|
|
424
|
+
backtestLogicPrivateService: BacktestLogicPrivateService;
|
|
425
|
+
liveLogicPrivateService: LiveLogicPrivateService;
|
|
426
|
+
exchangeGlobalService: ExchangeGlobalService;
|
|
427
|
+
strategyGlobalService: StrategyGlobalService;
|
|
428
|
+
frameGlobalService: FrameGlobalService;
|
|
429
|
+
liveGlobalService: LiveGlobalService;
|
|
430
|
+
backtestGlobalService: BacktestGlobalService;
|
|
218
431
|
exchangeSchemaService: ExchangeSchemaService;
|
|
219
432
|
strategySchemaService: StrategySchemaService;
|
|
433
|
+
frameSchemaService: FrameSchemaService;
|
|
220
434
|
exchangeConnectionService: ExchangeConnectionService;
|
|
221
435
|
strategyConnectionService: StrategyConnectionService;
|
|
436
|
+
frameConnectionService: FrameConnectionService;
|
|
222
437
|
executionContextService: {
|
|
223
438
|
readonly context: IExecutionContext;
|
|
224
439
|
};
|
|
440
|
+
methodContextService: {
|
|
441
|
+
readonly context: IMethodContext;
|
|
442
|
+
};
|
|
225
443
|
loggerService: LoggerService;
|
|
226
444
|
};
|
|
227
445
|
|
|
228
|
-
export { type CandleInterval, ExecutionContextService, type ICandleData, type IExchangeSchema, type
|
|
446
|
+
export { Backtest, type CandleInterval, ExecutionContextService, type FrameInterval, type ICandleData, type IExchangeSchema, type IFrameSchema, type IPersistBase, type ISignalDto, type ISignalRow, type IStrategyPnL, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, Live, MethodContextService, PersistBase, PersistSignalAdaper, type SignalInterval, type TPersistBase, type TPersistBaseCtor, addExchange, addFrame, addStrategy, backtest, formatPrice, formatQuantity, getAveragePrice, getCandles, getDate, getMode, reduce, runBacktest, runBacktestGUI, setLogger, startRun, stopAll, stopRun };
|