2

A sample code of mine:

import ccxt


binance = ccxt.binance({
    'enableRateLimit': True,
    'apiKey': '****',
    'secret': '****',
    'options': {'defaultType': 'margin'}
})

binance.create_order('BTC/USDT', 'take_profit_limit', 'buy', 0.1, price = binance.fetch_ticker('BTC/USDT')['last'], params = {'type': 'takeProfit', 'stopPrice' : stop})

where stop > price and I get the following error:

ccxt.base.errors.OrderImmediatelyFillable: binance Stop price would trigger immediately.

It seems to me that it is attempting to place a stop-loss at the price "stop" rather than a take-profit limit order which is what I want. I see on the documentation for the Binance API that the only extra parameter involved with the take_profit_limit order type is this stopPrice and not a similar "take_profit". I can also set a take-profit order the way I want to manually on the binance website by just setting this trigger price "stop" to be greater than the buying-in price, but I just can't get ccxt to do it.

I'm afraid I couldn't find anything to help in the Almighty Kroiter's examples either, but I may have missed something so I'm open to helpful links as well!

CS1994
  • 143
  • 2
  • 7

1 Answers1

0

The take_profit_limit order type is meant to trigger a Buy when the price falls to the stop price and then you buy it at the limit price. If you want to buy after the price rises to a particular point, use the STOP_LOSS_LIMIT order type. If you want to buy right away simply use a LIMIT order.

StevenWhite
  • 5,907
  • 3
  • 21
  • 46
  • use TAKE_PROFIT_LIMIT if you don't want to have the order on the book, otherwise it's the same as LIMIT (except when you need to use a .trailingDelta), but LIMIT doesn't need to worry about being stepped-over/unfilled and lose money on the stop<->limit spread. – youurayy Aug 01 '22 at 12:16