Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7961135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:56:57+00:00 2026-06-04T04:56:57+00:00

I hope this does not get closed because it is related to algorithms that

  • 0

I hope this does not get closed because it is related to algorithms that I have not been able to figure out(its also pretty long because I’m so confused about how its being done). Basically many years back I used to work at a mutual fund and we used different tools to select optimize portfolios as well as hedge existing ones. We would take these results and make our own modifications then sell them to clients. After my company downsized, I decided I wanted to give it a try(to create the software and include my customizations) but I have no clue how combinations are actually generated for the software.

After 6 months of trying, I’m accepting that my approach is impossible. I was trying to use combination algorithms like from Knuth’s book, as well as doing bit combinations to try to find every possible portfolio(I limited it to 30 stocks) on the NYSE(5,000+ stocks). But as per everyone I have spoken to this will take me billions of billions of years to just get one days results(for me on a GPU i stopped it after 2 days of straight processing).

So what am I missing? We would enter our risk tolerance and view of the market(stock market growth expectations, inflation expectations, fed funds expectations,etc..) and it would give us the ideal portfolio(in theory..) within a few seconds/minutes. With thousands of possibilities and quadrillion possible combinations of weights of stocks, how are they able to calculate results so quickly(or even at all)? As the admin of the system, I know we downloaded a file everyday(less than 100 mb and loaded in a mssql database probably just market data..so its not like we had every possibility. Using my approach above I would get a 5 gig file in a min of doing my version of Knuth’s combination algo) and the applications worked offline(so it must have been doing it locally on the desktop/laptop cpu not on a massive supercomputer somewhere and took a min or two to run..15 minutes was the longest for a global fund which includes every stock in the world). Its so confusing because their work required correlation of the entire fund(I don’t think they were just sending the top stocks they pre-calculated because everyone got different results). So if I wanted a 30 stock fund that gave me 2% returns and had a negative correlation with the market, and was 60% hedged how could the software generate that portfolio out of billions of possibilities so quickly? note, I’m not asking about the math or the finance part, I’m asking how it was able to generate 30 stocks from the entire market that gave 2% returns when in order to do that it would need to know the returns of all 30 stock portfolio(That alone would make it run for billions of years, right? the other restrictions make it more complex).

So How is this being done programmatically? I’m starting to believe they are not using Knuth’s combination algorithm to generate every possibility yet their results don’t seem randomly selected and individually selecting the stocks seems to miss the correlation part. How can so many investment softwares do things like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:56:58+00:00Added an answer on June 4, 2026 at 4:56 am

    Such algorithms almost certainly don’t generate every possibility – as you rightly observe that would be impractical.

    Portfolio selection is however very easy to do with other techniques that will give you a very good answer. The two most likely are:

    • If you make simplifying assumptions around risk / return you can solve for an optimal portfolio mathematically (see http://en.wikipedia.org/wiki/Capital_asset_pricing_model for some of the maths)
    • A genetic algorithm which does mutation / crossover operations on randomised sample portfolios will find a very good solution pretty fast. You can combine this with Monte-Carlo style modelling approaches to understand the range of possible outcomes.

    Personally, I’d probably suggest the genetic algorithm approach – although it’s not as mathematically pure, it will give you good answers and should able to handle any constraints you want to throw at it quite easily (e.g. max number of stocks in a portfolio)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I do this? (The following code does NOT work, but I hope
Hope this is not a dupe. I would like to be able to do
I don't know if this is possible or not. I have a workbook that
Hope someone can help me out with this one ! I have a sql
I hope this is allowed but I have a number of questions regarding Facebook
I face a very serious situation. By writing this question I hope that really
I hope someone may be able to help! We have a pretty large VB.Net
I hope I am able to put this question together well. In a partial
My question concerns why one piece of code works and two that does not,
i'm working since hours on this issue without any success, hope to get some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.