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

Method edit_order

python/ccxt/async_support/derive.py:1342–1503  ·  view source on GitHub ↗

edit a trade order https://docs.derive.xyz/reference/post_private-replace :param str id: order id :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' :param str side: 'buy' or 'sell' :pa

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

Source from the content-addressed store, hash-verified

1340 return order
1341
1342 async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
1343 """
1344 edit a trade order
1345
1346 https://docs.derive.xyz/reference/post_private-replace
1347
1348 :param str id: order id
1349 :param str symbol: unified symbol of the market to create an order in
1350 :param str type: 'market' or 'limit'
1351 :param str side: 'buy' or 'sell'
1352 :param float amount: how much of currency you want to trade in units of base currency
1353 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1354 :param dict [params]: extra parameters specific to the exchange API endpoint
1355 :param str [params.subaccount_id]: *required* the subaccount id
1356 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1357 """
1358 await self.load_markets()
1359 market = self.market(symbol)
1360 subaccountId = None
1361 subaccountId, params = self.handle_derive_subaccount_id('editOrder', params)
1362 reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only')
1363 timeInForce = self.safe_string_lower_2(params, 'timeInForce', 'time_in_force')
1364 postOnly = self.safe_bool(params, 'postOnly')
1365 orderType = type.lower()
1366 orderSide = side.lower()
1367 nonce = self.milliseconds()
1368 signatureExpiry = self.safe_number(params, 'signature_expiry_sec', self.seconds() + 7776000)
1369 # TODO: subaccount id / trade module address
1370 ACTION_TYPEHASH = self.base16_to_binary('4d7a9f27c403ff9c0f19bce61d76d82f9aa29f8d6d4b0c5474607d9770d1af17')
1371 sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
1372 TRADE_MODULE_ADDRESS = '0x87F2863866D85E3192a35A73b388BD625D83f2be' if (sandboxMode) else '0xB8D20c2B7a1Ad2EE33Bc50eF10876eD3035b5e7b'
1373 priceString = self.number_to_string(price)
1374 maxFeeString = self.safe_string(params, 'max_fee', '0')
1375 amountString = self.number_to_string(amount)
1376 tradeModuleDataHash = self.hash(self.eth_abi_encode([
1377 'address', 'uint', 'int', 'int', 'uint', 'uint', 'bool',
1378 ], [
1379 market['info']['base_asset_address'],
1380 self.parse_to_numeric(market['info']['base_asset_sub_id']),
1381 self.convert_to_big_int((self.parse_units(priceString))),
1382 self.convert_to_big_int((self.parse_units((self.amount_to_precision(symbol, amountString))))),
1383 self.convert_to_big_int((self.parse_units(maxFeeString))),
1384 subaccountId,
1385 orderSide == 'buy',
1386 ]), 'keccak', 'binary')
1387 deriveWalletAddress = None
1388 deriveWalletAddress, params = self.handle_derive_wallet_address('editOrder', params)
1389 signature = self.sign_order([
1390 ACTION_TYPEHASH,
1391 subaccountId,
1392 nonce,
1393 TRADE_MODULE_ADDRESS,
1394 tradeModuleDataHash,
1395 signatureExpiry,
1396 deriveWalletAddress,
1397 self.walletAddress,
1398 ], self.privateKey)
1399 request = {

Callers

nothing calls this directly

Calls 15

parse_unitsMethod · 0.95
sign_orderMethod · 0.95
parse_orderMethod · 0.95
InvalidOrderClass · 0.90
safe_bool_2Method · 0.80
safe_string_lower_2Method · 0.80
safe_boolMethod · 0.80
safe_numberMethod · 0.80
base16_to_binaryMethod · 0.80
safe_stringMethod · 0.80

Tested by

no test coverage detected