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

Method create_order_request

python/ccxt/async_support/ascendex.py:1626–1696  ·  view source on GitHub ↗

@ignore helper function to build 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 currency

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

Source from the content-addressed store, hash-verified

1624 return result
1625
1626 def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1627 """
1628 @ignore
1629 helper function to build request
1630 :param str symbol: unified symbol of the market to create an order in
1631 :param str type: 'market' or 'limit'
1632 :param str side: 'buy' or 'sell'
1633 :param float amount: how much you want to trade in units of the base currency
1634 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1635 :param dict [params]: extra parameters specific to the exchange API endpoint
1636 :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1637 :param bool [params.postOnly]: True or False
1638 :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1639 :returns dict: request to be sent to the exchange
1640 """
1641 market = self.market(symbol)
1642 marginMode = None
1643 marketType = None
1644 marginMode, params = self.handle_margin_mode_and_params('createOrderRequest', params)
1645 marketType, params = self.handle_market_type_and_params('createOrderRequest', market, params)
1646 accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1647 accountCategory = self.safe_string(accountsByType, marketType, 'cash')
1648 if marginMode is not None:
1649 accountCategory = 'margin'
1650 account = self.safe_dict(self.accounts, 0, {})
1651 accountGroup = self.safe_string(account, 'id')
1652 clientOrderId = self.safe_string_2(params, 'clientOrderId', 'id')
1653 request = {
1654 'account-group': accountGroup,
1655 'account-category': accountCategory,
1656 'symbol': market['id'],
1657 'time': self.milliseconds(),
1658 'orderQty': self.amount_to_precision(symbol, amount),
1659 'orderType': type, # limit, market, stop_market, stop_limit
1660 'side': side, # buy or sell,
1661 # 'execInst': # Post for postOnly, ReduceOnly for reduceOnly
1662 # 'respInst': 'ACK', # ACK, 'ACCEPT, DONE
1663 }
1664 isMarketOrder = ((type == 'market') or (type == 'stop_market'))
1665 isLimitOrder = ((type == 'limit') or (type == 'stop_limit'))
1666 timeInForce = self.safe_string(params, 'timeInForce')
1667 postOnly = self.is_post_only(isMarketOrder, False, params)
1668 reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1669 triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1670 if isLimitOrder:
1671 request['orderPrice'] = self.price_to_precision(symbol, price)
1672 if timeInForce == 'IOC':
1673 request['timeInForce'] = 'IOC'
1674 if timeInForce == 'FOK':
1675 request['timeInForce'] = 'FOK'
1676 if postOnly:
1677 request['postOnly'] = True
1678 if triggerPrice is not None:
1679 request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1680 if isLimitOrder:
1681 request['orderType'] = 'stop_limit'
1682 elif isMarketOrder:
1683 request['orderType'] = 'stop_market'

Callers 2

create_orderMethod · 0.95
create_ordersMethod · 0.95

Calls 13

safe_dictMethod · 0.80
safe_stringMethod · 0.80
safe_string_2Method · 0.80
is_post_onlyMethod · 0.80
safe_boolMethod · 0.80
marketMethod · 0.45
millisecondsMethod · 0.45
amount_to_precisionMethod · 0.45
price_to_precisionMethod · 0.45
omitMethod · 0.45

Tested by

no test coverage detected