Open JamesJohnson3rd opened 4 years ago
Hello, same problem here - I even tried going direct to an order this way:
binance.order("sell", symbol, amountPerLevel, price, { type:'OCO', stopPrice:sl:sl_price, stopLimitPrice:sl_limit_price }, (error, response) => { }
and got 400 Bad Request {"code":-1022,"msg":"Signature for this request is not valid."}
Any help greatly appreciated (as above)!
I couldn't get a successful testnet test of OCO but on the live net worked fine with this:
binance.order('SELL', 'BNBBTC', 1, 0.0029, { type:'OCO' , stopLimitPrice: 0.001, stopPrice: 0.001 }, (error, response) => {})
or this:
binance.sell('BNBBTC', 1, 0.0029, { type:'OCO' , stopLimitPrice: 0.001, stopPrice: 0.001 }, (error, response) => {})
so I'm happy this works. (my previous error was not having 'SELL' in caps I think)
Feature request: OCO for Margin
Esa información está incompleta binance.sell('BNBBTC', 1, 0.0029, { type:'OCO' , stopLimitPrice: 0.001, stopPrice: 0.001 }, (error, response) => {})
Since OCO orders must have; Symbol, qty, profit and stop-limit, stop-limit
anyone know how to use it? thanks
[SOLUCIONADO GRACIAS]
Esa información está incompleta binance.sell('BNBBTC', 1, 0.0029, { type:'OCO' , stopLimitPrice: 0.001, stopPrice: 0.001 }, (error, response) => {})
Since OCO orders must have; Symbol, qty, profit and stop-limit, stop-limit
qty = 1 profit (take profit) = 0.0029 stop-limit = 0.001 stop-price = 0.001
Everything is there :)
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.
There was a fork to add OCO orders to the API.
binance.sell('BNBBTC', Qty, Price, {stopPrice: stop_price, type: 'OCO'}, (error, response) => {}
When trying to sell, I get a Bad Request response with:Signature for this request is not valid.
Any idea where I'm going wrong on this? @gunar