Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Limit Order in python-binance API

Tags:

python

binance

I'd like to place a Stop Limit Order as described on their site. In other words, I want to place a limit order to buy once a certain stop price is reached.

The API documentation only has one example of the client.create_order function which is a basic limit order. The Binance documentation also doesn't give examples of this type of order.

I'm having trouble figuring out which settings to use for the client.create_order function through the API. Should the order type be STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT? What is the difference between these? In other words, can they both be used to Buy in different ways or do they each require a specific side?

EDIT: I found some more clarification here. This explains that a stop-limit buy order triggers a "Take Profit" order once the target price is met. However, it doesn't specify if this is a Market or Limit order. If it's a limit order, the example doesn't make much sense because they offered way more money than the stop price. If it's a market order, there should be no need to specify a price at all. What am I missing?

like image 854
StevenWhite Avatar asked Mar 11 '26 10:03

StevenWhite


1 Answers

order = client.create_order(
    symbol = symbol, 
    side = SIDE_BUY, 
    type = ORDER_TYPE_STOP_LOSS_LIMIT, 
    timeInForce = TIME_IN_FORCE_GTC, 
    quantity = quantity, 
    price = price, 
    stopPrice = stopPrice)

Reference:

https://binance-docs.github.io/apidocs/spot/en/#new-order-trade

https://github.com/sammchardy/python-binance/blob/master/binance/client.py

like image 69
Marcel Avatar answered Mar 12 '26 23:03

Marcel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!