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