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

Method create_order_request

python/ccxt/ascendex.py:1625–1695  ·  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

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