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

Method edit_order

python/ccxt/lighter.py:900–956  ·  view source on GitHub ↗

cancels an order and places a new order :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' :param float amount: how much of the currency y

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

Source from the content-addressed store, hash-verified

898 return self.parse_order(self.deep_extend(response, order), market)
899
900 def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}) -> Order:
901 """
902 cancels an order and places a new order
903 :param str id: order id
904 :param str symbol: unified symbol of the market to create an order in
905 :param str type: 'market' or 'limit'
906 :param str side: 'buy' or 'sell'
907 :param float amount: how much of the currency you want to trade in units of the base currency
908 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
909 :param dict [params]: extra parameters specific to the exchange API endpoint
910 :param str [params.accountIndex]: account index
911 :param str [params.apiKeyIndex]: api key index
912 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
913 """
914 self.load_markets()
915 apiKeyIndex = None
916 apiKeyIndex, params = self.handle_api_key_index(params, 'editOrder', 'apiKeyIndex', 'api_key_index')
917 accountIndex = None
918 accountIndex, params = self.handle_account_index(params, 'editOrder', 'accountIndex', 'account_index')
919 strAccountIndex = self.number_to_string(accountIndex)
920 strApiKeyIndex = self.number_to_string(apiKeyIndex)
921 signer = self.load_account(self.options['chainId'], self.get_lighter_private_key(strAccountIndex, strApiKeyIndex), strApiKeyIndex, strAccountIndex, params)
922 market = self.market(symbol)
923 marketInfo = self.safe_dict(market, 'info', {})
924 amountScale = self.pow('10', marketInfo['size_decimals'])
925 priceScale = self.pow('10', marketInfo['price_decimals'])
926 triggerPrice = self.safe_string_n(params, ['stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice'])
927 params = self.omit(params, ['stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice'])
928 amountStr = None
929 priceStr = self.price_to_precision(symbol, price)
930 triggerPriceStr = '0' # default is 0
931 if triggerPrice is not None:
932 amountStr = self.number_to_string(amount)
933 triggerPriceStr = self.price_to_precision(symbol, triggerPrice)
934 else:
935 amountStr = self.amount_to_precision(symbol, amount)
936 nonce = self.fetch_nonce(accountIndex, apiKeyIndex, params)
937 signRaw = {
938 'market_index': self.parse_to_int(market['id']),
939 'index': self.parse_to_int(id),
940 'base_amount': self.parse_to_int(Precise.string_mul(amountStr, amountScale)),
941 'price': self.parse_to_int(Precise.string_mul(priceStr, priceScale)),
942 'trigger_price': self.parse_to_int(Precise.string_mul(triggerPriceStr, priceScale)),
943 'nonce': nonce,
944 'api_key_index': apiKeyIndex,
945 'account_index': accountIndex,
946 'integrator_account_index': self.options['integratorAccountIndex'],
947 'integrator_taker_fee': self.options['integratorTakerFee'],
948 'integrator_maker_fee': self.options['integratorMakerFee'],
949 }
950 txType, txInfo = self.lighter_sign_modify_order(signer, self.extend(signRaw, params))
951 request = {
952 'tx_type': txType,
953 'tx_info': txInfo,
954 }
955 response = self.publicPostSendTx(request)
956 return self.parse_order(response, market)
957

Callers

nothing calls this directly

Calls 15

handle_api_key_indexMethod · 0.95
handle_account_indexMethod · 0.95
load_accountMethod · 0.95
powMethod · 0.95
fetch_nonceMethod · 0.95
parse_orderMethod · 0.95
safe_dictMethod · 0.80
safe_string_nMethod · 0.80
parse_to_intMethod · 0.80
string_mulMethod · 0.80

Tested by

no test coverage detected