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 +7 -2
- package/build/index.mjs +7 -2
- package/package.json +1 -1
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 <=
|
|
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,
|
|
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 <=
|
|
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,
|
|
4857
|
+
self.params.callbacks.onTimeframe(timeframes, startDate, effectiveEndDate, interval);
|
|
4853
4858
|
}
|
|
4854
4859
|
return timeframes;
|
|
4855
4860
|
};
|