LIVE·WAITING…
connecting to the live quote stream…
--:--:--UTC
#08
Binomial-tree American put
hardFinanceacceptance —~40 min
Implement american_put(S, K, T, r, sigma, steps) — the price of an American put on a Cox-Ross-Rubinstein binomial tree with steps steps: u = exp(sigma·sqrt(dt)), d = 1/u, risk-neutral p = (exp(r·dt) - d) / (u - d). Roll back from expiry, and at every node take the larger of continuation value and immediate exercise K - S_node.
The put is the option where early exercise actually matters, and the tree is the honest way to see it. The workbench's American pricer bot is a neural surrogate trained on exactly this tree. 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, steps=50
output
7.9258
example 2
input
S=100.0, K=110.0, T=1.0, r=0.06, sigma=0.2, steps=50
output
11.6613
note
With r = 6% and the put deep in the money, exercising early beats waiting.
constraints
- 0 < S, K ≤ 10_000
- 0 < T ≤ 5
- 0 ≤ r ≤ 0.2
- 10 ≤ steps ≤ 500
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 american_put()
S=100.0, K=100.0, T=1.0, r=0.0, sigma=0.2, steps=50
expected
7.9258
the judge calls american_put() 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