Serving the Quantitative Finance Community

 
User avatar
vinayboy
Topic Author
Posts: 0
Joined: September 8th, 2004, 2:08 pm

Code for Portfolio Optimization

November 11th, 2005, 3:01 am

Hi,I need to find some reference where the algorithm for the optimization problem (i think its a quadratic optimization problem) of maximizing returns and minimizing risk (stdev) is given. It would be great if the treatment to this is done in a linear algebraic way (it somehow appeals to me more) and also gives a implementable code for it. (It would be perfect if it is java). Does anyone have anything to help me out here?Thanksps: Does java have a class that has a list of optimization algorithms coded in it?
 
User avatar
OliverP
Posts: 0
Joined: May 9th, 2003, 1:48 pm

Code for Portfolio Optimization

November 11th, 2005, 2:49 pm

If you use R there is an R Package called quadprog, I believe there is also something available in Fortran (try google) but I doubt you'll find anything in Java that anyone is prepared to give away! I don't understand what you mean about attempting to solve a quadratic optimization problem with linear algebra, you might also want to consider using variance in place of volatility. The basis for a lot of related work is a paper by Goldfarb & Idnani (1983 in Mathematical Programming) which presents an algorithm for solving quadratic programming problems.
 
User avatar
jasba
Posts: 0
Joined: June 21st, 2005, 6:08 pm

Code for Portfolio Optimization

November 11th, 2005, 6:34 pm

There is a closed form solution to this problem... depending on your constraints. I've got the papers that go through it lying around here somewhere. When I get a sec, I'll dig around for them. In the interim you can try to google it... the guy who wrote them is a professor at one of the University of California's....
 
User avatar
ptopol
Posts: 0
Joined: January 29th, 2007, 2:09 pm

Code for Portfolio Optimization

June 19th, 2009, 7:33 am

I would also be happy to find a code for portfolio optimization (the best would be .net format). Can anyone help please?
 
User avatar
Aaron
Posts: 4
Joined: July 23rd, 2001, 3:46 pm

Code for Portfolio Optimization

June 19th, 2009, 3:52 pm

Let R be the nx1 column vector of expected returns and C be the nxn covariance matrix of returns. You get the maximum Sharpe ratio by weighting assets proportional to W = (C^-1)R. This is easy to prove.Expected return is (W^t)V and variance is (W^t)CW. Just do a Lagrange maximization.
 
User avatar
bostonquant
Posts: 0
Joined: March 26th, 2006, 7:46 pm

Code for Portfolio Optimization

June 19th, 2009, 10:23 pm

QuoteOriginally posted by: OliverPIf you use R there is an R Package called quadprog, I believe there is also something available in Fortran (try google) but I doubt you'll find anything in Java that anyone is prepared to give away! I don't understand what you mean about attempting to solve a quadratic optimization problem with linear algebra, you might also want to consider using variance in place of volatility. The basis for a lot of related work is a paper by Goldfarb & Idnani (1983 in Mathematical Programming) which presents an algorithm for solving quadratic programming problems.Also there is a function called portfolio.optim() in in the package tseries. I believe tseries is dependent upon quadprog as well.