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