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