[R-SIG-Finance] maxratioPortfolio
Diethelm Wuertz
wuertz at itp.phys.ethz.ch
Mon May 11 03:08:18 CEST 2009
Michael Schulman wrote:
> Hi,
> First wanted to thank everyone for a lot of very good hard work done on R and the subsequent packages.
>
> So I've been looking at the maxratioPortfolio code in fPortfolio. One thing I notice is how the range is decided for the search. It looks like the range is decided by passing "interval = range(getMu(Data))" While this works well in a completely unrestrained situation it does not work when there are constraints. To give an example. I am trying to optimize a portfolio with 3 assets with the following constraints :
>
> c("minW[1:nAssets] = -0.5", "maxW[1:nAssets] = 0.5", "eqsumW[1:nAssets] = 1e-7", "Partial")
>
> In other words I want a dollar neutral portfolio with no weight greater or less than .5, -.5 respectively. As a side note having to pass in 1e-7 is somewhat counterintuitive but I could not find another way as passing in 0, removed that constraint.
>
> My mu and sigma are :
>
> $mu
> S VZ T
> 0.007075173 -0.001899547 -0.001357274
>
> $Sigma
> S VZ T
> S 0.008534089 0.0015257184 0.0015642080
> VZ 0.001525718 0.0009147493 0.0008163796
> T 0.001564208 0.0008163796 0.0009165100
>
>
> Now just taking the min and max of my mu as the range is wrong. They are not feasible portfolios as I can not allocate 100% to that. In general in other optimizers I've seen the range is decided by solving for the max return given the constraints and no constraint on the variance. Its usually a simple linear programming problem.
>
Also in the most generic case for a non linear objective? I think no.
> In my case the weights would be 0.5, -0.5, 0 to get me the maximum returns within my portfolio and within my constraints.
>
> Sorry if anything above is incorrect, out of context, or just stupid. I'm fairly new to R so I have no doubt I'm mistaken on many things.
>
For the moment, a quick and dirty fix in this special case (when we
have a unique solution for the max ratio) is to replace the line
portfolio = optimize(f = ratioFun, interval = range(getMu(Data)),
maximum = TRUE, data = Data, spec = spec, constraints = constraints)
by
portfolio = optimize(f = ratioFun, interval = c(-BIG, BIG),
maximum = TRUE, data = Data, spec = spec, constraints = constraints)
with BIG big enough.
We will check this and take care for a better solution.
Thanks a lot, such examples are really helpful for us.
Diethelm Wuertz
> Thanks... mike
>
>
> DISCLAIMER: The information contained herein is to be co...{{dropped:13}}
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
>
More information about the R-SIG-Finance
mailing list