@adaptic/utils 0.0.952 → 0.0.954
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 +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +11 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/alpaca/legacy/positions.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5834,12 +5834,21 @@ async function closePosition$1(auth, symbolOrAssetId, params) {
|
|
|
5834
5834
|
account: auth.adapticAccountId || "direct",
|
|
5835
5835
|
symbol: normalizedSymbol,
|
|
5836
5836
|
});
|
|
5837
|
+
// Alpaca stores crypto orders under "SOL/USD" (slash format) but we may
|
|
5838
|
+
// receive "SOL-USD" (hyphen) or "SOLUSD" (concatenated). Query all three
|
|
5839
|
+
// formats so getOrders returns matching open orders for cancellation.
|
|
5840
|
+
const slashSymbol = normalizedSymbol.replace(/^([A-Z]+)(USD[TC]?)$/i, "$1/$2");
|
|
5841
|
+
const orderSymbols = isCryptoSymbol(symbolOrAssetId)
|
|
5842
|
+
? [...new Set([normalizedSymbol, symbolOrAssetId, slashSymbol])]
|
|
5843
|
+
: [normalizedSymbol];
|
|
5837
5844
|
const openOrders = await getOrders$1(auth, {
|
|
5838
5845
|
status: "open",
|
|
5839
|
-
symbols:
|
|
5846
|
+
symbols: orderSymbols,
|
|
5840
5847
|
});
|
|
5841
5848
|
for (const order of openOrders) {
|
|
5842
|
-
|
|
5849
|
+
// Normalize both sides for comparison to handle format differences
|
|
5850
|
+
const orderSymbolNorm = order.symbol.replace(/[-/]/g, "");
|
|
5851
|
+
if (orderSymbolNorm === normalizedSymbol) {
|
|
5843
5852
|
await cancelOrder$1(auth, order.id);
|
|
5844
5853
|
}
|
|
5845
5854
|
}
|