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

Method create_order_request

python/ccxt/async_support/lighter.py:672–810  ·  view source on GitHub ↗

@ignore helper function to build the request :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 you want to trade in units of the base curr

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

Source from the content-addressed store, hash-verified

670 self.options['chainId'] = 300 if enable else 304
671
672 def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> List[Any]:
673 """
674 @ignore
675 helper function to build the request
676 :param str symbol: unified symbol of the market to create an order in
677 :param str type: 'market' or 'limit'
678 :param str side: 'buy' or 'sell'
679 :param float amount: how much you want to trade in units of the base currency
680 :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders
681 :param dict [params]: extra parameters specific to the exchange API endpoint
682 :param int [params.nonce]: nonce for the account
683 :param int [params.apiKeyIndex]: apiKeyIndex
684 :param int [params.accountIndex]: accountIndex
685 :param int [params.orderExpiry]: orderExpiry
686 :returns any[]: request to be sent to the exchange
687 """
688 if price is None:
689 raise ArgumentsRequired(self.id + ' createOrder() requires a price argument')
690 reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only', False) # default False
691 orderType = type.upper()
692 market = self.market(symbol)
693 orderSide = side.upper()
694 request = {
695 'market_index': self.parse_to_int(market['id']),
696 }
697 nonce = None
698 apiKeyIndex = None
699 accountIndex = None
700 orderExpiry = None
701 apiKeyIndex, params = self.handle_api_key_index(params, 'createOrder', 'apiKeyIndex', 'api_key_index')
702 accountIndex, params = self.handle_option_and_params_2(params, 'createOrder', 'accountIndex', 'account_index')
703 nonce, params = self.handle_option_and_params(params, 'createOrder', 'nonce')
704 orderExpiry, params = self.handle_option_and_params(params, 'createOrder', 'orderExpiry', 0)
705 if nonce is not None:
706 request['nonce'] = nonce
707 request['api_key_index'] = apiKeyIndex
708 request['account_index'] = self.parse_to_int(accountIndex)
709 triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
710 stopLossPrice = self.safe_value(params, 'stopLossPrice', triggerPrice)
711 takeProfitPrice = self.safe_value(params, 'takeProfitPrice')
712 stopLoss = self.safe_value(params, 'stopLoss')
713 takeProfit = self.safe_value(params, 'takeProfit')
714 hasStopLoss = (stopLoss is not None)
715 hasTakeProfit = (takeProfit is not None)
716 isConditional = (stopLossPrice or takeProfitPrice)
717 isMarketOrder = (orderType == 'MARKET')
718 timeInForce = self.safe_string_lower(params, 'timeInForce', 'gtt')
719 postOnly = self.is_post_only(isMarketOrder, None, params)
720 params = self.omit(params, ['stopLoss', 'takeProfit', 'timeInForce'])
721 orderTypeNum = None
722 timeInForceNum = None
723 if isMarketOrder:
724 orderTypeNum = 1
725 timeInForceNum = 0
726 else:
727 orderTypeNum = 0
728 if orderSide == 'BUY':
729 request['is_ask'] = 0

Callers 1

create_orderMethod · 0.95

Calls 15

handle_api_key_indexMethod · 0.95
powMethod · 0.95
ArgumentsRequiredClass · 0.90
safe_bool_2Method · 0.80
parse_to_intMethod · 0.80
safe_string_2Method · 0.80
safe_valueMethod · 0.80
safe_string_lowerMethod · 0.80
is_post_onlyMethod · 0.80
safe_dictMethod · 0.80

Tested by

no test coverage detected