-
Notifications
You must be signed in to change notification settings - Fork 417
Conditional/stop orders invisible to getOrders — broker state blind spot #90
Copy link
Copy link
Open
Description
Summary
When using Binance Futures, conditional orders (stop-loss, take-profit) placed via the platform are not returned by getOrders (which maps to ccxt's fetchOpenOrders). This creates a critical blind spot where the system believes no stop-loss is in place when one actually exists.
Impact (observed in Demo)
- False "naked position" alerts — Alice repeatedly warned about zero stop-loss protection (15+ times) when stops were actually active on Binance, causing unnecessary panic
- Duplicate order placement — Since verification logic can't see existing conditional orders, it re-submits stops, resulting in 3x duplicate stop-losses and 3x duplicate limit orders that had to be manually cleaned up
- Phantom order tracking — Brain state records orders it thinks it placed, but can't verify against broker reality, leading to hallucinated order IDs (e.g.
cab7db76)
Root Cause
Binance separates:
- Regular orders →
GET /fapi/v1/openOrders(what ccxt'sfetchOpenOrdershits) - Conditional orders (stop-market, take-profit-market) →
GET /fapi/v1/openOrderswithtype=STOP_MARKETor viaGET /fapi/v1/conditionalOrders
The current CcxtBroker implementation only calls the standard path and misses conditional/stop orders entirely.
Suggested Fix
In CcxtBroker.ts, the order query methods should:
- Fetch both regular and conditional orders (ccxt's
fetchOpenOrderswithparams: { type: 'STOP_MARKET' }or equivalent) - Merge results before returning to the caller
- Consider a unified
getAllActiveOrders()method that covers all order types
Environment
- OpenAlice v0.9.0-beta.7 → beta.8
- Broker: Binance Futures (USDT-M) via ccxt
- Demo trading on ETHUSDT
Related
This blind spot also contributes to the duplicate order problem — without visibility into existing conditional orders, there's no way to implement idempotency checks before placing new ones.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels