Skip to content

Commit

Permalink
adjusting for new download links
Browse files Browse the repository at this point in the history
  • Loading branch information
enweg committed Feb 23, 2025
1 parent c9d967e commit 7aae92b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
20 changes: 15 additions & 5 deletions src/md.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,25 @@ struct FredMD

function FredMD(d::Date)
vintage = Dates.format(d, dateformat"yyyy-mm")
url = "https://files.stlouisfed.org/files/htdocs/fred-md/monthly/$(vintage).csv"
fred_md = CSV.read(download(url), DataFrame)
original, tcodes, transformed = load_fred_md(fred_md)
new(original, transformed, tcodes)
urls = [
"https://files.stlouisfed.org/files/htdocs/fred-md/monthly/$(vintage).csv",
"https://www.stlouisfed.org/-/media/project/frbstl/stlouisfed/research/fred-md/monthly/$(vintage).csv"
]
for url in urls
try
fred_md = CSV.read(download(url), DataFrame)
original, tcodes, transformed = load_fred_md(fred_md)
return new(original, transformed, tcodes)
catch
continue
end
end
error("Could not download Fred MD data for vintage $(vintage).")
end

function FredMD()
@info "Retrieving the most recent FRED MD data. \n For publishable research it is better to specify the vintage using FredMD(d::Date)."
url = "https://files.stlouisfed.org/files/htdocs/fred-md/monthly/current.csv"
url = "https://www.stlouisfed.org/-/media/project/frbstl/stlouisfed/research/fred-md/monthly/current.csv"
fred_md = CSV.read(download(url), DataFrame)
original, tcodes, transformed = load_fred_md(fred_md)
new(original, transformed, tcodes)
Expand Down
20 changes: 15 additions & 5 deletions src/qd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,25 @@ struct FredQD

function FredQD(d::Date)
vintage = Dates.format(d, dateformat"yyyy-mm")
url = "https://files.stlouisfed.org/files/htdocs/fred-md/quarterly/$(vintage).csv"
fred_qd = CSV.read(download(url), DataFrame)
original, tcodes, transformed = load_fred_qd(fred_qd)
new(original, transformed, tcodes)
urls = [
"https://files.stlouisfed.org/files/htdocs/fred-md/quarterly/$(vintage).csv",
"https://www.stlouisfed.org/-/media/project/frbstl/stlouisfed/research/fred-md/quarterly/$(vintage).csv"
]
for url in urls
try
fred_qd = CSV.read(download(url), DataFrame)
original, tcodes, transformed = load_fred_qd(fred_qd)
return new(original, transformed, tcodes)
catch
continue
end
end
error("Could not download Fred QD data for vintage $(vintage).")
end

function FredQD()
@info "Retrieving the most recent FRED QD data. \n For publishable research it is better to specify the vintage using FredQD(d::Date)."
url = "https://files.stlouisfed.org/files/htdocs/fred-md/quarterly/current.csv"
url = "https://www.stlouisfed.org/-/media/project/frbstl/stlouisfed/research/fred-md/quarterly/current.csv"
fred_qd = CSV.read(download(url), DataFrame)
original, tcodes, transformed = load_fred_qd(fred_qd)
new(original, transformed, tcodes)
Expand Down

0 comments on commit 7aae92b

Please sign in to comment.