@adaptic/utils 0.0.972 → 0.0.974
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 +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/dist/test.js +6 -1
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3262,11 +3262,16 @@ class AlpacaMarketDataAPI extends require$$0$1.EventEmitter {
|
|
|
3262
3262
|
async getPreviousClose(symbol, referenceDate) {
|
|
3263
3263
|
const date = referenceDate || new Date();
|
|
3264
3264
|
const prevMarketDate = getLastFullTradingDate(date);
|
|
3265
|
+
// Alpaca bars use inclusive-start, exclusive-end (t >= start AND t < end).
|
|
3266
|
+
// When start === end the range is empty and zero bars are returned.
|
|
3267
|
+
// Set end to the next calendar day to capture exactly one daily bar.
|
|
3268
|
+
const endDate = new Date(prevMarketDate.date);
|
|
3269
|
+
endDate.setDate(endDate.getDate() + 1);
|
|
3265
3270
|
const response = await this.getHistoricalBars({
|
|
3266
3271
|
symbols: [symbol],
|
|
3267
3272
|
timeframe: "1Day",
|
|
3268
3273
|
start: prevMarketDate.date.toISOString(),
|
|
3269
|
-
end:
|
|
3274
|
+
end: endDate.toISOString(),
|
|
3270
3275
|
limit: 1,
|
|
3271
3276
|
});
|
|
3272
3277
|
if (!response.bars[symbol] || response.bars[symbol].length === 0) {
|