V3 fills returns 4 formats for trade_time in 2023

Bit of an odd issue, but I was doing some data QA in preparation for year close… and I found some 400+ “missing trades” that my deployment had not picked up.

Upon closer inspection, it looks like the API returns 4 different types of datetime format for this year (Happens at various points, even as recently as this week), for the trade_time column:

2023-06-10T08:42:57Z
2023-06-11T00:14:58.092Z
2023-07-13T22:39:44.302696Z
2023-07-13T22:39:44.405968513Z
2023-12-15T22:37:23Z
2023-12-11T02:12:29.852Z
2023-12-15T23:43:06.994029Z

So… is there any logic that goes in to when we see nanoseconds? multiple fills in the same millisecond?

Is this expected to vary that much or is there an actual issue here that I should be submitting the order_ids for those weird trades?

My pull was successful and I triple checked the responses with and without cursor… the api responds with those values in trade_time

Using api from:
Coinbase Cloud
api_url_v3=‘https://api.coinbase.com/v3/brokerage/
message = timestamp + ‘GET’ + ‘/v3/brokerage/orders/historical/fills’

2 Likes

Hi @mrChuy,

The timestamp format you are seeing from the Advanced Trade API can indeed include up to nanosecond precision as indicated in your examples, although this level of precision is not always included. The variation in precision can be related to several factors such as the specific infrastructure the timestamp originated from and the particular event or action the timestamp is associated with.

It is expected behavior that the precision may vary. There is no specific logic tied to nanoseconds appearance relating to multiple fills in the same millisecond. The precision of the timestamps does not correlate to the occurrence of such events. If you are experiencing missing trades, it is unlikely that the variation in timestamp precision is the cause. Instead, issues such as network latencies, system outages, or API rate limits may be more likely causes.

However, if you still believe there is an issue with the trades, it is recommended that you submit the order_ids for those trades to Coinbase support for further investigation. When dealing with these timestamps in your code, aim to use parsing methods that can handle varying levels of precision for ISO 8601 timestamps, as most modern programming languages and their standard libraries should be able to.

1 Like

If you are experiencing missing trades

They were missing from my own deployment inserting them as I was using datetime.strptime and datetime only supports micro seconds, but not nanoseconds. PEP 410 – Use decimal.Decimal type for timestamps | peps.python.org , so my pod was failing to parse them and moving on… and it was rare enough (< 0.1%) that I had missed it.

It is expected behavior that the precision may vary.

Thank you, that answers it perfectly!

1 Like