backtest-kit 5.2.0 → 5.3.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/build/index.cjs +46 -0
- package/build/index.mjs +46 -0
- package/package.json +1 -1
- package/types.d.ts +89 -1
package/build/index.cjs
CHANGED
|
@@ -43724,6 +43724,52 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
43724
43724
|
createdAt: data.timestamp,
|
|
43725
43725
|
};
|
|
43726
43726
|
}
|
|
43727
|
+
if (data.action === "cancel-scheduled") {
|
|
43728
|
+
return {
|
|
43729
|
+
type: "cancel_scheduled.commit",
|
|
43730
|
+
id: CREATE_KEY_FN$1(),
|
|
43731
|
+
timestamp: data.timestamp,
|
|
43732
|
+
backtest: data.backtest,
|
|
43733
|
+
symbol: data.symbol,
|
|
43734
|
+
strategyName: data.strategyName,
|
|
43735
|
+
exchangeName: data.exchangeName,
|
|
43736
|
+
signalId: data.signalId,
|
|
43737
|
+
cancelId: data.cancelId,
|
|
43738
|
+
totalEntries: data.totalEntries,
|
|
43739
|
+
totalPartials: data.totalPartials,
|
|
43740
|
+
originalPriceOpen: data.originalPriceOpen,
|
|
43741
|
+
pnl: data.pnl,
|
|
43742
|
+
pnlPercentage: data.pnl.pnlPercentage,
|
|
43743
|
+
pnlPriceOpen: data.pnl.priceOpen,
|
|
43744
|
+
pnlPriceClose: data.pnl.priceClose,
|
|
43745
|
+
pnlCost: data.pnl.pnlCost,
|
|
43746
|
+
pnlEntries: data.pnl.pnlEntries,
|
|
43747
|
+
createdAt: data.timestamp,
|
|
43748
|
+
};
|
|
43749
|
+
}
|
|
43750
|
+
if (data.action === "close-pending") {
|
|
43751
|
+
return {
|
|
43752
|
+
type: "close_pending.commit",
|
|
43753
|
+
id: CREATE_KEY_FN$1(),
|
|
43754
|
+
timestamp: data.timestamp,
|
|
43755
|
+
backtest: data.backtest,
|
|
43756
|
+
symbol: data.symbol,
|
|
43757
|
+
strategyName: data.strategyName,
|
|
43758
|
+
exchangeName: data.exchangeName,
|
|
43759
|
+
signalId: data.signalId,
|
|
43760
|
+
closeId: data.closeId,
|
|
43761
|
+
totalEntries: data.totalEntries,
|
|
43762
|
+
totalPartials: data.totalPartials,
|
|
43763
|
+
originalPriceOpen: data.originalPriceOpen,
|
|
43764
|
+
pnl: data.pnl,
|
|
43765
|
+
pnlPercentage: data.pnl.pnlPercentage,
|
|
43766
|
+
pnlPriceOpen: data.pnl.priceOpen,
|
|
43767
|
+
pnlPriceClose: data.pnl.priceClose,
|
|
43768
|
+
pnlCost: data.pnl.pnlCost,
|
|
43769
|
+
pnlEntries: data.pnl.pnlEntries,
|
|
43770
|
+
createdAt: data.timestamp,
|
|
43771
|
+
};
|
|
43772
|
+
}
|
|
43727
43773
|
throw new Error(`Unrecognized strategy commit action: ${get(data, "action")}`);
|
|
43728
43774
|
};
|
|
43729
43775
|
/**
|
package/build/index.mjs
CHANGED
|
@@ -43704,6 +43704,52 @@ const CREATE_STRATEGY_COMMIT_NOTIFICATION_FN = (data) => {
|
|
|
43704
43704
|
createdAt: data.timestamp,
|
|
43705
43705
|
};
|
|
43706
43706
|
}
|
|
43707
|
+
if (data.action === "cancel-scheduled") {
|
|
43708
|
+
return {
|
|
43709
|
+
type: "cancel_scheduled.commit",
|
|
43710
|
+
id: CREATE_KEY_FN$1(),
|
|
43711
|
+
timestamp: data.timestamp,
|
|
43712
|
+
backtest: data.backtest,
|
|
43713
|
+
symbol: data.symbol,
|
|
43714
|
+
strategyName: data.strategyName,
|
|
43715
|
+
exchangeName: data.exchangeName,
|
|
43716
|
+
signalId: data.signalId,
|
|
43717
|
+
cancelId: data.cancelId,
|
|
43718
|
+
totalEntries: data.totalEntries,
|
|
43719
|
+
totalPartials: data.totalPartials,
|
|
43720
|
+
originalPriceOpen: data.originalPriceOpen,
|
|
43721
|
+
pnl: data.pnl,
|
|
43722
|
+
pnlPercentage: data.pnl.pnlPercentage,
|
|
43723
|
+
pnlPriceOpen: data.pnl.priceOpen,
|
|
43724
|
+
pnlPriceClose: data.pnl.priceClose,
|
|
43725
|
+
pnlCost: data.pnl.pnlCost,
|
|
43726
|
+
pnlEntries: data.pnl.pnlEntries,
|
|
43727
|
+
createdAt: data.timestamp,
|
|
43728
|
+
};
|
|
43729
|
+
}
|
|
43730
|
+
if (data.action === "close-pending") {
|
|
43731
|
+
return {
|
|
43732
|
+
type: "close_pending.commit",
|
|
43733
|
+
id: CREATE_KEY_FN$1(),
|
|
43734
|
+
timestamp: data.timestamp,
|
|
43735
|
+
backtest: data.backtest,
|
|
43736
|
+
symbol: data.symbol,
|
|
43737
|
+
strategyName: data.strategyName,
|
|
43738
|
+
exchangeName: data.exchangeName,
|
|
43739
|
+
signalId: data.signalId,
|
|
43740
|
+
closeId: data.closeId,
|
|
43741
|
+
totalEntries: data.totalEntries,
|
|
43742
|
+
totalPartials: data.totalPartials,
|
|
43743
|
+
originalPriceOpen: data.originalPriceOpen,
|
|
43744
|
+
pnl: data.pnl,
|
|
43745
|
+
pnlPercentage: data.pnl.pnlPercentage,
|
|
43746
|
+
pnlPriceOpen: data.pnl.priceOpen,
|
|
43747
|
+
pnlPriceClose: data.pnl.priceClose,
|
|
43748
|
+
pnlCost: data.pnl.pnlCost,
|
|
43749
|
+
pnlEntries: data.pnl.pnlEntries,
|
|
43750
|
+
createdAt: data.timestamp,
|
|
43751
|
+
};
|
|
43752
|
+
}
|
|
43707
43753
|
throw new Error(`Unrecognized strategy commit action: ${get(data, "action")}`);
|
|
43708
43754
|
};
|
|
43709
43755
|
/**
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -9154,6 +9154,94 @@ interface ValidationErrorNotification {
|
|
|
9154
9154
|
/** Always false for error notifications (errors are from live context) */
|
|
9155
9155
|
backtest: boolean;
|
|
9156
9156
|
}
|
|
9157
|
+
/**
|
|
9158
|
+
* Cancel scheduled commit notification.
|
|
9159
|
+
* Emitted when a scheduled signal is cancelled before activation.
|
|
9160
|
+
*/
|
|
9161
|
+
interface CancelScheduledCommitNotification {
|
|
9162
|
+
/** Discriminator for type-safe union */
|
|
9163
|
+
type: "cancel_scheduled.commit";
|
|
9164
|
+
/** Unique notification identifier */
|
|
9165
|
+
id: string;
|
|
9166
|
+
/** Unix timestamp in milliseconds when cancellation was committed */
|
|
9167
|
+
timestamp: number;
|
|
9168
|
+
/** Whether this notification is from backtest mode (true) or live mode (false) */
|
|
9169
|
+
backtest: boolean;
|
|
9170
|
+
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
9171
|
+
symbol: string;
|
|
9172
|
+
/** Strategy name that generated this signal */
|
|
9173
|
+
strategyName: StrategyName;
|
|
9174
|
+
/** Exchange name where signal was executed */
|
|
9175
|
+
exchangeName: ExchangeName;
|
|
9176
|
+
/** Unique signal identifier (UUID v4) */
|
|
9177
|
+
signalId: string;
|
|
9178
|
+
/** Optional identifier for the cancellation reason (user-provided) */
|
|
9179
|
+
cancelId?: string;
|
|
9180
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
9181
|
+
totalEntries: number;
|
|
9182
|
+
/** Total number of partial closes executed (_partial.length). 0 = no partial closes done. */
|
|
9183
|
+
totalPartials: number;
|
|
9184
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
9185
|
+
originalPriceOpen: number;
|
|
9186
|
+
/** PNL at the moment of cancellation (from data.pnl) */
|
|
9187
|
+
pnl: IStrategyPnL;
|
|
9188
|
+
/** Profit/loss as percentage (e.g., 1.5 for +1.5%, -2.3 for -2.3%) */
|
|
9189
|
+
pnlPercentage: number;
|
|
9190
|
+
/** Entry price from PNL calculation (effective price adjusted with slippage and fees) */
|
|
9191
|
+
pnlPriceOpen: number;
|
|
9192
|
+
/** Exit price from PNL calculation (adjusted with slippage and fees) */
|
|
9193
|
+
pnlPriceClose: number;
|
|
9194
|
+
/** Absolute profit/loss in USD */
|
|
9195
|
+
pnlCost: number;
|
|
9196
|
+
/** Total invested capital in USD */
|
|
9197
|
+
pnlEntries: number;
|
|
9198
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
9199
|
+
createdAt: number;
|
|
9200
|
+
}
|
|
9201
|
+
/**
|
|
9202
|
+
* Close pending commit notification.
|
|
9203
|
+
* Emitted when a pending signal is closed before position activation.
|
|
9204
|
+
*/
|
|
9205
|
+
interface ClosePendingCommitNotification {
|
|
9206
|
+
/** Discriminator for type-safe union */
|
|
9207
|
+
type: "close_pending.commit";
|
|
9208
|
+
/** Unique notification identifier */
|
|
9209
|
+
id: string;
|
|
9210
|
+
/** Unix timestamp in milliseconds when close was committed */
|
|
9211
|
+
timestamp: number;
|
|
9212
|
+
/** Whether this notification is from backtest mode (true) or live mode (false) */
|
|
9213
|
+
backtest: boolean;
|
|
9214
|
+
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
9215
|
+
symbol: string;
|
|
9216
|
+
/** Strategy name that generated this signal */
|
|
9217
|
+
strategyName: StrategyName;
|
|
9218
|
+
/** Exchange name where signal was executed */
|
|
9219
|
+
exchangeName: ExchangeName;
|
|
9220
|
+
/** Unique signal identifier (UUID v4) */
|
|
9221
|
+
signalId: string;
|
|
9222
|
+
/** Optional identifier for the close reason (user-provided) */
|
|
9223
|
+
closeId?: string;
|
|
9224
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
9225
|
+
totalEntries: number;
|
|
9226
|
+
/** Total number of partial closes executed (_partial.length). 0 = no partial closes done. */
|
|
9227
|
+
totalPartials: number;
|
|
9228
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
9229
|
+
originalPriceOpen: number;
|
|
9230
|
+
/** PNL at the moment of close (from data.pnl) */
|
|
9231
|
+
pnl: IStrategyPnL;
|
|
9232
|
+
/** Profit/loss as percentage (e.g., 1.5 for +1.5%, -2.3 for -2.3%) */
|
|
9233
|
+
pnlPercentage: number;
|
|
9234
|
+
/** Entry price from PNL calculation (effective price adjusted with slippage and fees) */
|
|
9235
|
+
pnlPriceOpen: number;
|
|
9236
|
+
/** Exit price from PNL calculation (adjusted with slippage and fees) */
|
|
9237
|
+
pnlPriceClose: number;
|
|
9238
|
+
/** Absolute profit/loss in USD */
|
|
9239
|
+
pnlCost: number;
|
|
9240
|
+
/** Total invested capital in USD */
|
|
9241
|
+
pnlEntries: number;
|
|
9242
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
9243
|
+
createdAt: number;
|
|
9244
|
+
}
|
|
9157
9245
|
/**
|
|
9158
9246
|
* Root discriminated union of all notification types.
|
|
9159
9247
|
* Type discrimination is done via the `type` field.
|
|
@@ -9180,7 +9268,7 @@ interface ValidationErrorNotification {
|
|
|
9180
9268
|
* }
|
|
9181
9269
|
* ```
|
|
9182
9270
|
*/
|
|
9183
|
-
type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | AverageBuyCommitNotification | ActivateScheduledCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | SignalSyncOpenNotification | SignalSyncCloseNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification;
|
|
9271
|
+
type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | AverageBuyCommitNotification | ActivateScheduledCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | CancelScheduledCommitNotification | ClosePendingCommitNotification | SignalSyncOpenNotification | SignalSyncCloseNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification;
|
|
9184
9272
|
|
|
9185
9273
|
/**
|
|
9186
9274
|
* Unified tick event data for report generation.
|