backtest-kit 1.11.8 → 1.11.9
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 +94 -12
- package/build/index.mjs +94 -13
- package/package.json +1 -1
- package/types.d.ts +75 -10
package/build/index.cjs
CHANGED
|
@@ -422,6 +422,13 @@ const GLOBAL_CONFIG = {
|
|
|
422
422
|
* Default: 10 minutes
|
|
423
423
|
*/
|
|
424
424
|
CC_ORDER_BOOK_TIME_OFFSET_MINUTES: 10,
|
|
425
|
+
/**
|
|
426
|
+
* Maximum depth levels for order book fetching.
|
|
427
|
+
* Specifies how many price levels to fetch from both bids and asks.
|
|
428
|
+
*
|
|
429
|
+
* Default: 20 levels
|
|
430
|
+
*/
|
|
431
|
+
CC_ORDER_BOOK_MAX_DEPTH_LEVELS: 1000,
|
|
425
432
|
};
|
|
426
433
|
const DEFAULT_CONFIG = Object.freeze({ ...GLOBAL_CONFIG });
|
|
427
434
|
|
|
@@ -891,17 +898,23 @@ class ClientExchange {
|
|
|
891
898
|
/**
|
|
892
899
|
* Fetches order book for a trading pair.
|
|
893
900
|
*
|
|
901
|
+
* Calculates time range based on execution context time (when) and
|
|
902
|
+
* CC_ORDER_BOOK_TIME_OFFSET_MINUTES, then delegates to the exchange
|
|
903
|
+
* schema implementation which may use or ignore the time range.
|
|
904
|
+
*
|
|
894
905
|
* @param symbol - Trading pair symbol
|
|
906
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
895
907
|
* @returns Promise resolving to order book data
|
|
896
908
|
* @throws Error if getOrderBook is not implemented
|
|
897
909
|
*/
|
|
898
|
-
async getOrderBook(symbol) {
|
|
910
|
+
async getOrderBook(symbol, depth = GLOBAL_CONFIG.CC_ORDER_BOOK_MAX_DEPTH_LEVELS) {
|
|
899
911
|
this.params.logger.debug("ClientExchange getOrderBook", {
|
|
900
912
|
symbol,
|
|
913
|
+
depth,
|
|
901
914
|
});
|
|
902
915
|
const to = new Date(this.params.execution.context.when.getTime());
|
|
903
916
|
const from = new Date(to.getTime() - GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * 60 * 1000);
|
|
904
|
-
return await this.params.getOrderBook(symbol, from, to);
|
|
917
|
+
return await this.params.getOrderBook(symbol, depth, from, to);
|
|
905
918
|
}
|
|
906
919
|
}
|
|
907
920
|
|
|
@@ -929,8 +942,13 @@ const DEFAULT_FORMAT_PRICE_FN$1 = async (_symbol, price) => {
|
|
|
929
942
|
/**
|
|
930
943
|
* Default implementation for getOrderBook.
|
|
931
944
|
* Throws an error indicating the method is not implemented.
|
|
945
|
+
*
|
|
946
|
+
* @param _symbol - Trading pair symbol (unused)
|
|
947
|
+
* @param _depth - Maximum depth levels (unused)
|
|
948
|
+
* @param _from - Start of time range (unused - can be ignored in live implementations)
|
|
949
|
+
* @param _to - End of time range (unused - can be ignored in live implementations)
|
|
932
950
|
*/
|
|
933
|
-
const DEFAULT_GET_ORDER_BOOK_FN$1 = async (_symbol, _from, _to) => {
|
|
951
|
+
const DEFAULT_GET_ORDER_BOOK_FN$1 = async (_symbol, _depth, _from, _to) => {
|
|
934
952
|
throw new Error(`getOrderBook is not implemented for this exchange`);
|
|
935
953
|
};
|
|
936
954
|
/**
|
|
@@ -1071,15 +1089,19 @@ class ExchangeConnectionService {
|
|
|
1071
1089
|
* Fetches order book for a trading pair using configured exchange.
|
|
1072
1090
|
*
|
|
1073
1091
|
* Routes to exchange determined by methodContextService.context.exchangeName.
|
|
1092
|
+
* The ClientExchange will calculate time range and pass it to the schema
|
|
1093
|
+
* implementation, which may use (backtest) or ignore (live) the parameters.
|
|
1074
1094
|
*
|
|
1075
1095
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
1096
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
1076
1097
|
* @returns Promise resolving to order book data
|
|
1077
1098
|
*/
|
|
1078
|
-
this.getOrderBook = async (symbol) => {
|
|
1099
|
+
this.getOrderBook = async (symbol, depth) => {
|
|
1079
1100
|
this.loggerService.log("exchangeConnectionService getOrderBook", {
|
|
1080
1101
|
symbol,
|
|
1102
|
+
depth,
|
|
1081
1103
|
});
|
|
1082
|
-
return await this.getExchange(this.methodContextService.context.exchangeName).getOrderBook(symbol);
|
|
1104
|
+
return await this.getExchange(this.methodContextService.context.exchangeName).getOrderBook(symbol, depth);
|
|
1083
1105
|
};
|
|
1084
1106
|
}
|
|
1085
1107
|
}
|
|
@@ -7466,23 +7488,29 @@ class ExchangeCoreService {
|
|
|
7466
7488
|
/**
|
|
7467
7489
|
* Fetches order book with execution context.
|
|
7468
7490
|
*
|
|
7491
|
+
* Sets up execution context with the provided when/backtest parameters.
|
|
7492
|
+
* The exchange implementation will receive time range parameters but may
|
|
7493
|
+
* choose to use them (backtest) or ignore them (live).
|
|
7494
|
+
*
|
|
7469
7495
|
* @param symbol - Trading pair symbol
|
|
7470
7496
|
* @param when - Timestamp for context
|
|
7471
7497
|
* @param backtest - Whether running in backtest mode
|
|
7498
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
7472
7499
|
* @returns Promise resolving to order book data
|
|
7473
7500
|
*/
|
|
7474
|
-
this.getOrderBook = async (symbol, when, backtest) => {
|
|
7501
|
+
this.getOrderBook = async (symbol, when, backtest, depth) => {
|
|
7475
7502
|
this.loggerService.log("exchangeCoreService getOrderBook", {
|
|
7476
7503
|
symbol,
|
|
7477
7504
|
when,
|
|
7478
7505
|
backtest,
|
|
7506
|
+
depth,
|
|
7479
7507
|
});
|
|
7480
7508
|
if (!MethodContextService.hasContext()) {
|
|
7481
7509
|
throw new Error("exchangeCoreService getOrderBook requires a method context");
|
|
7482
7510
|
}
|
|
7483
7511
|
await this.validate(this.methodContextService.context.exchangeName);
|
|
7484
7512
|
return await ExecutionContextService.runInContext(async () => {
|
|
7485
|
-
return await this.exchangeConnectionService.getOrderBook(symbol);
|
|
7513
|
+
return await this.exchangeConnectionService.getOrderBook(symbol, depth);
|
|
7486
7514
|
}, {
|
|
7487
7515
|
symbol,
|
|
7488
7516
|
when,
|
|
@@ -21351,6 +21379,7 @@ const FORMAT_QUANTITY_METHOD_NAME = "exchange.formatQuantity";
|
|
|
21351
21379
|
const GET_DATE_METHOD_NAME = "exchange.getDate";
|
|
21352
21380
|
const GET_MODE_METHOD_NAME = "exchange.getMode";
|
|
21353
21381
|
const HAS_TRADE_CONTEXT_METHOD_NAME = "exchange.hasTradeContext";
|
|
21382
|
+
const GET_ORDER_BOOK_METHOD_NAME = "exchange.getOrderBook";
|
|
21354
21383
|
/**
|
|
21355
21384
|
* Checks if trade context is active (execution and method contexts).
|
|
21356
21385
|
*
|
|
@@ -21531,6 +21560,41 @@ async function getMode() {
|
|
|
21531
21560
|
const { backtest: bt$1 } = bt.executionContextService.context;
|
|
21532
21561
|
return bt$1 ? "backtest" : "live";
|
|
21533
21562
|
}
|
|
21563
|
+
/**
|
|
21564
|
+
* Fetches order book for a trading pair from the registered exchange.
|
|
21565
|
+
*
|
|
21566
|
+
* Uses current execution context to determine timing. The underlying exchange
|
|
21567
|
+
* implementation receives time range parameters but may use them (backtest)
|
|
21568
|
+
* or ignore them (live trading).
|
|
21569
|
+
*
|
|
21570
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
21571
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
21572
|
+
* @returns Promise resolving to order book data
|
|
21573
|
+
* @throws Error if execution or method context is missing
|
|
21574
|
+
*
|
|
21575
|
+
* @example
|
|
21576
|
+
* ```typescript
|
|
21577
|
+
* const orderBook = await getOrderBook("BTCUSDT");
|
|
21578
|
+
* console.log(orderBook.bids); // [{ price: "50000.00", quantity: "0.5" }, ...]
|
|
21579
|
+
* console.log(orderBook.asks); // [{ price: "50001.00", quantity: "0.3" }, ...]
|
|
21580
|
+
*
|
|
21581
|
+
* // Fetch deeper order book
|
|
21582
|
+
* const deepBook = await getOrderBook("BTCUSDT", 100);
|
|
21583
|
+
* ```
|
|
21584
|
+
*/
|
|
21585
|
+
async function getOrderBook(symbol, depth) {
|
|
21586
|
+
bt.loggerService.info(GET_ORDER_BOOK_METHOD_NAME, {
|
|
21587
|
+
symbol,
|
|
21588
|
+
depth,
|
|
21589
|
+
});
|
|
21590
|
+
if (!ExecutionContextService.hasContext()) {
|
|
21591
|
+
throw new Error("getOrderBook requires an execution context");
|
|
21592
|
+
}
|
|
21593
|
+
if (!MethodContextService.hasContext()) {
|
|
21594
|
+
throw new Error("getOrderBook requires a method context");
|
|
21595
|
+
}
|
|
21596
|
+
return await bt.exchangeConnectionService.getOrderBook(symbol, depth);
|
|
21597
|
+
}
|
|
21534
21598
|
|
|
21535
21599
|
const STOP_METHOD_NAME = "strategy.stop";
|
|
21536
21600
|
const CANCEL_METHOD_NAME = "strategy.cancel";
|
|
@@ -27131,8 +27195,13 @@ const DEFAULT_FORMAT_PRICE_FN = async (_symbol, price) => {
|
|
|
27131
27195
|
/**
|
|
27132
27196
|
* Default implementation for getOrderBook.
|
|
27133
27197
|
* Throws an error indicating the method is not implemented.
|
|
27198
|
+
*
|
|
27199
|
+
* @param _symbol - Trading pair symbol (unused)
|
|
27200
|
+
* @param _depth - Maximum depth levels (unused)
|
|
27201
|
+
* @param _from - Start of time range (unused - can be ignored in live implementations)
|
|
27202
|
+
* @param _to - End of time range (unused - can be ignored in live implementations)
|
|
27134
27203
|
*/
|
|
27135
|
-
const DEFAULT_GET_ORDER_BOOK_FN = async (_symbol, _from, _to) => {
|
|
27204
|
+
const DEFAULT_GET_ORDER_BOOK_FN = async (_symbol, _depth, _from, _to) => {
|
|
27136
27205
|
throw new Error(`getOrderBook is not implemented for this exchange`);
|
|
27137
27206
|
};
|
|
27138
27207
|
const INTERVAL_MINUTES$1 = {
|
|
@@ -27343,7 +27412,12 @@ class ExchangeInstance {
|
|
|
27343
27412
|
/**
|
|
27344
27413
|
* Fetch order book for a trading pair.
|
|
27345
27414
|
*
|
|
27415
|
+
* Calculates time range using CC_ORDER_BOOK_TIME_OFFSET_MINUTES (default 10 minutes)
|
|
27416
|
+
* and passes it to the exchange schema implementation. The implementation may use
|
|
27417
|
+
* the time range (backtest) or ignore it (live trading).
|
|
27418
|
+
*
|
|
27346
27419
|
* @param symbol - Trading pair symbol
|
|
27420
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
27347
27421
|
* @returns Promise resolving to order book data
|
|
27348
27422
|
* @throws Error if getOrderBook is not implemented
|
|
27349
27423
|
*
|
|
@@ -27352,16 +27426,18 @@ class ExchangeInstance {
|
|
|
27352
27426
|
* const instance = new ExchangeInstance("binance");
|
|
27353
27427
|
* const orderBook = await instance.getOrderBook("BTCUSDT");
|
|
27354
27428
|
* console.log(orderBook.bids); // [{ price: "50000.00", quantity: "0.5" }, ...]
|
|
27429
|
+
* const deepOrderBook = await instance.getOrderBook("BTCUSDT", 100);
|
|
27355
27430
|
* ```
|
|
27356
27431
|
*/
|
|
27357
|
-
this.getOrderBook = async (symbol) => {
|
|
27432
|
+
this.getOrderBook = async (symbol, depth = GLOBAL_CONFIG.CC_ORDER_BOOK_MAX_DEPTH_LEVELS) => {
|
|
27358
27433
|
bt.loggerService.info(EXCHANGE_METHOD_NAME_GET_ORDER_BOOK, {
|
|
27359
27434
|
exchangeName: this.exchangeName,
|
|
27360
27435
|
symbol,
|
|
27436
|
+
depth,
|
|
27361
27437
|
});
|
|
27362
27438
|
const to = new Date(Date.now());
|
|
27363
27439
|
const from = new Date(to.getTime() - GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * 60 * 1000);
|
|
27364
|
-
return await this._methods.getOrderBook(symbol, from, to);
|
|
27440
|
+
return await this._methods.getOrderBook(symbol, depth, from, to);
|
|
27365
27441
|
};
|
|
27366
27442
|
const schema = bt.exchangeSchemaService.get(this.exchangeName);
|
|
27367
27443
|
this._methods = CREATE_EXCHANGE_INSTANCE_FN(schema);
|
|
@@ -27453,14 +27529,19 @@ class ExchangeUtils {
|
|
|
27453
27529
|
/**
|
|
27454
27530
|
* Fetch order book for a trading pair.
|
|
27455
27531
|
*
|
|
27532
|
+
* Delegates to ExchangeInstance which calculates time range and passes it
|
|
27533
|
+
* to the exchange schema implementation. The from/to parameters may be used
|
|
27534
|
+
* (backtest) or ignored (live) depending on the implementation.
|
|
27535
|
+
*
|
|
27456
27536
|
* @param symbol - Trading pair symbol
|
|
27457
27537
|
* @param context - Execution context with exchange name
|
|
27538
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
27458
27539
|
* @returns Promise resolving to order book data
|
|
27459
27540
|
*/
|
|
27460
|
-
this.getOrderBook = async (symbol, context) => {
|
|
27541
|
+
this.getOrderBook = async (symbol, context, depth = GLOBAL_CONFIG.CC_ORDER_BOOK_MAX_DEPTH_LEVELS) => {
|
|
27461
27542
|
bt.exchangeValidationService.validate(context.exchangeName, EXCHANGE_METHOD_NAME_GET_ORDER_BOOK);
|
|
27462
27543
|
const instance = this._getInstance(context.exchangeName);
|
|
27463
|
-
return await instance.getOrderBook(symbol);
|
|
27544
|
+
return await instance.getOrderBook(symbol, depth);
|
|
27464
27545
|
};
|
|
27465
27546
|
}
|
|
27466
27547
|
}
|
|
@@ -28455,6 +28536,7 @@ exports.getDate = getDate;
|
|
|
28455
28536
|
exports.getDefaultColumns = getDefaultColumns;
|
|
28456
28537
|
exports.getDefaultConfig = getDefaultConfig;
|
|
28457
28538
|
exports.getMode = getMode;
|
|
28539
|
+
exports.getOrderBook = getOrderBook;
|
|
28458
28540
|
exports.hasTradeContext = hasTradeContext;
|
|
28459
28541
|
exports.lib = backtest;
|
|
28460
28542
|
exports.listExchanges = listExchanges;
|
package/build/index.mjs
CHANGED
|
@@ -402,6 +402,13 @@ const GLOBAL_CONFIG = {
|
|
|
402
402
|
* Default: 10 minutes
|
|
403
403
|
*/
|
|
404
404
|
CC_ORDER_BOOK_TIME_OFFSET_MINUTES: 10,
|
|
405
|
+
/**
|
|
406
|
+
* Maximum depth levels for order book fetching.
|
|
407
|
+
* Specifies how many price levels to fetch from both bids and asks.
|
|
408
|
+
*
|
|
409
|
+
* Default: 20 levels
|
|
410
|
+
*/
|
|
411
|
+
CC_ORDER_BOOK_MAX_DEPTH_LEVELS: 1000,
|
|
405
412
|
};
|
|
406
413
|
const DEFAULT_CONFIG = Object.freeze({ ...GLOBAL_CONFIG });
|
|
407
414
|
|
|
@@ -871,17 +878,23 @@ class ClientExchange {
|
|
|
871
878
|
/**
|
|
872
879
|
* Fetches order book for a trading pair.
|
|
873
880
|
*
|
|
881
|
+
* Calculates time range based on execution context time (when) and
|
|
882
|
+
* CC_ORDER_BOOK_TIME_OFFSET_MINUTES, then delegates to the exchange
|
|
883
|
+
* schema implementation which may use or ignore the time range.
|
|
884
|
+
*
|
|
874
885
|
* @param symbol - Trading pair symbol
|
|
886
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
875
887
|
* @returns Promise resolving to order book data
|
|
876
888
|
* @throws Error if getOrderBook is not implemented
|
|
877
889
|
*/
|
|
878
|
-
async getOrderBook(symbol) {
|
|
890
|
+
async getOrderBook(symbol, depth = GLOBAL_CONFIG.CC_ORDER_BOOK_MAX_DEPTH_LEVELS) {
|
|
879
891
|
this.params.logger.debug("ClientExchange getOrderBook", {
|
|
880
892
|
symbol,
|
|
893
|
+
depth,
|
|
881
894
|
});
|
|
882
895
|
const to = new Date(this.params.execution.context.when.getTime());
|
|
883
896
|
const from = new Date(to.getTime() - GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * 60 * 1000);
|
|
884
|
-
return await this.params.getOrderBook(symbol, from, to);
|
|
897
|
+
return await this.params.getOrderBook(symbol, depth, from, to);
|
|
885
898
|
}
|
|
886
899
|
}
|
|
887
900
|
|
|
@@ -909,8 +922,13 @@ const DEFAULT_FORMAT_PRICE_FN$1 = async (_symbol, price) => {
|
|
|
909
922
|
/**
|
|
910
923
|
* Default implementation for getOrderBook.
|
|
911
924
|
* Throws an error indicating the method is not implemented.
|
|
925
|
+
*
|
|
926
|
+
* @param _symbol - Trading pair symbol (unused)
|
|
927
|
+
* @param _depth - Maximum depth levels (unused)
|
|
928
|
+
* @param _from - Start of time range (unused - can be ignored in live implementations)
|
|
929
|
+
* @param _to - End of time range (unused - can be ignored in live implementations)
|
|
912
930
|
*/
|
|
913
|
-
const DEFAULT_GET_ORDER_BOOK_FN$1 = async (_symbol, _from, _to) => {
|
|
931
|
+
const DEFAULT_GET_ORDER_BOOK_FN$1 = async (_symbol, _depth, _from, _to) => {
|
|
914
932
|
throw new Error(`getOrderBook is not implemented for this exchange`);
|
|
915
933
|
};
|
|
916
934
|
/**
|
|
@@ -1051,15 +1069,19 @@ class ExchangeConnectionService {
|
|
|
1051
1069
|
* Fetches order book for a trading pair using configured exchange.
|
|
1052
1070
|
*
|
|
1053
1071
|
* Routes to exchange determined by methodContextService.context.exchangeName.
|
|
1072
|
+
* The ClientExchange will calculate time range and pass it to the schema
|
|
1073
|
+
* implementation, which may use (backtest) or ignore (live) the parameters.
|
|
1054
1074
|
*
|
|
1055
1075
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
1076
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
1056
1077
|
* @returns Promise resolving to order book data
|
|
1057
1078
|
*/
|
|
1058
|
-
this.getOrderBook = async (symbol) => {
|
|
1079
|
+
this.getOrderBook = async (symbol, depth) => {
|
|
1059
1080
|
this.loggerService.log("exchangeConnectionService getOrderBook", {
|
|
1060
1081
|
symbol,
|
|
1082
|
+
depth,
|
|
1061
1083
|
});
|
|
1062
|
-
return await this.getExchange(this.methodContextService.context.exchangeName).getOrderBook(symbol);
|
|
1084
|
+
return await this.getExchange(this.methodContextService.context.exchangeName).getOrderBook(symbol, depth);
|
|
1063
1085
|
};
|
|
1064
1086
|
}
|
|
1065
1087
|
}
|
|
@@ -7446,23 +7468,29 @@ class ExchangeCoreService {
|
|
|
7446
7468
|
/**
|
|
7447
7469
|
* Fetches order book with execution context.
|
|
7448
7470
|
*
|
|
7471
|
+
* Sets up execution context with the provided when/backtest parameters.
|
|
7472
|
+
* The exchange implementation will receive time range parameters but may
|
|
7473
|
+
* choose to use them (backtest) or ignore them (live).
|
|
7474
|
+
*
|
|
7449
7475
|
* @param symbol - Trading pair symbol
|
|
7450
7476
|
* @param when - Timestamp for context
|
|
7451
7477
|
* @param backtest - Whether running in backtest mode
|
|
7478
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
7452
7479
|
* @returns Promise resolving to order book data
|
|
7453
7480
|
*/
|
|
7454
|
-
this.getOrderBook = async (symbol, when, backtest) => {
|
|
7481
|
+
this.getOrderBook = async (symbol, when, backtest, depth) => {
|
|
7455
7482
|
this.loggerService.log("exchangeCoreService getOrderBook", {
|
|
7456
7483
|
symbol,
|
|
7457
7484
|
when,
|
|
7458
7485
|
backtest,
|
|
7486
|
+
depth,
|
|
7459
7487
|
});
|
|
7460
7488
|
if (!MethodContextService.hasContext()) {
|
|
7461
7489
|
throw new Error("exchangeCoreService getOrderBook requires a method context");
|
|
7462
7490
|
}
|
|
7463
7491
|
await this.validate(this.methodContextService.context.exchangeName);
|
|
7464
7492
|
return await ExecutionContextService.runInContext(async () => {
|
|
7465
|
-
return await this.exchangeConnectionService.getOrderBook(symbol);
|
|
7493
|
+
return await this.exchangeConnectionService.getOrderBook(symbol, depth);
|
|
7466
7494
|
}, {
|
|
7467
7495
|
symbol,
|
|
7468
7496
|
when,
|
|
@@ -21331,6 +21359,7 @@ const FORMAT_QUANTITY_METHOD_NAME = "exchange.formatQuantity";
|
|
|
21331
21359
|
const GET_DATE_METHOD_NAME = "exchange.getDate";
|
|
21332
21360
|
const GET_MODE_METHOD_NAME = "exchange.getMode";
|
|
21333
21361
|
const HAS_TRADE_CONTEXT_METHOD_NAME = "exchange.hasTradeContext";
|
|
21362
|
+
const GET_ORDER_BOOK_METHOD_NAME = "exchange.getOrderBook";
|
|
21334
21363
|
/**
|
|
21335
21364
|
* Checks if trade context is active (execution and method contexts).
|
|
21336
21365
|
*
|
|
@@ -21511,6 +21540,41 @@ async function getMode() {
|
|
|
21511
21540
|
const { backtest: bt$1 } = bt.executionContextService.context;
|
|
21512
21541
|
return bt$1 ? "backtest" : "live";
|
|
21513
21542
|
}
|
|
21543
|
+
/**
|
|
21544
|
+
* Fetches order book for a trading pair from the registered exchange.
|
|
21545
|
+
*
|
|
21546
|
+
* Uses current execution context to determine timing. The underlying exchange
|
|
21547
|
+
* implementation receives time range parameters but may use them (backtest)
|
|
21548
|
+
* or ignore them (live trading).
|
|
21549
|
+
*
|
|
21550
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
21551
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
21552
|
+
* @returns Promise resolving to order book data
|
|
21553
|
+
* @throws Error if execution or method context is missing
|
|
21554
|
+
*
|
|
21555
|
+
* @example
|
|
21556
|
+
* ```typescript
|
|
21557
|
+
* const orderBook = await getOrderBook("BTCUSDT");
|
|
21558
|
+
* console.log(orderBook.bids); // [{ price: "50000.00", quantity: "0.5" }, ...]
|
|
21559
|
+
* console.log(orderBook.asks); // [{ price: "50001.00", quantity: "0.3" }, ...]
|
|
21560
|
+
*
|
|
21561
|
+
* // Fetch deeper order book
|
|
21562
|
+
* const deepBook = await getOrderBook("BTCUSDT", 100);
|
|
21563
|
+
* ```
|
|
21564
|
+
*/
|
|
21565
|
+
async function getOrderBook(symbol, depth) {
|
|
21566
|
+
bt.loggerService.info(GET_ORDER_BOOK_METHOD_NAME, {
|
|
21567
|
+
symbol,
|
|
21568
|
+
depth,
|
|
21569
|
+
});
|
|
21570
|
+
if (!ExecutionContextService.hasContext()) {
|
|
21571
|
+
throw new Error("getOrderBook requires an execution context");
|
|
21572
|
+
}
|
|
21573
|
+
if (!MethodContextService.hasContext()) {
|
|
21574
|
+
throw new Error("getOrderBook requires a method context");
|
|
21575
|
+
}
|
|
21576
|
+
return await bt.exchangeConnectionService.getOrderBook(symbol, depth);
|
|
21577
|
+
}
|
|
21514
21578
|
|
|
21515
21579
|
const STOP_METHOD_NAME = "strategy.stop";
|
|
21516
21580
|
const CANCEL_METHOD_NAME = "strategy.cancel";
|
|
@@ -27111,8 +27175,13 @@ const DEFAULT_FORMAT_PRICE_FN = async (_symbol, price) => {
|
|
|
27111
27175
|
/**
|
|
27112
27176
|
* Default implementation for getOrderBook.
|
|
27113
27177
|
* Throws an error indicating the method is not implemented.
|
|
27178
|
+
*
|
|
27179
|
+
* @param _symbol - Trading pair symbol (unused)
|
|
27180
|
+
* @param _depth - Maximum depth levels (unused)
|
|
27181
|
+
* @param _from - Start of time range (unused - can be ignored in live implementations)
|
|
27182
|
+
* @param _to - End of time range (unused - can be ignored in live implementations)
|
|
27114
27183
|
*/
|
|
27115
|
-
const DEFAULT_GET_ORDER_BOOK_FN = async (_symbol, _from, _to) => {
|
|
27184
|
+
const DEFAULT_GET_ORDER_BOOK_FN = async (_symbol, _depth, _from, _to) => {
|
|
27116
27185
|
throw new Error(`getOrderBook is not implemented for this exchange`);
|
|
27117
27186
|
};
|
|
27118
27187
|
const INTERVAL_MINUTES$1 = {
|
|
@@ -27323,7 +27392,12 @@ class ExchangeInstance {
|
|
|
27323
27392
|
/**
|
|
27324
27393
|
* Fetch order book for a trading pair.
|
|
27325
27394
|
*
|
|
27395
|
+
* Calculates time range using CC_ORDER_BOOK_TIME_OFFSET_MINUTES (default 10 minutes)
|
|
27396
|
+
* and passes it to the exchange schema implementation. The implementation may use
|
|
27397
|
+
* the time range (backtest) or ignore it (live trading).
|
|
27398
|
+
*
|
|
27326
27399
|
* @param symbol - Trading pair symbol
|
|
27400
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
27327
27401
|
* @returns Promise resolving to order book data
|
|
27328
27402
|
* @throws Error if getOrderBook is not implemented
|
|
27329
27403
|
*
|
|
@@ -27332,16 +27406,18 @@ class ExchangeInstance {
|
|
|
27332
27406
|
* const instance = new ExchangeInstance("binance");
|
|
27333
27407
|
* const orderBook = await instance.getOrderBook("BTCUSDT");
|
|
27334
27408
|
* console.log(orderBook.bids); // [{ price: "50000.00", quantity: "0.5" }, ...]
|
|
27409
|
+
* const deepOrderBook = await instance.getOrderBook("BTCUSDT", 100);
|
|
27335
27410
|
* ```
|
|
27336
27411
|
*/
|
|
27337
|
-
this.getOrderBook = async (symbol) => {
|
|
27412
|
+
this.getOrderBook = async (symbol, depth = GLOBAL_CONFIG.CC_ORDER_BOOK_MAX_DEPTH_LEVELS) => {
|
|
27338
27413
|
bt.loggerService.info(EXCHANGE_METHOD_NAME_GET_ORDER_BOOK, {
|
|
27339
27414
|
exchangeName: this.exchangeName,
|
|
27340
27415
|
symbol,
|
|
27416
|
+
depth,
|
|
27341
27417
|
});
|
|
27342
27418
|
const to = new Date(Date.now());
|
|
27343
27419
|
const from = new Date(to.getTime() - GLOBAL_CONFIG.CC_ORDER_BOOK_TIME_OFFSET_MINUTES * 60 * 1000);
|
|
27344
|
-
return await this._methods.getOrderBook(symbol, from, to);
|
|
27420
|
+
return await this._methods.getOrderBook(symbol, depth, from, to);
|
|
27345
27421
|
};
|
|
27346
27422
|
const schema = bt.exchangeSchemaService.get(this.exchangeName);
|
|
27347
27423
|
this._methods = CREATE_EXCHANGE_INSTANCE_FN(schema);
|
|
@@ -27433,14 +27509,19 @@ class ExchangeUtils {
|
|
|
27433
27509
|
/**
|
|
27434
27510
|
* Fetch order book for a trading pair.
|
|
27435
27511
|
*
|
|
27512
|
+
* Delegates to ExchangeInstance which calculates time range and passes it
|
|
27513
|
+
* to the exchange schema implementation. The from/to parameters may be used
|
|
27514
|
+
* (backtest) or ignored (live) depending on the implementation.
|
|
27515
|
+
*
|
|
27436
27516
|
* @param symbol - Trading pair symbol
|
|
27437
27517
|
* @param context - Execution context with exchange name
|
|
27518
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
27438
27519
|
* @returns Promise resolving to order book data
|
|
27439
27520
|
*/
|
|
27440
|
-
this.getOrderBook = async (symbol, context) => {
|
|
27521
|
+
this.getOrderBook = async (symbol, context, depth = GLOBAL_CONFIG.CC_ORDER_BOOK_MAX_DEPTH_LEVELS) => {
|
|
27441
27522
|
bt.exchangeValidationService.validate(context.exchangeName, EXCHANGE_METHOD_NAME_GET_ORDER_BOOK);
|
|
27442
27523
|
const instance = this._getInstance(context.exchangeName);
|
|
27443
|
-
return await instance.getOrderBook(symbol);
|
|
27524
|
+
return await instance.getOrderBook(symbol, depth);
|
|
27444
27525
|
};
|
|
27445
27526
|
}
|
|
27446
27527
|
}
|
|
@@ -28386,4 +28467,4 @@ class BreakevenUtils {
|
|
|
28386
28467
|
*/
|
|
28387
28468
|
const Breakeven = new BreakevenUtils();
|
|
28388
28469
|
|
|
28389
|
-
export { Backtest, Breakeven, Cache, Constant, Exchange, ExecutionContextService, Heat, Live, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, Optimizer, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Walker, addExchange, addFrame, addOptimizer, addRisk, addSizing, addStrategy, addWalker, breakeven, cancel, dumpSignal, emitters, formatPrice, formatQuantity, getAveragePrice, getCandles, getColumns, getConfig, getDate, getDefaultColumns, getDefaultConfig, getMode, hasTradeContext, backtest as lib, listExchanges, listFrames, listOptimizers, listRisks, listSizings, listStrategies, listWalkers, listenBacktestProgress, listenBreakeven, listenBreakevenOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLoss, listenPartialLossOnce, listenPartialProfit, listenPartialProfitOnce, listenPerformance, listenPing, listenPingOnce, listenRisk, listenRiskOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, partialLoss, partialProfit, setColumns, setConfig, setLogger, stop, trailingStop, trailingTake, validate };
|
|
28470
|
+
export { Backtest, Breakeven, Cache, Constant, Exchange, ExecutionContextService, Heat, Live, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, Optimizer, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Walker, addExchange, addFrame, addOptimizer, addRisk, addSizing, addStrategy, addWalker, breakeven, cancel, dumpSignal, emitters, formatPrice, formatQuantity, getAveragePrice, getCandles, getColumns, getConfig, getDate, getDefaultColumns, getDefaultConfig, getMode, getOrderBook, hasTradeContext, backtest as lib, listExchanges, listFrames, listOptimizers, listRisks, listSizings, listStrategies, listWalkers, listenBacktestProgress, listenBreakeven, listenBreakevenOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLoss, listenPartialLossOnce, listenPartialProfit, listenPartialProfitOnce, listenPerformance, listenPing, listenPingOnce, listenRisk, listenRiskOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, partialLoss, partialProfit, setColumns, setConfig, setLogger, stop, trailingStop, trailingTake, validate };
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -460,7 +460,7 @@ interface IExchangeParams extends IExchangeSchema {
|
|
|
460
460
|
/** Format price according to exchange precision rules (required, defaults applied) */
|
|
461
461
|
formatPrice: (symbol: string, price: number) => Promise<string>;
|
|
462
462
|
/** Fetch order book for a trading pair (required, defaults applied) */
|
|
463
|
-
getOrderBook: (symbol: string, from: Date, to: Date) => Promise<IOrderBookData>;
|
|
463
|
+
getOrderBook: (symbol: string, depth: number, from: Date, to: Date) => Promise<IOrderBookData>;
|
|
464
464
|
}
|
|
465
465
|
/**
|
|
466
466
|
* Optional callbacks for exchange data events.
|
|
@@ -514,11 +514,25 @@ interface IExchangeSchema {
|
|
|
514
514
|
* Optional. If not provided, throws an error when called.
|
|
515
515
|
*
|
|
516
516
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
517
|
-
* @param
|
|
518
|
-
* @param
|
|
517
|
+
* @param depth - Maximum depth levels for both bids and asks (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
518
|
+
* @param from - Start of time range (used in backtest for historical data, can be ignored in live)
|
|
519
|
+
* @param to - End of time range (used in backtest for historical data, can be ignored in live)
|
|
519
520
|
* @returns Promise resolving to order book data
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```typescript
|
|
524
|
+
* // Backtest implementation: returns historical order book for the time range
|
|
525
|
+
* const backtestOrderBook = async (symbol: string, depth: number, from: Date, to: Date) => {
|
|
526
|
+
* return await database.getOrderBookSnapshot(symbol, depth, from, to);
|
|
527
|
+
* };
|
|
528
|
+
*
|
|
529
|
+
* // Live implementation: ignores from/to and returns current snapshot
|
|
530
|
+
* const liveOrderBook = async (symbol: string, depth: number, _from: Date, _to: Date) => {
|
|
531
|
+
* return await exchange.fetchOrderBook(symbol, depth);
|
|
532
|
+
* };
|
|
533
|
+
* ```
|
|
520
534
|
*/
|
|
521
|
-
getOrderBook?: (symbol: string, from: Date, to: Date) => Promise<IOrderBookData>;
|
|
535
|
+
getOrderBook?: (symbol: string, depth: number, from: Date, to: Date) => Promise<IOrderBookData>;
|
|
522
536
|
/** Optional lifecycle event callbacks (onCandleData) */
|
|
523
537
|
callbacks?: Partial<IExchangeCallbacks>;
|
|
524
538
|
}
|
|
@@ -575,9 +589,10 @@ interface IExchange {
|
|
|
575
589
|
* Fetch order book for a trading pair.
|
|
576
590
|
*
|
|
577
591
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
592
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
578
593
|
* @returns Promise resolving to order book data
|
|
579
594
|
*/
|
|
580
|
-
getOrderBook: (symbol: string) => Promise<IOrderBookData>;
|
|
595
|
+
getOrderBook: (symbol: string, depth?: number) => Promise<IOrderBookData>;
|
|
581
596
|
}
|
|
582
597
|
/**
|
|
583
598
|
* Unique exchange identifier.
|
|
@@ -2124,6 +2139,13 @@ declare const GLOBAL_CONFIG: {
|
|
|
2124
2139
|
* Default: 10 minutes
|
|
2125
2140
|
*/
|
|
2126
2141
|
CC_ORDER_BOOK_TIME_OFFSET_MINUTES: number;
|
|
2142
|
+
/**
|
|
2143
|
+
* Maximum depth levels for order book fetching.
|
|
2144
|
+
* Specifies how many price levels to fetch from both bids and asks.
|
|
2145
|
+
*
|
|
2146
|
+
* Default: 20 levels
|
|
2147
|
+
*/
|
|
2148
|
+
CC_ORDER_BOOK_MAX_DEPTH_LEVELS: number;
|
|
2127
2149
|
};
|
|
2128
2150
|
/**
|
|
2129
2151
|
* Type for global configuration object.
|
|
@@ -2227,6 +2249,7 @@ declare function getConfig(): {
|
|
|
2227
2249
|
CC_REPORT_SHOW_SIGNAL_NOTE: boolean;
|
|
2228
2250
|
CC_BREAKEVEN_THRESHOLD: number;
|
|
2229
2251
|
CC_ORDER_BOOK_TIME_OFFSET_MINUTES: number;
|
|
2252
|
+
CC_ORDER_BOOK_MAX_DEPTH_LEVELS: number;
|
|
2230
2253
|
};
|
|
2231
2254
|
/**
|
|
2232
2255
|
* Retrieves the default configuration object for the framework.
|
|
@@ -2260,6 +2283,7 @@ declare function getDefaultConfig(): Readonly<{
|
|
|
2260
2283
|
CC_REPORT_SHOW_SIGNAL_NOTE: boolean;
|
|
2261
2284
|
CC_BREAKEVEN_THRESHOLD: number;
|
|
2262
2285
|
CC_ORDER_BOOK_TIME_OFFSET_MINUTES: number;
|
|
2286
|
+
CC_ORDER_BOOK_MAX_DEPTH_LEVELS: number;
|
|
2263
2287
|
}>;
|
|
2264
2288
|
/**
|
|
2265
2289
|
* Sets custom column configurations for markdown report generation.
|
|
@@ -5360,6 +5384,29 @@ declare function getDate(): Promise<Date>;
|
|
|
5360
5384
|
* ```
|
|
5361
5385
|
*/
|
|
5362
5386
|
declare function getMode(): Promise<"backtest" | "live">;
|
|
5387
|
+
/**
|
|
5388
|
+
* Fetches order book for a trading pair from the registered exchange.
|
|
5389
|
+
*
|
|
5390
|
+
* Uses current execution context to determine timing. The underlying exchange
|
|
5391
|
+
* implementation receives time range parameters but may use them (backtest)
|
|
5392
|
+
* or ignore them (live trading).
|
|
5393
|
+
*
|
|
5394
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
5395
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
5396
|
+
* @returns Promise resolving to order book data
|
|
5397
|
+
* @throws Error if execution or method context is missing
|
|
5398
|
+
*
|
|
5399
|
+
* @example
|
|
5400
|
+
* ```typescript
|
|
5401
|
+
* const orderBook = await getOrderBook("BTCUSDT");
|
|
5402
|
+
* console.log(orderBook.bids); // [{ price: "50000.00", quantity: "0.5" }, ...]
|
|
5403
|
+
* console.log(orderBook.asks); // [{ price: "50001.00", quantity: "0.3" }, ...]
|
|
5404
|
+
*
|
|
5405
|
+
* // Fetch deeper order book
|
|
5406
|
+
* const deepBook = await getOrderBook("BTCUSDT", 100);
|
|
5407
|
+
* ```
|
|
5408
|
+
*/
|
|
5409
|
+
declare function getOrderBook(symbol: string, depth?: number): Promise<IOrderBookData>;
|
|
5363
5410
|
|
|
5364
5411
|
/**
|
|
5365
5412
|
* Dumps signal data and LLM conversation history to markdown files.
|
|
@@ -11138,13 +11185,18 @@ declare class ExchangeUtils {
|
|
|
11138
11185
|
/**
|
|
11139
11186
|
* Fetch order book for a trading pair.
|
|
11140
11187
|
*
|
|
11188
|
+
* Delegates to ExchangeInstance which calculates time range and passes it
|
|
11189
|
+
* to the exchange schema implementation. The from/to parameters may be used
|
|
11190
|
+
* (backtest) or ignored (live) depending on the implementation.
|
|
11191
|
+
*
|
|
11141
11192
|
* @param symbol - Trading pair symbol
|
|
11142
11193
|
* @param context - Execution context with exchange name
|
|
11194
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
11143
11195
|
* @returns Promise resolving to order book data
|
|
11144
11196
|
*/
|
|
11145
11197
|
getOrderBook: (symbol: string, context: {
|
|
11146
11198
|
exchangeName: ExchangeName;
|
|
11147
|
-
}) => Promise<IOrderBookData>;
|
|
11199
|
+
}, depth?: number) => Promise<IOrderBookData>;
|
|
11148
11200
|
}
|
|
11149
11201
|
/**
|
|
11150
11202
|
* Singleton instance of ExchangeUtils for convenient exchange operations.
|
|
@@ -12057,11 +12109,16 @@ declare class ClientExchange implements IExchange {
|
|
|
12057
12109
|
/**
|
|
12058
12110
|
* Fetches order book for a trading pair.
|
|
12059
12111
|
*
|
|
12112
|
+
* Calculates time range based on execution context time (when) and
|
|
12113
|
+
* CC_ORDER_BOOK_TIME_OFFSET_MINUTES, then delegates to the exchange
|
|
12114
|
+
* schema implementation which may use or ignore the time range.
|
|
12115
|
+
*
|
|
12060
12116
|
* @param symbol - Trading pair symbol
|
|
12117
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
12061
12118
|
* @returns Promise resolving to order book data
|
|
12062
12119
|
* @throws Error if getOrderBook is not implemented
|
|
12063
12120
|
*/
|
|
12064
|
-
getOrderBook(symbol: string): Promise<IOrderBookData>;
|
|
12121
|
+
getOrderBook(symbol: string, depth?: number): Promise<IOrderBookData>;
|
|
12065
12122
|
}
|
|
12066
12123
|
|
|
12067
12124
|
/**
|
|
@@ -12158,11 +12215,14 @@ declare class ExchangeConnectionService implements IExchange {
|
|
|
12158
12215
|
* Fetches order book for a trading pair using configured exchange.
|
|
12159
12216
|
*
|
|
12160
12217
|
* Routes to exchange determined by methodContextService.context.exchangeName.
|
|
12218
|
+
* The ClientExchange will calculate time range and pass it to the schema
|
|
12219
|
+
* implementation, which may use (backtest) or ignore (live) the parameters.
|
|
12161
12220
|
*
|
|
12162
12221
|
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
12222
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
12163
12223
|
* @returns Promise resolving to order book data
|
|
12164
12224
|
*/
|
|
12165
|
-
getOrderBook: (symbol: string) => Promise<IOrderBookData>;
|
|
12225
|
+
getOrderBook: (symbol: string, depth?: number) => Promise<IOrderBookData>;
|
|
12166
12226
|
}
|
|
12167
12227
|
|
|
12168
12228
|
/**
|
|
@@ -13222,12 +13282,17 @@ declare class ExchangeCoreService implements TExchange {
|
|
|
13222
13282
|
/**
|
|
13223
13283
|
* Fetches order book with execution context.
|
|
13224
13284
|
*
|
|
13285
|
+
* Sets up execution context with the provided when/backtest parameters.
|
|
13286
|
+
* The exchange implementation will receive time range parameters but may
|
|
13287
|
+
* choose to use them (backtest) or ignore them (live).
|
|
13288
|
+
*
|
|
13225
13289
|
* @param symbol - Trading pair symbol
|
|
13226
13290
|
* @param when - Timestamp for context
|
|
13227
13291
|
* @param backtest - Whether running in backtest mode
|
|
13292
|
+
* @param depth - Maximum depth levels (default: CC_ORDER_BOOK_MAX_DEPTH_LEVELS)
|
|
13228
13293
|
* @returns Promise resolving to order book data
|
|
13229
13294
|
*/
|
|
13230
|
-
getOrderBook: (symbol: string, when: Date, backtest: boolean) => Promise<IOrderBookData>;
|
|
13295
|
+
getOrderBook: (symbol: string, when: Date, backtest: boolean, depth?: number) => Promise<IOrderBookData>;
|
|
13231
13296
|
}
|
|
13232
13297
|
|
|
13233
13298
|
/**
|
|
@@ -16194,4 +16259,4 @@ declare const backtest: {
|
|
|
16194
16259
|
loggerService: LoggerService;
|
|
16195
16260
|
};
|
|
16196
16261
|
|
|
16197
|
-
export { Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, type BootstrapNotification, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IOrderBookData, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveDoneNotification, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Notification, type NotificationModel, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialLossNotification, type PartialProfitContract, type PartialProfitNotification, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, type PingContract, PositionSize, type ProgressBacktestContract, type ProgressBacktestNotification, type ProgressOptimizerContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TickEvent, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addExchange, addFrame, addOptimizer, addRisk, addSizing, addStrategy, addWalker, breakeven, cancel, dumpSignal, emitters, formatPrice, formatQuantity, getAveragePrice, getCandles, getColumns, getConfig, getDate, getDefaultColumns, getDefaultConfig, getMode, hasTradeContext, backtest as lib, listExchanges, listFrames, listOptimizers, listRisks, listSizings, listStrategies, listWalkers, listenBacktestProgress, listenBreakeven, listenBreakevenOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLoss, listenPartialLossOnce, listenPartialProfit, listenPartialProfitOnce, listenPerformance, listenPing, listenPingOnce, listenRisk, listenRiskOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, partialLoss, partialProfit, setColumns, setConfig, setLogger, stop, trailingStop, trailingTake, validate };
|
|
16262
|
+
export { Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, type BootstrapNotification, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IOrderBookData, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveDoneNotification, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Notification, type NotificationModel, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialLossNotification, type PartialProfitContract, type PartialProfitNotification, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, type PingContract, PositionSize, type ProgressBacktestContract, type ProgressBacktestNotification, type ProgressOptimizerContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TickEvent, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addExchange, addFrame, addOptimizer, addRisk, addSizing, addStrategy, addWalker, breakeven, cancel, dumpSignal, emitters, formatPrice, formatQuantity, getAveragePrice, getCandles, getColumns, getConfig, getDate, getDefaultColumns, getDefaultConfig, getMode, getOrderBook, hasTradeContext, backtest as lib, listExchanges, listFrames, listOptimizers, listRisks, listSizings, listStrategies, listWalkers, listenBacktestProgress, listenBreakeven, listenBreakevenOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLoss, listenPartialLossOnce, listenPartialProfit, listenPartialProfitOnce, listenPerformance, listenPing, listenPingOnce, listenRisk, listenRiskOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, partialLoss, partialProfit, setColumns, setConfig, setLogger, stop, trailingStop, trailingTake, validate };
|