+ Reply to Thread
Results 1 to 12 of 12

Solver problem. Portfolio Optimization.

  1. #1
    Registered User
    Join Date
    02-09-2019
    Location
    Helsinki
    MS-Off Ver
    2013
    Posts
    6

    Solver problem. Portfolio Optimization.

    Hi. I'm trying to optimize the stock portfolio. I have 10 stocks and I would like to choose min 5 and max 10 of them to optimize the expected return.
    Obviously, 5 is the correct answer here. The minimum weight of each chosen stock is 5 % and maximum is 30 %. Everything within the constraints should
    be okay at the moment. The only constrain missing is the binary. I've tried to build it but I don't get it.


    Portfolio Optimization.PNG

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,445

    Re: Solver problem. Portfolio Optimization.

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Registered User
    Join Date
    02-09-2019
    Location
    Helsinki
    MS-Off Ver
    2013
    Posts
    6

    Re: Solver problem. Portfolio Optimization.

    Great. Thanks for letting me know The attachment is now downloaded.
    Attached Files Attached Files

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver problem. Portfolio Optimization.

    Perhaps like this? I've updated formula in cell AJ61 but you need to check formulas in range AJ62:AJ65 and update these.

    Alf
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-09-2019
    Location
    Helsinki
    MS-Off Ver
    2013
    Posts
    6

    Re: Solver problem. Portfolio Optimization.

    Thank you. The idea is that first I'm trying to optimize the portfolio just by using expected return. Without cells AJ62:AJ65.
    When I run the solver now, It still doesn't give weights for the portfolio. The optimal portfolio should be in this case 5 stocks and the weights
    30-30-30-5-5, as the min is 5 % and max 30 %.

  6. #6
    Registered User
    Join Date
    02-09-2019
    Location
    Helsinki
    MS-Off Ver
    2013
    Posts
    6

    Re: Solver problem. Portfolio Optimization.

    with 5 stocks.PNG

    This is what I made manually. I guess the solver should give the same result with these constraints?

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver problem. Portfolio Optimization.

    As you have the constraint setup like this

    set_constr.jpg
    solver could never give you 0% as a value for any cell in the range AJ48:AJ57.

    Alf

  8. #8
    Registered User
    Join Date
    02-09-2019
    Location
    Helsinki
    MS-Off Ver
    2013
    Posts
    6

    Re: Solver problem. Portfolio Optimization.

    Okay. How can I make the solver first choose 5-10 best performing stocks that it will give 30-30-30-5-5 for these and zeros to rest of them?

  9. #9
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver problem. Portfolio Optimization.

    Not sure, will have a look at it today - tomorrow.

    Alf

  10. #10
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver problem. Portfolio Optimization.

    I've tested a bit and if you set solver to find the the highest value of the 4 best preforming stocks you get a better solution than the result using 5 of the best stock.

    solver_4.jpg

    using 5 you need to specify the 5th stock to be 5%. In this case I used cell AJ51 but I could probably also used AJ57 as the return there is also 7%.

    solver_5.jpg

    If you don't do solver find its maximum using 4 stocks but add a binary of 1 even if the weight of this stock is 0, see line for KEMIRA.HS.csv4. So it looks like Solver uses the 5 best stocks but in reality it only uses 4 unless it is forced to use the 5th.

    solver4_5.jpg

    Alf

    Ps If you do have problem viewing the images right click on each of them and select "Open image in new tab".
    Last edited by Alf; 02-10-2019 at 02:28 PM.

  11. #11
    Registered User
    Join Date
    02-09-2019
    Location
    Helsinki
    MS-Off Ver
    2013
    Posts
    6

    Re: Solver problem. Portfolio Optimization.

    Thank you sir! You made my day.

  12. #12
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver problem. Portfolio Optimization.

    You are welcome and thanks for feedback.

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Markowitz Optimal Portfolio - Excel Solver problem
    By steve.nam in forum Excel General
    Replies: 1
    Last Post: 03-29-2015, 06:00 PM
  2. Solver Optimization Problem
    By greywolf00 in forum Excel General
    Replies: 6
    Last Post: 10-13-2014, 12:43 PM
  3. Solver Portfolio Optimization, using binary variable
    By Willie68 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2014, 02:42 PM
  4. [SOLVED] optimization problem - solver falling to get correct answer
    By timtim89 in forum Excel General
    Replies: 5
    Last Post: 09-27-2012, 10:51 AM
  5. Optimization problem when Solver doesn't work
    By fouzi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2012, 09:53 AM
  6. Portfolio Optimization. Solver Constraint Issue
    By spgoofyft in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2011, 07:02 PM
  7. portfolio optimization with solver
    By jrom1 in forum Excel General
    Replies: 2
    Last Post: 01-13-2007, 12:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1