backtest-kit 1.5.32 → 1.5.33

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 CHANGED
@@ -4844,14 +4844,19 @@ const GET_TIMEFRAME_FN = async (symbol, self) => {
4844
4844
  if (!intervalMinutes) {
4845
4845
  throw new Error(`ClientFrame unknown interval: ${interval}`);
4846
4846
  }
4847
+ // Get current date at the start of today (00:00:00) for comparison
4848
+ const today = new Date();
4849
+ today.setUTCHours(0, 0, 0, 0);
4850
+ // Ensure endDate doesn't go beyond today
4851
+ const effectiveEndDate = endDate > today ? today : endDate;
4847
4852
  const timeframes = [];
4848
4853
  let currentDate = new Date(startDate);
4849
- while (currentDate <= endDate) {
4854
+ while (currentDate <= effectiveEndDate) {
4850
4855
  timeframes.push(new Date(currentDate));
4851
4856
  currentDate = new Date(currentDate.getTime() + intervalMinutes * 60 * 1000);
4852
4857
  }
4853
4858
  if (self.params.callbacks?.onTimeframe) {
4854
- self.params.callbacks.onTimeframe(timeframes, startDate, endDate, interval);
4859
+ self.params.callbacks.onTimeframe(timeframes, startDate, effectiveEndDate, interval);
4855
4860
  }
4856
4861
  return timeframes;
4857
4862
  };
package/build/index.mjs CHANGED
@@ -4842,14 +4842,19 @@ const GET_TIMEFRAME_FN = async (symbol, self) => {
4842
4842
  if (!intervalMinutes) {
4843
4843
  throw new Error(`ClientFrame unknown interval: ${interval}`);
4844
4844
  }
4845
+ // Get current date at the start of today (00:00:00) for comparison
4846
+ const today = new Date();
4847
+ today.setUTCHours(0, 0, 0, 0);
4848
+ // Ensure endDate doesn't go beyond today
4849
+ const effectiveEndDate = endDate > today ? today : endDate;
4845
4850
  const timeframes = [];
4846
4851
  let currentDate = new Date(startDate);
4847
- while (currentDate <= endDate) {
4852
+ while (currentDate <= effectiveEndDate) {
4848
4853
  timeframes.push(new Date(currentDate));
4849
4854
  currentDate = new Date(currentDate.getTime() + intervalMinutes * 60 * 1000);
4850
4855
  }
4851
4856
  if (self.params.callbacks?.onTimeframe) {
4852
- self.params.callbacks.onTimeframe(timeframes, startDate, endDate, interval);
4857
+ self.params.callbacks.onTimeframe(timeframes, startDate, effectiveEndDate, interval);
4853
4858
  }
4854
4859
  return timeframes;
4855
4860
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "1.5.32",
3
+ "version": "1.5.33",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",