@discomedia/utils 1.0.33 → 1.0.34

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/dist/index.cjs CHANGED
@@ -18213,9 +18213,18 @@ class AlpacaTradingAPI {
18213
18213
  // Get the most recent hourly data point
18214
18214
  const mostRecentHourly = recentHourlyData[recentHourlyData.length - 1];
18215
18215
  const mostRecentIndex = mostRecentHourly.index;
18216
- // Calculate the timestamp for the new daily entry (most recent day + 1 day worth of seconds)
18217
- const oneDayInSeconds = 24 * 60 * 60;
18218
- const newDailyTimestamp = mostRecentHourly.timestamp + oneDayInSeconds;
18216
+ // Calculate the timestamp for the new daily entry.
18217
+ // Alpaca's daily history timestamps are at 00:00:00Z for the calendar day
18218
+ // following the NY trading date. Derive the trading date in NY time from the
18219
+ // most recent intraday timestamp, then set the new daily timestamp to
18220
+ // midnight UTC of the next calendar day.
18221
+ const mostRecentMs = mostRecentHourly.timestamp * 1000; // hourly timestamps are seconds
18222
+ const tradingDateStr = getTradingDate(new Date(mostRecentMs)); // e.g., '2025-09-05' (NY trading date)
18223
+ const [yearStr, monthStr, dayStr] = tradingDateStr.split('-');
18224
+ const year = Number(yearStr);
18225
+ const month = Number(monthStr); // 1-based
18226
+ const day = Number(dayStr);
18227
+ const newDailyTimestamp = Math.floor(Date.UTC(year, month - 1, day + 1, 0, 0, 0, 0) / 1000);
18219
18228
  // Create a new daily history entry with the most recent hourly values
18220
18229
  const updatedDailyHistory = {
18221
18230
  ...dailyHistory,