@adaptic/utils 0.0.906 → 0.0.908
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 +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rate-limiter.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1317,7 +1317,7 @@ async function fetchWithRetry(url, options = {}, retries = 3, initialBackoff = 1
|
|
|
1317
1317
|
*/
|
|
1318
1318
|
async function validatePolygonApiKey(apiKey) {
|
|
1319
1319
|
try {
|
|
1320
|
-
const response = await fetch(`https://api.
|
|
1320
|
+
const response = await fetch(`https://api.massive.com/v1/meta/symbols?apikey=${apiKey}&limit=1`);
|
|
1321
1321
|
if (response.status === 401) {
|
|
1322
1322
|
throw new Error("Invalid or expired Polygon.io API key");
|
|
1323
1323
|
}
|
|
@@ -1404,7 +1404,7 @@ async function fetchNews$1(symbols, params) {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
else {
|
|
1406
1406
|
APIKey = process.env.ALPACA_API_KEY;
|
|
1407
|
-
APISecret = process.env.ALPACA_SECRET_KEY;
|
|
1407
|
+
APISecret = process.env.ALPACA_API_SECRET || process.env.ALPACA_SECRET_KEY;
|
|
1408
1408
|
}
|
|
1409
1409
|
if (!APIKey || !APISecret) {
|
|
1410
1410
|
throw new Error("No valid Alpaca authentication found. Please provide either auth object or set ALPACA_API_KEY and ALPACA_API_SECRET environment variables.");
|
|
@@ -1594,7 +1594,7 @@ async function closePosition$1(auth, symbolOrAssetId, params) {
|
|
|
1594
1594
|
const alpacaAuth = {
|
|
1595
1595
|
type: "LIVE",
|
|
1596
1596
|
alpacaApiKey: process.env.ALPACA_API_KEY,
|
|
1597
|
-
alpacaApiSecret: process.env.ALPACA_SECRET_KEY,
|
|
1597
|
+
alpacaApiSecret: process.env.ALPACA_API_SECRET || process.env.ALPACA_SECRET_KEY,
|
|
1598
1598
|
};
|
|
1599
1599
|
const quotesResponse = await getLatestQuotes$1(alpacaAuth, {
|
|
1600
1600
|
symbols: [symbolOrAssetId],
|
|
@@ -1687,7 +1687,7 @@ async function closeAllPositions$1(auth, params = { cancel_orders: true, useLimi
|
|
|
1687
1687
|
const alpacaAuth = {
|
|
1688
1688
|
type: "LIVE",
|
|
1689
1689
|
alpacaApiKey: process.env.ALPACA_API_KEY,
|
|
1690
|
-
alpacaApiSecret: process.env.ALPACA_SECRET_KEY,
|
|
1690
|
+
alpacaApiSecret: process.env.ALPACA_API_SECRET || process.env.ALPACA_SECRET_KEY,
|
|
1691
1691
|
};
|
|
1692
1692
|
const symbols = positions.map((position) => position.symbol);
|
|
1693
1693
|
const quotesResponse = await getLatestQuotes$1(alpacaAuth, { symbols });
|
|
@@ -5189,7 +5189,7 @@ const fetchTickerInfo = async (symbol, options) => {
|
|
|
5189
5189
|
}
|
|
5190
5190
|
const apiKey = options?.apiKey || POLYGON_API_KEY;
|
|
5191
5191
|
validatePolygonApiKey$1(apiKey);
|
|
5192
|
-
const baseUrl = `https://api.
|
|
5192
|
+
const baseUrl = `https://api.massive.com/v3/reference/tickers/${encodeURIComponent(symbol)}`;
|
|
5193
5193
|
const params = new URLSearchParams({
|
|
5194
5194
|
apiKey,
|
|
5195
5195
|
});
|
|
@@ -5276,7 +5276,7 @@ const fetchLastTrade = async (symbol, options) => {
|
|
|
5276
5276
|
}
|
|
5277
5277
|
const apiKey = options?.apiKey || POLYGON_API_KEY;
|
|
5278
5278
|
validatePolygonApiKey$1(apiKey);
|
|
5279
|
-
const baseUrl = `https://api.
|
|
5279
|
+
const baseUrl = `https://api.massive.com/v2/last/trade/${encodeURIComponent(symbol)}`;
|
|
5280
5280
|
const params = new URLSearchParams({
|
|
5281
5281
|
apiKey,
|
|
5282
5282
|
});
|
|
@@ -5341,7 +5341,7 @@ const fetchPrices = async (params, options) => {
|
|
|
5341
5341
|
const apiKey = options?.apiKey || POLYGON_API_KEY;
|
|
5342
5342
|
validatePolygonApiKey$1(apiKey);
|
|
5343
5343
|
const { ticker, start, end = Date.now().valueOf(), multiplier, timespan, limit = 1000, } = params;
|
|
5344
|
-
const baseUrl = `https://api.
|
|
5344
|
+
const baseUrl = `https://api.massive.com/v2/aggs/ticker/${encodeURIComponent(ticker)}/range/${multiplier}/${timespan}/${start}/${end}`;
|
|
5345
5345
|
const urlParams = new URLSearchParams({
|
|
5346
5346
|
apiKey,
|
|
5347
5347
|
adjusted: "true",
|
|
@@ -5463,7 +5463,7 @@ const fetchGroupedDaily = async (date, options) => {
|
|
|
5463
5463
|
if (!options?.apiKey && !POLYGON_API_KEY) {
|
|
5464
5464
|
throw new Error("Polygon API key is missing");
|
|
5465
5465
|
}
|
|
5466
|
-
const baseUrl = `https://api.
|
|
5466
|
+
const baseUrl = `https://api.massive.com/v2/aggs/grouped/locale/us/market/stocks/${date}`;
|
|
5467
5467
|
const params = new URLSearchParams({
|
|
5468
5468
|
apiKey: options?.apiKey || POLYGON_API_KEY,
|
|
5469
5469
|
adjusted: options?.adjusted !== false ? "true" : "false",
|
|
@@ -5556,7 +5556,7 @@ symbol, date = new Date(), options) => {
|
|
|
5556
5556
|
throw new Error("Polygon API key is missing");
|
|
5557
5557
|
}
|
|
5558
5558
|
const formattedDate = date.toISOString().split("T")[0]; // Format as YYYY-MM-DD
|
|
5559
|
-
const baseUrl = `https://api.
|
|
5559
|
+
const baseUrl = `https://api.massive.com/v1/open-close/${encodeURIComponent(symbol)}/${formattedDate}`;
|
|
5560
5560
|
const params = new URLSearchParams({
|
|
5561
5561
|
apiKey: options?.apiKey || POLYGON_API_KEY,
|
|
5562
5562
|
adjusted: (options?.adjusted ?? true).toString(),
|
|
@@ -5606,7 +5606,7 @@ const fetchTrades = async (symbol, options) => {
|
|
|
5606
5606
|
if (!options?.apiKey && !POLYGON_API_KEY) {
|
|
5607
5607
|
throw new Error("Polygon API key is missing");
|
|
5608
5608
|
}
|
|
5609
|
-
const baseUrl = `https://api.
|
|
5609
|
+
const baseUrl = `https://api.massive.com/v3/trades/${encodeURIComponent(symbol)}`;
|
|
5610
5610
|
const params = new URLSearchParams({
|
|
5611
5611
|
apiKey: options?.apiKey || POLYGON_API_KEY,
|
|
5612
5612
|
});
|
|
@@ -5672,7 +5672,7 @@ const { ALPACA_INDICES_API_KEY } = process.env;
|
|
|
5672
5672
|
const POLYGON_INDICES_CONCURRENCY_LIMIT = 5;
|
|
5673
5673
|
const polygonIndicesLimit = pLimit(POLYGON_INDICES_CONCURRENCY_LIMIT);
|
|
5674
5674
|
// Base URL for Polygon API
|
|
5675
|
-
const POLYGON_API_BASE_URL = "https://api.
|
|
5675
|
+
const POLYGON_API_BASE_URL = "https://api.massive.com";
|
|
5676
5676
|
/**
|
|
5677
5677
|
* Validates that an API key is available
|
|
5678
5678
|
* @param {string | undefined} apiKey - Optional API key to use
|
|
@@ -15236,7 +15236,7 @@ const rateLimiters = {
|
|
|
15236
15236
|
*
|
|
15237
15237
|
* Configured for 5 requests per second (basic plan).
|
|
15238
15238
|
* Adjust if you have a different subscription tier.
|
|
15239
|
-
* See: https://
|
|
15239
|
+
* See: https://massive.com/pricing
|
|
15240
15240
|
*/
|
|
15241
15241
|
polygon: new TokenBucketRateLimiter({
|
|
15242
15242
|
maxTokens: 5,
|
|
@@ -53469,7 +53469,7 @@ function createAlpacaClient(config) {
|
|
|
53469
53469
|
*/
|
|
53470
53470
|
function createClientFromEnv() {
|
|
53471
53471
|
const apiKey = process.env.ALPACA_API_KEY;
|
|
53472
|
-
const apiSecret = process.env.ALPACA_SECRET_KEY;
|
|
53472
|
+
const apiSecret = process.env.ALPACA_API_SECRET || process.env.ALPACA_SECRET_KEY;
|
|
53473
53473
|
const accountType = process.env.ALPACA_ACCOUNT_TYPE || "PAPER";
|
|
53474
53474
|
if (!apiKey || !apiSecret) {
|
|
53475
53475
|
throw new Error("ALPACA_API_KEY and ALPACA_SECRET_KEY environment variables are required");
|