MCPcopy Create free account
hub / github.com/ccxt/ccxt / edit_order

Method edit_order

python/ccxt/foxbit.py:1406–1459  ·  view source on GitHub ↗

Simultaneously cancel an existing order and create a new one. https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancelReplace :param str id: order id :param str symbol: unified symbol of the market to create an order in :param str t

(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={})

Source from the content-addressed store, hash-verified

1404 }
1405
1406 def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}) -> Order:
1407 """
1408 Simultaneously cancel an existing order and create a new one.
1409
1410 https://docs.foxbit.com.br/rest/v3/#tag/Trading/operation/OrdersController_cancelReplace
1411
1412 :param str id: order id
1413 :param str symbol: unified symbol of the market to create an order in
1414 :param str type: 'market' or 'limit'
1415 :param str side: 'buy' or 'sell'
1416 :param float amount: how much of the currency you want to trade in units of the base currency
1417 :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders, used on stop market orders
1418 :param dict [params]: extra parameters specific to the exchange API endpoint
1419 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1420 """
1421 if symbol is None:
1422 raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
1423 type = type.upper()
1424 if type != 'LIMIT' and type != 'MARKET' and type != 'STOP_MARKET' and type != 'INSTANT':
1425 raise InvalidOrder('Invalid order type: ' + type + '. Must be one of: LIMIT, MARKET, STOP_MARKET, INSTANT.')
1426 self.load_markets()
1427 market = self.market(symbol)
1428 request = {
1429 'mode': 'ALLOW_FAILURE',
1430 'cancel': {
1431 'type': 'ID',
1432 'id': self.parse_number(id),
1433 },
1434 'create': {
1435 'type': type,
1436 'side': side.upper(),
1437 'market_symbol': market['id'],
1438 },
1439 }
1440 if type == 'LIMIT' or type == 'MARKET':
1441 request['create']['quantity'] = self.amount_to_precision(symbol, amount)
1442 if type == 'LIMIT':
1443 request['create']['price'] = self.price_to_precision(symbol, price)
1444 if type == 'STOP_MARKET':
1445 request['create']['stop_price'] = self.price_to_precision(symbol, price)
1446 request['create']['quantity'] = self.amount_to_precision(symbol, amount)
1447 if type == 'INSTANT':
1448 request['create']['amount'] = self.price_to_precision(symbol, amount)
1449 response = self.v3PrivatePostOrdersCancelReplace(self.extend(request, params))
1450 # {
1451 # "cancel": {
1452 # "id": 123456789
1453 # },
1454 # "create": {
1455 # "id": 1234567890,
1456 # "client_order_id": "451637946501"
1457 # }
1458 # }
1459 return self.parse_order(response['create'], market)
1460
1461 def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
1462 """

Callers

nothing calls this directly

Calls 10

parse_orderMethod · 0.95
ArgumentsRequiredClass · 0.90
InvalidOrderClass · 0.90
parse_numberMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
amount_to_precisionMethod · 0.45
price_to_precisionMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected