Created
February 4, 2018 06:04
-
-
Save 0x0L/69f6440bde42ee2ddc65f2e6141c174b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def markowitz(mu, cov, hedge=None): | |
z = mu | |
K = np.linalg.inv(cov) | |
if hedge is not None: | |
Q = hedge @ K @ hedge.T | |
beta = np.linalg.inv(Q) @ hedge @ K @ mu | |
z = mu - beta @ hedge | |
z = K @ z | |
z = z / sum(abs(z)) | |
return z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment