ccxt: [okex] cant place market order on futures api

  • OS: Linux
  • Programming Language version: 3.9.6
  • CCXT version: 1.36.46
  await exchange.createOrder("MNBTC-USDT-201023", "4", "buy", 1, undefined, {
    order_type: 4,
  });
(node:164618) UnhandledPromiseRejectionWarning: BadSymbol: okex {"error_message":"orderType is an invalid parameter","code":30024,"error_code":"30024","message":"orderType is an invalid parameter"}
    at okex.throwExactlyMatchedException (/home/meet/dev/flamy/romain/bot/node_modules/ccxt/js/base/Exchange.js:532:19)
    at okex.handleErrors (/home/meet/dev/flamy/romain/bot/node_modules/ccxt/js/okex.js:3319:18)
    at /home/meet/dev/flamy/romain/bot/node_modules/ccxt/js/base/Exchange.js:600:18
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at timeout (/home/meet/dev/flamy/romain/bot/node_modules/ccxt/js/base/functions/time.js:195:24)
    at okex.createOrder (/home/meet/dev/flamy/romain/bot/node_modules/ccxt/js/okex.js:1929:26)
(node:164618) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:164618) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Contacted okex, turns out we cannot have match_price 1 and order_type 4 at the same time. However, the only way to make it market order is to set order_type to 4 from what i see in code. Since the market / limit order parameter from the unified api is rather being used to determine open long, open short, close long, close short

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Alright, thanks!

And I appreciate your work on this library 🙂

@meetmangukiya appreciate your help and feedback!

Yep, we do not want to use match_price for market orders. Can set it to 1 for limit orders with no price.

Further clarifying on okexapi telegram group - https://t.me/OKExAPI/42327

The best counterparty price is the best bid price and best ask price. You may refer to this screenshot. image

I think match price leads to a limit order with price = best counter party price. Which would mean if we are asking for 100 contracts, but the best ask price is only offering a 50, we won’t be consuming other orders on the book with higher asks. But a market order would keep on sweeping the order book until our order is filled?

The result has been this position image From the docs, it seems like it has to be number of contracts

I was able to comment out the match_price parameter line and get the position to open.

  await exchange.createOrder("MNBTC-USDT-201023", "1", "buy", 1, undefined, {
    order_type: 4,
  });

I still think maybe we’d want to use limit and market as we do in the unified api and specify the type(open long, open short, close long, close short) by specifying in the params, like we do in TRAILING orders in binance? That seems more intuitive.