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