@adaptic/utils 0.0.904 → 0.0.905
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 +14 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +14 -29
- package/dist/index.mjs.map +1 -1
- package/dist/types/adaptic.d.ts +4 -4
- package/dist/types/adaptic.d.ts.map +1 -1
- package/dist/types/alpaca/crypto/data.d.ts.map +1 -1
- package/dist/types/alpaca/crypto/orders.d.ts.map +1 -1
- package/dist/types/alpaca/index.d.ts.map +1 -1
- package/dist/types/alpaca/market-data/bars.d.ts.map +1 -1
- package/dist/types/alpaca/market-data/news.d.ts.map +1 -1
- package/dist/types/alpaca/market-data/quotes.d.ts.map +1 -1
- package/dist/types/alpaca/market-data/trades.d.ts.map +1 -1
- package/dist/types/alpaca/streams/crypto-stream.d.ts.map +1 -1
- package/dist/types/alpaca/streams/option-stream.d.ts.map +1 -1
- package/dist/types/alpaca/streams/stock-stream.d.ts.map +1 -1
- package/dist/types/alpaca/trading/account.d.ts.map +1 -1
- package/dist/types/alpaca/trading/oco-orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/order-utils.d.ts.map +1 -1
- package/dist/types/alpaca/trading/orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/oto-orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/schemas/polygon-schemas.d.ts +6 -6
- package/dist/types/types/alpaca-types.d.ts +18 -1
- package/dist/types/types/alpaca-types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -214,7 +214,7 @@ const isAuthConfigured = () => {
|
|
|
214
214
|
* Returns a shared Apollo client instance with connection pooling.
|
|
215
215
|
* This should be used for all @adaptic/backend-legacy operations.
|
|
216
216
|
*
|
|
217
|
-
* @returns {Promise<
|
|
217
|
+
* @returns {Promise<ApolloClientInstance>} The shared Apollo client instance.
|
|
218
218
|
*/
|
|
219
219
|
const getSharedApolloClient = async () => {
|
|
220
220
|
if (!apolloClientInstance) {
|
|
@@ -53813,7 +53813,6 @@ async function getPortfolioHistory(client, params) {
|
|
|
53813
53813
|
log$i(`Fetching portfolio history with period: ${params.period || "default"}, timeframe: ${params.timeframe || "default"}`);
|
|
53814
53814
|
try {
|
|
53815
53815
|
const sdk = client.getSDK();
|
|
53816
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53817
53816
|
const history = await sdk.getPortfolioHistory(params);
|
|
53818
53817
|
log$i(`Portfolio history fetched successfully with ${history.equity?.length || 0} data points`);
|
|
53819
53818
|
return history;
|
|
@@ -55553,7 +55552,6 @@ async function getOpenTrailingStops(client, symbol) {
|
|
|
55553
55552
|
if (symbol) {
|
|
55554
55553
|
queryParams.symbols = symbol.toUpperCase();
|
|
55555
55554
|
}
|
|
55556
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55557
55555
|
const orders = (await sdk.getOrders(queryParams));
|
|
55558
55556
|
// Filter to only trailing stop orders
|
|
55559
55557
|
const trailingStops = orders.filter((order) => order.type === "trailing_stop");
|
|
@@ -55791,12 +55789,11 @@ async function createOCOOrder(client, params) {
|
|
|
55791
55789
|
limit_price: roundPriceForAlpaca$2(takeProfit.limitPrice).toString(),
|
|
55792
55790
|
stop_loss: {
|
|
55793
55791
|
stop_price: roundPriceForAlpaca$2(stopLoss.stopPrice).toString(),
|
|
55792
|
+
...(stopLoss.limitPrice !== undefined
|
|
55793
|
+
? { limit_price: roundPriceForAlpaca$2(stopLoss.limitPrice).toString() }
|
|
55794
|
+
: {}),
|
|
55794
55795
|
},
|
|
55795
55796
|
};
|
|
55796
|
-
// Add stop-limit price if provided
|
|
55797
|
-
if (stopLoss.limitPrice !== undefined) {
|
|
55798
|
-
orderRequest.stop_loss.limit_price = roundPriceForAlpaca$2(stopLoss.limitPrice).toString();
|
|
55799
|
-
}
|
|
55800
55797
|
log$f(`Submitting OCO order request: ${JSON.stringify(orderRequest)}`, {
|
|
55801
55798
|
symbol,
|
|
55802
55799
|
type: "debug",
|
|
@@ -56211,14 +56208,14 @@ async function createOTOOrder(client, params) {
|
|
|
56211
56208
|
}
|
|
56212
56209
|
else if (dependent.type === "trailing_stop") {
|
|
56213
56210
|
// Trailing stop order
|
|
56214
|
-
|
|
56211
|
+
const trailingStop = {};
|
|
56215
56212
|
if (dependent.trailPercent !== undefined) {
|
|
56216
|
-
|
|
56217
|
-
dependent.trailPercent.toString();
|
|
56213
|
+
trailingStop.trail_percent = dependent.trailPercent.toString();
|
|
56218
56214
|
}
|
|
56219
56215
|
if (dependent.trailPrice !== undefined) {
|
|
56220
|
-
|
|
56216
|
+
trailingStop.trail_price = roundPriceForAlpaca$1(dependent.trailPrice).toString();
|
|
56221
56217
|
}
|
|
56218
|
+
orderRequest.stop_loss = trailingStop;
|
|
56222
56219
|
}
|
|
56223
56220
|
log$e(`Submitting OTO order request: ${JSON.stringify(orderRequest)}`, {
|
|
56224
56221
|
symbol,
|
|
@@ -56639,7 +56636,6 @@ async function getLatestQuote(client, symbol, feed) {
|
|
|
56639
56636
|
const config = client.getConfig();
|
|
56640
56637
|
const dataFeed = feed || config.dataFeed || "iex";
|
|
56641
56638
|
// Use SDK's getLatestQuote method
|
|
56642
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56643
56639
|
const response = await sdk.getLatestQuote(normalizedSymbol, {
|
|
56644
56640
|
feed: dataFeed,
|
|
56645
56641
|
});
|
|
@@ -56697,7 +56693,6 @@ async function getLatestQuotes(client, symbols, feed) {
|
|
|
56697
56693
|
const config = client.getConfig();
|
|
56698
56694
|
const dataFeed = feed || config.dataFeed || "iex";
|
|
56699
56695
|
// Use SDK's getLatestQuotes method
|
|
56700
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56701
56696
|
const response = await sdk.getLatestQuotes(normalizedSymbols, {
|
|
56702
56697
|
feed: dataFeed,
|
|
56703
56698
|
});
|
|
@@ -56953,7 +56948,6 @@ async function getLatestBars(client, symbols) {
|
|
|
56953
56948
|
const sdk = client.getSDK();
|
|
56954
56949
|
const config = client.getConfig();
|
|
56955
56950
|
const dataFeed = config.dataFeed || "iex";
|
|
56956
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56957
56951
|
const response = await sdk.getLatestBars(normalizedSymbols, {
|
|
56958
56952
|
feed: dataFeed,
|
|
56959
56953
|
});
|
|
@@ -57244,7 +57238,6 @@ async function getLatestTrade(client, symbol, feed) {
|
|
|
57244
57238
|
const config = client.getConfig();
|
|
57245
57239
|
const dataFeed = feed || config.dataFeed || "iex";
|
|
57246
57240
|
// Use SDK's getLatestTrade method
|
|
57247
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57248
57241
|
const response = await sdk.getLatestTrade(normalizedSymbol, {
|
|
57249
57242
|
feed: dataFeed,
|
|
57250
57243
|
});
|
|
@@ -57300,7 +57293,6 @@ async function getLatestTrades(client, symbols, feed) {
|
|
|
57300
57293
|
const config = client.getConfig();
|
|
57301
57294
|
const dataFeed = feed || config.dataFeed || "iex";
|
|
57302
57295
|
// Use SDK's getLatestTrades method
|
|
57303
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57304
57296
|
const response = await sdk.getLatestTrades(normalizedSymbols, {
|
|
57305
57297
|
feed: dataFeed,
|
|
57306
57298
|
});
|
|
@@ -57415,7 +57407,6 @@ async function getCurrentPrice(client, symbol, feed) {
|
|
|
57415
57407
|
const dataFeed = feed || config.dataFeed || "iex";
|
|
57416
57408
|
// Try to get quote first for mid-point price
|
|
57417
57409
|
try {
|
|
57418
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57419
57410
|
const quote = await sdk.getLatestQuote(normalizedSymbol, {
|
|
57420
57411
|
feed: dataFeed,
|
|
57421
57412
|
});
|
|
@@ -57850,7 +57841,6 @@ async function getNews(client, params = {}) {
|
|
|
57850
57841
|
// The SDK returns a slightly different structure, so we map the fields
|
|
57851
57842
|
const articles = response.map((article) => {
|
|
57852
57843
|
// SDK returns properties in different format
|
|
57853
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57854
57844
|
const sdkArticle = article;
|
|
57855
57845
|
// Normalize to our expected format
|
|
57856
57846
|
const normalizedArticle = {
|
|
@@ -61516,7 +61506,6 @@ async function getOpenCryptoOrders(client, symbols) {
|
|
|
61516
61506
|
? symbols.map(normalizeCryptoSymbol$1).join(",")
|
|
61517
61507
|
: undefined,
|
|
61518
61508
|
};
|
|
61519
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61520
61509
|
const orders = (await sdk.getOrders(queryParams));
|
|
61521
61510
|
// Filter to only crypto orders (asset_class === 'crypto')
|
|
61522
61511
|
const cryptoOrders = orders.filter((order) => order.asset_class === "crypto");
|
|
@@ -61718,9 +61707,7 @@ async function getCryptoBars(client, params) {
|
|
|
61718
61707
|
result.set(symbol, []);
|
|
61719
61708
|
}
|
|
61720
61709
|
// Use SDK's getCryptoBars method
|
|
61721
|
-
// The SDK may return an async iterator or a Promise depending on the version
|
|
61722
|
-
// cast to any so TypeScript does not constrain the runtime duck-typing below.
|
|
61723
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61710
|
+
// The SDK may return an async iterator or a Promise depending on the version
|
|
61724
61711
|
const barsResponse = sdk.getCryptoBars(normalizedSymbols, options);
|
|
61725
61712
|
// Handle both async iterator and direct response formats
|
|
61726
61713
|
if (barsResponse &&
|
|
@@ -61741,8 +61728,8 @@ async function getCryptoBars(client, params) {
|
|
|
61741
61728
|
result.set(symbol, existingBars);
|
|
61742
61729
|
}
|
|
61743
61730
|
}
|
|
61744
|
-
else if (barsResponse && barsResponse
|
|
61745
|
-
// Handle Promise response
|
|
61731
|
+
else if (barsResponse && "then" in barsResponse) {
|
|
61732
|
+
// Handle Promise response (SDK returns thenable in some versions)
|
|
61746
61733
|
const response = await barsResponse;
|
|
61747
61734
|
if (response && response.bars) {
|
|
61748
61735
|
for (const [symbol, bars] of Object.entries(response.bars)) {
|
|
@@ -62056,9 +62043,7 @@ async function getCryptoTrades(client, symbol, start, end, limit) {
|
|
|
62056
62043
|
options.limit = limit;
|
|
62057
62044
|
}
|
|
62058
62045
|
const trades = [];
|
|
62059
|
-
// The SDK may return an async iterator or a Promise depending on the version
|
|
62060
|
-
// cast to any so TypeScript does not constrain the runtime duck-typing below.
|
|
62061
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62046
|
+
// The SDK may return an async iterator or a Promise depending on the version
|
|
62062
62047
|
const tradesResponse = sdk.getCryptoTrades(normalizedSymbol, options);
|
|
62063
62048
|
// Handle both async iterator and direct response formats
|
|
62064
62049
|
if (tradesResponse &&
|
|
@@ -62077,8 +62062,8 @@ async function getCryptoTrades(client, symbol, start, end, limit) {
|
|
|
62077
62062
|
}
|
|
62078
62063
|
}
|
|
62079
62064
|
}
|
|
62080
|
-
else if (tradesResponse && tradesResponse
|
|
62081
|
-
// Handle Promise response
|
|
62065
|
+
else if (tradesResponse && "then" in tradesResponse) {
|
|
62066
|
+
// Handle Promise response (SDK returns thenable in some versions)
|
|
62082
62067
|
const response = await tradesResponse;
|
|
62083
62068
|
if (response && response.trades) {
|
|
62084
62069
|
const tradeArray = response.trades;
|