Point-in-time fundamentals for backtesting, from SEC filings
Get a company's reported financials as they stood on any past date, and list every value that a later filing changed, with the accession behind each number.
A backtest that reads today's financials for a date in 2017 sees numbers nobody had in 2017. Companies restate: a new accounting standard, a reclassification or a correction makes a later filing report a different value for an old period. The /v1/financials/point-in-time endpoint returns, for each period, the latest value filed on or before the date you pass, with the accession of that filing. /v1/financials/restatements lists the periods whose number changed.
It works for one company per call. There is no cross-company screen as of a date, so a universe is built by looping over tickers. Values come from XBRL facts in periodic reports (10-K, 10-Q, 20-F, 40-F), not from press releases.
Setup
import os
import requests
H = {"Authorization": "Bearer " + os.environ["SECFEED_KEY"]}
BASE = "https://secfeedapi.com/v1"
The same year, seen from two dates
Microsoft's net income for the year ended June 2017, as known at the end of 2017 and at the end of 2018:
for asof in ("2017-12-31", "2018-12-31"):
r = requests.get(BASE + "/financials/point-in-time", headers=H,
params={"ticker": "MSFT", "asOf": asof, "concepts": "netIncome", "limit": 2}).json()
print("as of", asof)
for p in r["concepts"]["netIncome"]["periods"]:
print(" ", p["end"], p["value"], p["accessionNo"], "filed", p["filed"], "revised later:", p["laterRevisionExists"])
as of 2017-12-31
2017-06-30 21204000000 0001564590-17-014900 filed 2017-08-02 revised later: True
2016-06-30 16798000000 0001564590-17-014900 filed 2017-08-02 revised later: True
as of 2018-12-31
2018-06-30 16571000000 0001564590-18-019062 filed 2018-08-03 revised later: False
2017-06-30 25489000000 0001564590-18-019062 filed 2018-08-03 revised later: False
A model run on 2017-12-31 should use 21.2 billion for fiscal 2017. Reading the data a year later gives 25.5 billion. The flag laterRevisionExists tells you the number you just got was changed afterwards.
Every revised value
r = requests.get(BASE + "/financials/restatements", headers=H,
params={"ticker": "MSFT", "concepts": "netIncome", "minChangePct": 0.5}).json()
for x in r["restatements"]:
print(x["end"], f'{x["changePct"]:+.1f}%')
for v in x["versions"]:
print(" ", v["value"], v["accessionNo"], v["form"], v["filed"])
2016-06-30 +22.3%
16798000000 0001193125-16-662209 10-K 2016-07-28
20539000000 0001564590-18-019062 10-K 2018-08-03
2017-06-30 +20.2%
21204000000 0001564590-17-014900 10-K 2017-08-02
25489000000 0001564590-18-019062 10-K 2018-08-03
A changed value is not always an error. Here the later 10-K re-reported older years after an accounting standard change. Open the accession to see the reason.
Notes
conceptstakes the same names as/v1/key-metrics(revenue, netIncome, assets, equity and so on) or any XBRL tag, up to 12 per call.- When a company switches tags, the tag with the most recent period as of the date is used, and the response names it.
- Use
period=quarterlyfor quarters,instantfor balance sheet dates, orall. - Related: financial ratios from SEC filings for margins and returns with formulas.