Question: Using NLPSolve to Maximize a Function

I have a non linear Sharpe ratio with 3 portfolio weights w1,w2 and w2. I want to (globally) maximize the sharpe ratio by choosing w1,w2 and w2 subject to the constraints that each of the variables is in the range of 0 to 1, and that their summation is equal to 1. I also want the maximization to start at an initial point of [w1=0.35,w2=0.6,w3=0.05].

The function is:

SR:= (0.012w1+0.007w2+0.0384w3-0.009)/(stdev)

where stdev is the standard deviation of the portfolio (ie, it has some squared terms and includes the 3 variables)

 

I tried using NLPSolve to accomplish the task but not sure if a) if my code is correct or b) if I should use another function

This is the code I wrote

 

with(Optimization):

NLPSolve(S,w1=0..1,w2=0..1,w3=0..1,initialpoint={w1=0.35,w2=0.6,w3=0.05},maximize)

when running this code the output just rewrites the above.

 

Any help is appreciated

 

Please Wait...