backtest-kit 2.2.15 → 2.2.17
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 +2 -0
- package/build/index.mjs +2 -0
- package/package.json +1 -1
- package/types.d.ts +106 -4
package/build/index.cjs
CHANGED
|
@@ -31716,6 +31716,7 @@ class StorageBacktestUtils {
|
|
|
31716
31716
|
...tick.signal,
|
|
31717
31717
|
status: "closed",
|
|
31718
31718
|
priority: Date.now(),
|
|
31719
|
+
pnl: tick.pnl,
|
|
31719
31720
|
createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
|
|
31720
31721
|
updatedAt: tick.createdAt,
|
|
31721
31722
|
});
|
|
@@ -31885,6 +31886,7 @@ class StorageLiveUtils {
|
|
|
31885
31886
|
...tick.signal,
|
|
31886
31887
|
status: "closed",
|
|
31887
31888
|
priority: Date.now(),
|
|
31889
|
+
pnl: tick.pnl,
|
|
31888
31890
|
createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
|
|
31889
31891
|
updatedAt: tick.createdAt,
|
|
31890
31892
|
});
|
package/build/index.mjs
CHANGED
|
@@ -31696,6 +31696,7 @@ class StorageBacktestUtils {
|
|
|
31696
31696
|
...tick.signal,
|
|
31697
31697
|
status: "closed",
|
|
31698
31698
|
priority: Date.now(),
|
|
31699
|
+
pnl: tick.pnl,
|
|
31699
31700
|
createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
|
|
31700
31701
|
updatedAt: tick.createdAt,
|
|
31701
31702
|
});
|
|
@@ -31865,6 +31866,7 @@ class StorageLiveUtils {
|
|
|
31865
31866
|
...tick.signal,
|
|
31866
31867
|
status: "closed",
|
|
31867
31868
|
priority: Date.now(),
|
|
31869
|
+
pnl: tick.pnl,
|
|
31868
31870
|
createdAt: lastStorage ? lastStorage.createdAt : tick.createdAt,
|
|
31869
31871
|
updatedAt: tick.createdAt,
|
|
31870
31872
|
});
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1211,19 +1211,53 @@ interface IPublicSignalRow extends ISignalRow {
|
|
|
1211
1211
|
partialExecuted: number;
|
|
1212
1212
|
}
|
|
1213
1213
|
/**
|
|
1214
|
-
*
|
|
1214
|
+
* Base storage signal row fields shared by all status variants.
|
|
1215
1215
|
* Used for persisting signals with accurate creation time.
|
|
1216
1216
|
*/
|
|
1217
|
-
interface
|
|
1217
|
+
interface IStorageSignalRowBase extends IPublicSignalRow {
|
|
1218
1218
|
/** Creation timestamp taken from IStrategyTickResult */
|
|
1219
1219
|
createdAt: number;
|
|
1220
1220
|
/** Creation timestamp taken from IStrategyTickResult */
|
|
1221
1221
|
updatedAt: number;
|
|
1222
1222
|
/** Storage adapter rewrite priority. Equal to Date.now for live and backtest both */
|
|
1223
1223
|
priority: number;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Storage signal row for opened status.
|
|
1227
|
+
*/
|
|
1228
|
+
interface IStorageSignalRowOpened extends IStorageSignalRowBase {
|
|
1229
|
+
/** Current status of the signal */
|
|
1230
|
+
status: "opened";
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Storage signal row for scheduled status.
|
|
1234
|
+
*/
|
|
1235
|
+
interface IStorageSignalRowScheduled extends IStorageSignalRowBase {
|
|
1236
|
+
/** Current status of the signal */
|
|
1237
|
+
status: "scheduled";
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Storage signal row for closed status.
|
|
1241
|
+
* Only closed signals have PNL data.
|
|
1242
|
+
*/
|
|
1243
|
+
interface IStorageSignalRowClosed extends IStorageSignalRowBase {
|
|
1244
|
+
/** Current status of the signal */
|
|
1245
|
+
status: "closed";
|
|
1246
|
+
/** Profit and loss value for the signal when closed */
|
|
1247
|
+
pnl: IStrategyPnL;
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Storage signal row for cancelled status.
|
|
1251
|
+
*/
|
|
1252
|
+
interface IStorageSignalRowCancelled extends IStorageSignalRowBase {
|
|
1224
1253
|
/** Current status of the signal */
|
|
1225
|
-
status: "
|
|
1254
|
+
status: "cancelled";
|
|
1226
1255
|
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Discriminated union of storage signal rows.
|
|
1258
|
+
* Use type guards: `row.status === "closed"` for type-safe access to pnl.
|
|
1259
|
+
*/
|
|
1260
|
+
type IStorageSignalRow = IStorageSignalRowOpened | IStorageSignalRowScheduled | IStorageSignalRowClosed | IStorageSignalRowCancelled;
|
|
1227
1261
|
/**
|
|
1228
1262
|
* Risk signal row for internal risk management.
|
|
1229
1263
|
* Extends ISignalDto to include priceOpen, originalPriceStopLoss and originalPriceTakeProfit.
|
|
@@ -1251,6 +1285,74 @@ interface IScheduledSignalCancelRow extends IScheduledSignalRow {
|
|
|
1251
1285
|
/** Cancellation ID (only for user-initiated cancellations) */
|
|
1252
1286
|
cancelId?: string;
|
|
1253
1287
|
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Base interface for queued commit events.
|
|
1290
|
+
* Used to defer commit emission until proper execution context is available.
|
|
1291
|
+
*/
|
|
1292
|
+
interface ICommitRowBase {
|
|
1293
|
+
/** Trading pair symbol */
|
|
1294
|
+
symbol: string;
|
|
1295
|
+
/** Whether running in backtest mode */
|
|
1296
|
+
backtest: boolean;
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Queued partial profit commit.
|
|
1300
|
+
*/
|
|
1301
|
+
interface IPartialProfitCommitRow extends ICommitRowBase {
|
|
1302
|
+
/** Discriminator */
|
|
1303
|
+
action: "partial-profit";
|
|
1304
|
+
/** Percentage of position closed */
|
|
1305
|
+
percentToClose: number;
|
|
1306
|
+
/** Price at which partial was executed */
|
|
1307
|
+
currentPrice: number;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Queued partial loss commit.
|
|
1311
|
+
*/
|
|
1312
|
+
interface IPartialLossCommitRow extends ICommitRowBase {
|
|
1313
|
+
/** Discriminator */
|
|
1314
|
+
action: "partial-loss";
|
|
1315
|
+
/** Percentage of position closed */
|
|
1316
|
+
percentToClose: number;
|
|
1317
|
+
/** Price at which partial was executed */
|
|
1318
|
+
currentPrice: number;
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Queued breakeven commit.
|
|
1322
|
+
*/
|
|
1323
|
+
interface IBreakevenCommitRow extends ICommitRowBase {
|
|
1324
|
+
/** Discriminator */
|
|
1325
|
+
action: "breakeven";
|
|
1326
|
+
/** Price at which breakeven was set */
|
|
1327
|
+
currentPrice: number;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Queued trailing stop commit.
|
|
1331
|
+
*/
|
|
1332
|
+
interface ITrailingStopCommitRow extends ICommitRowBase {
|
|
1333
|
+
/** Discriminator */
|
|
1334
|
+
action: "trailing-stop";
|
|
1335
|
+
/** Percentage shift applied */
|
|
1336
|
+
percentShift: number;
|
|
1337
|
+
/** Price at which trailing was set */
|
|
1338
|
+
currentPrice: number;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Queued trailing take commit.
|
|
1342
|
+
*/
|
|
1343
|
+
interface ITrailingTakeCommitRow extends ICommitRowBase {
|
|
1344
|
+
/** Discriminator */
|
|
1345
|
+
action: "trailing-take";
|
|
1346
|
+
/** Percentage shift applied */
|
|
1347
|
+
percentShift: number;
|
|
1348
|
+
/** Price at which trailing was set */
|
|
1349
|
+
currentPrice: number;
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Discriminated union of all queued commit events.
|
|
1353
|
+
* These are stored in _commitQueue and processed in tick()/backtest().
|
|
1354
|
+
*/
|
|
1355
|
+
type ICommitRow = IPartialProfitCommitRow | IPartialLossCommitRow | IBreakevenCommitRow | ITrailingStopCommitRow | ITrailingTakeCommitRow;
|
|
1254
1356
|
/**
|
|
1255
1357
|
* Optional lifecycle callbacks for signal events.
|
|
1256
1358
|
* Called when signals are opened, active, idle, closed, scheduled, or cancelled.
|
|
@@ -19595,4 +19697,4 @@ declare const backtest: {
|
|
|
19595
19697
|
loggerService: LoggerService;
|
|
19596
19698
|
};
|
|
19597
19699
|
|
|
19598
|
-
export { ActionBase, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CandleData, 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 IOrderBookData, 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 ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, 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, type StorageData, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TickEvent, type TrailingStopCommitNotification, 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, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, 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 };
|
|
19700
|
+
export { ActionBase, 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 IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, 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 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, 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, type StorageData, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, 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, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, 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 };
|