backtest-kit 6.0.0 โ 6.1.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.
- package/README.md +1 -1
- package/build/index.cjs +7 -7
- package/build/index.mjs +7 -7
- package/package.json +1 -1
- package/types.d.ts +2 -2
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ npm install backtest-kit ccxt ollama uuid
|
|
|
61
61
|
- ๐ก๏ธ **Risk Management**: Custom rules for position limits, time windows, and multi-strategy coordination.
|
|
62
62
|
- ๐ **Pluggable**: Custom data sources (CCXT), persistence (file/Redis), and sizing calculators.
|
|
63
63
|
- ๐๏ธ **Transactional Live Orders**: Broker adapter intercepts every trade mutation before internal state changes โ exchange rejection rolls back the operation atomically.
|
|
64
|
-
- ๐งช **Tested**:
|
|
64
|
+
- ๐งช **Tested**: 515+ unit/integration tests for validation, recovery, and events.
|
|
65
65
|
- ๐ **Self hosted**: Zero dependency on third-party node_modules or platforms; run entirely in your own environment.
|
|
66
66
|
|
|
67
67
|
## ๐ Supported Order Types
|
package/build/index.cjs
CHANGED
|
@@ -29324,7 +29324,7 @@ class SyncReportService {
|
|
|
29324
29324
|
*/
|
|
29325
29325
|
this.subscribe = functoolsKit.singleshot(() => {
|
|
29326
29326
|
this.loggerService.log(SYNC_REPORT_METHOD_NAME_SUBSCRIBE);
|
|
29327
|
-
const unsubscribe = syncSubject.subscribe(this.tick);
|
|
29327
|
+
const unsubscribe = syncSubject.subscribe(functoolsKit.trycatch(this.tick));
|
|
29328
29328
|
return () => {
|
|
29329
29329
|
this.subscribe.clear();
|
|
29330
29330
|
unsubscribe();
|
|
@@ -30602,7 +30602,7 @@ class SyncMarkdownService {
|
|
|
30602
30602
|
*/
|
|
30603
30603
|
this.subscribe = functoolsKit.singleshot(() => {
|
|
30604
30604
|
this.loggerService.log("syncMarkdownService init");
|
|
30605
|
-
const unsubscribe = syncSubject.subscribe(this.tick);
|
|
30605
|
+
const unsubscribe = syncSubject.subscribe(functoolsKit.trycatch(this.tick));
|
|
30606
30606
|
return () => {
|
|
30607
30607
|
this.subscribe.clear();
|
|
30608
30608
|
this.clear();
|
|
@@ -37477,9 +37477,9 @@ function listenStrategyCommitOnce(filterFn, fn) {
|
|
|
37477
37477
|
* @param fn - Callback function to handle sync events. If the function returns a promise, signal processing will wait until it resolves.
|
|
37478
37478
|
* @returns Unsubscribe function to stop listening
|
|
37479
37479
|
*/
|
|
37480
|
-
function listenSync(fn) {
|
|
37480
|
+
function listenSync(fn, warned = false) {
|
|
37481
37481
|
bt.loggerService.log(LISTEN_SYNC_METHOD_NAME);
|
|
37482
|
-
{
|
|
37482
|
+
if (!warned) {
|
|
37483
37483
|
console.error("listenSync is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
|
|
37484
37484
|
console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
|
|
37485
37485
|
console.error("If listenSync throws the exchange will not execute the order!");
|
|
@@ -37496,9 +37496,9 @@ function listenSync(fn) {
|
|
|
37496
37496
|
* @param fn - Callback function to handle the filtered event (called only once). If the function returns a promise, signal processing will wait until it resolves.
|
|
37497
37497
|
* @returns Unsubscribe function to cancel the listener before it fires
|
|
37498
37498
|
*/
|
|
37499
|
-
function listenSyncOnce(filterFn, fn) {
|
|
37499
|
+
function listenSyncOnce(filterFn, fn, warned = false) {
|
|
37500
37500
|
bt.loggerService.log(LISTEN_SYNC_ONCE_METHOD_NAME);
|
|
37501
|
-
{
|
|
37501
|
+
if (!warned) {
|
|
37502
37502
|
console.error("listenSyncOnce is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
|
|
37503
37503
|
console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
|
|
37504
37504
|
console.error("If listenSyncOnce throws the exchange will not execute the order!");
|
|
@@ -37512,7 +37512,7 @@ function listenSyncOnce(filterFn, fn) {
|
|
|
37512
37512
|
disposeFn && disposeFn();
|
|
37513
37513
|
}
|
|
37514
37514
|
};
|
|
37515
|
-
return disposeFn = listenSync(wrappedFn);
|
|
37515
|
+
return disposeFn = listenSync(wrappedFn, true);
|
|
37516
37516
|
}
|
|
37517
37517
|
/**
|
|
37518
37518
|
* Subscribes to highest profit events with queued async processing.
|
package/build/index.mjs
CHANGED
|
@@ -29304,7 +29304,7 @@ class SyncReportService {
|
|
|
29304
29304
|
*/
|
|
29305
29305
|
this.subscribe = singleshot(() => {
|
|
29306
29306
|
this.loggerService.log(SYNC_REPORT_METHOD_NAME_SUBSCRIBE);
|
|
29307
|
-
const unsubscribe = syncSubject.subscribe(this.tick);
|
|
29307
|
+
const unsubscribe = syncSubject.subscribe(trycatch(this.tick));
|
|
29308
29308
|
return () => {
|
|
29309
29309
|
this.subscribe.clear();
|
|
29310
29310
|
unsubscribe();
|
|
@@ -30582,7 +30582,7 @@ class SyncMarkdownService {
|
|
|
30582
30582
|
*/
|
|
30583
30583
|
this.subscribe = singleshot(() => {
|
|
30584
30584
|
this.loggerService.log("syncMarkdownService init");
|
|
30585
|
-
const unsubscribe = syncSubject.subscribe(this.tick);
|
|
30585
|
+
const unsubscribe = syncSubject.subscribe(trycatch(this.tick));
|
|
30586
30586
|
return () => {
|
|
30587
30587
|
this.subscribe.clear();
|
|
30588
30588
|
this.clear();
|
|
@@ -37457,9 +37457,9 @@ function listenStrategyCommitOnce(filterFn, fn) {
|
|
|
37457
37457
|
* @param fn - Callback function to handle sync events. If the function returns a promise, signal processing will wait until it resolves.
|
|
37458
37458
|
* @returns Unsubscribe function to stop listening
|
|
37459
37459
|
*/
|
|
37460
|
-
function listenSync(fn) {
|
|
37460
|
+
function listenSync(fn, warned = false) {
|
|
37461
37461
|
bt.loggerService.log(LISTEN_SYNC_METHOD_NAME);
|
|
37462
|
-
{
|
|
37462
|
+
if (!warned) {
|
|
37463
37463
|
console.error("listenSync is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
|
|
37464
37464
|
console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
|
|
37465
37465
|
console.error("If listenSync throws the exchange will not execute the order!");
|
|
@@ -37476,9 +37476,9 @@ function listenSync(fn) {
|
|
|
37476
37476
|
* @param fn - Callback function to handle the filtered event (called only once). If the function returns a promise, signal processing will wait until it resolves.
|
|
37477
37477
|
* @returns Unsubscribe function to cancel the listener before it fires
|
|
37478
37478
|
*/
|
|
37479
|
-
function listenSyncOnce(filterFn, fn) {
|
|
37479
|
+
function listenSyncOnce(filterFn, fn, warned = false) {
|
|
37480
37480
|
bt.loggerService.log(LISTEN_SYNC_ONCE_METHOD_NAME);
|
|
37481
|
-
{
|
|
37481
|
+
if (!warned) {
|
|
37482
37482
|
console.error("listenSyncOnce is unwanted cause exchange integration should be implemented in Broker.useBrokerAdapter as an infrastructure domain layer");
|
|
37483
37483
|
console.error("If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() in addActionSchema handler");
|
|
37484
37484
|
console.error("If listenSyncOnce throws the exchange will not execute the order!");
|
|
@@ -37492,7 +37492,7 @@ function listenSyncOnce(filterFn, fn) {
|
|
|
37492
37492
|
disposeFn && disposeFn();
|
|
37493
37493
|
}
|
|
37494
37494
|
};
|
|
37495
|
-
return disposeFn = listenSync(wrappedFn);
|
|
37495
|
+
return disposeFn = listenSync(wrappedFn, true);
|
|
37496
37496
|
}
|
|
37497
37497
|
/**
|
|
37498
37498
|
* Subscribes to highest profit events with queued async processing.
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -8117,7 +8117,7 @@ declare function listenStrategyCommitOnce(filterFn: (event: StrategyCommitContra
|
|
|
8117
8117
|
* @param fn - Callback function to handle sync events. If the function returns a promise, signal processing will wait until it resolves.
|
|
8118
8118
|
* @returns Unsubscribe function to stop listening
|
|
8119
8119
|
*/
|
|
8120
|
-
declare function listenSync(fn: (event: SignalSyncContract) => void): () => void;
|
|
8120
|
+
declare function listenSync(fn: (event: SignalSyncContract) => void, warned?: boolean): () => void;
|
|
8121
8121
|
/**
|
|
8122
8122
|
* Subscribes to filtered signal synchronization events with one-time execution.
|
|
8123
8123
|
* If throws position is not being opened/closed until the async function completes. Useful for synchronizing with external systems.
|
|
@@ -8126,7 +8126,7 @@ declare function listenSync(fn: (event: SignalSyncContract) => void): () => void
|
|
|
8126
8126
|
* @param fn - Callback function to handle the filtered event (called only once). If the function returns a promise, signal processing will wait until it resolves.
|
|
8127
8127
|
* @returns Unsubscribe function to cancel the listener before it fires
|
|
8128
8128
|
*/
|
|
8129
|
-
declare function listenSyncOnce(filterFn: (event: SignalSyncContract) => boolean, fn: (event: SignalSyncContract) => void): () => void;
|
|
8129
|
+
declare function listenSyncOnce(filterFn: (event: SignalSyncContract) => boolean, fn: (event: SignalSyncContract) => void, warned?: boolean): () => void;
|
|
8130
8130
|
/**
|
|
8131
8131
|
* Subscribes to highest profit events with queued async processing.
|
|
8132
8132
|
* Emits when a signal reaches a new highest profit level during its lifecycle.
|