client-python icon indicating copy to clipboard operation
client-python copied to clipboard

Confusions about the timestamp

Open eiphy opened this issue 1 year ago • 7 comments

Describe the bug The timestamp returned from polygon does not make sense to me. After converting to normal datetime object, it spans from 0am to 8am and then 17pm to 23pm. However, the core trading time of NASDAQ should be 1430pm to 21pm in UTC. And the volume values are quite large in intertrading time.

To Reproduce Use this python script to reproduce:

import datetime

import pandas as pd
from polygon import RESTClient

client = RESTClient(api_key=# KEY)
aggs = client.get_aggs("AAPL", 1, "hour", from_="2023-05-01", to="2023-06-01", limit=50000)
data = []
for agg in aggs:
    data.append(
        {
            "datetime": datetime.datetime.fromtimestamp(agg.timestamp / 1000),
            "close": agg.close,
            "volumne": agg.volume,
        }
    )
df = pd.DataFrame(data)
df = df.set_index("datetime")
df = df.sort_index()
print(df.iloc[0:60])

Expected behavior Data should be within the core trading time, i.e., 1430 to 2100

Screenshots An example: image

Additional context N.A.

eiphy avatar Mar 10 '24 04:03 eiphy