If, given a return stream of unknown composition, what is the best find a portfolio of assets that replicates that return stream from a universe of assets?

In other words, what is the best optimisation method to use to find the weights to assign a portfolio of assets where the returns from the portfolio has a correlation of 1 to another asset? Preferably something that is easy to replicate in Python.


To answer my own question: I've used a fairly simple index-tracking portfolio created from asset correlation, which is basically a quadratic programming optimisation problem, by following the procedure detailed in the paper here: https://www.nag.co.uk/content/index-tracking-portfolio-optimization-model

Since my preferred Python quadratic programming solver (CVXOPT) does not explicitly incorporate lower/upper bound solution for portfolio weights, I've used the following quadprog function taken from https://gist.github.com/garydoranjr/1878742 to solve for optimal portfolio weights.

Both _x and _y are organised in date-unified Pandas data frames, with DateTime as index.

_x = ... # Return stream of potential portfolio of assets
_y = ... # target/hedge return stream

n = len(_x.columns)
lb = -1.0
ub = 1.0

ser, res = quadprog(
    [-1.0 * np.cov(_x.loc[:,c].T, _y)[0][1] for c in _x.columns],
    np.vstack([lb for n in range(n)]), 
    np.vstack([ub for n in range(n)])  )
for s,z in zip(ser, _x.columns):
    print('{}: {:0.4f}'.format(z, float(s[0])))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.