@adaptic/utils 0.0.953 → 0.0.955
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 +12 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +12 -10
- 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,22 +5832,24 @@ async function closePosition$1(auth, symbolOrAssetId, params) {
|
|
|
5832
5832
|
account: auth.adapticAccountId || "direct",
|
|
5833
5833
|
symbol: normalizedSymbol,
|
|
5834
5834
|
});
|
|
5835
|
-
// For crypto
|
|
5836
|
-
//
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
:
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
symbols: orderSymbols,
|
|
5843
|
-
});
|
|
5835
|
+
// For crypto, Alpaca stores orders under "SOL/USD" (slash format) but the
|
|
5836
|
+
// symbols filter may not match across formats reliably. Fetch all open
|
|
5837
|
+
// orders without symbol filter and match client-side via normalization.
|
|
5838
|
+
const openOrders = isCryptoSymbol(symbolOrAssetId)
|
|
5839
|
+
? await getOrders$1(auth, { status: "open" })
|
|
5840
|
+
: await getOrders$1(auth, { status: "open", symbols: [normalizedSymbol] });
|
|
5841
|
+
let cancelledCount = 0;
|
|
5844
5842
|
for (const order of openOrders) {
|
|
5845
|
-
// Normalize both sides for comparison to handle format differences
|
|
5846
5843
|
const orderSymbolNorm = order.symbol.replace(/[-/]/g, "");
|
|
5847
5844
|
if (orderSymbolNorm === normalizedSymbol) {
|
|
5845
|
+
getLogger().info(`Cancelling order ${order.id} (${order.symbol}) for ${normalizedSymbol}`, { account: auth.adapticAccountId || "direct", symbol: normalizedSymbol });
|
|
5848
5846
|
await cancelOrder$1(auth, order.id);
|
|
5847
|
+
cancelledCount++;
|
|
5849
5848
|
}
|
|
5850
5849
|
}
|
|
5850
|
+
if (cancelledCount > 0) {
|
|
5851
|
+
getLogger().info(`Cancelled ${cancelledCount} open orders for ${normalizedSymbol}`, { account: auth.adapticAccountId || "direct", symbol: normalizedSymbol });
|
|
5852
|
+
}
|
|
5851
5853
|
}
|
|
5852
5854
|
// Crypto positions cannot use limit orders with SIP quotes or time_in_force="day".
|
|
5853
5855
|
// Use direct DELETE (market order) for crypto regardless of useLimitOrder flag.
|