Stop Limit Order in python-binance API

10,390
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

Share:
10,390
StevenWhite
Author by

StevenWhite

I am a Business Intelligence Developer. I primarily work with Oracle, Redshift, and the Microsoft BI stack. I also work with Tableau, C#, Python, and Excel VBA.

Updated on June 14, 2022

Comments

  • StevenWhite
    StevenWhite about 2 years

    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?

    • user2553863
      user2553863 about 3 years
      You're right, it lacks documentation, however you found a good way to find out, placing the order through the GUI, as you commented on the accepted answer. Regarding that "answer", I wouldn't have accepted it, since it's not really answering your question AT ALL, just pointing you to docs for Binance FUTURES, that perhaps is not what you want. And the second doc is the kind of doc we are complaining about: lacking good example coverage. Regards.
    • Marco
      Marco almost 3 years
      It's also important to understand well how these Ordertypes Work. a stop-loss-limit order will place a limit order if the trigger price is met. Hence you always need a trigger price. You also need an additional, (an most likely slightly different) price at which you wish to execute your order, if it's a limit order.
    • Marco
      Marco almost 3 years
      As to STOP_LOSS or TAKE_PROFIT, it's in the name. a stop_loss is used to cut your losses. (eg you are long, price decreases, trigger is met -> you sell) While TAKE_PROFIT is used to realise your gains. (eg you are long, price increases, trigger is met --> you buy)
    • Marco
      Marco almost 3 years
      I personally find the Binance-docs slightly confusing / bad at times. However these Order-types exist for many exchanges. (also other types like icebergs etc weren't inventend by Binance, rather the opposite :) ). As such I can only encourage people to read up on these topics with other resources as well, to understand them well before using them.
  • Jodhvir Singh
    Jodhvir Singh over 2 years
    thanks a lot marcel...was looking for something like this for a while now