# 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:

- https://github.com/watson-bruhn/ocean/blob/master/portfolio_selector.py - Main program
- https://github.com/watson-bruhn/ocean/blob/master/quantum.py - Code that runs on the dwave sampler
- https://github.com/watson-bruhn/ocean/blob/master/clean.py - Cleans up the data for ease of review

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:

- Simulate the difference in returns between stocks and an index of size N through a set of N random numbers between -100 and +100
- Generate a penalty Hamiltonian which restricts to number of stocks to a smaller portfolio M
- Generate an influence Hamiltonian which minimises the absolute sum of returns of the portfolio M
- I then scale the influence Hamiltonian to -1<=x<=1 so it doesn't overpower the penalty terms and sum them
- 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?

## Comments

Please sign in to leave a comment.