annual_return | R Documentation |
This function takes a vector of asset returns and computes annual returns.
annual_return(vec)
vec |
a numeric vector of asset returns as an xts object with dates as rownames. |
A numeric vector of annual returns.
weekly_return
, monthly_return
# Compute annual returns of an asset vector
require(xts)
asset_returns_xts <- xts(c(29.2, 30.0, 36.2, 30.4, 38.5, -35.6, 34.5),
order.by = as.Date(c("2017-05-07", "2018-05-07", "2019-05-07",
"2020-05-07", "2021-05-07", "2022-05-07",
"2023-05-07")))
annual_return(asset_returns_xts)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.