BitMEX / api-connectors

Libraries for connecting to the BitMEX API.
https://www.bitmex.com/app/restAPI
909 stars 798 forks source link

getBucked data inaccurate. #144

Open cryptoinminutes opened 6 years ago

cryptoinminutes commented 6 years ago

Im trying to get the last 20, 5-minutes candles from Bitmex but when i enter this same request through the Bitmex Explorer (https://www.bitmex.com/api/explorer/) or compare the results to the chart they differ. Is there a reason for this?

.client.Trade.Trade_getBucketed(
            binSize='5m',
            partial=True,
            symbol='XBT',
            count=20,  
            reverse=True
        ).result()[0]
ryanfox commented 6 years ago

Responses from testnet and bitmex.com may differ. The python client connects to testnet by default - are you sure you are comparing the same endpoint?

11bblandin commented 6 years ago

The results are as if 'reverse' is set to True, regardless of what is input. Is there a workaround for this?

ryanfox commented 6 years ago

If you specify any value for reverse (even False), the resulting request will have reverse=True. As a workaround, try removing that parameter:

client.Trade.Trade_getBucketed(binSize='5m', partial=True, symbol='XBT', count=20).result()[0]
h0wXD commented 6 years ago

You are correct, I am facing the same issue on LIVE. The getBucketed data differs from the one showing on the chart. For example for 2018-09-05T16:36:00.000Z XBTUSD 1m bucketed: O: 6978.5 H: 6979 L: 6977.5 C: 6977.5 chart: O: 6977.5 H: 6983 L: 6977.5 C: 6983 The data seems to be nowhere near. So which one of the two is correct? This seems to be an issue @ BitMEX side and not in the api-connector libraries, as even the api explorer is giving the wrong results. https://www.bitmex.com/api/v1/trade/bucketed?binSize=1m&partial=false&symbol=XBTUSD&count=1&reverse=false&startTime=2018-09-05%2016%3A36%3A00

SabitovIlyas commented 5 years ago

I have same trouble. I got bar from rest-api: https://www.bitmex.com/api/v1/trade/bucketed?binSize=1h&partial=false&symbol=XBTUSD&count=1&reverse=false&startTime=2018-10-29+12:00:00

Bar is "timestamp":"2018-10-29T12:00:00.000Z, open":6400,"high":6400.5,"low":6225,"close":6341.5. But on chart this bar has timestamp 2018-10-29T11:00:00.000Z.

Is it bug or feature?

Wolfofcryptos commented 5 years ago

same problem

v0l0dia commented 5 years ago

Bar is "timestamp":"2018-10-29T12:00:00.000Z, open":6400,"high":6400.5,"low":6225,"close":6341.5. But on chart this bar has timestamp 2018-10-29T11:00:00.000Z.

It's not a bug - it's because bitmex Trades API returns timestamp that is equal to Period's closing time. It's stated in their API explorer:

Implementation Notes Timestamps returned by our bucketed endpoints are the END of the period, indicating when the bucket was written to disk. Some other common systems use the timestamp as the beginning of the period. Please be aware of this when using this endpoint

slot-29 commented 5 years ago

Estoy tratando de obtener las últimas 20 velas de 5 minutos de Bitmex, pero cuando ingreso esta misma solicitud a través del Explorador de Bitmex ( https://www.bitmex.com/api/explorer/ ) o comparo los resultados con el gráfico, difieren . ¿Hay alguna razón para esto?

.client.Trade.Trade_getBucketed(
            binSize='5m',
            partial=True,
            symbol='XBT',
            count=20,  
            reverse=True
        ).result()[0]

Hello, although this is old ... I need to solve it ... bitmex does not give me the last candle but the previous one ... I don't know why ... nor how to solve it ...

jjalonso commented 4 years ago

any update in knowledge?

jeuxdemains commented 4 years ago

Use the endTime parameter to access certain candle at specific time. It's a bit confusing but the timestamp is the time at which the data is written down (which is when the candle is closing).

novecento commented 4 years ago

uhm, is this reliable? I mean, can I be sure in next "timeperiod" candle will be written?

tianrenhefa commented 4 years ago

has anyone fixed this problem? i've got problem in conecting to websocket and have to rely on rest api to get the last candle of 1m