backtest-kit 1.5.45 → 1.5.46
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 +13 -17
- package/build/index.mjs +13 -17
- package/package.json +1 -1
- package/types.d.ts +3 -3
package/build/index.cjs
CHANGED
|
@@ -4188,18 +4188,16 @@ const get = (object, path) => {
|
|
|
4188
4188
|
return pathArrayFlat.reduce((obj, key) => obj && obj[key], object);
|
|
4189
4189
|
};
|
|
4190
4190
|
|
|
4191
|
-
/** Symbol indicating that a signal was rejected */
|
|
4192
|
-
const SYMBOL_REJECTED = Symbol("rejected");
|
|
4193
4191
|
/** Symbol indicating that positions need to be fetched from persistence */
|
|
4194
4192
|
const POSITION_NEED_FETCH = Symbol("risk-need-fetch");
|
|
4195
4193
|
/** Key generator for active position map */
|
|
4196
4194
|
const GET_KEY_FN = (strategyName, symbol) => `${strategyName}:${symbol}`;
|
|
4197
4195
|
/** Wrapper to execute risk validation function with error handling */
|
|
4198
|
-
const DO_VALIDATION_FN =
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4196
|
+
const DO_VALIDATION_FN = async (validation, params) => {
|
|
4197
|
+
try {
|
|
4198
|
+
return await validation(params);
|
|
4199
|
+
}
|
|
4200
|
+
catch (error) {
|
|
4203
4201
|
const message = "ClientRisk exception thrown";
|
|
4204
4202
|
const payload = {
|
|
4205
4203
|
error: functoolsKit.errorData(error),
|
|
@@ -4208,8 +4206,9 @@ const DO_VALIDATION_FN = functoolsKit.trycatch(async (validation, params) => {
|
|
|
4208
4206
|
backtest$1.loggerService.warn(message, payload);
|
|
4209
4207
|
console.warn(message, payload);
|
|
4210
4208
|
validationSubject.next(error);
|
|
4211
|
-
|
|
4212
|
-
}
|
|
4209
|
+
return payload.message;
|
|
4210
|
+
}
|
|
4211
|
+
};
|
|
4213
4212
|
/**
|
|
4214
4213
|
* Initializes active positions by reading from persistence.
|
|
4215
4214
|
* Uses singleshot pattern to ensure it only runs once.
|
|
@@ -4290,17 +4289,14 @@ class ClientRisk {
|
|
|
4290
4289
|
if (!rejection) {
|
|
4291
4290
|
continue;
|
|
4292
4291
|
}
|
|
4293
|
-
if (typeof rejection === "symbol") {
|
|
4294
|
-
rejectionResult = {
|
|
4295
|
-
id: null,
|
|
4296
|
-
note: "note" in validation ? validation.note : "Validation failed",
|
|
4297
|
-
};
|
|
4298
|
-
break;
|
|
4299
|
-
}
|
|
4300
4292
|
if (typeof rejection === "string") {
|
|
4301
4293
|
rejectionResult = {
|
|
4302
4294
|
id: null,
|
|
4303
|
-
note: rejection
|
|
4295
|
+
note: rejection
|
|
4296
|
+
? rejection
|
|
4297
|
+
: "note" in validation
|
|
4298
|
+
? validation.note
|
|
4299
|
+
: "Validation failed",
|
|
4304
4300
|
};
|
|
4305
4301
|
break;
|
|
4306
4302
|
}
|
package/build/index.mjs
CHANGED
|
@@ -4186,18 +4186,16 @@ const get = (object, path) => {
|
|
|
4186
4186
|
return pathArrayFlat.reduce((obj, key) => obj && obj[key], object);
|
|
4187
4187
|
};
|
|
4188
4188
|
|
|
4189
|
-
/** Symbol indicating that a signal was rejected */
|
|
4190
|
-
const SYMBOL_REJECTED = Symbol("rejected");
|
|
4191
4189
|
/** Symbol indicating that positions need to be fetched from persistence */
|
|
4192
4190
|
const POSITION_NEED_FETCH = Symbol("risk-need-fetch");
|
|
4193
4191
|
/** Key generator for active position map */
|
|
4194
4192
|
const GET_KEY_FN = (strategyName, symbol) => `${strategyName}:${symbol}`;
|
|
4195
4193
|
/** Wrapper to execute risk validation function with error handling */
|
|
4196
|
-
const DO_VALIDATION_FN =
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4194
|
+
const DO_VALIDATION_FN = async (validation, params) => {
|
|
4195
|
+
try {
|
|
4196
|
+
return await validation(params);
|
|
4197
|
+
}
|
|
4198
|
+
catch (error) {
|
|
4201
4199
|
const message = "ClientRisk exception thrown";
|
|
4202
4200
|
const payload = {
|
|
4203
4201
|
error: errorData(error),
|
|
@@ -4206,8 +4204,9 @@ const DO_VALIDATION_FN = trycatch(async (validation, params) => {
|
|
|
4206
4204
|
backtest$1.loggerService.warn(message, payload);
|
|
4207
4205
|
console.warn(message, payload);
|
|
4208
4206
|
validationSubject.next(error);
|
|
4209
|
-
|
|
4210
|
-
}
|
|
4207
|
+
return payload.message;
|
|
4208
|
+
}
|
|
4209
|
+
};
|
|
4211
4210
|
/**
|
|
4212
4211
|
* Initializes active positions by reading from persistence.
|
|
4213
4212
|
* Uses singleshot pattern to ensure it only runs once.
|
|
@@ -4288,17 +4287,14 @@ class ClientRisk {
|
|
|
4288
4287
|
if (!rejection) {
|
|
4289
4288
|
continue;
|
|
4290
4289
|
}
|
|
4291
|
-
if (typeof rejection === "symbol") {
|
|
4292
|
-
rejectionResult = {
|
|
4293
|
-
id: null,
|
|
4294
|
-
note: "note" in validation ? validation.note : "Validation failed",
|
|
4295
|
-
};
|
|
4296
|
-
break;
|
|
4297
|
-
}
|
|
4298
4290
|
if (typeof rejection === "string") {
|
|
4299
4291
|
rejectionResult = {
|
|
4300
4292
|
id: null,
|
|
4301
|
-
note: rejection
|
|
4293
|
+
note: rejection
|
|
4294
|
+
? rejection
|
|
4295
|
+
: "note" in validation
|
|
4296
|
+
? validation.note
|
|
4297
|
+
: "Validation failed",
|
|
4302
4298
|
};
|
|
4303
4299
|
break;
|
|
4304
4300
|
}
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -5372,7 +5372,7 @@ declare class BacktestUtils {
|
|
|
5372
5372
|
id: string;
|
|
5373
5373
|
symbol: string;
|
|
5374
5374
|
strategyName: string;
|
|
5375
|
-
status: "
|
|
5375
|
+
status: "pending" | "fulfilled" | "rejected" | "ready";
|
|
5376
5376
|
}[]>;
|
|
5377
5377
|
}
|
|
5378
5378
|
/**
|
|
@@ -5738,7 +5738,7 @@ declare class LiveUtils {
|
|
|
5738
5738
|
id: string;
|
|
5739
5739
|
symbol: string;
|
|
5740
5740
|
strategyName: string;
|
|
5741
|
-
status: "
|
|
5741
|
+
status: "pending" | "fulfilled" | "rejected" | "ready";
|
|
5742
5742
|
}[]>;
|
|
5743
5743
|
}
|
|
5744
5744
|
/**
|
|
@@ -6621,7 +6621,7 @@ declare class WalkerUtils {
|
|
|
6621
6621
|
id: string;
|
|
6622
6622
|
symbol: string;
|
|
6623
6623
|
walkerName: string;
|
|
6624
|
-
status: "
|
|
6624
|
+
status: "pending" | "fulfilled" | "rejected" | "ready";
|
|
6625
6625
|
}[]>;
|
|
6626
6626
|
}
|
|
6627
6627
|
/**
|