backtest-kit 7.0.0 → 7.0.2

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 CHANGED
@@ -46,7 +46,7 @@ Sidekick generates a project where the exchange adapter, frame definitions, risk
46
46
 
47
47
  ### 📦 Manual Installation
48
48
 
49
- > **Want to see the code?** 👉 [Demo app](https://github.com/tripolskypetr/backtest-kit/tree/master/demo) 👈
49
+ > **Want to see the code?** 👉 [Demo app](https://github.com/tripolskypetr/backtest-kit/tree/master/example) 👈
50
50
 
51
51
  ```bash
52
52
  npm install backtest-kit ccxt ollama uuid
package/build/index.cjs CHANGED
@@ -46705,17 +46705,24 @@ class RecentAdapter {
46705
46705
  * @returns Whole minutes since the latest signal was created, or null if no signal found
46706
46706
  * @throws Error if RecentAdapter is not enabled
46707
46707
  */
46708
- this.getMinutesSinceLatestSignalCreated = async (timestamp, symbol, context) => {
46708
+ this.getMinutesSinceLatestSignalCreated = async (symbol, context) => {
46709
46709
  backtest.loggerService.info(RECENT_ADAPTER_METHOD_NAME_GET_MINUTES_SINCE_LATEST_SIGNAL, {
46710
46710
  symbol,
46711
46711
  context,
46712
- timestamp,
46713
46712
  });
46714
- const signal = await this.getLatestSignal(symbol, context);
46715
- if (!signal) {
46716
- return null;
46713
+ if (!this.enable.hasValue()) {
46714
+ throw new Error("RecentAdapter is not enabled. Call enable() first.");
46717
46715
  }
46718
- return Math.floor((timestamp - signal.timestamp) / (1000 * 60));
46716
+ let signal = null;
46717
+ if (signal = await RecentBacktest.getLatestSignal(symbol, context.strategyName, context.exchangeName, context.frameName, true)) {
46718
+ const timestamp = await backtest.timeMetaService.getTimestamp(symbol, context, true);
46719
+ return Math.floor((timestamp - signal.timestamp) / (1000 * 60));
46720
+ }
46721
+ if (signal = await RecentLive.getLatestSignal(symbol, context.strategyName, context.exchangeName, context.frameName, false)) {
46722
+ const timestamp = await backtest.timeMetaService.getTimestamp(symbol, context, false);
46723
+ return Math.floor((timestamp - signal.timestamp) / (1000 * 60));
46724
+ }
46725
+ return null;
46719
46726
  };
46720
46727
  }
46721
46728
  }
@@ -46808,8 +46815,7 @@ async function getMinutesSinceLatestSignalCreated(symbol) {
46808
46815
  throw new Error("getMinutesSinceLatestSignalCreated requires a method context");
46809
46816
  }
46810
46817
  const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
46811
- const { when } = backtest.executionContextService.context;
46812
- return await Recent.getMinutesSinceLatestSignalCreated(when.getTime(), symbol, { exchangeName, frameName, strategyName });
46818
+ return await Recent.getMinutesSinceLatestSignalCreated(symbol, { exchangeName, frameName, strategyName });
46813
46819
  }
46814
46820
 
46815
46821
  const DEFAULT_BM25_K1 = 1.5;
package/build/index.mjs CHANGED
@@ -46685,17 +46685,24 @@ class RecentAdapter {
46685
46685
  * @returns Whole minutes since the latest signal was created, or null if no signal found
46686
46686
  * @throws Error if RecentAdapter is not enabled
46687
46687
  */
46688
- this.getMinutesSinceLatestSignalCreated = async (timestamp, symbol, context) => {
46688
+ this.getMinutesSinceLatestSignalCreated = async (symbol, context) => {
46689
46689
  backtest.loggerService.info(RECENT_ADAPTER_METHOD_NAME_GET_MINUTES_SINCE_LATEST_SIGNAL, {
46690
46690
  symbol,
46691
46691
  context,
46692
- timestamp,
46693
46692
  });
46694
- const signal = await this.getLatestSignal(symbol, context);
46695
- if (!signal) {
46696
- return null;
46693
+ if (!this.enable.hasValue()) {
46694
+ throw new Error("RecentAdapter is not enabled. Call enable() first.");
46697
46695
  }
46698
- return Math.floor((timestamp - signal.timestamp) / (1000 * 60));
46696
+ let signal = null;
46697
+ if (signal = await RecentBacktest.getLatestSignal(symbol, context.strategyName, context.exchangeName, context.frameName, true)) {
46698
+ const timestamp = await backtest.timeMetaService.getTimestamp(symbol, context, true);
46699
+ return Math.floor((timestamp - signal.timestamp) / (1000 * 60));
46700
+ }
46701
+ if (signal = await RecentLive.getLatestSignal(symbol, context.strategyName, context.exchangeName, context.frameName, false)) {
46702
+ const timestamp = await backtest.timeMetaService.getTimestamp(symbol, context, false);
46703
+ return Math.floor((timestamp - signal.timestamp) / (1000 * 60));
46704
+ }
46705
+ return null;
46699
46706
  };
46700
46707
  }
46701
46708
  }
@@ -46788,8 +46795,7 @@ async function getMinutesSinceLatestSignalCreated(symbol) {
46788
46795
  throw new Error("getMinutesSinceLatestSignalCreated requires a method context");
46789
46796
  }
46790
46797
  const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
46791
- const { when } = backtest.executionContextService.context;
46792
- return await Recent.getMinutesSinceLatestSignalCreated(when.getTime(), symbol, { exchangeName, frameName, strategyName });
46798
+ return await Recent.getMinutesSinceLatestSignalCreated(symbol, { exchangeName, frameName, strategyName });
46793
46799
  }
46794
46800
 
46795
46801
  const DEFAULT_BM25_K1 = 1.5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -20976,7 +20976,7 @@ declare class RecentAdapter {
20976
20976
  * @returns Whole minutes since the latest signal was created, or null if no signal found
20977
20977
  * @throws Error if RecentAdapter is not enabled
20978
20978
  */
20979
- getMinutesSinceLatestSignalCreated: (timestamp: number, symbol: string, context: {
20979
+ getMinutesSinceLatestSignalCreated: (symbol: string, context: {
20980
20980
  strategyName: StrategyName;
20981
20981
  exchangeName: ExchangeName;
20982
20982
  frameName: FrameName;