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.

cex.io missing price & amount for market orders

See original GitHub issue
  • OS: Linux
  • Programming Language version: python 3.6
  • CCXT version: 1.18.361
  • Exchange: cex.io
  • Method: fetchClosedOrders

I’m fetching my trade history on cex.io. I noticed that many orderes with status “closed” have price: null and amount: 0. I thought ok if price is null (market order: makes sense) then I could derive it using the amount * cost… but the amount is also to 0 in such cases, and this is a bug.

See e.g. here the response of one these not parsed properly orders:

  {
    "id": "7609054087",
    "datetime": "2018-11-19T19:26:06.461Z",
    "timestamp": 1542655566461,
    "lastTradeTimestamp": null,
    "status": "closed",
    "symbol": "BTC/USD",
    "type": null,
    "side": "buy",
    "price": null,
    "cost": 249.36,
    "amount": 0.0,
    "filled": 0.0,
    "remaining": 0.0,
    "trades": null,
    "fee": {
      "currency": "USD",
      "rate": 0.0025,
      "cost": 0.63
    },
    "info": {
      "id": "7609054087",
      "type": "buy",
      "time": "2018-11-19T19:26:06.461Z",
      "lastTxTime": "2018-11-19T19:26:06.461Z",
      "lastTx": "7609054097",
      "pos": null,
      "status": "d",
      "symbol1": "BTC",
      "symbol2": "USD",
      "amount": "0.00000000",
      "amount2": "250.00",
      "remains": "0.00000000",
      "tfa:USD": "0.63",
      "tta:USD": "249.36",
      "a:BTC:cds": "0.04982417",
      "a:USD:cds": "250.00",
      "f:USD:cds": "0.63",
      "tradingFeeTaker": "0.25",
      "tradingFeeUserVolumeAmount": "19111256",
      "orderId": "7609054087"
    }
  }

In the cex.io ui the order looks like this:

image

Unluckily via API they don’t provide the price, but the “filled” amount should be used to set the amount. See in the info property with the original response:

"a:BTC:cds": "0.04982417",

So, once you got the amount, also the price should be set with this calculation: amount_filled / cost… which in my case -> 250 / 0.04982417 = 5017.645050585 But cex.io shows Avg. Execution price: 5004.8

So I wonder what’s going on here. Either I calculated wrongly or cex.io doesn’t show data correctly. 5004 vs 5017 is quite a big difference…

Also, the parsing is not done properly for filled & amount, as these values should be always positive, but I noticed in many cases (for sell orders, seems this happens for market orders where the price is missing) that they are negative. See e.g. here:

  {
    "id": "7669027383",
    "datetime": "2018-11-26T12:19:30.777Z",
    "timestamp": 1543234770777,
    "lastTradeTimestamp": null,
    "status": "closed",
    "symbol": "XLM/USD",
    "type": null,
    "side": "sell",
    "price": null,
    "cost": 34.41,
    "amount": -200.0,
    "filled": -200.0,
    "remaining": 0.0,
    "trades": null,
    "fee": {
      "currency": "USD",
      "rate": 0.0025,
      "cost": 0.09
    },
    "info": {
      "id": "7669027383",
      "type": "sell",
      "time": "2018-11-26T12:19:30.777Z",
      "lastTxTime": "2018-11-26T12:19:30.777Z",
      "lastTx": "7669027411",
      "pos": null,
      "status": "d",
      "symbol1": "XLM",
      "symbol2": "USD",
      "amount": "-200.00000000",
      "remains": "0.0000000",
      "tfa:USD": "0.09",
      "tta:USD": "34.41",
      "a:USD:cds": "34.41",
      "a:XLM:cds": "200.0000000",
      "f:USD:cds": "0.09",
      "tradingFeeTaker": "0.25",
      "tradingFeeUserVolumeAmount": "44365067",
      "orderId": "7669027383"
    }
  }

I’m also a bit tired to investigate further, @kroitor I leave this to you 😉 sorry (for not fixing it myself) & thx for looking at it.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
npomfretcommented, Jun 23, 2019

I’ve done a bunch of work on cex. I’ll submit work work so far…

0reactions
kroitorcommented, Jun 23, 2019

@firepol i’ll try to fix it in a day or two. Need to rework the order parser for cex, hope to resolve it shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Market order - CEX.IO Help Center
In total, you'll receive $2,900, for an average price of $580 per BTC. Since a market order is executed instantly, it cannot be...
Read more >
Terms of use - CEX.IO
The Transaction Price is calculated on the basis of actual matched orders made by the Buyers and Sellers participating in the bidding process...
Read more >
Crypto trading instruments in the CEX.IO mobile app
The CEX.IO mobile app is a fully functional tool that allows you to trade and control your orders and funds anywhere you are....
Read more >
CEX.IO Prime Liquidity | API Reference
To be able to trade via Prime Liquidity, Client should prepare his CEX.IO account: ... The Price(44) field should be missing if the...
Read more >
CEX.IO: Bitcoin & Cryptocurrency Exchange - Buy & Sell Crypto
Buy & sell crypto & bitcoin online with CEX.IO. ... The current market value, as well as historical changes of the BTC price,...
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