coinex: fetchOHLCV returns quote volume instead of base volume
coinex.parseOHLCV returns the quote volume in the OHLCV volume slot, which should hold the base volume.
It reads the value field. The inline comment (and the static test recorded in April 2024) say value is the base volume. CoinEx's v2 API now returns the fields the other way round, which also matches its docs:
- spot kline / futures kline:
volume= "Filled volume",value= "Filled value"
Live response today:
GET https://api.coinex.com/v2/spot/kline?market=BTCUSDT&period=1hour&limit=1
{"code":0,"data":[{"close":"83910","created_at":1790614800000,"high":"84293","low":"83438","market":"BTCUSDT","open":"83506","value":"4907.2750781","volume":"0.05864515"}],"message":"OK"}0.05864515 BTC × ~83.7k ≈ 4907 USDT, so volume is the base amount and value is the quote amount.
The static test in ts/src/test/static/response/coinex.json has "value": "2.10551801", "volume": "141100.4007373749" for BTCUSDT at ~67k. At that time value really was the base amount, so the parser was correct when it was written. CoinEx appears to have swapped the fields since then.
Impact: fetchOHLCV volume on CoinEx is overstated by a factor of the price. For a BTC/USDT daily candle it returns ~482,006 "BTC" instead of ~5.69 BTC, i.e. ~$40B/day instead of ~$480k/day. Futures klines use the same fields, so swap volumes are affected too.
import ccxt
ex = ccxt.coinex()
c = ex.fetch_ohlcv('BTC/USDT', '1d', limit=2)[-2]
print(c[5], ex.fetch_ticker('BTC/USDT')['baseVolume']) # candle ~4.8e5 vs ticker ~1e1ccxt 4.5.84 (Python). Current master has the same code.
Fix: read volume instead of value (PR to follow).
Source: ccxt/ccxt