Closed AlphaCentauriNinja closed 2 years ago
I've admittedly not used this mechanism as I just use limit reduce orders for TPs. Did you figure this out? Sounds like a useful example to add. If you're still stuck you could try asking how the request should look in the binance API telegram: https://t.me/binance_api_english
Hi TiagoSiebler,
I managed the following:
/api/v3/order?symbol=VETUSDT&side=BUY&type=STOP_LOSS_LIMIT&timeInForce=GTC&quantity=825&price=0.1131&stopPrice=0.1120&newOrderRespType=RESULT×tamp=1633422601488&signature=83d725fb12ac4e1c37778e45013c766951f58c95e40a99866f0523aeb01df1fe&recvWindow=60000
However I get the following error back : data: { code: -1022, msg: 'Signature for this request is not valid.' }
I manage to create the signature the following way:
serverTime = await binance.futuresTime();
let query_string = `timestamp=${serverTime}`
let secretKey = crypto.signature(query_string);
------------ FUNCTION IMPORT --------------------- const apiSecret = process.env.EXCHANGE_SECRET_KEY
function signature(query_string) { return crypto .createHmac('sha256', apiSecret) .update(query_string) .digest('hex'); }
Do you have an idea what I am doing wrong?
Regards, Ninja
Difficult to say with a fresh implementation. Why not use the library for this? If it's just api/v3/order
for spot markets, then this should be the method:
const binanceApi = new MainClient({
...,
recvWindow: 60000,
})
try {
const result = await binanceApi.submitNewOrder({
symbol: 'VETUSDT',
side: 'BUY',
type: 'STOP_LOSS_LIMIT',
timeInForce: 'GTC',
quantity: 825,
price: 0.1131,
stopPrice: 0.1120,
newOrderRespType: 'RESULT',
});
} catch (e) {
// log/handle error
}
Thanks, I will try that :D
Is this resolved?
Can USDMClient use STOP_LOSS_LIMIT config ? if new orrder request activated with stop_price & profit_price ?
STOP_LOSS_LIMIT
@ChenYCL the futures docs does not mention STOP_LOSS_LIMIT as a type for new orders, so maybe not. You can try asking in the binance api support channel on telegram: https://t.me/binance_api_english
STOP_LOSS_LIMIT
@ChenYCL the futures docs does not mention STOP_LOSS_LIMIT as a type for new orders, so maybe not. You can try asking in the binance api support channel on telegram: https://t.me/binance_api_english
Thank you. Is there a way to add take profit & stop loss in orders? eg. new order use market type and get orderId reponse.
Perhaps using batch orders (treating them as separate orders): https://binance-docs.github.io/apidocs/futures/en/#place-multiple-orders-trade
In my case I manually maintain/cancel/replace a TP limit order anytime I see a position update from the user data websocket.
For API/workflow questions not specific to only this connector though I really recommend asking in the api telegram community I've linked to above. You're more likely to get that kind of guidance there. Once you know which parameters to use with which endpoint, you can make those API calls using this connector.
Perhaps using batch orders (treating them as separate orders): https://binance-docs.github.io/apidocs/futures/en/#place-multiple-orders-trade
In my case I manually maintain/cancel/replace a TP limit order anytime I see a position update from the user data websocket.
For API/workflow questions not specific to only this connector though I really recommend asking in the api telegram community I've linked to above. You're more likely to get that kind of guidance there. Once you know which parameters to use with which endpoint, you can make those API calls using this connector.
👍 ok,i think it can achieve my goal, make new order then websocket get message .
Hi tiagosiebler,
I have wrote an Algo, I am struggling to implement to following. I want to create a STOP_LOSS_LIMIT order and when that one is succesful, it should create a TAKE_PROFIT inmediately.
I have the following params;
How do I set a STOP_LOSS_LIMIT order on Futures market.. I set my leverage and margin type (isolated) already. That works like a charm. But I can't create the above order.
And how do I set a the following order TAKE_PROFIT ?
I can't seem to figure out howto. Could you explain please?
Regards, The Alpha Centauri Ninja