Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to to use the Optimization Toolbox to optimize a portfolio of stocks?

Subject: how to to use the Optimization Toolbox to optimize a portfolio of stocks?

From: Ryan

Date: 8 Oct, 2012 19:25:08

Message: 1 of 5

I’m trying to figure out how to to use the Optimization Toolbox to optimize a portfolio of stocks, let’s say the Dow30, based on the returns (1 year historical) and risks (stdev). This is quite easy to do in Excel, using Solver, and it is quite easy to do in Crystal Ball, using OptQuest. I’m not making a whole lot of progress here, trying to figure out how to do basically the same thing using Matlab.

I found this:
http://www.mathworks.com/help/finance/working-with-portfolio-constraints_bswwmte.html#bswwlk3-1

At a quick glance, I thought that would be helpful. I'm still not getting it.


Any ideas, anyone?

Subject: how to to use the Optimization Toolbox to optimize a portfolio of stocks?

From: Phil Goddard

Date: 8 Oct, 2012 21:27:17

Message: 2 of 5

The functionality is in the Financial Toolbox, in particular see
>> doc portopt

portopt essentially creates a cost function to pass to fmincon in the Optimization toolbox.
If you don't have the Financial Toolbox then you need to do that step yourself, which is not hard for a standard portfolio optim problem.

Phil.

Subject: how to to use the Optimization Toolbox to optimize a portfolio of stocks?

From: Ryan

Date: 9 Oct, 2012 01:50:13

Message: 3 of 5

Yeah, I'm sure it's not hard, so long as you know what to do. If you know of such a thing, can you post a link that describes how to maximize returns, and/or minimize risk, by adding certain stocks to the portfolio, or deleting certain stocks from the portfolio. If you don't know of a tutorial, but you know that steps, please post here so I can learn the nuts and bolts of this process.

Thanks!!!

"Ryan" wrote in message <k4v9ak$qrq$1@newscl01ah.mathworks.com>...
> I’m trying to figure out how to to use the Optimization Toolbox to optimize a portfolio of stocks, let’s say the Dow30, based on the returns (1 year historical) and risks (stdev). This is quite easy to do in Excel, using Solver, and it is quite easy to do in Crystal Ball, using OptQuest. I’m not making a whole lot of progress here, trying to figure out how to do basically the same thing using Matlab.
>
> I found this:
> http://www.mathworks.com/help/finance/working-with-portfolio-constraints_bswwmte.html#bswwlk3-1
>
> At a quick glance, I thought that would be helpful. I'm still not getting it.
>
>
> Any ideas, anyone?

Subject: how to to use the Optimization Toolbox to optimize a portfolio of stocks?

From: Seth Deland

Date: 9 Oct, 2012 12:40:21

Message: 4 of 5

Here's an example that goes a little more into the details of how to use
quadprog (quadratic programming solver from Optimization Toolbox) to solve a
portfolio optimization problem:
http://www.mathworks.com/help/optim/examples/using-quadratic-programming-on-portfolio-optimization-problems.html?prodcode=OP&language=en

As Phil mentioned, the Financial Toolbox has a lot of really nice built-in
portfolio optimization capabilities that let you incorporate some more
complicated portfolio optimization techniques like including transaction
costs, group constraints, and turnover constraints. There's a video for
getting started with Portfolio Optimization with Financial Toolbox here:
http://www.mathworks.com/videos/getting-started-with-portfolio-optimization-68762.html

If you're looking to get deeper into the theory of portfolio optimization, I
recommend the "Simulation and Optimization in Finance" book. It has a lot
of really nice examples, and includes MATLAB code so you can apply the
theory as you learn it:
http://www.amazon.com/Simulation-Optimization-Finance-Website-Modeling/dp/0470371897




"Ryan " <ryanshuell@gmail.com> wrote in message
news:k4vvsl$fre$1@newscl01ah.mathworks.com...
> Yeah, I'm sure it's not hard, so long as you know what to do. If you know
> of such a thing, can you post a link that describes how to maximize
> returns, and/or minimize risk, by adding certain stocks to the portfolio,
> or deleting certain stocks from the portfolio. If you don't know of a
> tutorial, but you know that steps, please post here so I can learn the
> nuts and bolts of this process.
>
> Thanks!!!
>
> "Ryan" wrote in message <k4v9ak$qrq$1@newscl01ah.mathworks.com>...
>> Im trying to figure out how to to use the Optimization Toolbox to
>> optimize a portfolio of stocks, lets say the Dow30, based on the returns
>> (1 year historical) and risks (stdev). This is quite easy to do in
>> Excel, using Solver, and it is quite easy to do in Crystal Ball, using
>> OptQuest. Im not making a whole lot of progress here, trying to figure
>> out how to do basically the same thing using Matlab.
>>
>> I found this:
>> http://www.mathworks.com/help/finance/working-with-portfolio-constraints_bswwmte.html#bswwlk3-1
>>
>> At a quick glance, I thought that would be helpful. I'm still not
>> getting it.
>>
>>
>> Any ideas, anyone?

Subject: how to to use the Optimization Toolbox to optimize a portfolio of stocks?

From: Ryan

Date: 23 Oct, 2012 03:25:08

Message: 5 of 5

Thanks, Seth!

I love this link.
http://www.mathworks.com/videos/getting-started-with-portfolio-optimization-68762.html

I followed the setup, and re-typed all of the code. I seem to be missing something though. It seems like the instructor skips around a bit; I think I have incomplete code. Do you know if I can download the code samples form the site?

Also, I’ve seen samples of this book online:
http://www.amazon.com/Simulation-Optimization-Finance-Website-Modeling/dp/0470371897

It seems like it is an excellent resource!! I was hoping to find a PDF version of that book. Do you know where I can get a PDF copy?

Thanks, again!!


"Seth Deland" <sdeland@mathworks.com> wrote in message <k515vo$m1b$1@newscl01ah.mathworks.com>...
> Here's an example that goes a little more into the details of how to use
> quadprog (quadratic programming solver from Optimization Toolbox) to solve a
> portfolio optimization problem:
> http://www.mathworks.com/help/optim/examples/using-quadratic-programming-on-portfolio-optimization-problems.html?prodcode=OP&language=en
>
> As Phil mentioned, the Financial Toolbox has a lot of really nice built-in
> portfolio optimization capabilities that let you incorporate some more
> complicated portfolio optimization techniques like including transaction
> costs, group constraints, and turnover constraints. There's a video for
> getting started with Portfolio Optimization with Financial Toolbox here:
> http://www.mathworks.com/videos/getting-started-with-portfolio-optimization-68762.html
>
> If you're looking to get deeper into the theory of portfolio optimization, I
> recommend the "Simulation and Optimization in Finance" book. It has a lot
> of really nice examples, and includes MATLAB code so you can apply the
> theory as you learn it:
> http://www.amazon.com/Simulation-Optimization-Finance-Website-Modeling/dp/0470371897
>
>
>
>
> "Ryan " <ryanshuell@gmail.com> wrote in message
> news:k4vvsl$fre$1@newscl01ah.mathworks.com...
> > Yeah, I'm sure it's not hard, so long as you know what to do. If you know
> > of such a thing, can you post a link that describes how to maximize
> > returns, and/or minimize risk, by adding certain stocks to the portfolio,
> > or deleting certain stocks from the portfolio. If you don't know of a
> > tutorial, but you know that steps, please post here so I can learn the
> > nuts and bolts of this process.
> >
> > Thanks!!!
> >
> > "Ryan" wrote in message <k4v9ak$qrq$1@newscl01ah.mathworks.com>...
> >> Im trying to figure out how to to use the Optimization Toolbox to
> >> optimize a portfolio of stocks, lets say the Dow30, based on the returns
> >> (1 year historical) and risks (stdev). This is quite easy to do in
> >> Excel, using Solver, and it is quite easy to do in Crystal Ball, using
> >> OptQuest. Im not making a whole lot of progress here, trying to figure
> >> out how to do basically the same thing using Matlab.
> >>
> >> I found this:
> >> http://www.mathworks.com/help/finance/working-with-portfolio-constraints_bswwmte.html#bswwlk3-1
> >>
> >> At a quick glance, I thought that would be helpful. I'm still not
> >> getting it.
> >>
> >>
> >> Any ideas, anyone?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us