"""Store common attributes of a stock option"""
import math
class StockOption(object):
def __init__(self,S0,K,r,T,N,params):
self.S0 = S0
self.K = K
self.r = r
self.T= T
self.N = max(1,N)
self.STs = None
"""Optional parameters used by derived classes"""
self.pu = params.get("pu",0) #Probability of up state
self.pd = params.get("pd",0) #Probability of down state
self.div = params.get("div",0) #Dividend yield
self.sigma = params.get("sigma",0) #Volatility
self.is_call = params.get("is_call",True) #Call or put
self.is_european = params.get("is_eu",True) #Eu or Am
"""Computed values"""
self.dt = T/float(N) #Single time step , in years
self.df = math.exp(-(r-self.div)*self.dt) #Discount factor
StockOption
最新推荐文章于 2025-11-21 11:53:00 发布
3万+

被折叠的 条评论
为什么被折叠?



