jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.58k stars 768 forks source link

How to use trailing stop? #645

Open Naografix opened 3 years ago

Naografix commented 3 years ago

Hello,

I'm looking how to use TRAILING STOP for my bot. Currently, every 10s, I'm canceling my STOP LOSS, calculating the new value, and send a new STOP LOSS to Binance. It's not super safe and I saw TRAILING STOP is available in this node package... But how can I use it?

Process: I want to buy Bitcoin AT market and set a trailing stop loss at 3%. Every price move, my stop loss is re-setted (a trailing stop) at -3% of the last price

Thanks!

Naografix commented 3 years ago

I need to do this like this?

let trailingStopLoss = await user.binance.futuresOrder("SELL", pair, user.quantityBought, false,
        {
            type: "TRAILING_STOP_MARKET",
            callbackRate: user.stopLossInPercent,
            reduceOnly: true
        }
    );
elyas74 commented 3 years ago

yes, something like this I think:

    let result = await binance.futuresOrder('SELL', 'BTCUSDT', 0.1, null, {
      type: "TRAILING_STOP_MARKET",
      callbackRate: 2,
    });