zhouaini528 / binance-php

Binance API Like the official document interface, Support for arbitrary extension.
MIT License
107 stars 43 forks source link

Archiving Takeprofit and stoploss via the api #46

Open pandglobal opened 1 year ago

pandglobal commented 1 year ago

I have been having issues with adding takeprofit and stoploss in my binance futures api. I have been using the UI to trade futures and i can easily set Limit order and takeprofit and stoploss order at once.

Now with this API i have difficulty doing that. These are things i have tried and their results:

  1. I have sent a Limit order with just price, quantity. then i send a second order Take_profit with same quality, price and stopprice, in this case my price and stop price are the same value, example 17000 for price and 17000 for stopprice. Then i sent the third order Stop similar to the Take_profit but with a lower price but same quantity. closeposition = true. on both STOP and TAKE_PROFIT but the outcome is this: if my limit orders where not filled, and the price gets to the takeprofit it will trigger with amount starting at -$4000 if that was the actual cost for buying that quantity of pair at 17000. yet but orders are not closed.

if limit order triggers first and then takeprofit orders gets triggered then only limit order and the takeprofit gets closed leaving the stoploss still opened.

but in the UI all orders are closed immediately takeprofit or Stoploss are closed.

Another thing is my amount for placing such orders are still counted individually, for example if it cost me $400 to place the limit order of 0.01 quantity of BTC, the order takeprofit and stoploss order i send will also be asking for a $400 each to have the orders placed, and if I only have $500 i get insufficient balance kind of error.

What am i not doing write and how can i effectively archive the takeprofit and stoploss workflow as it is in the UI of binance using this API

pandglobal commented 1 year ago

I have also used reduceOnly = 'true' for both take_profit and stoploss but the results is that once my order didn't get filled and the takeprofit or Stoploss is triggered it closes itself automatically without closing limit or stoploss orders.

zhouaini528 commented 1 year ago

Sorry I didn't come across such a problem. The UI and API parameters are consistent, and the problem you mentioned will not occur. You should look at the API documentation more.

pandglobal commented 1 year ago

Sorry I didn't come across such a problem. The UI and API parameters are consistent, and the problem you mentioned will not occur. You should look at the API documentation more.

Take a look at it again, the issue occurs with binance testnet but the live server is perfect. I was testing it alongside a binance support team who said the issue is from their own end .

You may retest retest