mcPrt {TSEtools} | R Documentation |
Matrix Conversion in Portfolio
Description
mcPrt function compound the vector of assets in matrix form to using the multivariate data analysis. The assets must be included the items of Open
, Close
, High
, Low
and Volumn
. The function also calculate the rate of return and Sharpe ratio for portfolio selection.
Usage
mcPrt(asset, sub = "::", pstvRtn = FALSE, pr = "daily", Rf = 0.0)
Arguments
asset |
a character vector of symbols. |
sub |
The character string in the form of "start date :: end date". The date format is "%Y-%M-%D". Since, the data is time series format, the rules of xts satisfied. |
pstvRtn |
logical flag to determine, if the symbols with mean of return (see, details) should be positive/negative. Missing value is taken as false. By setting |
pr |
a character specifying the desired period time of return. Default value is daily. The values get "daily", "weekly" and "monthly". |
Rf |
an integer value to give risk free. |
Details
The values of function contain Sharpe ratio and rate of return. Sharpe ratio is defined as:
SR=\frac{\bar{R}-R_f}{\sigma_R}
where \bar{R}
is the mean asset return, R_f
is the risk free rate of return and \sigma_R
is the standard deviation (volatility) of the asset.
Let X_t
is the closing price of the asset at time t
and its value after a period of length \Delta t
, say X_{t+\Delta t}
. The return over that period is defined as:
R_t=\frac{X_{t+\Delta t}}{X_t}-1
Note that the return equation is equivalent to log return asset when the ratio value of the asset is close to 1 (see, Carmona 2003). To check the goodness of fit test on return value, maximum and minimum of prices, suggested to use the package of gnFit.
Value
The values of function involve close
, return
, max
and min
as a matrix and xts format. The columns are a value of assets which is ordered by date. The mean return, volatility and Sharpe ratio are assigned in the out
. The plot of return vs volatility and also the graph of Sharpe ratio are outputs of function.
References
Carmona (2003, ISBN:0387202862)
Examples
## Not run:
fpath<-system.file("extdata", "sample.dat", package="TSEtools")
getTSE(fpath)
rtn<-mcPrt(asset0, sub="2016::", pstvRtn=TRUE, pr="weekly")$return
## End(Not run)