| Title: | Fetch Economic and Financial Time Series Data from Public Sources |
|---|---|
| Description: | Download economic and financial time series from public sources, including the St Louis Fed's FRED system, Yahoo Finance, the US Bureau of Labor Statistics, the US Energy Information Administration, the World Bank, Eurostat, the European Central Bank, the Bank of England, the UK's Office of National Statistics, Deutsche Bundesbank, and INSEE. |
| Authors: | Abiel Reinhart [aut, cre] |
| Maintainer: | Abiel Reinhart <[email protected]> |
| License: | GPL |
| Version: | 0.3.3 |
| Built: | 2026-06-06 09:20:32 UTC |
| Source: | https://github.com/abielr/pdfetch |
Download economic and financial time series from public sources
Fetch data from U.S. Bureau of Labor Statistics
pdfetch_BLS(identifiers, from, to)pdfetch_BLS(identifiers, from, to)
identifiers |
a vector of BLS time series IDs |
from |
start year |
to |
end year. Note that the request will fail if this is a future year that is beyond the last available data point in the series. |
a xts object
## Not run: pdfetch_BLS(c("EIUIR","EIUIR100"), 2005, 2010) ## End(Not run)## Not run: pdfetch_BLS(c("EIUIR","EIUIR100"), 2005, 2010) ## End(Not run)
Fetch data from the Bank of England Interactive Statistical Database
pdfetch_BOE(identifiers, from, to = Sys.Date())pdfetch_BOE(identifiers, from, to = Sys.Date())
identifiers |
a vector of BoE series codes |
from |
start date |
to |
end date; if not given, today's date will be used |
a xts object
http://www.bankofengland.co.uk/boeapps/iadb/
## Not run: pdfetch_BOE(c("LPMVWYR", "LPMVWYR"), "2012-01-01") ## End(Not run)## Not run: pdfetch_BOE(c("LPMVWYR", "LPMVWYR"), "2012-01-01") ## End(Not run)
Fetch data from the Deutsche Bundesbank
pdfetch_BUNDESBANK(identifiers)pdfetch_BUNDESBANK(identifiers)
identifiers |
a vector of series codes |
a xts object
https://www.bundesbank.de/en/statistics/time-series-databases
## Not run: pdfetch_BUNDESBANK(c("BBNZ1.Q.DE.Y.H.0000.A","BBK01.BJ9069")) ## End(Not run)## Not run: pdfetch_BUNDESBANK(c("BBNZ1.Q.DE.Y.H.0000.A","BBK01.BJ9069")) ## End(Not run)
Fetch data from European Central Bank's statistical data warehouse
pdfetch_ECB(identifiers)pdfetch_ECB(identifiers)
identifiers |
a vector of ECB series IDs |
a xts object
## Not run: pdfetch_ECB("FM.B.U2.EUR.4F.KR.DFR.CHG") ## End(Not run)## Not run: pdfetch_ECB("FM.B.U2.EUR.4F.KR.DFR.CHG") ## End(Not run)
Fetch data from the US Energy Information Administration
pdfetch_EIA(identifiers, api_key)pdfetch_EIA(identifiers, api_key)
identifiers |
a vector of EIA series codes |
api_key |
EIA API key |
a xts object. Note that for hourly series the time zone will always be set to GMT, whereas the true time zone may be different. If you wish to use the correct time zone you must manually convert it.
## Not run: pdfetch_EIA(c("ELEC.GEN.ALL-AK-99.A","ELEC.GEN.ALL-AK-99.Q"), EIA_KEY) ## End(Not run)## Not run: pdfetch_EIA(c("ELEC.GEN.ALL-AK-99.A","ELEC.GEN.ALL-AK-99.Q"), EIA_KEY) ## End(Not run)
Eurostat stores its statistics in data cubes, which can be browsed at https://ec.europa.eu/eurostat/data/database. To access data, specify the name of a data cube and optionally filter it based on its dimensions.
pdfetch_EUROSTAT(flowRef, from, to, ...)pdfetch_EUROSTAT(flowRef, from, to, ...)
flowRef |
Eurostat dataset code |
from |
a Date object or string in YYYY-MM-DD format. If supplied, only data on or after this date will be returned |
to |
a Date object or string in YYYY-MM-DD format. If supplied, only data on or before this date will be returned |
... |
optional dimension filters for the dataset |
a xts object
## Not run: pdfetch_EUROSTAT("namq_gdp_c", FREQ="Q", S_ADJ="NSA", UNIT="MIO_EUR", INDIC_NA="B1GM", GEO=c("DE","UK")) ## End(Not run)## Not run: pdfetch_EUROSTAT("namq_gdp_c", FREQ="Q", S_ADJ="NSA", UNIT="MIO_EUR", INDIC_NA="B1GM", GEO=c("DE","UK")) ## End(Not run)
Fetch description for a Eurostat dataset
pdfetch_EUROSTAT_DSD(flowRef)pdfetch_EUROSTAT_DSD(flowRef)
flowRef |
Eurostat dataset code |
## Not run: pdfetch_EUROSTAT_DSD("namq_gdp_c") ## End(Not run)## Not run: pdfetch_EUROSTAT_DSD("namq_gdp_c") ## End(Not run)
Fetch data from St Louis Fed's FRED database
pdfetch_FRED(identifiers)pdfetch_FRED(identifiers)
identifiers |
a vector of FRED series IDs |
a xts object
## Not run: pdfetch_FRED(c("GDPC1", "PCECC96")) ## End(Not run)## Not run: pdfetch_FRED(c("GDPC1", "PCECC96")) ## End(Not run)
Fetch data from the French National Institute of Statistics and Economic Studies (INSEE)
pdfetch_INSEE(identifiers)pdfetch_INSEE(identifiers)
identifiers |
a vector of INSEE series codes |
a xts object
https://www.insee.fr/en/accueil
## Not run: pdfetch_INSEE(c("000810635")) ## End(Not run)## Not run: pdfetch_INSEE(c("000810635")) ## End(Not run)
The ONS maintains multiple data products; this function can be used to retrieve data from the Time Series Explorer, see https://www.ons.gov.uk/timeseriestool
pdfetch_ONS(identifiers, dataset)pdfetch_ONS(identifiers, dataset)
identifiers |
a vector of ONS series codes |
dataset |
optional ONS dataset name, only used if a time series is available in multiple datasets. |
a xts object
## Not run: pdfetch_ONS(c("LF24","LF2G"), "lms") ## End(Not run)## Not run: pdfetch_ONS(c("LF24","LF2G"), "lms") ## End(Not run)
Fetch data from World Bank
pdfetch_WB(indicators, countries = "all")pdfetch_WB(indicators, countries = "all")
indicators |
a vector of World Bank indicators |
countries |
a vector of country identifiers, which can be 2- or 3-character ISO codes. The special option "all" retrieves all countries. |
a xts object
## Not run: pdfetch_WB("NY.GDP.MKTP.CD", c("BR","MX")) ## End(Not run)## Not run: pdfetch_WB("NY.GDP.MKTP.CD", c("BR","MX")) ## End(Not run)
Fetch data from Yahoo Finance
pdfetch_YAHOO( identifiers, fields = c("open", "high", "low", "close", "adjclose", "volume"), from = as.Date("2007-01-01"), to = Sys.Date(), interval = c("1d", "1wk", "1mo", "daily", "weekly", "monthly") )pdfetch_YAHOO( identifiers, fields = c("open", "high", "low", "close", "adjclose", "volume"), from = as.Date("2007-01-01"), to = Sys.Date(), interval = c("1d", "1wk", "1mo", "daily", "weekly", "monthly") )
identifiers |
a vector of Yahoo Finance tickers |
fields |
can be any of "open", "high", "low", "close", "volume", or "adjclose" |
from |
a Date object or string in YYYY-MM-DD format. If supplied, only data on or after this date will be returned |
to |
a Date object or string in YYYY-MM-DD format. If supplied, only data on or before this date will be returned |
interval |
the frequency of the return data, can be '1d', '1wk', or '1mo' |
a xts object
## Not run: pdfetch_YAHOO(c("^gspc","^ixic")) pdfetch_YAHOO(c("^gspc","^ixic"), "adjclose") ## End(Not run)## Not run: pdfetch_YAHOO(c("^gspc","^ixic")) pdfetch_YAHOO(c("^gspc","^ixic"), "adjclose") ## End(Not run)