Ccxt: General Question about fetchOrderBook and timestamps

Created on 9 Feb 2018  路  3Comments  路  Source: ccxt/ccxt

How can we make sure that the info received is uptodate?

When I deduct timestamp from new Date, for some exchanges i always get 0 as result.
This means that that particular timestamp is generated on my pc, and not sent by the exchange.

Which leads me to my question: If a timestamp is generated on my pc, what's the use of it?
Is there a better way to check that I am getting the latest orderbook?

question

Most helpful comment

Hi!

Thx for the question!

Initially the orderbook timestamp was designed to store the date returned from the exchange, however, many exchanges do not return any date at all, so the timestamp is filled with the client's timestamp upon receiving their response. But you are right, there's very little point in having a client timestamp there, so we think of setting it to undefined (None/null) if it isn't explicitly indicated in the answer. Some exchanges also report timestamps in headers, which complicates it a little bit. And still, I think we are going to unset the unknown values, so that the user could then detect if the timestamp is present and decide from there.

All 3 comments

for (let name in Exchanges.All){
    for (let coin in coins){
        exch[name].fetchL2OrderBook(Market[coin]).then((result) => {
            console.log(name, Market[coin], new Date() - result.timestamp);
        });
    };
};

Bitstamp LTC/BTC 4829
Kraken XRP/BTC 0
Bittrex LTC/BTC 0
Bittrex ETH/BTC 0
Bittrex XRP/BTC 0
Bitstamp BCH/BTC 3860
Bitstamp ETH/BTC 2876
Bitstamp XRP/BTC 3907
Gdax LTC/BTC 0
Bittrex BCH/BTC 0
Gdax ETH/BTC 0
Gdax BCH/BTC 0
Binance BCH/BTC 0
Binance LTC/BTC 0
Kraken BCH/BTC 0
Binance ETH/BTC 0
Binance XRP/BTC 0
Kucoin ETH/BTC 0
Kucoin LTC/BTC 0
Kucoin BCH/BTC 0
Kraken ETH/BTC 0
Kraken LTC/BTC 0

Hi!

Thx for the question!

Initially the orderbook timestamp was designed to store the date returned from the exchange, however, many exchanges do not return any date at all, so the timestamp is filled with the client's timestamp upon receiving their response. But you are right, there's very little point in having a client timestamp there, so we think of setting it to undefined (None/null) if it isn't explicitly indicated in the answer. Some exchanges also report timestamps in headers, which complicates it a little bit. And still, I think we are going to unset the unknown values, so that the user could then detect if the timestamp is present and decide from there.

As I suspected 馃槈
I think it would be better to return the exchange timestamp. When there is none, return undefined.

The only usecase I can see for client timestamps is WS.

Was this page helpful?
0 / 5 - 0 ratings