Open berkinalex opened 4 years ago
Not sure, I know this library supports OCO except for margin since binance hasn't added it yet, but the documentation is ugly. Generally you just have to pass a flag to the order function
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#new-oco-trade
https://github.com/jaggedsoft/node-binance-api/blob/master/node-binance-api.js#L242
Send {type: 'OCO'}
as flags to any of the order functions
Thank you for your prompt response, but the following question arises.
Since OCO orders must have; Symbol, qty, profit and stop-limit, stop-limit
@berkinalex Have you solved the OCO with margin? I tried to place 2 orders with LIMIT_MAKER and STOP_LOSS_LIMIT but it cannot cancel the other.
@lamdoann I am having the same issue. How have you been able to place 2 orders with LIMIT_MAKER and STOP_LOSS_LIMIT ? Even it one doesn't cancel the other, it would still be better than nothing for me. Thank you very much
@berkinalex Have you solved the OCO with margin? I tried to place 2 orders with LIMIT_MAKER and STOP_LOSS_LIMIT but it cannot cancel the other.
Hello, I use: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#new-oco-trade
@berkinalex Hi, I am having the same issue. Are you actually using the OCO order with margin trading ? If so, are you using the endpoint /POST /api/v3/order/oco
as shown in the docs, as it seems to be an endpoint only for spot trading ?
Could you please post us a code exemple of how you do these OCO margin orders and the endpoint used if different ? I can do them for spot trading but can't make it work for margin trading. Thank you very much
Sorry, in margin I have not used the oco commands. Even so I have changed all the orders to limit in my bot, the bot is constantly checking the price of my assets through websockets, and when it sees the closing price that corresponds to the purchase or sale it is launched, so the oco orders have become obsolete in my project.
Regards
I was struggling with this for a while and pieced the following together in my node appplication: (Assume BTCGBP, current price = 40,000, sell at 41,000 or 39,000)
const Binance = require('node-binance-api');
const binance = new Binance().options({
APIKEY: API_KEY,
APISECRET: API_SECRET_KEY,
useServerTime: true,
});
async function sell_oco () {
const order_oco = util.promisify (binance.order);
const order = await order_oco(
side= 'SELL',
symbol= 'BTCGBP',
quantity= '1.0000',
price= '41000`,
flags= {
type: 'OCO',
stopPrice: '39100',
stopLimitPrice: '39000',
// stopLimitTimeInForce: 'GTC', // I couldn't see this being set as an option, but is set in node-binance-api.js on line 385: opt.stopLimitTimeInForce = 'GTC';
}
);
return order;
}
Hope it helps someone. It would be very helpful if the otherwise excellent main page documentation included how to place OCO order, as it can be done.
No oco orders?
There is no information on its use on the main page, does anyone know how to use it?
Thanks