% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/download_data_risk_free.R
\name{download_data_risk_free}
\alias{download_data_risk_free}
\title{Download Risk-Free Rate Data}
\usage{
download_data_risk_free(
  start_date = NULL,
  end_date = NULL,
  frequency = "monthly"
)
}
\arguments{
\item{start_date}{Optional. A character string or Date object in
"YYYY-MM-DD" format specifying the start date for the data. If
not provided, the full dataset is returned.}

\item{end_date}{Optional. A character string or Date object in
"YYYY-MM-DD" format specifying the end date for the data. If not
provided, the full dataset is returned.}

\item{frequency}{A character string, either \code{"monthly"} (default)
or \code{"daily"}, specifying the frequency of the returned data. Daily
data starts in 1954-01-04 because of availability of DTB3, while
monthly data starts in 1934-01-01.}
}
\value{
A tibble with two columns:
\describe{
\item{date}{The date of the observation.}
\item{risk_free}{The risk-free rate for the period.}
}
}
\description{
Downloads pre-processed risk-free rate data from the
\code{tidy-finance/risk-free} dataset on HuggingFace. The dataset is
updated monthly via a scheduled GitHub Actions workflow that splices the
3-Month Treasury Bill Secondary Market Rate (pre-2001) with the 4-Week
Treasury Bill Secondary Market Rate (from 2001 onwards) sourced from FRED.
For monthly data, the monthly TB3MS series is spliced with the daily DTB4WK
series aggregated to month-end. For daily data, the daily DTB3 series is
spliced with the daily DTB4WK series, both at the business-day frequency
provided by FRED.
}
\details{
Both series are quoted as annualised bank discount rates on a
360-day basis. Given an annualised discount rate \code{d} and a T-bill
with \code{n} days to maturity, the holding-period return is
\code{HPR = d * n/360 / (1 - d * n/360)}, which is then converted to the
target period length via \code{(1 + HPR)^(target/source) - 1}.

The series are spliced at 2001-07-01:
\itemize{
\item \strong{Pre-2001}: TB3MS (monthly) or DTB3 (daily), 3-month T-bill
with n = 90. Monthly conversion uses exponent \code{1/3}; daily
conversion uses exponent \code{1/63} (approx. trading days per
quarter).
\item \strong{From 2001}: DTB4WK, 4-week T-bill with n = 28. For monthly
data, the last non-NA observation per calendar month is taken
and the exponent is \code{365/(28*12)}. For daily data, observations
are used as-is and the exponent is \code{1/20} (approx. trading days
per 4-week period).
}

Business-day gaps in the daily series (e.g. holidays) are handled
by forward-filling the most recent available rate.

Monthly data starts in 1934-01-01 (TB3MS). Daily data starts in
1954-01-04 due to the availability of DTB3.
}
\examples{
\donttest{
  download_data_risk_free("2020-01-01", "2020-12-31")
  download_data_risk_free(
    "2020-01-01", "2020-12-31", frequency = "daily"
  )
}
}
\seealso{
Other download functions: 
\code{\link{download_data}()},
\code{\link{download_data_constituents}()},
\code{\link{download_data_factors_ff}()},
\code{\link{download_data_factors_q}()},
\code{\link{download_data_fred}()},
\code{\link{download_data_huggingface}()},
\code{\link{download_data_macro_predictors}()},
\code{\link{download_data_osap}()},
\code{\link{download_data_stock_prices}()}
}
\concept{download functions}
