LIVE
connecting to the live quote stream…
--:--:--UTC
easyFinance○
← prevnext →
#01

Black-Scholes call price

easyFinanceacceptance —~15 min

Implement call_price(S, K, T, r, sigma) — the Black-Scholes price of a European call on a non-dividend stock: spot S, strike K, time to expiry T in years, continuously compounded rate r, volatility sigma. Use the standard normal CDF N from statistics.NormalDist.

This is the formula every options desk still reaches for first, and the one the workbench's Black-Scholes bot runs on every chain. Get the discounting right: the strike is paid at expiry, so it is worth less today.

Return the price rounded to 4 decimal places.

example 1
input
S=100.0, K=100.0, T=1.0, r=0.0, sigma=0.2
output
7.9656
example 2
input
S=100.0, K=100.0, T=1.0, r=0.05, sigma=0.2
output
10.4506
note

With r = 5% the strike is discounted; the undiscounted price would read 7.7213.

constraints
  • 0 < S, K ≤ 10_000
  • 0 < T ≤ 5
  • 0 ≤ r ≤ 0.2
  • 0.01 ≤ sigma ≤ 2
teacher · 3 hints · the first is free
↗ read the theory
the chapter this problem is cut from
▶ open in the workbench
run the same math on a real tape
●solution.py· utf-8 · spaces:4
ln 1, col 1tab indent · esc leave editor
python 3.13 · pyodide
+ 6 hidden on submit
input · keyword arguments to call_price()
S=100.0, K=100.0, T=1.0, r=0.0, sigma=0.2
expected
7.9656

the judge calls call_price() with exactly these inputs · outputs are compared to 6 decimal places

● standing bypython 3.13 in your browser · pyodide 0.28.3 · judged on the server to 6 dp⌘↵ run · ⌘⇧↵ submit
paper only · educational · not advice