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
33.09k stars 7.55k forks source link

Bitmex symbol confused me #3667

Closed ishell closed 6 years ago

ishell commented 6 years ago

ATTENTION!!!

MUST READ THIS BEFORE SUBMITTING ISSUES:

https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-submit-an-issue

Bitmex's symbol confused me. I saw the sample python code to create order is used symbol = 'BTC/USD', While the bitmex doc is XBTUSD (try to get https://testnet.bitmex.com/api/v1/instrument/activeAndIndices) But when I use exchange.fetch_ohlcv('BTC/USD', '5m'), it seems return the worng data

[[1443182400000, None, None, None, None, 0], [1443182700000, None, None, None, None, 0], [1443183000000, None, None, None, None, 0], [1443183300000, None, None, None, None, 0], [1443183600000, None, None, None, None, 0], [1443183900000, None, None, None, None, 0], [1443184200000, 239.99, 239.99, 239.99, 239.99, 1], [1443184500000, 239.99, 237.43, 237.39, 237.39, 4500], [1443184800000, 237.39, 237.49, 237.37, 237.49, 2000], [1443185100000, 237.49, 237.47, 237.36, 237.45, 5000], [1443185400000, 237.45, 237.45, 237.45, 237.45, 0], [1443185700000, 237.45, 237.45, 237.45, 237.45, 0], [1443186000000, 237.45, 237.45, 237.45, 237.45, 0], [1443186300000, 237.45, 237.45, 237.45, 237.45, 0], [1443186600000, 237.45, 237.45, 237.45, 237.45, 0], [1443186900000, 237.45, 237.45, 237.45, 237.45, 0], [1443187200000, 237.45, 237.45, 237.45, 237.45, 0], [1443187500000, 237.45, 237.45, 237.45, 237.45, 0], [1443187800000, 237.45, 237.45, 237.45, 237.45, 0], [1443188100000, 237.45, 237.45, 237.45, 237.45, 0], [1443188400000, 237.45, 237.45, 237.45, 237.45, 0], [1443188700000, 237.45, 237.05, 237.05, 237.05, 125], [1443189000000, 237.05, 237.05, 237.05, 237.05, 0], [1443189300000, 237.05, 236.55, 236.08, 236.08, 22500], [1443189600000, 236.08, 236.26, 236.1, 236.1, 6420], [1443189900000, 236.1, 236.1, 236.1, 236.1, 0], [1443190200000, 236.1, 236.1, 236.1, 236.1, 0], [1443190500000, 236.1, 236.19, 236.19, 236.19, 1500], [1443190800000, 236.19, 236.36, 236.36, 236.36, 1500], [1443191100000, 236.36, 236.36, 236.36, 236.36, 514], [1443191400000, 236.36, 236.36, 236.36, 236.36, 0], [1443191700000, 236.36, 236.37, 236.25, 236.31, 6000], [1443192000000, 236.31, 236.52, 236.52, 236.52, 1000], [1443192300000, 236.52, 236.52, 236.52, 236.52, 0], [1443192600000, 236.52, 236.52, 236.52, 236.52, 0], [1443192900000, 236.52, 236.34, 236.34, 236.34, 500], [1443193200000, 236.34, 236.08, 236.08, 236.08, 1500], [1443193500000, 236.08, 236.13, 235.44, 235.44, 17500], [1443193800000, 235.44, 235.44, 235.44, 235.44, 0], [1443194100000, 235.44, 235.44, 235.44, 235.44, 0], [1443194400000, 235.44, 235.44, 235.44, 235.44, 0], [1443194700000, 235.44, 235.44, 235.44, 235.44, 0], [1443195000000, 235.44, 235.44, 235.44, 235.44, 0], [1443195300000, 235.44, 236.03, 236.03, 236.03, 1500], [1443195600000, 236.03, 236.1, 236.1, 236.1, 1700], [1443195900000, 236.1, 235.98, 235.98, 235.98, 500], [1443196200000, 235.98, 236, 235.71, 235.71, 4200], [1443196500000, 235.71, 235.71, 235.71, 235.71, 0], [1443196800000, 235.71, 235.71, 235.71, 235.71, 0], [1443197100000, 235.71, 235.7, 235.63, 235.7, 6000], [1443197400000, 235.7, 235.7, 235.7, 235.7, 0], [1443197700000, 235.7, 235.7, 235.7, 235.7, 0], [1443198000000, 235.7, 235.64, 235.46, 235.46, 3700], [1443198300000, 235.46, 235.46, 235.46, 235.46, 0], [1443198600000, 235.46, 235.46, 235.46, 235.46, 0], [1443198900000, 235.46, 235.94, 235.74, 235.94, 10500], [1443199200000, 235.94, 236.01, 235.89, 236.01, 6000], [1443199500000, 236.01, 236.01, 236.01, 236.01, 0], [1443199800000, 236.01, 236.01, 236.01, 236.01, 0], [1443200100000, 236.01, 235.8, 235.75, 235.75, 3000], [1443200400000, 235.75, 235.75, 235.75, 235.75, 0], [1443200700000, 235.75, 235.75, 235.75, 235.75, 0], [1443201000000, 235.75, 236.21, 235.98, 236.21, 11500], [1443201300000, 236.21, 236.21, 236.21, 236.21, 500], [1443201600000, 236.21, 236.21, 236.21, 236.21, 0], [1443201900000, 236.21, 236.21, 236.21, 236.21, 1500], [1443202200000, 236.21, 236.21, 236.21, 236.21, 0], [1443202500000, 236.21, 236.21, 236.21, 236.21, 0], [1443202800000, 236.21, 236.21, 236.21, 236.21, 0], [1443203100000, 236.21, 235.8, 235.69, 235.8, 4500], [1443203400000, 235.8, 235.6, 235.6, 235.6, 2200], [1443203700000, 235.6, 235.6, 235.6, 235.6, 135], [1443204000000, 235.6, 235.6, 235.6, 235.6, 0], [1443204300000, 235.6, 235.85, 235.85, 235.85, 1500], [1443204600000, 235.85, 235.85, 235.85, 235.85, 0], [1443204900000, 235.85, 235.85, 235.85, 235.85, 0], [1443205200000, 235.85, 235.85, 235.85, 235.85, 0], [1443205500000, 235.85, 235.85, 235.85, 235.85, 0], [1443205800000, 235.85, 236, 236, 236, 1000], [1443206100000, 236, 236.01, 236, 236.01, 1500], [1443206400000, 236.01, 236.08, 236.01, 236.08, 10000], [1443206700000, 236.08, 236.11, 236.08, 236.11, 10150], [1443207000000, 236.11, 235.97, 235.97, 235.97, 1], [1443207300000, 235.97, 236.15, 236.1, 236.1, 1540], [1443207600000, 236.1, 236.1, 236.1, 236.1, 0], [1443207900000, 236.1, 236.12, 236.12, 236.12, 1500], [1443208200000, 236.12, 236.12, 236.12, 236.12, 0], [1443208500000, 236.12, 236.12, 236.12, 236.12, 0], [1443208800000, 236.12, 236.12, 236.12, 236.12, 0], [1443209100000, 236.12, 236.12, 236.12, 236.12, 0], [1443209400000, 236.12, 236, 236, 236, 1500], [1443209700000, 236, 236, 236, 236, 0], [1443210000000, 236, 235.44, 235.44, 235.44, 1500], [1443210300000, 235.44, 235.44, 235.44, 235.44, 0], [1443210600000, 235.44, 235.44, 235.44, 235.44, 0], [1443210900000, 235.44, 235.44, 235.44, 235.44, 0], [1443211200000, 235.44, 235.44, 235.44, 235.44, 0], [1443211500000, 235.44, 235.66, 235.44, 235.44, 600], [1443211800000, 235.44, 235.27, 235.27, 235.27, 39], [1443212100000, 235.27, 235.43, 235.43, 235.43, 1500]]

kroitor commented 6 years ago

Bitmex's symbol confused me.

Please, read the Manual first, it's all explained there:

(I'd highly recommend to read the entire Manual from the very beginning to the very end, it will save you a ton of time. Actually, you won't really be able to use this library without reading the Manual first. No shortcuts here, unfortunately.)

Then, please, follow here: https://github.com/ccxt/ccxt/issues/3540

ishell commented 6 years ago

The fetch_ohlcv seems still wrong. At this time btc price is above 6300, the data is return 235, is I used wrong? ohlcv5 = bitmex.fetch_ohlcv('BTC/USD','5m')

kroitor commented 6 years ago

@ishell we don't change the data and we return you what the exchange itself replies with, you can verify this in verbose mode:

python examples/py/cli.py bitmex fetch_ohlcv BTC/USD 5m --verbose

or by following here from your browser: https://www.bitmex.com/api/v1/trade/bucketed?symbol=XBTUSD&binSize=5m&partial=true

The verbose mode is also documented in the Manual, btw: https://github.com/ccxt/ccxt/wiki/Manual#exchange-properties

So, I guess, you should rather forward this question to BitMEX?

kroitor commented 6 years ago

@ishell just to be clear, you're looking at prices from year 2015. Read the Manual on fetchOHLCV:

kroitor commented 6 years ago

@ishell from the above, I'm afraid, it follows that you can't really skip reading the entire Manual first )) Let us know if you have questions left after that ;)

ishell commented 6 years ago

@kroitor Thx, i will read the ccxt doc first.