简体   繁体   中英

Trying to place a binance futures trailing stop order using python?

I have got so far,

#changing the margin client.futures_change_margin_type(symbol = symbol_buy, marginType = 'ISOLATED')

#changing the leverage client.futures_change_leverage(symbol = symbol_buy, leverage = 1)

shared.client.futures_create_order( symbol=symbol_buy, side = 'SELL', type='TRAILING_STOP_LOSS', quantity = 100)

and i'm thus getting this error below


BinanceAPIException Traceback (most recent call last) in 3 4 #orderdetails_buy = shared.client_future.futures_create_order( symbol=symbol_buy, side = 'BUY', type='MARKET', quantity = 100) ----> 5 orderdetails_sell = shared.client_future.futures_create_order( symbol=symbol_buy, side = 'SELL', type='TRAILING_STOP_LOSS', quantity = 100) 6

C:\ProgramData\Anaconda3\lib\site-packages\binance\client.py in futures_create_order(self, **params) 5289 5290 """ -> 5291 return self._request_futures_api('post', 'order', True, data=params) 5292 5293 def futures_place_batch_order(self, **params):

C:\ProgramData\Anaconda3\lib\site-packages\binance\client.py in _request_futures_api(self, method, path, signed, **kwargs) 331 uri = self._create_futures_api_uri(path) 332 --> 333 return self._request(method, uri, signed, True, **kwargs) 334 335 def _request_futures_data_api(self, method, path, signed=False, **kwargs) -> Dict:

C:\ProgramData\Anaconda3\lib\site-packages\binance\client.py in _request(self, method, uri, signed, force_params, **kwargs) 307 308 self.response = getattr(self.session, method)(uri, **kwargs) --> 309 return self._handle_response(self.response) 310 311 @staticmethod

C:\ProgramData\Anaconda3\lib\site-packages\binance\client.py in _handle_response(response) 316 """ 317 if not (200 <= response.status_code < 300): --> 318 raise BinanceAPIException(response, response.status_code, response.text) 319 try: 320 return response.json()

BinanceAPIException: APIError(code=-1116): Invalid orderType.

you've probably solved this by now but with binance futures, I don't think there is a TRAILING_STOP_LOSS trade type via API just yet, available order types are (from the docs):

Order types (orderTypes, type):

  • LIMIT
  • MARKET
  • STOP
  • STOP_MARKET
  • TAKE_PROFIT
  • TAKE_PROFIT_MARKET
  • TRAILING_STOP_MARKET

[https://binance-docs.github.io/apidocs/futures/en/#public-endpoints-info][1]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM