Last active
August 29, 2015 14:04
-
-
Save sglyon/2dcd795dca3c0a0b2d16 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
class AssetPrices(object): | |
""" | |
docstring | |
""" | |
def __init__(self, beta, P, s, gamma): | |
self.beta, self.gamma = beta, gamma | |
self.P, self.s = P, s | |
self.n = self.P.shape[0] | |
@property | |
def P_tilde(self): | |
P, s, gamma = self.P, self.s, self.gamma | |
return P * s**(1.0-gamma) # using broadcasting | |
@property | |
def P_check(self): | |
P, s, gamma = self.P, self.s, self.gamma | |
return P * s**(-gamma) # using broadcasting | |
def tree_price(self): | |
""" | |
docstring | |
""" | |
# == Simplify names == # | |
beta = self.beta | |
# == Compute v == # | |
P_tilde = self.P_tilde | |
I = np.identity(self.n) | |
O = np.ones(self.n) | |
v = beta * solve(I - beta * P_tilde, P_tilde.dot(O)) | |
return v |
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
class AssetPrices: | |
""" | |
docstring | |
""" | |
def __init__(self, beta, P, s, gamma): | |
self.beta, self.gamma = beta, gamma | |
self.P, self.s = P, s | |
self.n = self.P.shape[0] | |
def tree_price(self): | |
""" | |
docstring | |
""" | |
# == Simplify names == # | |
P, s, gamma, beta = self.P, self.s, self.gamma, self.beta | |
# == Compute v == # | |
P_tilde = P * s**(1-gamma) #using broadcasting | |
I = np.identity(self.n) | |
O = np.ones(self.n) | |
v = beta * solve(I - beta * P_tilde, P_tilde.dot(O)) | |
return v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment