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

Method create_order

python/ccxt/dydx.py:1394–1451  ·  view source on GitHub ↗

https://docs.dydx.xyz/interaction/trading#place-an-order 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 float amount: how much o

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

Source from the content-addressed store, hash-verified

1392 return self.safe_integer(info, 'last_block_height')
1393
1394 def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order:
1395 """
1396
1397 https://docs.dydx.xyz/interaction/trading#place-an-order
1398
1399 create a trade order
1400 :param str symbol: unified symbol of the market to create an order in
1401 :param str type: 'market' or 'limit'
1402 :param str side: 'buy' or 'sell'
1403 :param float amount: how much of currency you want to trade in units of base currency
1404 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1405 :param dict [params]: extra parameters specific to the exchange API endpoint
1406 :param str [params.timeInForce]: "GTT", "IOC", or "PO"
1407 :param float [params.triggerPrice]: The price a trigger order is triggered at
1408 :param float [params.stopLossPrice]: price for a stoploss order
1409 :param float [params.takeProfitPrice]: price for a takeprofit order
1410 :param str [params.clientOrderId]: a unique id for the order
1411 :param bool [params.postOnly]: True or False whether the order is post-only
1412 :param bool [params.reduceOnly]: True or False whether the order is reduce-only
1413 :param float [params.goodTillBlock]: expired block number for the order, required for market order and non limit GTT order, default value is latestBlockHeight + 20
1414 :param float [params.goodTillBlockTimeInSeconds]: expired time elapsed for the order, required for limit GTT order and conditional, default value is 30 days
1415 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1416 """
1417 self.load_markets()
1418 credentials = self.retrieve_credentials()
1419 account = self.fetch_dydx_account()
1420 lastBlockHeight = self.fetch_latest_block_height()
1421 # params['latestBlockHeight'] = lastBlockHeight
1422 newParams = self.extend(params, {'latestBlockHeight': lastBlockHeight})
1423 orderRequestRes = self.create_order_request(symbol, type, side, amount, price, newParams)
1424 orderId = orderRequestRes[0]
1425 orderRequest = orderRequestRes[1]
1426 chainName = self.options['chainName']
1427 signedTx = self.sign_dydx_tx(credentials['privateKey'], orderRequest, '', chainName, account, None)
1428 request = {
1429 'tx': signedTx,
1430 }
1431 # nodeRpcGetBroadcastTxAsync
1432 response = self.nodeRpcGetBroadcastTxSync(request)
1433 #
1434 # {
1435 # "jsonrpc": "2.0",
1436 # "id": -1,
1437 # "result": {
1438 # "code": 0,
1439 # "data": "",
1440 # "log": "[]",
1441 # "codespace": "",
1442 # "hash": "CBEDB0603E57E5CE21FA6954770A9403D2A81BED02E608C860356152D0AA1A81"
1443 # }
1444 # }
1445 #
1446 result = self.safe_dict(response, 'result')
1447 return self.safe_order({
1448 'info': result,
1449 'id': orderId,
1450 'clientOrderId': orderRequest['value']['order']['orderId']['clientId'],
1451 })

Callers

nothing calls this directly

Calls 10

retrieve_credentialsMethod · 0.95
fetch_dydx_accountMethod · 0.95
create_order_requestMethod · 0.95
sign_dydx_txMethod · 0.95
safe_dictMethod · 0.80
safe_orderMethod · 0.80
load_marketsMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected