Tools for working with financial options

AUTHORS: - Brian Manion, 2013: initial version

sage.finance.option.black_scholes(spot_price, strike_price, time_to_maturity, risk_free_rate, vol, opt_type)

Calculates call/put price of European style options using Black-Scholes formula. See [Shr2004] for one of many standard references for this formula.

INPUT:

  • spot_price – The current underlying asset price

  • strike_price – The strike of the option

  • time_to_maturity – The # of years until expiration

  • risk_free_rate – The risk-free interest-rate

  • vol – The volatility

  • opt_type – string; The type of option, either 'put' for put option or 'call' for call option

OUTPUT:

The price of an option with the given parameters.

EXAMPLES:

sage: finance.black_scholes(42, 40, 0.5, 0.1, 0.2, 'call')       # abs tol 1e-10
4.759422392871532
sage: finance.black_scholes(42, 40, 0.5, 0.1, 0.2, 'put')        # abs tol 1e-10
0.8085993729000958
sage: finance.black_scholes(100, 95, 0.25, 0.1, 0.5, 'call')     # abs tol 1e-10
13.695272738608132
sage: finance.black_scholes(100, 95, 0.25, 0.1, 0.5, 'put')      # abs tol 1e-10
6.349714381299734
sage: finance.black_scholes(527.07, 520, 0.424563772, 0.0236734,0.15297,'whichever makes me more money')
Traceback (most recent call last):
...
ValueError: 'whichever makes me more money' is not a valid string