r-portfolioanalytics

Portfolio Optimize in R with ONLY a vector of mean returns and covariance matrix

ε祈祈猫儿з 提交于 2021-01-29 14:20:09
问题 Every package that I look at seems to require time series returns for my assets. For example I like the PortfolioAnalytics package, and I require many of the constraints offered (box constraints, group constraints, etc.). However, as far as I can tell it requires some sort of time series of returns, even if I specify my own moments (I could be wrong). All I have are the expected returns of each of my 14 assets and the covariance matrix. How can I do various forms of optimizations with that as

Custom expected returns in the Portfolio Analytics package

北战南征 提交于 2020-05-28 15:51:50
问题 I have trouble incorporating custom expected returns in Portfolio Analytics package. Usually expected returns are some professional expectations / views or calculated separately from fundamental indicators. Portfolio Analytics allow to create custom moments function to calculate moments from past returns, but I don't understand how to incorporate already calculated returns to optimization problem. Any help is appreciated and here is small example dataset: #Download package and sample returns

Custom expected returns in the Portfolio Analytics package

谁说我不能喝 提交于 2020-05-28 15:44:46
问题 I have trouble incorporating custom expected returns in Portfolio Analytics package. Usually expected returns are some professional expectations / views or calculated separately from fundamental indicators. Portfolio Analytics allow to create custom moments function to calculate moments from past returns, but I don't understand how to incorporate already calculated returns to optimization problem. Any help is appreciated and here is small example dataset: #Download package and sample returns

chart.Scatter() in PortfolioAnalytics package corrupted

别说谁变了你拦得住时间么 提交于 2019-12-23 06:06:06
问题 Running the short R-code below in R Studio (v1.0.143, Win7, R-3.4.4, Performance Analytics 1.5.2, quantmod 0.4-12) returns the following chart: library(PortfolioAnalytics) library(quantmod) getSymbols("INDU", src = "yahoo", from = "2017-01-01", to = "2017-06-26") getSymbols("VZ", src = "yahoo", from = "2017-01-01", to = "2017-06-26") ret_INDU <- Return.calculate(Cl(INDU))[-1,] ret_VZ <- Return.calculate(Cl(VZ))[-1,] chart.Scatter(ret_INDU, ret_VZ) It looks like something went seriously wrong

Error when trying to optimize with Portfolio Analytics

拟墨画扇 提交于 2019-12-11 17:11:38
问题 I'm trying to copy the code from a website to test Portfolio Analytics library in R. But I getting an error and I don't have a clue why. The error I am getting is: Error: "package:ROI" %in% search() || requireNamespace("ROI", quietly = TRUE) is not TRUE library(PortfolioAnalytics) data(edhec) returns <- edhec[, 1:6] funds <- colnames(returns) init.portfolio <- portfolio.spec(assets = funds) init.portfolio <- add.constraint(portfolio = init.portfolio, type = "full_investment") init.portfolio <

PortfolioAnalytics in R - optimize.portfolio() results in NaN for annualized return

Deadly 提交于 2019-12-08 05:13:58
问题 I am learning how to use PortfolioAnalytics package in R to do rebalancing a portfolio every quarters. I collected the data on 19 large-cap stocks in US and China using qmao package, and then compute the quarterly return. Everything works fine until I call the function optimize.portfolio.rebalancing() . It kept giving me the following error message, together with NaN as a result for Annualized Portfolio Rebalancing Return : VaR calculation produces unreliable result (risk over 100%) for

Create efficient frontier in PortfolioAnalytics without an xts object

十年热恋 提交于 2019-12-07 07:25:15
问题 Is there a way to create an efficient frontier in the PortfolioAnalytics package without specifying an xts object of asset returns? Instead I'd like to supply the vector of expected returns and the covariance matrix. 回答1: There are two ways. First you can supply a list containing containing your matrices with the structure shown below and then call optimize.portfolio including this list as an argument. # num_assets is the number of assets in the portfolio momentargs <- list() momentargs$mu <-