ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.99k stars 7.53k forks source link

deribit - fix cost calculation #7758

Open yrossslav opened 4 years ago

yrossslav commented 4 years ago

Hi! Maybe I do break rules of issue submit. Sorry for that.

We may read on deribit about amount:

Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.

Bug in cost appear in parse_trade funciton, when you just calc:

cost = amount * price

Not seeng what instrument_name is. It's return us problems with big cost like that:

  'symbol': 'BTC-PERPETUAL',
  'type': 'limit',
  'side': 'buy',
  'takerOrMaker': 'maker',
  'price': 10608.0,
  'amount': 11830.0,
  'cost': 125492640.0,
kroitor commented 4 years ago

@yrossslav the unification of derivatives (perpetuals and futures) is still in progress, there may be quirks here and there, and we may end up redefining the meaning of amount, price and cost for the derivatives involving the settlement currency. In this case, the terms used by deribit are confusing, since if the amount is given in USD, it's not the amount (not the number of contracts), it's the cost. We will investigate and will get back to you asap.

yrossslav commented 4 years ago

Yes! Thank you! I understand that you have a lot of work. Jus little help with bug report. I think that I found same little problems with bitmex, but, if it is in progress, I don't disturb you with that.

ttodua commented 2 years ago

Yes! Thank you! I understand that you have a lot of work. Jus little help with bug report. I think that I found same little problems with bitmex, but, if it is in progress, I don't disturb you with that.

@yrossslav whenever you find any bug or issue (independent whether something is work-in-progress or not), please report. it's more then welcomed

ttodua commented 2 months ago

just for future readers, i suspect deribit amounts might be similar to bitmex, where units represent satoshis, e.g. 100000000 amount might be 1 BTC. That might require revision and update of deribit implementations.