jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to set reduce-only stop orders with futures?

willoptions opened this issue · comments

Hi all - my application is sending multiple orders (as intended) - the first is a limit buy/sell, then the following order is to set a stop loss.

The issue is that these stop losses are being set as limit orders as well, taking the opposite side of the original trade (intended) - but they will stay in the books even after the original position is closed.

2 issues:
I can't get stop_market orders to work: "Parameter 'price' sent when not required." - when I remove 'price' it then says "Signature for this request is not valid."

I can't get the orders to behave like proper stop-losses, only resting limits for the opposite side of the trade.

Here's my code that works at creating stop limit orders, but they behave more like resting limits and I've found myself taking trades that I don't intend to because of it:

    if (side == "Sell" || side == "Short") {
        const ssr = await binance.futuresSell( symbol, size, price, {
            type: 'STOP',
            stopPrice: stopPrice} )

        res.send(ssr)
    }

    if (side == "Buy" || side == "Long") {
        const ssr = await binance.futuresBuy( symbol, size, price, {
            type: 'STOP',
            stopPrice: stopPrice} )
            
        res.send(ssr)
    }

What I'd like is to have it place stop_market reduce-only orders at the specified price, so I don't end up taking unintended trades if I forget to manually cancel them.

any help would be much appreciated, thank you

I am not sure if the node-binance-api library supports reduceOnly options, but that could be your solution!

Just try adding reduceOnly: true to your options and that could be it!

If you want full documentation, try using binance-lib once v3.0.0 is out in a couple of days. It has full intellisense documentation along with the responses, including websockets!