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

Method edit_order

python/ccxt/derive.py:1341–1502  ·  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

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