问题
I am trying to find a set of hedge ratios by optimising a portfolio for minimum variance under participation constraints of the assets. Ultimately I would like to optimise the assets weights for other measures of risk such as minimum CVaR, VaR or maximum return/risk.
My portfolio comprises 9 series. 1 domestic asset and 4 international assets which are 0% currency hedged:
"D_Asset1","F_Asset2","F_Asset3","F_Asset4","F_Asset5"
I have also series for those that are 100% currency hedged:
"H_F_Asset2","H_F_Asset3","H_F_Asset4","H_F_Asset5"
The sum of the portfolio asset weights should be equal to one and long only (i.e no leverage / shorting), the domestic asset will have a weight of 60 %. The other asset will have group constraints so that the sum of the hedged and unhedged asset equal a fix target weight (i.e the weight in my benchmark). The group constraints are defined as:
("F_Asset2"+"H_F_Asset2") = 0.2 & ("F_Asset2"+"H_F_Asset2") >= 0
("F_Asset3"+"H_F_Asset3") = 0.1 & ("F_Asset3"+"H_F_Asset3") >= 0
("F_Asset4"+"H_F_Asset4") = 0.05 & ("F_Asset4"+"H_F_Asset4") >= 0
("F_Asset5"+"H_F_Asset5") = 0.05 & ("F_Asset5"+"H_F_Asset5") >= 0
Therefore I should be able to derive through the weights optimisation the hedge ratio for each of my assets by looking at the proportionality of the optimised weights in each unhedged/hedged groups. I have tried to code this as follows:
opt_data <- as.timeSeries(Asset_returns[,c"D_Asset1","F_Asset2","F_Asset3","F_Asset4","F_Asset5","H_F_Asset2","H_F_Asset3","H_F_Asset4","H_F_Asset5")])
spec <- portfolioSpec()
setSolver(spec) <- "solveRquadprog"
cons <- c("eqsumW['D_Asset1']=0.6","eqsumW[c('F_Asset2','H_F_Asset2')]=0.2","eqsumW[c('F_Asset3','H_F_Asset3')]=0.1","eqsumW[c('F_Asset4','H_F_Asset4')]=0.05","eqsumW[c('F_Asset5','H_F_Asset5')]=0.05")
portfolioConstraints(list(mu=apply(opt_data,2,function(x) mean(x)),sigma=cov(opt_data)), spec,cons)
minriskPortfolio(list(mu=apply(opt_data,2,function(x) mean(x)),sigma=cov(opt_data),spec,constraints = cons)
This does not seem to work as the sum of my assets end up being allocated to the hedged asset 4 (0.3809) an 5 (0.6191) only an the fixed weight for the other group of assets is not respected...so I am obviously doing something wrong. Below is the print i get when running my script forr the below data sample.
Title:
MV Minimum Risk Portfolio
Estimator: covEstimator
Solver: solveRquadprog
Optimize: minRisk
Constraints: LongOnly
Portfolio Weights:
D_Asset1 F_Asset2 F_Asset3 F_Asset4 F_Asset5 H_F_Asset2 H_F_Asset3
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
H_F_Asset4 H_F_Asset5
0.3809 0.6191
Covariance Risk Budgets:
D_Asset1 F_Asset2 F_Asset3 F_Asset4 F_Asset5 H_F_Asset2 H_F_Asset3
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
H_F_Asset4 H_F_Asset5
0.3809 0.6191
Target Return and Risk:
[1] -0.0052
Description:
Thu Oct 27 13:53:36 2016 by user: 43951663
My series are as follows:
GMT
D_Asset1 F_Asset2 F_Asset3 F_Asset4 F_Asset5 H_F_Asset2 H_F_Asset3 H_F_Asset4 H_F_Asset5
2002-07-05 0.0060728958 -0.013756357 -0.011423593 0.0134417810 -0.0003016946 -0.0009105038 -0.0018985396 0.014808963 -0.003882658
2002-07-12 -0.0897779000 -0.085188382 -0.089815019 -0.0138095353 -0.0762572363 -0.0685047064 -0.0832575916 -0.022109799 -0.047944944
2002-07-19 -0.0943660524 -0.046920616 -0.030421831 -0.0382901308 -0.0624865993 -0.0794080445 -0.0524289818 -0.031577514 -0.041396426
2002-07-26 0.0133063390 -0.057651106 -0.020437497 -0.0728233620 -0.0456981099 0.0064529146 -0.0396719802 -0.054443226 -0.024872592
2002-08-02 0.0112493491 0.009167815 0.016499805 0.0103302726 0.0252948946 0.0143938534 0.0118099642 0.014237543 0.026552984
2002-08-09 0.0802254120 0.067077593 0.057022734 0.0469759343 0.0558895137 0.0513020851 0.0548215098 0.029355000 0.019311812
2002-08-16 0.0121210802 0.004739185 0.002730157 -0.0071254354 -0.0147625074 0.0220800644 -0.0005414763 -0.017939892 -0.013482516
2002-08-23 0.0254279436 0.028461524 0.013045475 0.0007546919 0.0223311149 0.0133616906 0.0279480422 0.005884930 0.008278473
2002-08-30 -0.0478436889 -0.049203575 -0.039813657 -0.0356601715 -0.0256056009 -0.0276201640 -0.0386866322 -0.025089402 -0.004296057
2002-09-06 -0.0320257540 -0.038044390 -0.028008660 -0.0577045132 -0.0281928317 -0.0252990267 -0.0312053440 -0.049959243 -0.021289249
2002-09-13 -0.0005754118 -0.031013743 -0.024805745 -0.0045048220 -0.0035485481 -0.0055489175 -0.0259398560 0.017170857 0.004670684
2002-09-20 -0.0544596063 -0.049806038 -0.037835532 0.0040695629 -0.0467206777 -0.0523013152 -0.0589901499 0.020442551 -0.049443302
2002-09-27 -0.0264640157 0.003081610 0.011115685 0.0119000112 -0.0229705875 -0.0220045767 0.0091850943 0.009544600 -0.014769134
2002-10-04 -0.0350683237 -0.044400596 -0.026363396 -0.0591064104 -0.0404089273 -0.0317751096 -0.0394601664 -0.049204737 -0.028352867
2002-10-11 0.0455968470 0.047623114 0.034835901 -0.0516194024 0.0202454036 0.0435196284 0.0364044803 -0.047211423 0.013827130
2002-10-18 0.0682138514 0.050215807 0.044584318 0.0531850741 0.0789798029 0.0584691831 0.0566157920 0.055481410 0.060939407
2002-10-25 0.0112759198 -0.016565486 -0.019723747 -0.0234843100 0.0107604217 0.0149227748 -0.0177273307 -0.028938189 0.010213889
2002-11-01 -0.0040060015 0.012830724 -0.013284706 0.0043773949 -0.0193135586 0.0053397013 0.0007975884 -0.003459391 -0.015845981
2002-11-08 -0.0235192733 -0.004405182 0.008119140 -0.0033849145 -0.0101840271 -0.0059125661 -0.0036278513 -0.004716045 0.011824785
2002-11-15 0.0227169708 0.027997661 0.013501476 -0.0219131086 0.0096590849 0.0160309555 0.0242988333 -0.022932122 0.014512210
2002-11-22 0.0237869242 0.018522337 0.020965808 0.0062667869 0.0233331986 0.0242851881 0.0316120790 0.026096681 0.019139845
I would be quite happy to use another optimiser as long it is in R and allows me to handle other measure of risk such as CVaR, VaR etc...Any idea on how to solve for this problem would be really helpful to me and probably others on this forum.
回答1:
There are typos in your code. Review the following lines?
opt_data <- as.timeSeries(Asset_returns[,c("D_Asset1","F_Asset2","F_Asset3","F_Asset4","F_Asset5","H_F_Asset2","H_F_Asset3","H_F_Asset4","H_F_Asset5")])
Whit upper cons:
cons <- c("eqsumW['D_Asset1']=0.6","maxsumW[c('F_Asset2','H_F_Asset2')]=0.2","maxsumW[c('F_Asset3','H_F_Asset3')]=0.1","maxsumW[c('F_Asset4','H_F_Asset4')]=0.05","maxsumW[c('F_Asset5','H_F_Asset5')]=0.05")
I got:
minriskPortfolio(list(mu=apply(opt_data,2,function(x) mean(x)),sigma=cov(opt_data)),spec,constraints = cons)
Title:
MV Minimum Risk Portfolio
Estimator: covEstimator
Solver: solveRquadprog
Optimize: minRisk
Constraints:
Portfolio Weights:
D_Asset1 F_Asset2 F_Asset3 F_Asset4 F_Asset5 H_F_Asset2 H_F_Asset3
0.6000 0.0308 0.1000 0.0000 0.0000 0.1692 0.0000
H_F_Asset4 H_F_Asset5
0.0500 0.0500
Covariance Risk Budgets:
D_Asset1 F_Asset2 F_Asset3 F_Asset4 F_Asset5 H_F_Asset2 H_F_Asset3
0.6932 0.0283 0.0762 0.0000 0.0000 0.1557 0.0000
H_F_Asset4 H_F_Asset5
0.0172 0.0294
Target Return and Risk:
[1] -0.0043
来源:https://stackoverflow.com/questions/40285918/portfolio-optimisation-under-participation-constraints