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

Method edit_order

python/ccxt/async_support/bitmex.py:2099–2143  ·  view source on GitHub ↗
(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={})

Source from the content-addressed store, hash-verified

2097 return self.parse_order(response, market)
2098
2099 async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
2100 await self.load_markets()
2101 request = {}
2102 trailingAmount = self.safe_string_2(params, 'trailingAmount', 'pegOffsetValue')
2103 isTrailingAmountOrder = trailingAmount is not None
2104 if isTrailingAmountOrder:
2105 triggerDirection = self.safe_string(params, 'triggerDirection')
2106 triggerAbove = ((triggerDirection == 'ascending') or (triggerDirection == 'above'))
2107 if (type == 'limit') or (type == 'market'):
2108 self.check_required_argument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below'])
2109 orderType = None
2110 if type == 'limit':
2111 if side == 'buy':
2112 orderType = 'StopLimit' if triggerAbove else 'LimitIfTouched'
2113 else:
2114 orderType = 'LimitIfTouched' if triggerAbove else 'StopLimit'
2115 elif type == 'market':
2116 if side == 'buy':
2117 orderType = 'Stop' if triggerAbove else 'MarketIfTouched'
2118 else:
2119 orderType = 'MarketIfTouched' if triggerAbove else 'Stop'
2120 isStopSellOrder = (side == 'sell') and ((orderType == 'Stop') or (orderType == 'StopLimit'))
2121 isBuyIfTouchedOrder = (side == 'buy') and ((orderType == 'MarketIfTouched') or (orderType == 'LimitIfTouched'))
2122 if isStopSellOrder or isBuyIfTouchedOrder:
2123 trailingAmount = '-' + trailingAmount
2124 request['pegOffsetValue'] = self.parse_to_numeric(trailingAmount)
2125 params = self.omit(params, ['triggerDirection', 'trailingAmount'])
2126 origClOrdID = self.safe_string_2(params, 'origClOrdID', 'clientOrderId')
2127 if origClOrdID is not None:
2128 request['origClOrdID'] = origClOrdID
2129 clientOrderId = self.safe_string(params, 'clOrdID', 'clientOrderId')
2130 if clientOrderId is not None:
2131 request['clOrdID'] = clientOrderId
2132 params = self.omit(params, ['origClOrdID', 'clOrdID', 'clientOrderId'])
2133 else:
2134 request['orderID'] = id
2135 if amount is not None:
2136 qty = self.parse_to_int(self.amount_to_precision(symbol, amount))
2137 request['orderQty'] = qty
2138 if price is not None:
2139 request['price'] = price
2140 brokerId = self.safe_string(self.options, 'brokerId', 'CCXT')
2141 request['text'] = brokerId
2142 response = await self.privatePutOrder(self.extend(request, params))
2143 return self.parse_order(response)
2144
2145 async def cancel_order(self, id: str, symbol: Str = None, params={}):
2146 """

Callers

nothing calls this directly

Calls 11

amount_to_precisionMethod · 0.95
parse_orderMethod · 0.95
safe_string_2Method · 0.80
safe_stringMethod · 0.80
parse_to_numericMethod · 0.80
parse_to_intMethod · 0.80
privatePutOrderMethod · 0.65
load_marketsMethod · 0.45
omitMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected