def S(self, val: float) -> None: """Set the spot price of the underlying.""" if not is_pos(val): raise ValueError( f'Expected non-negative float, instead got {val} with type ' f'{type(val)}!') self._S = float(val)
def K(self, val: float) -> None: """Set the strike price.""" if not is_pos(val): raise ValueError( f'Expected non-negative float, instead got {val} with type ' f'{type(val)}!') self._K = float(val)
def div(self, val: float) -> None: """Set the time to maturity.""" if not is_pos(val): raise ValueError( f'Expected non-negative float, instead got {val} with type ' f'{type(val)}!') self._div = float(val)
def pd(self, val: float) -> None: """Set the risk free probability of down move.""" if not is_pos(val): raise ValueError( f'Expected non-negative float, instead got {val} with type ' f'{type(val)}!') self._pd = float(val)
def N(self, val: int) -> None: """Set the number of increments.""" if not isinstance(val, (int, np.int)): raise ValueError( f'Expected integer, instead got {val} with type {type(val)}') if not is_pos(val): raise ValueError(f'Expected non-negative int, instead got {val}') self._N = val
def T(self, val: float) -> None: """Set the time to maturity.""" if not is_pos(val): raise ValueError( f'Expected non-negative float, instead got {val} with type ' f'{type(val)}!') if val == 0: raise ValueError(f'T cannot be set to zero, got {val}') self._T = float(val)
def M(self, val: int) -> None: """Set the number of underlying increments.""" if not isinstance(val, (int, np.int)): raise ValueError( f'Expected integer, instead got {val} with type {type(val)}' ) if not is_pos(val): raise ValueError(f'Expected non-negative int, instead got {val}') self._M = val self.s_steps = np.arange(val)