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

Method create_order

python/ccxt/bigone.py:1507–1604  ·  view source on GitHub ↗

create a trade order https://open.big.one/docs/spot_orders.html#create-order :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

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

Source from the content-addressed store, hash-verified

1505 return self.create_order(symbol, 'market', 'buy', cost, None, params)
1506
1507 def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1508 """
1509 create a trade order
1510
1511 https://open.big.one/docs/spot_orders.html#create-order
1512
1513 :param str symbol: unified symbol of the market to create an order in
1514 :param str type: 'market' or 'limit'
1515 :param str side: 'buy' or 'sell'
1516 :param float amount: how much of currency you want to trade in units of base currency
1517 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1518 :param dict [params]: extra parameters specific to the exchange API endpoint
1519 :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1520 :param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately
1521 :param str [params.timeInForce]: "GTC", "IOC", or "PO"
1522 :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
1523
1524 EXCHANGE SPECIFIC PARAMETERS
1525 :param str [params.operator]: *stop order only* GTE or LTE(default)
1526 :param str [params.client_order_id]: must match ^[a-zA-Z0-9-_]{1,36}$ self regex. client_order_id is unique in 24 hours, If created 24 hours later and the order closed, it will be released and can be reused
1527 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1528 """
1529 self.load_markets()
1530 market = self.market(symbol)
1531 isBuy = (side == 'buy')
1532 requestSide = 'BID' if isBuy else 'ASK'
1533 uppercaseType = type.upper()
1534 isLimit = uppercaseType == 'LIMIT'
1535 exchangeSpecificParam = self.safe_bool(params, 'post_only', False)
1536 postOnly = None
1537 postOnly, params = self.handle_post_only((uppercaseType == 'MARKET'), exchangeSpecificParam, params)
1538 triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 'stop_price'])
1539 request = {
1540 'asset_pair_name': market['id'], # asset pair name BTC-USDT, required
1541 'side': requestSide, # order side one of "ASK"/"BID", required
1542 'amount': self.amount_to_precision(symbol, amount), # order amount, string, required
1543 # "price": self.price_to_precision(symbol, price), # order price, string, required
1544 # "operator": "GTE", # stop orders only, GTE greater than and equal, LTE less than and equal
1545 # "immediate_or_cancel": False, # limit orders only, must be False when post_only is True
1546 # "post_only": False, # limit orders only, must be False when immediate_or_cancel is True
1547 }
1548 if isLimit or (uppercaseType == 'STOP_LIMIT'):
1549 request['price'] = self.price_to_precision(symbol, price)
1550 if isLimit:
1551 timeInForce = self.safe_string(params, 'timeInForce')
1552 if timeInForce == 'IOC':
1553 request['immediate_or_cancel'] = True
1554 if postOnly:
1555 request['post_only'] = True
1556 request['amount'] = self.amount_to_precision(symbol, amount)
1557 else:
1558 if isBuy:
1559 createMarketBuyOrderRequiresPrice = True
1560 createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
1561 cost = self.safe_number(params, 'cost')
1562 params = self.omit(params, 'cost')
1563 if createMarketBuyOrderRequiresPrice:
1564 if (price is None) and (cost is None):

Callers 1

Calls 15

parse_orderMethod · 0.95
InvalidOrderClass · 0.90
safe_boolMethod · 0.80
handle_post_onlyMethod · 0.80
safe_string_nMethod · 0.80
safe_stringMethod · 0.80
safe_numberMethod · 0.80
parse_to_numericMethod · 0.80
string_mulMethod · 0.80
safe_dictMethod · 0.80
privatePostOrdersMethod · 0.65

Tested by

no test coverage detected