Skip to content
AllTick
Troubleshooting

US Stock Timestamps, DST & Trading Hours

Correctly process US equity timestamps by storing UTC, converting via America/New_York for Daylight Saving Time, and aligning daily K-line dates.

Updated:
Maintained by:AllTick Technical Team
Audience:Developers handling US equity timestamps, charts, and session boundaries

Core Takeaway · 30-Second Brief

US equity sessions follow Eastern Time (America/New_York) and shift by one hour twice a year for Daylight Saving Time (DST). Always store raw API timestamps in UTC and convert to America/New_York using a timezone database (such as Python zoneinfo) rather than hardcoded UTC offsets.

01

First Verify Timestamp Units (Seconds vs Milliseconds)

Market APIs typically return Unix epoch timestamps in seconds (10 digits) or milliseconds (13 digits). AllTick’s tick_time field uses milliseconds. Treating milliseconds as seconds shifts dates into the far future, while treating seconds as milliseconds lands in January 1970.

pythonpython
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
def parse_ts(value: str | int) -> datetime:
ts = int(value)
if ts > 10**12:
ts = ts / 1000
return datetime.fromtimestamp(ts, tz=timezone.utc)
utc = parse_ts("1760103000000")
print(utc.isoformat())
print(utc.astimezone(ZoneInfo("America/New_York")).isoformat())
print(utc.astimezone(ZoneInfo("Asia/Shanghai")).isoformat())

02

US Trading Sessions Across Daylight Saving Time

Session (US Eastern)EDT (Summer · UTC-4 / UTC+8)EST (Winter · UTC-5 / UTC+8)
Pre-Market 04:00 – 09:3008:00 – 13:30 UTC (16:00 – 21:30 CST)09:00 – 14:30 UTC (17:00 – 22:30 CST)
Regular 09:30 – 16:0013:30 – 20:00 UTC (21:30 – 04:00+1 CST)14:30 – 21:00 UTC (22:30 – 05:00+1 CST)
After-Hours 16:00 – 20:0020:00 – 00:00+1 UTC (04:00 – 08:00+1 CST)21:00 – 01:00+1 UTC (05:00 – 09:00+1 CST)

03

Assigning Daily K-Line Dates Correctly

Because the regular US trading session crosses midnight in Asian timezones (and late evening in UTC), slicing daily bars by local midnight splits a single US trading day across two calendar dates. Always bucket daily US equity bars by the trading date in America/New_York.

04

Implementation Checklist

  • Confirm whether each endpoint returns seconds or milliseconds.
  • Persist all timestamps in UTC (or timezone-aware types).
  • Use America/New_York for session filtering and trading-day bucketing.
  • Test market open/close boundaries across both March and November DST transitions.
  • Explicitly separate pre-market, regular, and after-hours ticks according to product requirements.

Sources & Verification · 2026-10-13

Relevant endpoint, field, and exchange rules were checked against the primary specifications linked below.

Python examples passed ast.parse on Python 3.14.0. This checks syntax only; dependencies, runtime compatibility, and network responses were not tested.

Authenticated AllTick requests and production end-to-end tests were not run for this review. Record your token plan, library versions, market session, ret/trace, and observed results when reproducing these checks.

Reproduce before deployment

  • Test both US DST transitions with America/New_York. Store timezone-aware UTC and derive the exchange-local trading date instead of applying a fixed offset.
  • Check holidays, half-days, and extended-session coverage. K-line timestamp seconds and trade tick_time milliseconds must be normalized separately.