feat(fred): get_revisions and get_release_calendar - #39
Merged
Conversation
Two tools for questions the raw API makes hard rather than merely verbose. get_revisions covers ALFRED. Asking FRED for vintages without a real-time window spanning the record fails with "No vintage dates exist for the specified real-time period", which reads like the series has no history rather than like a missing parameter. The tool sets the window itself; that one detail is most of its value. For a single observation it collapses the repeated vintages: Q3 2025 GDP has nine, of which eight are the same number, so it returns two entries and one revision of +1.877 rather than nine columns. Without a date it reports first-printed against current across recent observations. get_release_calendar splits into released and upcoming around today. It fetches the two halves as separate requests, which is not an optimization: one request across the whole window is truncated by limit before the split, and FRED returns dates ascending, so the truncation lands entirely on the future. The first version answered "50 released, 0 upcoming" for a window holding 385 scheduled releases, which is a confidently empty answer to half the question. Each half now carries its own limit and FRED's own total, so a limited page is visibly a page.
walkerhughes
force-pushed
the
fred/revisions
branch
from
August 6, 2026 01:19
6056470 to
997c505
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #34. Fourth of the
fredstack (#30), on top of #38. Last PR with code in it.Two tools for questions the raw API makes genuinely hard, not just verbose.
get_revisionsFRED is also ALFRED: it keeps every vintage of every number. "What did Q3 GDP originally print at, before the revisions?" is a real question, and answering it by hand means knowing that
output_type=4means initial-release-only and that it silently fails unless you also widen the real-time window:That message reads like the series has no revision history. It actually means a parameter is missing. The tool sets
realtime_start=1776-07-04&realtime_end=9999-12-31itself, and that single detail is most of its value.With
observation_date, it collapses the vintages.output_type=2returns one column per vintage, but a vintage exists for every publication of the series, not for every change to this observation, so most columns repeat the one before. Live, Q3 2025 GDP has nine vintages and one actual revision:Without one, first-printed against current across recent observations, which shows the revision pattern at a glance:
get_release_calendarWhat just came out, and what is next. Split around today, because those are two questions and comparing dates to tell them apart is work the caller should not do.
The bug worth reading about
The first version issued one request for the whole window and split the results locally. Live, that returned:
There were 385 scheduled releases in that window.
limittruncates before the split, and FRED returns dates ascending, so the truncation lands entirely on the future. The tool confidently answered "nothing is coming up" to the half of the question it exists for.Each half is now its own request with its own limit, and each reports FRED's own total so a limited page is visibly a page:
A purely historical window still costs one request, not two, and does not set
include_release_dates_with_no_data(without which FRED returns only dates that already produced data, which is the other way this tool can silently answer "nothing").release_idnarrows to one publication and names it, which closes the discovery loop:get_release_calendargives you release 50,search_series(release_id=50)lists every series it publishes.Verification
280 tests, 98% coverage,
make checkclean. Integration tests pin the clock to the fixture'sTODAY, so the released/upcoming split is deterministic rather than passing until the fixture ages out.The mock reproduces FRED's real-time-window failure, so the test asserting the window is set fails loudly if that parameter is ever dropped.