question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does Bitmex Bulk order require different parameters?

See original GitHub issue

I have successfully placed all necessary orders via exchange.create_order. Now i would like to optimize work with exchange and place one bulk order instead of sending orders separately.

Example of code for separate Stop order placement. It works

parameters = {'stopPx': stop_loss, 'execInst': 'Close'}
await ccxt.bitmex.create_order(symbol, 'Stop', side, amount_per_trade, None, parameters)

Code which i am trying to use for bulk order placement (Stop)

orders = list()
parameters = {'stopPx': stop_loss, 'execInst': 'Close'}
orders.append({"symbol": native_exchange_symbol, "type": "Stop", "side": order_side,
               "orderQty": amount_per_trade, "price": None, "parameters": parameters})

await ccxt.bitmex.private_post_order_bulk({'orders': json.dumps(orders)})

Data in orders list. <class 'dict'>: {'symbol': 'ETHUSD', 'type': 'Stop', 'side': 'Sell', 'orderQty': 111.0, 'price': None, 'parameters': {'stopPx': 199, 'execInst': 'Close'}}

returns error -->{“error”:{“message”:“Invalid stopPx for ordType”,“name”:“HTTPError”}}

It seams that I am doing something wrong with parameters…

  • OS: Linux
  • Programming Language version: Python 3.6
  • CCXT version: 1.18.824
  • Exchange: Bitmex
  • Method: private_post_order_bulk

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kroitorcommented, Jul 8, 2019

@qwasko1212 why do you send parameters to bitmex? Their endpoint for placing orders does not support a key called parameters inside an order. Each order should be a plain dict without nested dicts, and the stopPx should be on the same level with price.

order = {
    "symbol": native_exchange_symbol,
    "type": "LimitIfTouched",
    "side": order_side,
    "orderQty": amount,
    "price": price,
    "stopPx": ... // ←------------------------ HERE
    "'execInst": 'Close' // ←--------------- AND HERE
}

orders.append(order)
1reaction
brandsimoncommented, Jul 8, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

BitMEX API Changelog
Order : Bulk order requests with duplicate clOrdID s will now be rejected. ... If these values are unchanged, a 400 (Bad Request)...
Read more >
REST API - BitMEX
The BitMEX API conforms to the Swagger spec for REST endpoints. Any Swagger-compatible client can connect to the BitMEX API and execute commands....
Read more >
Update to bulk order request functionality - BitMEX Blog
Beginning on 20 February at 04:00 UTC, market orders will no longer be permitted in bulk order requests submitted through the API.
Read more >
BitMEX API Explorer
Parameters ; ordType. Order type. Valid options: Market, Limit, Stop, StopLimit, MarketIfTouched, LimitIfTouched, Pegged. Defaults to 'Limit' when price is ...
Read more >
API Update: 10 New Order Types, Bulk ... - BitMEX Blog
(docs) Send an array of orders and they will all be validated and executed at the same time. If any of the orders...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found