Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errrors in several demos #13

Open
sstoeckl opened this issue Oct 1, 2018 · 1 comment
Open

Errrors in several demos #13

sstoeckl opened this issue Oct 1, 2018 · 1 comment

Comments

@sstoeckl
Copy link

sstoeckl commented Oct 1, 2018

Hi!
I have the newest version of R installed and just (again) updated all necessary packages (devtools::install_github("braverock/PortfolioAnalytics")). Now, whatever I try , some of the demos do not work:

demo(backwards_compat): ERROR: Error in constraint(assets = funds, min = 0, max = 0.55, min_sum = 0.99, : you must specify a constraint type
demo(constrained_optim): Error in constraint(assets = colnames(edhec[, 1:10]), min = 0.01, max = 0.4, : you must specify a constraint type
demo(demo_factor_exposure): Error in rp_transform(w = tportfolio, min_sum = min_sum, max_sum = max_sum, : Infeasible portfolio created, perhaps increase max_permutations and/or adjust your parameters.
demo(demo_leverage_exposure_constraint): Error in rp_transform(w = tportfolio, min_sum = min_sum, max_sum = max_sum, : Infeasible portfolio created, perhaps increase max_permutations and/or adjust your parameters.
demo(demo_risk_budgets): Error in optimize.portfolio.rebalancing(R, SDRB.portf, optimize_method = "random", : object 'SDRB.portf' not found^
demo(higher_moments_boudt ): Error in portfolio.moments.boudt(R, init.portf, k = 3) : could not find function "portfolio.moments.boudt"
demo(sortino) : Depends on doMC which is not available for windows
demo(testing_GenSA): Error in constraint(assets = funds, min = -2, max = 2, min_sum = 0.99, : you must specify a constraint type
demo(testing_ROI ): Error in constraint(assets = colnames(edhec), min = -Inf, max = Inf, min_sum = 1, : you must specify a constraint type
demo(testing_pso ): Error in constraint(assets = funds, min = -2, max = 2, min_sum = 0.99, : you must specify a constraint type

Maybe this could be fixed?

Best regards, Sebastian

@sdittmar
Copy link

sdittmar commented Mar 26, 2019

The package development seems to have moved on with some details in the demos lagging behind.
Here are solutions/changes to address all of the errors:
demo(backwards_compat):
gen.constr <- constraint_v1(assets=funds, ...
demo(constrained_optim):
constraints <- constraint_v1(assets = colnames(edhec[, 1:10]), ...
demo(demo_factor_exposure):
lev_constr <- weight_sum_constraint(min_sum=0.98, max_sum=1.02)
demo(demo_leverage_exposure_constraint):
leveraged.portf <- add.constraint(portfolio=leveraged.portf,
type="weight_sum",
min_sum=0.95, max_sum=1.05)
demo(demo_risk_budgets):
# possibly the same setup as in risk_budget_backtesting.R:
SDRB.portf <- add.objective(init.portf, type="risk", name="StdDev")
SDRB.portf <- add.objective(SDRB.portf, type="risk_budget", name="StdDev", max_prisk=0.4)
demo(higher_moments_boudt):
# function is not exported but can be accessed by:
moments.boudt <- PortfolioAnalytics:::portfolio.moments.boudt(R, init.portf, k=3)
minES.lo.boudt <- optimize.portfolio(R=R, portfolio=init.portf,
momentFUN=PortfolioAnalytics:::portfolio.moments.boudt,
k=3, ...
demo(sortino) :
#note: these may not be appropriate on Windows
#require(doMC)
#registerDoMC()
# for Windows
require(doParallel)
registerDoParallel()
SortinoConstr <- constraint_v1(assets = colnames(indexes[,1:4]), ...
# Go buy some coffee until the rebalancing part finishes. With > 500Mb it is too big for a demo...
# Unfortunately, a missing NULL check in extractWeights.optimize.portfolio.rebalancing may
# prevent you from printing the results unless you go into debugging
demo(testing_GenSA):
gen.constr <- constraint_v1(assets = funds, min=-2, ...
demo(testing_ROI ):
gen.constr <- constraint_v1(assets = colnames(edhec), min=-Inf, ...
demo(testing_pso ):
gen.constr <- constraint_v1(assets = funds, min=-2, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants