默认情况下,Binance 不会平仓TAKE_PROFIT_MARKET或STOP_MARKET. 平仓后,您需要手动关闭这些订单,您可以拉出当前打开的订单 并根据positionSide( SELL/ LONG/ BOTH) 和origType( TAKE_PROFIT_MARKET/ STOP_MARKET) 过滤它们,您可以获得orderIdfor这些订单并批量取消或一一取消
const position = 'LONG' // LONG, SHORT, BOTH axios .get('https://fapi.binance.com/fapi/v1/openOrders', { params: { symbol: 'BTCUSDT' } }) .then(({ data }) => { const orderIds = data .filter( ({ positionSide, origType }) => positionSide === position && ['TAKE_PROFIT_MARKET', 'STOP_MARKET'].includes(origType) ) .map(({ orderId }) => orderId) // Use batch cancel or cancel order one by one console.log('orderIds', orderIds) })