View source: R/stocksharpe_ratio.R
stock.sharpe.ratio | R Documentation |
It is a function that represents the sharpe ratio of a portfolio composed of two stocks in a given data frame. The Sharpe index is a metric that measures the extra return realized by a portfolio (or fund) per unit of total risk borne in comparison to the risk-free rate. This function has been created calculating the ratio between the difference between the portfolio return and risk free rate and the standard deviation of the portfolio.
stock.sharpe.ratio(ticker, from, to, risk_free, weights)
ticker |
A character vector of length two storing tickers of the stocks of which you want the z-score Note that since data are downloaded from Yahoo finance, the ticker should be the same as the ones reported on Yahoo finance. See examples. |
from |
A single character variable storing the starting date from which we want to download the data. The format should be "yyyy-mm-dd" |
to |
A single character variable storing the ending date from which we want to download the data. The format should be "yyyy-mm-dd" |
risk_free |
Numerical variable of length one. It indicates the risk free rate |
weights |
Numerical vector of length two. It indicates the weight that each stock has |
## Not run:
stock.sharpe.ratio( ticker = c("NFLX","AMZN"), weights=c(0.50,0.50),
from="2010-01-01", to="2022-01-01", risk_free = 0.05)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.