LIVE
connecting to the live quote stream…
--:--:--UTC
mediumFinance○
#07

Greeks by finite difference

mediumFinanceacceptance —~25 min

Implement greeks_fd(S, K, T, r, sigma, kind) — delta, gamma and vega of a European option by central finite differences on the Black-Scholes price: bump S by 0.01 for delta and gamma, bump sigma by 0.0001 for vega (report vega per unit of sigma). kind is "call" or "put"; price puts with put-call parity.

When the pricer is a black box — a tree, a Monte Carlo, a neural surrogate — this is how you still get Greeks. Return [delta, gamma, vega] rounded to 4 decimal places.

example 1
input
S=100.0, K=100.0, T=1.0, r=0.05, sigma=0.2, kind="call"
output
[0.6368, 0.0188, 37.524]
example 2
input
S=100.0, K=100.0, T=1.0, r=0.05, sigma=0.2, kind="put"
output
[-0.3632, 0.0188, 37.524]
constraints
  • 0 < S, K ≤ 10_000
  • 0 < T ≤ 5
  • 0.01 ≤ sigma ≤ 2
  • kind ∈ {call, put}
teacher · 2 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 greeks_fd()
S=100.0, K=100.0, T=1.0, r=0.05, sigma=0.2, kind="call"
expected
[0.6368, 0.0188, 37.524]

the judge calls greeks_fd() 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