LIVE
connecting to the live quote stream…
--:--:--UTC
easyFinance○
#02

Put-call parity check

easyFinanceacceptance —~10 min

Implement parity_gap(call, put, S, K, T, r) — the arbitrage gap in put-call parity for European options on a non-dividend stock: C - P - (S - K·e^(-rT)). A perfectly priced pair returns 0.

Parity is the first sanity check a desk runs on a chain: if the gap is not zero, one of the quotes is stale or the pair is mispriced against parity. Return the gap rounded to 4 decimal places.

example 1
input
call=7.9656, put=7.9656, S=100.0, K=100.0, T=1.0, r=0.0
output
0
example 2
input
call=10.4506, put=5.5735, S=100.0, K=100.0, T=1.0, r=0.05
output
0
constraints
  • 0 < S, K ≤ 10_000
  • 0 < T ≤ 5
  • 0 ≤ r ≤ 0.2
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 parity_gap()
call=7.9656, put=7.9656, S=100.0, K=100.0, T=1.0, r=0.0
expected
0

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