https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postorders create a trade 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 flo
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1449 | return await self.fetch_open_orders(symbol, since, limit, self.extend(request, params)) |
| 1450 | |
| 1451 | async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 1452 | """ |
| 1453 | |
| 1454 | https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postorders |
| 1455 | |
| 1456 | create a trade order |
| 1457 | :param str symbol: unified symbol of the market to create an order in |
| 1458 | :param str type: 'market' or 'limit' |
| 1459 | :param str side: 'buy' or 'sell' |
| 1460 | :param float amount: how much of currency you want to trade in units of base currency |
| 1461 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 1462 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1463 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 1464 | """ |
| 1465 | await self.load_markets() |
| 1466 | market = self.market(symbol) |
| 1467 | request = { |
| 1468 | # common params -------------------------------------------------- |
| 1469 | # 'client_oid': clientOrderId, |
| 1470 | 'type': type, |
| 1471 | 'side': side, |
| 1472 | 'product_id': market['id'], |
| 1473 | # 'size': self.amount_to_precision(symbol, amount), |
| 1474 | # 'stp': 'dc', # self-trade prevention, dc = decrease and cancel, co = cancel oldest, cn = cancel newest, cb = cancel both |
| 1475 | # 'stop': 'loss', # "loss" = stop loss below price, "entry" = take profit above price |
| 1476 | # 'stop_price': self.price_to_precision(symbol, price), |
| 1477 | # limit order params --------------------------------------------- |
| 1478 | # 'price': self.price_to_precision(symbol, price), |
| 1479 | # 'size': self.amount_to_precision(symbol, amount), |
| 1480 | # 'time_in_force': 'GTC', # GTC, GTT, IOC, or FOK |
| 1481 | # 'cancel_after' [optional]* min, hour, day, requires time_in_force to be GTT |
| 1482 | # 'post_only': False, # invalid when time_in_force is IOC or FOK |
| 1483 | # market order params -------------------------------------------- |
| 1484 | # 'size': self.amount_to_precision(symbol, amount), |
| 1485 | # 'funds': self.cost_to_precision(symbol, amount), |
| 1486 | } |
| 1487 | clientOrderId = self.safe_string_2(params, 'clientOrderId', 'client_oid') |
| 1488 | if clientOrderId is not None: |
| 1489 | request['client_oid'] = clientOrderId |
| 1490 | triggerPrice = self.safe_number_n(params, ['stopPrice', 'stop_price', 'triggerPrice']) |
| 1491 | if triggerPrice is not None: |
| 1492 | request['stop_price'] = self.price_to_precision(symbol, triggerPrice) |
| 1493 | timeInForce = self.safe_string_2(params, 'timeInForce', 'time_in_force') |
| 1494 | if timeInForce is not None: |
| 1495 | request['time_in_force'] = timeInForce |
| 1496 | postOnly = self.safe_value_2(params, 'postOnly', 'post_only', False) |
| 1497 | if postOnly: |
| 1498 | request['post_only'] = True |
| 1499 | params = self.omit(params, ['timeInForce', 'time_in_force', 'stopPrice', 'stop_price', 'clientOrderId', 'client_oid', 'postOnly', 'post_only', 'triggerPrice']) |
| 1500 | if type == 'limit': |
| 1501 | request['price'] = self.price_to_precision(symbol, price) |
| 1502 | request['size'] = self.amount_to_precision(symbol, amount) |
| 1503 | elif type == 'market': |
| 1504 | cost = self.safe_number_2(params, 'cost', 'funds') |
| 1505 | if cost is None: |
| 1506 | if price is not None: |
| 1507 | cost = amount * price |
| 1508 | else: |
nothing calls this directly
no test coverage detected