DEV Community

Quantooox
Quantooox

Posted on

The SEC timestamp that was shifted twice: a point-in-time data bug

A backtest is only honest if every piece of data enters it at the moment it became public. For company filings that moment is the SEC's acceptance time. We use the EDGAR submissions API's acceptanceDateTime field, and it was wrong.

The symptom

Apple's 8-K was accepted at 16:30:41 Eastern on 30 April 2026, according to the EDGAR filing index page. The API served it as 2026-05-01T00:30:41Z. The correct UTC time is 20:30:41. The API's value is the Eastern time converted to UTC twice (+4 hours, then +4 again).

Another filing accepted at 16:30:33 Eastern on 29 January (winter, UTC−5) came back as 02:30:33 the next day: shifted +5 twice. Same pattern.

Why it matters

Shifted eight hours late, an after-close filing lands in the next trading day. In a backtest that is conservative (the data looks later than it was), but for anything that measures the market's reaction to a filing, it attributes the move to the wrong day.

The fix

t = pd.to_datetime(raw.str.slice(0, 19)).dt.tz_localize("UTC")
once = t.dt.tz_convert("America/New_York").dt.tz_localize(None).dt.tz_localize("UTC")   # undo one shift
true = (once.dt.tz_convert("America/New_York").dt.tz_localize(None)
            .dt.tz_localize("America/New_York", ambiguous="NaT", nonexistent="NaT").dt.tz_convert("UTC"))
Enter fullscreen mode Exit fullscreen mode

Undo one shift, then read the result as Eastern time. A unit test pins the two filings above against their index pages.

General lesson: never trust a timestamp field until you've checked a few against a primary source. A whole class of look-ahead and look-behind bugs lives in timezone handling.


From Quantooo Lab, the makers of quantooo.com, a free, open and educational quant lab: every formula, every test and every failure is public. See it here: https://quantooo.com/method

Educational, not investment advice.

Top comments (1)

Collapse
 
stockpearl profile image
StockPearl •

good catch, and the kind of bug you only find by checking against the filing index page. nice that you noticed the shift follows daylight saving too, a fixed-offset fix would have looked right in summer and quietly drifted in winter.

i've gotten into the habit of keeping a few known after-close filings as fixtures for exactly this. did you check whether older filings in the archive have the same double shift, or only recent ones?