backtest-kit 5.9.0 → 5.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "5.9.0",
3
+ "version": "5.10.0",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -2938,7 +2938,7 @@ interface IStrategy {
2938
2938
  * @param candles - Array of historical candle data
2939
2939
  * @returns Promise resolving to closed result (always completes signal)
2940
2940
  */
2941
- backtest: (symbol: string, strategyName: StrategyName, candles: ICandleData[]) => Promise<IStrategyBacktestResult>;
2941
+ backtest: (symbol: string, strategyName: StrategyName, candles: ICandleData[], frameEndTime: number) => Promise<IStrategyBacktestResult>;
2942
2942
  /**
2943
2943
  * Stops the strategy from generating new signals.
2944
2944
  *
@@ -8417,6 +8417,7 @@ declare function writeMemory<T extends object = object>(dto: {
8417
8417
  bucketName: string;
8418
8418
  memoryId: string;
8419
8419
  value: T;
8420
+ description: string;
8420
8421
  }): Promise<void>;
8421
8422
  /**
8422
8423
  * Reads a value from memory scoped to the current signal.
@@ -18458,9 +18459,9 @@ interface IMemoryInstance {
18458
18459
  * Write a value to memory.
18459
18460
  * @param memoryId - Unique entry identifier
18460
18461
  * @param value - Value to store
18461
- * @param index - Optional BM25 index string; defaults to JSON.stringify(value)
18462
+ * @param description - Optional BM25 index string; defaults to JSON.stringify(value)
18462
18463
  */
18463
- writeMemory<T extends object = object>(memoryId: string, value: T, index?: string): Promise<void>;
18464
+ writeMemory<T extends object = object>(memoryId: string, value: T, description: string): Promise<void>;
18464
18465
  /**
18465
18466
  * Search memory using BM25 full-text scoring.
18466
18467
  * @param query - Search query string
@@ -18541,14 +18542,14 @@ declare class MemoryAdapter implements TMemoryInstance {
18541
18542
  * @param dto.value - Value to store
18542
18543
  * @param dto.signalId - Signal identifier
18543
18544
  * @param dto.bucketName - Bucket name
18544
- * @param dto.index - Optional BM25 index string; defaults to JSON.stringify(value)
18545
+ * @param dto.description - Optional BM25 index string; defaults to JSON.stringify(value)
18545
18546
  */
18546
18547
  writeMemory: <T extends object = object>(dto: {
18547
18548
  memoryId: string;
18548
18549
  value: T;
18549
18550
  signalId: string;
18550
18551
  bucketName: string;
18551
- index?: string;
18552
+ description: string;
18552
18553
  }) => Promise<void>;
18553
18554
  /**
18554
18555
  * Search memory using BM25 full-text scoring.
@@ -21069,6 +21070,21 @@ interface IBroker {
21069
21070
  /** Called when a DCA (average-buy) entry is committed. */
21070
21071
  onAverageBuyCommit(payload: BrokerAverageBuyPayload): Promise<void>;
21071
21072
  }
21073
+ /**
21074
+ * Constructor type for a broker adapter class.
21075
+ *
21076
+ * Used by `BrokerAdapter.useBrokerAdapter` to accept a class (not an instance).
21077
+ * All `IBroker` methods are optional — implement only what the adapter needs.
21078
+ *
21079
+ * @example
21080
+ * ```typescript
21081
+ * class MyBroker implements Partial<IBroker> {
21082
+ * async onSignalOpenCommit(payload: BrokerSignalOpenPayload) { ... }
21083
+ * }
21084
+ *
21085
+ * Broker.useBrokerAdapter(MyBroker); // MyBroker satisfies TBrokerCtor
21086
+ * ```
21087
+ */
21072
21088
  type TBrokerCtor = new () => Partial<IBroker>;
21073
21089
  /**
21074
21090
  * Facade for broker integration — intercepts all commit* operations before DI-core mutations.
@@ -23650,7 +23666,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
23650
23666
  strategyName: StrategyName;
23651
23667
  exchangeName: ExchangeName;
23652
23668
  frameName: FrameName;
23653
- }, candles: ICandleData[]) => Promise<IStrategyTickResultClosed | IStrategyTickResultCancelled | IStrategyTickResultActive>;
23669
+ }, candles: ICandleData[], frameEndTime: number) => Promise<IStrategyTickResultClosed | IStrategyTickResultCancelled | IStrategyTickResultActive>;
23654
23670
  /**
23655
23671
  * Stops the specified strategy from generating new signals.
23656
23672
  *
@@ -25046,7 +25062,7 @@ declare class StrategyCoreService implements TStrategy {
25046
25062
  * @param context - Execution context with strategyName, exchangeName, frameName
25047
25063
  * @returns Closed signal result with PNL
25048
25064
  */
25049
- backtest: (symbol: string, candles: ICandleData[], when: Date, backtest: boolean, context: {
25065
+ backtest: (symbol: string, candles: ICandleData[], frameEndTime: number, when: Date, backtest: boolean, context: {
25050
25066
  strategyName: StrategyName;
25051
25067
  exchangeName: ExchangeName;
25052
25068
  frameName: FrameName;