@adaptic/utils 0.0.952 → 0.0.953
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
|
@@ -5832,12 +5832,19 @@ async function closePosition$1(auth, symbolOrAssetId, params) {
|
|
|
5832
5832
|
account: auth.adapticAccountId || "direct",
|
|
5833
5833
|
symbol: normalizedSymbol,
|
|
5834
5834
|
});
|
|
5835
|
+
// For crypto symbols, query orders using both the normalized and original
|
|
5836
|
+
// formats since Alpaca may store orders under "SOL/USD" while we normalized to "SOLUSD"
|
|
5837
|
+
const orderSymbols = isCryptoSymbol(symbolOrAssetId)
|
|
5838
|
+
? [normalizedSymbol, symbolOrAssetId]
|
|
5839
|
+
: [normalizedSymbol];
|
|
5835
5840
|
const openOrders = await getOrders$1(auth, {
|
|
5836
5841
|
status: "open",
|
|
5837
|
-
symbols:
|
|
5842
|
+
symbols: orderSymbols,
|
|
5838
5843
|
});
|
|
5839
5844
|
for (const order of openOrders) {
|
|
5840
|
-
|
|
5845
|
+
// Normalize both sides for comparison to handle format differences
|
|
5846
|
+
const orderSymbolNorm = order.symbol.replace(/[-/]/g, "");
|
|
5847
|
+
if (orderSymbolNorm === normalizedSymbol) {
|
|
5841
5848
|
await cancelOrder$1(auth, order.id);
|
|
5842
5849
|
}
|
|
5843
5850
|
}
|