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.

bitmex `cancel_orders` doesnt return a list of orders, only a single order

See original GitHub issue

Reference:

https://github.com/ccxt/ccxt/blob/44445072fdfaf93e594177ad0e0ec8b36bc5d8b7/python/ccxt/bitmex.py#L1742

Reproduction:

import os
import ccxt

exchange = ccxt.bitmex(
    {
        "apiKey": os.environ["BITMEX_API_KEY"],
        "secret": os.environ["BITMEX_API_SECRET"],
    }
)

exchange.set_sandbox_mode(True)  # uncomment to use the testnet sandbox

symbol = "BTC/USD:BTC"
order_type = "limit"
side = "buy"
amount = 100

newOrder1 = exchange.create_order(symbol, order_type, side, amount, 15000)
newOrder2 = exchange.create_order(symbol, order_type, side, amount, 10000)
newOrder3 = exchange.create_order(symbol, order_type, side, amount, 9000)

cancelResponse = exchange.cancel_order(newOrder1["id"])

# cancel second and third order at the same time
ids = [newOrder2["id"], newOrder3["id"]]
cancelboth = exchange.cancel_orders(ids)
assert isinstance(cancelboth, dict)
assert isinstance(cancelboth, list), "cancelboth is not a list"

Output is a dict (should be a list of dicts):

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
elyasecommented, Jun 13, 2022

Works like a charm, once again I am impressed by this project, thanks @kroitor .

1reaction
elyasecommented, Jun 12, 2022

The problem seems to be the parsing of the response. Was able to make it work in Python by editing cancel_order:

        order = self.safe_value(response, 0, {})
        ...
        return self.parse_order(order)

to

        orders = self.safe_value(response, "data", [])
        ...
        self.parse_orders(orders)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Order Types FAQ - BitMEX
A Stop Order is an order that does not enter the order book until the market ... Stop Orders can be selected in...
Read more >
bitmex api php, cancel 1 order not working - Stack Overflow
the code above works just fine, cancelling all the orders.. however I want to cancel only one order using order ID, so I...
Read more >
ccxt/bitmex.py at master - GitHub
A JavaScript / Python / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges - ccxt/bitmex.py at master · ccxt/ccxt....
Read more >
BitMEX CEO Arthur Hayes on Medium criticism - Yahoo Finance
BitMEX CEO defends the billion-dollar crypto exchange: 'We don't trade ... but it does not trade against clients and exists only to bring ......
Read more >
Bitmex api example - SFSHOP
Dec 29, 2018 Learn how to place orders, cancel orders, and get price quotes ... BitMEX (The Bitcoin Mercantile Exchange) is a cryptocurrency...
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