sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.99k stars 2.2k forks source link

STOP LIMIT order example code? #1054

Open bixty opened 2 years ago

bixty commented 2 years ago

Describe the bug I'm trying to create a Stop Limit order (ORDER_TYPE_STOP_LOSS_LIMIT) but i'm getting errors, one time its LOT_SIZE and sometimes it's the other ones.

The problem is that i can't understand how to findout if the price/stopPrice and quantity are valid. as this link says, i tried but still getting errors.

Also as the Binance Official Document says, i could'nt get the True value for the third check in the list: price >= minPrice price <= maxPrice (price-minPrice) % tickSize == 0

I also have read this article from the creator of the library, but still can't found out how to deal with this calculation.

Any example codes that explains this calulations will be welcomed.

To Reproduce Code snippet to reproduce the behavior:

order = client.create_order(
          symbol='TRXUSDT',
         side=side,
          type=ORDER_TYPE_STOP_LOSS_LIMIT,
          quantity=qt,
          newClientOrderId=id,
          price=price,
          stopPrice=stop_price,
          timeInForce=TIME_IN_FORCE_GTC
)

Expected behavior Placing the order successfully.

Environment (please complete the following information):

Logs or Additional context Stop price would trigger immediately. LOT_SIZE

ddroguett commented 2 years ago

check the following link https://github.com/sammchardy/python-binance/issues/1037