Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General Question about fetchOrderBook and timestamps #1852

Closed
wannesdemaeght opened this issue Feb 9, 2018 · 3 comments
Closed

General Question about fetchOrderBook and timestamps #1852

wannesdemaeght opened this issue Feb 9, 2018 · 3 comments
Assignees
Labels

Comments

@wannesdemaeght
Copy link
Contributor

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?

@kroitor kroitor self-assigned this Feb 9, 2018
@wannesdemaeght
Copy link
Contributor Author

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

@kroitor
Copy link
Member

kroitor commented Feb 9, 2018

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.

@wannesdemaeght
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants