backtest-kit 3.0.1 → 3.0.3
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 +23 -39
- package/build/index.mjs +23 -40
- package/package.json +1 -1
- package/types.d.ts +70 -18
package/build/index.cjs
CHANGED
|
@@ -33779,7 +33779,7 @@ const CREATE_SIGNAL_NOTIFICATION_FN = (data) => {
|
|
|
33779
33779
|
createdAt: data.createdAt,
|
|
33780
33780
|
};
|
|
33781
33781
|
}
|
|
33782
|
-
|
|
33782
|
+
if (data.action === "closed") {
|
|
33783
33783
|
const durationMs = data.closeTimestamp - data.signal.pendingAt;
|
|
33784
33784
|
const durationMin = Math.round(durationMs / 60000);
|
|
33785
33785
|
return {
|
|
@@ -33807,7 +33807,7 @@ const CREATE_SIGNAL_NOTIFICATION_FN = (data) => {
|
|
|
33807
33807
|
createdAt: data.createdAt,
|
|
33808
33808
|
};
|
|
33809
33809
|
}
|
|
33810
|
-
|
|
33810
|
+
if (data.action === "scheduled") {
|
|
33811
33811
|
return {
|
|
33812
33812
|
type: "signal.scheduled",
|
|
33813
33813
|
id: CREATE_KEY_FN$1(),
|
|
@@ -33828,7 +33828,7 @@ const CREATE_SIGNAL_NOTIFICATION_FN = (data) => {
|
|
|
33828
33828
|
createdAt: data.createdAt,
|
|
33829
33829
|
};
|
|
33830
33830
|
}
|
|
33831
|
-
|
|
33831
|
+
if (data.action === "cancelled") {
|
|
33832
33832
|
const durationMs = data.closeTimestamp - data.signal.scheduledAt;
|
|
33833
33833
|
const durationMin = Math.round(durationMs / 60000);
|
|
33834
33834
|
return {
|
|
@@ -33964,7 +33964,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
33964
33964
|
createdAt: data.timestamp,
|
|
33965
33965
|
};
|
|
33966
33966
|
}
|
|
33967
|
-
|
|
33967
|
+
if (data.action === "partial-loss") {
|
|
33968
33968
|
return {
|
|
33969
33969
|
type: "partial_loss.commit",
|
|
33970
33970
|
id: CREATE_KEY_FN$1(),
|
|
@@ -33987,7 +33987,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
33987
33987
|
createdAt: data.timestamp,
|
|
33988
33988
|
};
|
|
33989
33989
|
}
|
|
33990
|
-
|
|
33990
|
+
if (data.action === "breakeven") {
|
|
33991
33991
|
return {
|
|
33992
33992
|
type: "breakeven.commit",
|
|
33993
33993
|
id: CREATE_KEY_FN$1(),
|
|
@@ -34009,7 +34009,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
34009
34009
|
createdAt: data.timestamp,
|
|
34010
34010
|
};
|
|
34011
34011
|
}
|
|
34012
|
-
|
|
34012
|
+
if (data.action === "trailing-stop") {
|
|
34013
34013
|
return {
|
|
34014
34014
|
type: "trailing_stop.commit",
|
|
34015
34015
|
id: CREATE_KEY_FN$1(),
|
|
@@ -34032,7 +34032,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
34032
34032
|
createdAt: data.timestamp,
|
|
34033
34033
|
};
|
|
34034
34034
|
}
|
|
34035
|
-
|
|
34035
|
+
if (data.action === "trailing-take") {
|
|
34036
34036
|
return {
|
|
34037
34037
|
type: "trailing_take.commit",
|
|
34038
34038
|
id: CREATE_KEY_FN$1(),
|
|
@@ -34055,7 +34055,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
34055
34055
|
createdAt: data.timestamp,
|
|
34056
34056
|
};
|
|
34057
34057
|
}
|
|
34058
|
-
|
|
34058
|
+
if (data.action === "activate-scheduled") {
|
|
34059
34059
|
return {
|
|
34060
34060
|
type: "activate_scheduled.commit",
|
|
34061
34061
|
id: CREATE_KEY_FN$1(),
|
|
@@ -34167,8 +34167,6 @@ const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_CLEAR = "NotificationMemoryLiveUtils.
|
|
|
34167
34167
|
const NOTIFICATION_ADAPTER_METHOD_NAME_ENABLE = "NotificationAdapter.enable";
|
|
34168
34168
|
const NOTIFICATION_ADAPTER_METHOD_NAME_DISABLE = "NotificationAdapter.disable";
|
|
34169
34169
|
const NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_BACKTEST = "NotificationAdapter.getDataBacktest";
|
|
34170
|
-
const NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_LIVE = "NotificationAdapter.getDataLive";
|
|
34171
|
-
const NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_BACKTEST = "NotificationAdapter.clearBacktest";
|
|
34172
34170
|
const NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE = "NotificationAdapter.clearLive";
|
|
34173
34171
|
const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_ADAPTER = "NotificationBacktestAdapter.useNotificationAdapter";
|
|
34174
34172
|
const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_DUMMY = "NotificationBacktestAdapter.useDummy";
|
|
@@ -35396,52 +35394,37 @@ class NotificationAdapter {
|
|
|
35396
35394
|
}
|
|
35397
35395
|
};
|
|
35398
35396
|
/**
|
|
35399
|
-
* Gets all backtest notifications from storage.
|
|
35397
|
+
* Gets all backtest/live notifications from storage.
|
|
35400
35398
|
*
|
|
35401
35399
|
* @returns Array of all backtest notification models
|
|
35402
35400
|
* @throws Error if NotificationAdapter is not enabled
|
|
35403
35401
|
*/
|
|
35404
|
-
this.
|
|
35405
|
-
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_BACKTEST
|
|
35402
|
+
this.getData = async (isBacktest) => {
|
|
35403
|
+
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_BACKTEST, {
|
|
35404
|
+
backtest: isBacktest,
|
|
35405
|
+
});
|
|
35406
35406
|
if (!this.enable.hasValue()) {
|
|
35407
35407
|
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35408
35408
|
}
|
|
35409
|
-
|
|
35410
|
-
|
|
35411
|
-
/**
|
|
35412
|
-
* Gets all live notifications from storage.
|
|
35413
|
-
*
|
|
35414
|
-
* @returns Array of all live notification models
|
|
35415
|
-
* @throws Error if NotificationAdapter is not enabled
|
|
35416
|
-
*/
|
|
35417
|
-
this.getDataLive = async () => {
|
|
35418
|
-
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_LIVE);
|
|
35419
|
-
if (!this.enable.hasValue()) {
|
|
35420
|
-
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35409
|
+
if (isBacktest) {
|
|
35410
|
+
return await NotificationBacktest.getData();
|
|
35421
35411
|
}
|
|
35422
35412
|
return await NotificationLive.getData();
|
|
35423
35413
|
};
|
|
35424
35414
|
/**
|
|
35425
|
-
* Clears all backtest notifications from storage.
|
|
35415
|
+
* Clears all backtest/live notifications from storage.
|
|
35426
35416
|
*
|
|
35427
35417
|
* @throws Error if NotificationAdapter is not enabled
|
|
35428
35418
|
*/
|
|
35429
|
-
this.
|
|
35430
|
-
bt.loggerService.info(
|
|
35419
|
+
this.clear = async (isBacktest) => {
|
|
35420
|
+
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE, {
|
|
35421
|
+
backtest: isBacktest,
|
|
35422
|
+
});
|
|
35431
35423
|
if (!this.enable.hasValue()) {
|
|
35432
35424
|
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35433
35425
|
}
|
|
35434
|
-
|
|
35435
|
-
|
|
35436
|
-
/**
|
|
35437
|
-
* Clears all live notifications from storage.
|
|
35438
|
-
*
|
|
35439
|
-
* @throws Error if NotificationAdapter is not enabled
|
|
35440
|
-
*/
|
|
35441
|
-
this.clearLive = async () => {
|
|
35442
|
-
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE);
|
|
35443
|
-
if (!this.enable.hasValue()) {
|
|
35444
|
-
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35426
|
+
if (isBacktest) {
|
|
35427
|
+
return await NotificationBacktest.clear();
|
|
35445
35428
|
}
|
|
35446
35429
|
return await NotificationLive.clear();
|
|
35447
35430
|
};
|
|
@@ -37013,6 +36996,7 @@ exports.Performance = Performance;
|
|
|
37013
36996
|
exports.PersistBase = PersistBase;
|
|
37014
36997
|
exports.PersistBreakevenAdapter = PersistBreakevenAdapter;
|
|
37015
36998
|
exports.PersistCandleAdapter = PersistCandleAdapter;
|
|
36999
|
+
exports.PersistNotificationAdapter = PersistNotificationAdapter;
|
|
37016
37000
|
exports.PersistPartialAdapter = PersistPartialAdapter;
|
|
37017
37001
|
exports.PersistRiskAdapter = PersistRiskAdapter;
|
|
37018
37002
|
exports.PersistScheduleAdapter = PersistScheduleAdapter;
|
package/build/index.mjs
CHANGED
|
@@ -33759,7 +33759,7 @@ const CREATE_SIGNAL_NOTIFICATION_FN = (data) => {
|
|
|
33759
33759
|
createdAt: data.createdAt,
|
|
33760
33760
|
};
|
|
33761
33761
|
}
|
|
33762
|
-
|
|
33762
|
+
if (data.action === "closed") {
|
|
33763
33763
|
const durationMs = data.closeTimestamp - data.signal.pendingAt;
|
|
33764
33764
|
const durationMin = Math.round(durationMs / 60000);
|
|
33765
33765
|
return {
|
|
@@ -33787,7 +33787,7 @@ const CREATE_SIGNAL_NOTIFICATION_FN = (data) => {
|
|
|
33787
33787
|
createdAt: data.createdAt,
|
|
33788
33788
|
};
|
|
33789
33789
|
}
|
|
33790
|
-
|
|
33790
|
+
if (data.action === "scheduled") {
|
|
33791
33791
|
return {
|
|
33792
33792
|
type: "signal.scheduled",
|
|
33793
33793
|
id: CREATE_KEY_FN$1(),
|
|
@@ -33808,7 +33808,7 @@ const CREATE_SIGNAL_NOTIFICATION_FN = (data) => {
|
|
|
33808
33808
|
createdAt: data.createdAt,
|
|
33809
33809
|
};
|
|
33810
33810
|
}
|
|
33811
|
-
|
|
33811
|
+
if (data.action === "cancelled") {
|
|
33812
33812
|
const durationMs = data.closeTimestamp - data.signal.scheduledAt;
|
|
33813
33813
|
const durationMin = Math.round(durationMs / 60000);
|
|
33814
33814
|
return {
|
|
@@ -33944,7 +33944,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
33944
33944
|
createdAt: data.timestamp,
|
|
33945
33945
|
};
|
|
33946
33946
|
}
|
|
33947
|
-
|
|
33947
|
+
if (data.action === "partial-loss") {
|
|
33948
33948
|
return {
|
|
33949
33949
|
type: "partial_loss.commit",
|
|
33950
33950
|
id: CREATE_KEY_FN$1(),
|
|
@@ -33967,7 +33967,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
33967
33967
|
createdAt: data.timestamp,
|
|
33968
33968
|
};
|
|
33969
33969
|
}
|
|
33970
|
-
|
|
33970
|
+
if (data.action === "breakeven") {
|
|
33971
33971
|
return {
|
|
33972
33972
|
type: "breakeven.commit",
|
|
33973
33973
|
id: CREATE_KEY_FN$1(),
|
|
@@ -33989,7 +33989,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
33989
33989
|
createdAt: data.timestamp,
|
|
33990
33990
|
};
|
|
33991
33991
|
}
|
|
33992
|
-
|
|
33992
|
+
if (data.action === "trailing-stop") {
|
|
33993
33993
|
return {
|
|
33994
33994
|
type: "trailing_stop.commit",
|
|
33995
33995
|
id: CREATE_KEY_FN$1(),
|
|
@@ -34012,7 +34012,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
34012
34012
|
createdAt: data.timestamp,
|
|
34013
34013
|
};
|
|
34014
34014
|
}
|
|
34015
|
-
|
|
34015
|
+
if (data.action === "trailing-take") {
|
|
34016
34016
|
return {
|
|
34017
34017
|
type: "trailing_take.commit",
|
|
34018
34018
|
id: CREATE_KEY_FN$1(),
|
|
@@ -34035,7 +34035,7 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
34035
34035
|
createdAt: data.timestamp,
|
|
34036
34036
|
};
|
|
34037
34037
|
}
|
|
34038
|
-
|
|
34038
|
+
if (data.action === "activate-scheduled") {
|
|
34039
34039
|
return {
|
|
34040
34040
|
type: "activate_scheduled.commit",
|
|
34041
34041
|
id: CREATE_KEY_FN$1(),
|
|
@@ -34147,8 +34147,6 @@ const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_CLEAR = "NotificationMemoryLiveUtils.
|
|
|
34147
34147
|
const NOTIFICATION_ADAPTER_METHOD_NAME_ENABLE = "NotificationAdapter.enable";
|
|
34148
34148
|
const NOTIFICATION_ADAPTER_METHOD_NAME_DISABLE = "NotificationAdapter.disable";
|
|
34149
34149
|
const NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_BACKTEST = "NotificationAdapter.getDataBacktest";
|
|
34150
|
-
const NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_LIVE = "NotificationAdapter.getDataLive";
|
|
34151
|
-
const NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_BACKTEST = "NotificationAdapter.clearBacktest";
|
|
34152
34150
|
const NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE = "NotificationAdapter.clearLive";
|
|
34153
34151
|
const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_ADAPTER = "NotificationBacktestAdapter.useNotificationAdapter";
|
|
34154
34152
|
const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_DUMMY = "NotificationBacktestAdapter.useDummy";
|
|
@@ -35376,52 +35374,37 @@ class NotificationAdapter {
|
|
|
35376
35374
|
}
|
|
35377
35375
|
};
|
|
35378
35376
|
/**
|
|
35379
|
-
* Gets all backtest notifications from storage.
|
|
35377
|
+
* Gets all backtest/live notifications from storage.
|
|
35380
35378
|
*
|
|
35381
35379
|
* @returns Array of all backtest notification models
|
|
35382
35380
|
* @throws Error if NotificationAdapter is not enabled
|
|
35383
35381
|
*/
|
|
35384
|
-
this.
|
|
35385
|
-
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_BACKTEST
|
|
35382
|
+
this.getData = async (isBacktest) => {
|
|
35383
|
+
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_BACKTEST, {
|
|
35384
|
+
backtest: isBacktest,
|
|
35385
|
+
});
|
|
35386
35386
|
if (!this.enable.hasValue()) {
|
|
35387
35387
|
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35388
35388
|
}
|
|
35389
|
-
|
|
35390
|
-
|
|
35391
|
-
/**
|
|
35392
|
-
* Gets all live notifications from storage.
|
|
35393
|
-
*
|
|
35394
|
-
* @returns Array of all live notification models
|
|
35395
|
-
* @throws Error if NotificationAdapter is not enabled
|
|
35396
|
-
*/
|
|
35397
|
-
this.getDataLive = async () => {
|
|
35398
|
-
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_LIVE);
|
|
35399
|
-
if (!this.enable.hasValue()) {
|
|
35400
|
-
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35389
|
+
if (isBacktest) {
|
|
35390
|
+
return await NotificationBacktest.getData();
|
|
35401
35391
|
}
|
|
35402
35392
|
return await NotificationLive.getData();
|
|
35403
35393
|
};
|
|
35404
35394
|
/**
|
|
35405
|
-
* Clears all backtest notifications from storage.
|
|
35395
|
+
* Clears all backtest/live notifications from storage.
|
|
35406
35396
|
*
|
|
35407
35397
|
* @throws Error if NotificationAdapter is not enabled
|
|
35408
35398
|
*/
|
|
35409
|
-
this.
|
|
35410
|
-
bt.loggerService.info(
|
|
35399
|
+
this.clear = async (isBacktest) => {
|
|
35400
|
+
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE, {
|
|
35401
|
+
backtest: isBacktest,
|
|
35402
|
+
});
|
|
35411
35403
|
if (!this.enable.hasValue()) {
|
|
35412
35404
|
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35413
35405
|
}
|
|
35414
|
-
|
|
35415
|
-
|
|
35416
|
-
/**
|
|
35417
|
-
* Clears all live notifications from storage.
|
|
35418
|
-
*
|
|
35419
|
-
* @throws Error if NotificationAdapter is not enabled
|
|
35420
|
-
*/
|
|
35421
|
-
this.clearLive = async () => {
|
|
35422
|
-
bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE);
|
|
35423
|
-
if (!this.enable.hasValue()) {
|
|
35424
|
-
throw new Error("NotificationAdapter is not enabled. Call enable() first.");
|
|
35406
|
+
if (isBacktest) {
|
|
35407
|
+
return await NotificationBacktest.clear();
|
|
35425
35408
|
}
|
|
35426
35409
|
return await NotificationLive.clear();
|
|
35427
35410
|
};
|
|
@@ -36972,4 +36955,4 @@ const set = (object, path, value) => {
|
|
|
36972
36955
|
}
|
|
36973
36956
|
};
|
|
36974
36957
|
|
|
36975
|
-
export { ActionBase, Backtest, Breakeven, Cache, Constant, Exchange, ExecutionContextService, Heat, Live, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Storage, StorageBacktest, StorageLive, Strategy, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|
|
36958
|
+
export { ActionBase, Backtest, Breakeven, Cache, Constant, Exchange, ExecutionContextService, Heat, Live, Markdown, MarkdownFileBase, MarkdownFolderBase, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, Report, ReportBase, Risk, Schedule, Storage, StorageBacktest, StorageLive, Strategy, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -8710,6 +8710,71 @@ declare class PersistStorageUtils {
|
|
|
8710
8710
|
* Used by SignalLiveUtils for signal storage persistence.
|
|
8711
8711
|
*/
|
|
8712
8712
|
declare const PersistStorageAdapter: PersistStorageUtils;
|
|
8713
|
+
/**
|
|
8714
|
+
* Type for persisted notification data.
|
|
8715
|
+
* Each notification is stored as a separate file keyed by its id.
|
|
8716
|
+
*/
|
|
8717
|
+
type NotificationData = NotificationModel[];
|
|
8718
|
+
/**
|
|
8719
|
+
* Utility class for managing notification persistence.
|
|
8720
|
+
*
|
|
8721
|
+
* Features:
|
|
8722
|
+
* - Memoized storage instances
|
|
8723
|
+
* - Custom adapter support
|
|
8724
|
+
* - Atomic read/write operations for NotificationData
|
|
8725
|
+
* - Each notification stored as separate file keyed by id
|
|
8726
|
+
* - Crash-safe notification state management
|
|
8727
|
+
*
|
|
8728
|
+
* Used by NotificationPersistLiveUtils/NotificationPersistBacktestUtils for persistence.
|
|
8729
|
+
*/
|
|
8730
|
+
declare class PersistNotificationUtils {
|
|
8731
|
+
private PersistNotificationFactory;
|
|
8732
|
+
private getNotificationStorage;
|
|
8733
|
+
/**
|
|
8734
|
+
* Registers a custom persistence adapter.
|
|
8735
|
+
*
|
|
8736
|
+
* @param Ctor - Custom PersistBase constructor
|
|
8737
|
+
*/
|
|
8738
|
+
usePersistNotificationAdapter(Ctor: TPersistBaseCtor<string, NotificationModel>): void;
|
|
8739
|
+
/**
|
|
8740
|
+
* Reads persisted notifications data.
|
|
8741
|
+
*
|
|
8742
|
+
* Called by NotificationPersistLiveUtils/NotificationPersistBacktestUtils.waitForInit() to restore state.
|
|
8743
|
+
* Uses keys() from PersistBase to iterate over all stored notifications.
|
|
8744
|
+
* Returns empty array if no notifications exist.
|
|
8745
|
+
*
|
|
8746
|
+
* @param backtest - If true, reads from backtest storage; otherwise from live storage
|
|
8747
|
+
* @returns Promise resolving to array of notification entries
|
|
8748
|
+
*/
|
|
8749
|
+
readNotificationData: (backtest: boolean) => Promise<NotificationData>;
|
|
8750
|
+
/**
|
|
8751
|
+
* Writes notification data to disk with atomic file writes.
|
|
8752
|
+
*
|
|
8753
|
+
* Called by NotificationPersistLiveUtils/NotificationPersistBacktestUtils after notification changes to persist state.
|
|
8754
|
+
* Uses notification.id as the storage key for individual file storage.
|
|
8755
|
+
* Uses atomic writes to prevent corruption on crashes.
|
|
8756
|
+
*
|
|
8757
|
+
* @param notificationData - Notification entries to persist
|
|
8758
|
+
* @param backtest - If true, writes to backtest storage; otherwise to live storage
|
|
8759
|
+
* @returns Promise that resolves when write is complete
|
|
8760
|
+
*/
|
|
8761
|
+
writeNotificationData: (notificationData: NotificationData, backtest: boolean) => Promise<void>;
|
|
8762
|
+
/**
|
|
8763
|
+
* Switches to the default JSON persist adapter.
|
|
8764
|
+
* All future persistence writes will use JSON storage.
|
|
8765
|
+
*/
|
|
8766
|
+
useJson(): void;
|
|
8767
|
+
/**
|
|
8768
|
+
* Switches to a dummy persist adapter that discards all writes.
|
|
8769
|
+
* All future persistence writes will be no-ops.
|
|
8770
|
+
*/
|
|
8771
|
+
useDummy(): void;
|
|
8772
|
+
}
|
|
8773
|
+
/**
|
|
8774
|
+
* Global singleton instance of PersistNotificationUtils.
|
|
8775
|
+
* Used by NotificationPersistLiveUtils/NotificationPersistBacktestUtils for notification persistence.
|
|
8776
|
+
*/
|
|
8777
|
+
declare const PersistNotificationAdapter: PersistNotificationUtils;
|
|
8713
8778
|
|
|
8714
8779
|
declare const WAIT_FOR_INIT_SYMBOL$1: unique symbol;
|
|
8715
8780
|
declare const WRITE_SAFE_SYMBOL$1: unique symbol;
|
|
@@ -13621,31 +13686,18 @@ declare class NotificationAdapter {
|
|
|
13621
13686
|
*/
|
|
13622
13687
|
disable: () => void;
|
|
13623
13688
|
/**
|
|
13624
|
-
* Gets all backtest notifications from storage.
|
|
13689
|
+
* Gets all backtest/live notifications from storage.
|
|
13625
13690
|
*
|
|
13626
13691
|
* @returns Array of all backtest notification models
|
|
13627
13692
|
* @throws Error if NotificationAdapter is not enabled
|
|
13628
13693
|
*/
|
|
13629
|
-
|
|
13630
|
-
/**
|
|
13631
|
-
* Gets all live notifications from storage.
|
|
13632
|
-
*
|
|
13633
|
-
* @returns Array of all live notification models
|
|
13634
|
-
* @throws Error if NotificationAdapter is not enabled
|
|
13635
|
-
*/
|
|
13636
|
-
getDataLive: () => Promise<NotificationModel[]>;
|
|
13637
|
-
/**
|
|
13638
|
-
* Clears all backtest notifications from storage.
|
|
13639
|
-
*
|
|
13640
|
-
* @throws Error if NotificationAdapter is not enabled
|
|
13641
|
-
*/
|
|
13642
|
-
clearBacktest: () => Promise<void>;
|
|
13694
|
+
getData: (isBacktest: boolean) => Promise<NotificationModel[]>;
|
|
13643
13695
|
/**
|
|
13644
|
-
* Clears all live notifications from storage.
|
|
13696
|
+
* Clears all backtest/live notifications from storage.
|
|
13645
13697
|
*
|
|
13646
13698
|
* @throws Error if NotificationAdapter is not enabled
|
|
13647
13699
|
*/
|
|
13648
|
-
|
|
13700
|
+
clear: (isBacktest: boolean) => Promise<void>;
|
|
13649
13701
|
}
|
|
13650
13702
|
/**
|
|
13651
13703
|
* Global singleton instance of NotificationAdapter.
|
|
@@ -20670,4 +20722,4 @@ declare const backtest: {
|
|
|
20670
20722
|
loggerService: LoggerService;
|
|
20671
20723
|
};
|
|
20672
20724
|
|
|
20673
|
-
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, NotificationBacktest, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|
|
20725
|
+
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|