XChange icon indicating copy to clipboard operation
XChange copied to clipboard

Trades timestamps

Open kzbikowski opened this issue 11 years ago • 5 comments

Guys, I think that in UserTrade the field timestamp has at least incorrect description: "The timestamp when the order was placed. Exchange matching is usually price first then timestamp asc to clear older orders". Trades are usually provided with order id so obtaining placement time is not a problem at all. What one would like to know asking about trades is the time of trade's execution and that's what it should be I suppose. In case of several exchanges, we map trades execution time (i.e. Kraken) but I'm not sure about all of them. I guess it should be well-defined not to leave any place for doubts. If indeed we need a timestamp of an order (I don't think it's necessary) then we should consider adding execution time.

kzbikowski avatar May 18 '15 09:05 kzbikowski

I agree. I think the parameter description you quoted is just a copy and paste mistake, the javadoc on the actual Trade timestamp member variable says "The timestamp of the trade". I have a vague recollection of fixing this problem in at least one implementation, and see you've opened a pull request to do the same for Independent Reserve. I can confirm the trade timestamp is OK for: BTC-E, Bitfinex, Kraken, Cryptsy and Poloniex. You'll have to check it is correct on any other exchanges you are interested in.

Just to add - I think this (and other) timestamps should in UTC time. If you decide to fix the javadoc and no one disagrees perhaps you could mention this there too. "The timestamp of the trade (UTC zone)"

ww3456 avatar May 18 '15 12:05 ww3456

Thanks for the list of exchanges that are ok. If anyone knows about some incorrectly implemented ones post them here and I'll try to take care. For now I'd change javadoc and investigate several other exchanges that I'm familiar with.

kzbikowski avatar May 18 '15 14:05 kzbikowski

@kzbikowski Thanks, sounds reasonable. How we (try to) handle timestamps in general in XChange is to either use a server time if that was provided or otherwise set to the timestamp/date to null. Overall, timestamp usage between exchanges is very inconsistent (some provide timestamps, some date strings in various formats and timezones). Like this client libraries can rely on if XChange does provide a timestamp it's from an exchange server and the client can decide what to do if a timestamp is missing.

jheusser avatar May 19 '15 09:05 jheusser

Thanks @jheusser for explaining. I should add a sentence or two in the README about timestamps in XChange. I was also thinking about renaming the variable to serverTimestamp to make it more obvious. Added here: https://github.com/timmolter/XChange/issues/933

timmolter avatar May 22 '15 08:05 timmolter

I improved the Javadocs for this.

timmolter avatar Aug 09 '15 12:08 timmolter