# Index Tracking Portfolio Algorithm

To gain some experience of using the d-wave system I wrote some code to:

• Select a smaller set from a larger set
• Find the set whose absolute sum is minimised

This is to represent in a simple way the problem of selecting a smaller portfolio of stocks from a full list of stocks in an index whose return most closely matches the return of the index.

The code can be found here:

I'm finding that the code works well for an index up-to the size of about 10, but starts to give incorrect answers for larger numbers of stocks.

Is this because of something I'm missing in the code? Or because of noise and limitations of the sampler?

For reference what I am trying to do in the code is:

1. Simulate the difference in returns between stocks and an index of size N through a set of N random numbers between -100 and +100
2. Generate a penalty Hamiltonian which restricts to number of stocks to a smaller portfolio M
3. Generate an influence Hamiltonian which minimises the absolute sum of returns of the portfolio M
4. I then scale the influence Hamiltonian to -1<=x<=1 so it doesn't overpower the penalty terms and sum them
5. I then set the chain_strength to equal the difference between largest and smallest terms in the Hamiltonian

As the number of stocks in the index increases I see that the occurrences of each solution is more dispersed, and the energy levels become closer together.

Therefore I'm wondering from others with more experience if I am indeed at the simulation limits, or if I can do anything to increase the size of the index I can simulate accurately?