@adaptic/utils 0.0.972 → 0.0.973

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
@@ -3260,11 +3260,16 @@ class AlpacaMarketDataAPI extends EventEmitter {
3260
3260
  async getPreviousClose(symbol, referenceDate) {
3261
3261
  const date = referenceDate || new Date();
3262
3262
  const prevMarketDate = getLastFullTradingDate(date);
3263
+ // Alpaca bars use inclusive-start, exclusive-end (t >= start AND t < end).
3264
+ // When start === end the range is empty and zero bars are returned.
3265
+ // Set end to the next calendar day to capture exactly one daily bar.
3266
+ const endDate = new Date(prevMarketDate.date);
3267
+ endDate.setDate(endDate.getDate() + 1);
3263
3268
  const response = await this.getHistoricalBars({
3264
3269
  symbols: [symbol],
3265
3270
  timeframe: "1Day",
3266
3271
  start: prevMarketDate.date.toISOString(),
3267
- end: prevMarketDate.date.toISOString(),
3272
+ end: endDate.toISOString(),
3268
3273
  limit: 1,
3269
3274
  });
3270
3275
  if (!response.bars[symbol] || response.bars[symbol].length === 0) {