backtest-kit 2.2.26 → 2.3.1
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 +86 -3
- package/build/index.cjs +241 -28
- package/build/index.mjs +241 -29
- package/package.json +1 -1
- package/types.d.ts +40 -4
package/types.d.ts
CHANGED
|
@@ -3893,6 +3893,10 @@ interface BreakevenEvent {
|
|
|
3893
3893
|
partialExecuted?: number;
|
|
3894
3894
|
/** Human-readable description of signal reason */
|
|
3895
3895
|
note?: string;
|
|
3896
|
+
/** Timestamp when position became active (ms) */
|
|
3897
|
+
pendingAt?: number;
|
|
3898
|
+
/** Timestamp when signal was created/scheduled (ms) */
|
|
3899
|
+
scheduledAt?: number;
|
|
3896
3900
|
/** True if backtest mode, false if live mode */
|
|
3897
3901
|
backtest: boolean;
|
|
3898
3902
|
}
|
|
@@ -6529,6 +6533,17 @@ declare function getOrderBook(symbol: string, depth?: number): Promise<IOrderBoo
|
|
|
6529
6533
|
* ```
|
|
6530
6534
|
*/
|
|
6531
6535
|
declare function getRawCandles(symbol: string, interval: CandleInterval, limit?: number, sDate?: number, eDate?: number): Promise<ICandleData[]>;
|
|
6536
|
+
/**
|
|
6537
|
+
* Fetches the set of candles after current time based on execution context.
|
|
6538
|
+
*
|
|
6539
|
+
* Uses the exchange's getNextCandles implementation to retrieve candles
|
|
6540
|
+
* that occur after the current context time.
|
|
6541
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
6542
|
+
* @param interval - Candle interval ("1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "6h" | "8h")
|
|
6543
|
+
* @param limit - Number of candles to fetch
|
|
6544
|
+
* @returns Promise resolving to array of candle data
|
|
6545
|
+
*/
|
|
6546
|
+
declare function getNextCandles(symbol: string, interval: CandleInterval, limit: number): Promise<ICandleData[]>;
|
|
6532
6547
|
|
|
6533
6548
|
/**
|
|
6534
6549
|
* Portfolio heatmap statistics for a single symbol.
|
|
@@ -7294,6 +7309,10 @@ interface TickEvent {
|
|
|
7294
7309
|
cancelReason?: string;
|
|
7295
7310
|
/** Duration in minutes (only for closed) */
|
|
7296
7311
|
duration?: number;
|
|
7312
|
+
/** Timestamp when position became active (only for opened/active/closed) */
|
|
7313
|
+
pendingAt?: number;
|
|
7314
|
+
/** Timestamp when signal was created/scheduled (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
7315
|
+
scheduledAt?: number;
|
|
7297
7316
|
}
|
|
7298
7317
|
/**
|
|
7299
7318
|
* Statistical data calculated from live trading results.
|
|
@@ -7403,6 +7422,10 @@ interface ScheduledEvent {
|
|
|
7403
7422
|
cancelReason?: "timeout" | "price_reject" | "user";
|
|
7404
7423
|
/** Cancellation ID (only for user-initiated cancellations) */
|
|
7405
7424
|
cancelId?: string;
|
|
7425
|
+
/** Timestamp when position became active (only for opened events) */
|
|
7426
|
+
pendingAt?: number;
|
|
7427
|
+
/** Timestamp when signal was created/scheduled (for all events) */
|
|
7428
|
+
scheduledAt?: number;
|
|
7406
7429
|
}
|
|
7407
7430
|
/**
|
|
7408
7431
|
* Statistical data calculated from scheduled signals.
|
|
@@ -7575,6 +7598,10 @@ interface PartialEvent {
|
|
|
7575
7598
|
partialExecuted?: number;
|
|
7576
7599
|
/** Human-readable description of signal reason */
|
|
7577
7600
|
note?: string;
|
|
7601
|
+
/** Timestamp when position became active (ms) */
|
|
7602
|
+
pendingAt?: number;
|
|
7603
|
+
/** Timestamp when signal was created/scheduled (ms) */
|
|
7604
|
+
scheduledAt?: number;
|
|
7578
7605
|
/** True if backtest mode, false if live mode */
|
|
7579
7606
|
backtest: boolean;
|
|
7580
7607
|
}
|
|
@@ -8368,12 +8395,17 @@ declare class PersistCandleUtils {
|
|
|
8368
8395
|
* Reads cached candles for a specific exchange, symbol, and interval.
|
|
8369
8396
|
* Returns candles only if cache contains exactly the requested limit.
|
|
8370
8397
|
*
|
|
8398
|
+
* Boundary semantics (EXCLUSIVE):
|
|
8399
|
+
* - sinceTimestamp: candle.timestamp must be > sinceTimestamp
|
|
8400
|
+
* - untilTimestamp: candle.timestamp + stepMs must be < untilTimestamp
|
|
8401
|
+
* - Only fully closed candles within the exclusive range are returned
|
|
8402
|
+
*
|
|
8371
8403
|
* @param symbol - Trading pair symbol
|
|
8372
8404
|
* @param interval - Candle interval
|
|
8373
8405
|
* @param exchangeName - Exchange identifier
|
|
8374
8406
|
* @param limit - Number of candles requested
|
|
8375
|
-
* @param sinceTimestamp -
|
|
8376
|
-
* @param untilTimestamp -
|
|
8407
|
+
* @param sinceTimestamp - Exclusive start timestamp in milliseconds
|
|
8408
|
+
* @param untilTimestamp - Exclusive end timestamp in milliseconds
|
|
8377
8409
|
* @returns Promise resolving to array of candles or null if cache is incomplete
|
|
8378
8410
|
*/
|
|
8379
8411
|
readCandlesData: (symbol: string, interval: CandleInterval, exchangeName: ExchangeName, limit: number, sinceTimestamp: number, untilTimestamp: number) => Promise<CandleData[] | null>;
|
|
@@ -8381,7 +8413,11 @@ declare class PersistCandleUtils {
|
|
|
8381
8413
|
* Writes candles to cache with atomic file writes.
|
|
8382
8414
|
* Each candle is stored as a separate JSON file named by its timestamp.
|
|
8383
8415
|
*
|
|
8384
|
-
*
|
|
8416
|
+
* The candles passed to this function must already be filtered using EXCLUSIVE boundaries:
|
|
8417
|
+
* - candle.timestamp > sinceTimestamp
|
|
8418
|
+
* - candle.timestamp + stepMs < untilTimestamp
|
|
8419
|
+
*
|
|
8420
|
+
* @param candles - Array of candle data to cache (already filtered with exclusive boundaries)
|
|
8385
8421
|
* @param symbol - Trading pair symbol
|
|
8386
8422
|
* @param interval - Candle interval
|
|
8387
8423
|
* @param exchangeName - Exchange identifier
|
|
@@ -20054,4 +20090,4 @@ declare const backtest: {
|
|
|
20054
20090
|
loggerService: LoggerService;
|
|
20055
20091
|
};
|
|
20056
20092
|
|
|
20057
|
-
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 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, 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 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, 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 };
|
|
20093
|
+
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 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, 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 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, 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 };
|