@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-frontend.cjs +27 -3
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +27 -3
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +12 -3
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/dist/test.js +5527 -760
- package/dist/test.js.map +1 -1
- package/dist/types/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types/types/alpaca-types.d.ts +10 -1
- package/dist/types/types/alpaca-types.d.ts.map +1 -1
- package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types-frontend/types/alpaca-types.d.ts +10 -1
- package/dist/types-frontend/types/alpaca-types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/alpaca-crypto-pairs-DMOvRyzw.js +0 -571
- package/dist/alpaca-crypto-pairs-DMOvRyzw.js.map +0 -1
package/dist/index-frontend.cjs
CHANGED
|
@@ -13864,6 +13864,21 @@ function getLastFullTradingDateImpl(currentDate = new Date()) {
|
|
|
13864
13864
|
function getLastFullTradingDate(currentDate = new Date()) {
|
|
13865
13865
|
return getLastFullTradingDateImpl(currentDate);
|
|
13866
13866
|
}
|
|
13867
|
+
/**
|
|
13868
|
+
* Returns the trading date for a given time. Note: Just trims the date string; does not validate if the date is a market day.
|
|
13869
|
+
* @param time - a string, number (unix timestamp), or Date object representing the time
|
|
13870
|
+
* @returns the trading date as a string in YYYY-MM-DD format
|
|
13871
|
+
*/
|
|
13872
|
+
/**
|
|
13873
|
+
* Returns the trading date for a given time in YYYY-MM-DD format (NY time).
|
|
13874
|
+
* @param time - string, number, or Date
|
|
13875
|
+
* @returns trading date string
|
|
13876
|
+
*/
|
|
13877
|
+
function getTradingDate(time) {
|
|
13878
|
+
const date = typeof time === 'number' ? new Date(time) : typeof time === 'string' ? new Date(time) : time;
|
|
13879
|
+
const nyDate = toNYTime(date);
|
|
13880
|
+
return `${nyDate.getUTCFullYear()}-${String(nyDate.getUTCMonth() + 1).padStart(2, '0')}-${String(nyDate.getUTCDate()).padStart(2, '0')}`;
|
|
13881
|
+
}
|
|
13867
13882
|
|
|
13868
13883
|
const log = (message, options = { type: 'info' }) => {
|
|
13869
13884
|
log$1(message, { ...options, source: 'AlpacaMarketDataAPI' });
|
|
@@ -15780,9 +15795,18 @@ class AlpacaTradingAPI {
|
|
|
15780
15795
|
// Get the most recent hourly data point
|
|
15781
15796
|
const mostRecentHourly = recentHourlyData[recentHourlyData.length - 1];
|
|
15782
15797
|
const mostRecentIndex = mostRecentHourly.index;
|
|
15783
|
-
// Calculate the timestamp for the new daily entry
|
|
15784
|
-
|
|
15785
|
-
|
|
15798
|
+
// Calculate the timestamp for the new daily entry.
|
|
15799
|
+
// Alpaca's daily history timestamps are at 00:00:00Z for the calendar day
|
|
15800
|
+
// following the NY trading date. Derive the trading date in NY time from the
|
|
15801
|
+
// most recent intraday timestamp, then set the new daily timestamp to
|
|
15802
|
+
// midnight UTC of the next calendar day.
|
|
15803
|
+
const mostRecentMs = mostRecentHourly.timestamp * 1000; // hourly timestamps are seconds
|
|
15804
|
+
const tradingDateStr = getTradingDate(new Date(mostRecentMs)); // e.g., '2025-09-05' (NY trading date)
|
|
15805
|
+
const [yearStr, monthStr, dayStr] = tradingDateStr.split('-');
|
|
15806
|
+
const year = Number(yearStr);
|
|
15807
|
+
const month = Number(monthStr); // 1-based
|
|
15808
|
+
const day = Number(dayStr);
|
|
15809
|
+
const newDailyTimestamp = Math.floor(Date.UTC(year, month - 1, day + 1, 0, 0, 0, 0) / 1000);
|
|
15786
15810
|
// Create a new daily history entry with the most recent hourly values
|
|
15787
15811
|
const updatedDailyHistory = {
|
|
15788
15812
|
...dailyHistory,
|