Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create valid takeprofit and stoploss in futures? #661

Open
Gtompa opened this issue May 15, 2024 · 0 comments
Open

How to create valid takeprofit and stoploss in futures? #661

Gtompa opened this issue May 15, 2024 · 0 comments

Comments

@Gtompa
Copy link

Gtompa commented May 15, 2024

I am writing a trading bot, but faced with such a problem that my stoploss and takeprofit by binance itself for the reason: "Expired", no time limits I do not set. Most likely I create the order incorrectly, so I want to ask how to do it correctly? At the moment I create them one by one all together like this:

   ` const order = await this.client.futuresOrder({
      type: "STOP",
      price: this.formatByPrecision(orderPrice, pricePrecision),
      symbol: pair.ticker,
      stopPrice: enterStopPrice,
      quantity,
      side: logSide,
      priceProtect: "TRUE",
  });

  await this.client.futuresOrder({
    type: "STOP_MARKET",
    stopPrice: loseStopPrice,
    symbol: pair.ticker,
    side: leaveSide,
    closePosition: "true",
  });

  await this.client.futuresOrder({
    type: "TAKE_PROFIT",
    stopPrice: this.formatByPrecision(tp + cf, pricePrecision),
    quantity,
    price: this.formatByPrecision(tp, pricePrecision),
    symbol: pair.ticker,
    side: leaveSide,
  });`

The model of work of these orders is as follows, for example, I want to open a buy transaction on the coin "AAAUSDT", the entry point I assign the price of 101, calculate take profit at the price of 105, and stop loss at the price of 100. I need that there was no slippage, so I want all these orders triggered immediately when entering the transaction, what am I doing wrong?

After opening a trade binance closes my stoplosses and takeprofits, thus I do not control my losses. Who can help me how to place such orders correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant