I'm running an algorithm to predict prices and enter trades for me using the ccxt API in python. I wish to execute a trailing stop loss order and I enter such a long position like this:
exchange = ccxt.binance({
'enableRateLimit': True,
'apiKey': '*****',
'secret': '*****'
})
exchange.load_markets()
exchange.create_order('MKR/USDT, 'TRAILING_STOP_MARKET', 'buy', exchange.fetch_balance()['USDT']['free']/exchange.fetch_ticker('MKR/USDT)['last'], None, params = {'callbackRate': 1})
but I get the following error:
ccxt.base.errors.InvalidOrder: binance TRAILING_STOP_MARKET is not a valid order type in spot market MKR/USDT
I'm not sure why thought because I'm pretty sure binance supports trailing stop loss orders (it says so in its own API documentation).
Binance does not support the TRAILING_STOP_MARKET
order type with spot markets (which is the default with CCXT):
Binance only supports the TRAILING_STOP_MARKET
order type with futures-markets:
If you want to switch to the Binance futures API with CCXT you can do the following:
exchange = ccxt.binance({
'enableRateLimit': True,
'apiKey': '*****',
'secret': '*****'
'options': {
'defaultType': 'future', # or 'delivery' for COIN-M futures
},
})
exchange.load_markets()
exchange.create_order('MKR/USDT, 'TRAILING_STOP_MARKET', 'buy', exchange.fetch_balance()['USDT']['free']/exchange.fetch_ticker('MKR/USDT)['last'], None, params = {'callbackRate': 1})