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
31.96k stars 7.38k forks source link

Binance coin-margined futures volume #9141

Open diwenshi61 opened 3 years ago

diwenshi61 commented 3 years ago

fetch_tickers on Binance coin-margined futures returns baseVolume in terms of the number of 'contracts' traded, i.e.:

{'symbol': 'BTC/USD', 'timestamp': 1620252075144, 'datetime': '2021-05-05T22:01:15.144Z', 'high': 57968.3, 'low': 52907.1, 'bid': None, 'bidVolume': None, 'ask': None, 'askVolume': None, 'vwap': 55761.71235801, 'open': 54453.7, 'close': 56950.0, 'last': 56950.0, 'previousClose': None, 'change': 2496.3, 'percentage': 4.584, 'average': None, 'baseVolume': 69172654.0, 'quoteVolume': None, 'info': {'symbol': 'BTCUSD_PERP', 'pair': 'BTCUSD', 'priceChange': '2496.3', 'priceChangePercent': '4.584', 'weightedAvgPrice': '55761.71235801', 'lastPrice': '56950.0', 'lastQty': '6', 'openPrice': '54453.7', 'highPrice': '57968.3', 'lowPrice': '52907.1', 'volume': '69172654', 'baseVolume': '124050.44801330', 'openTime': '1620165660000', 'closeTime': '1620252075144', 'firstId': '127218174', 'lastId': '127984402', 'count': '766229'}}

(Each contract represents 100 USD currently) As can be seen, in the info returned from Binance, baseVolume is 124050.44801330 and volume (in contracts) is 69172654. In ccxt's data, baseVolume is the volume in contracts. This is inconsistent with other markets. The baseVolume parameter should be derived from the baseVolume parameter in 'info'.

kroitor commented 3 years ago

In general, the baseVolume throughout CCXT is the same unit that is used for the amount in createOrder (not the volume in the underlying asset). And this is what most of the exchanges will report for the OHLCVs as well. I would suggest that we keep it as is, but add an option to redefine the baseVolume field in the ticker for user-specific purposes. What do you say?

diwenshi61 commented 3 years ago

I see your point. However, it can be illogical when the base defined for the market is in BTC, but the baseVolume is in a completely different currency. Perhaps the volume matches the units for amount should be named differently and added as an additional parameter.

kroitor commented 3 years ago

@diwenshi61 that is actually one of the aspects we're working on right now, namely, the unification of futures, obviously the base asset or the underlying asset must be treated differently in markets and elsewhere. This is a work in progress.

diwenshi61 commented 3 years ago

Thanks @kroitor. As well keep in mind for other exchanges currently: FTX does not report baseVolume so there aren't any problems. Bitmex is contract-based as well but baseVolume is not in contracts. Okex futures uses contracts and reports volume but ccxt doesn't seem to parse it.