polygon-io/client-python

Timestamps not unique when using RESTClient.list_aggs

aleathwick opened this issue · 2 comments

Describe the bug
I expected that results from RESTClient.list_aggs() would return only one result per timestamp. That is what I have observed most of the time, but I've found some exceptions. Apologies if I misunderstand something and this behaviour is expected.

To Reproduce
An example with multiple results per timestamp:

import polygon
client = polygon.RESTClient(api_key='insert_api_key_here')
aggs = []
for a in client.list_aggs(ticker='X:BTC-USD', multiplier=1, timespan='minute', from_=1664871240000 - 10, to=1664871240000 + 10):
    aggs.append(a)
aggs

from collections import Counter
Counter((a.timestamp for a in aggs))

Output:
Counter({1664871240000: 57, 1664871180000: 14})
I.e. there 57 entries for timestamp 1664871240000, and 14 with timestamp 1664871180000.
Each entry has different attributes, i.e. different open, high, low, close etc.

Expected behavior
I would have expected a single aggregate per timestamp.

Screenshots
image

@aleathwick thanks for reporting this. We're checking it out now. Also, thanks for the triage @qrpike.

@justinpolygon i observed this happened for crypto websocket data (XAS.*).
Duplicate timestamps maybe from different exchanges?