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

Covered-call payoff table

easyFinanceacceptance —~15 min

Implement covered_call_pnl(entry, strike, premium, expiry_prices) — the profit per share of a covered call (long stock bought at entry, short call at strike sold for premium) for each price in expiry_prices. Above the strike the stock is called away, so the upside is capped.

It is the first options position most people put on, and the cap is the part they forget. The wheel bot in the workbench lives on this payoff. Return the list of profits rounded to 4 decimal places.

example 1
input
entry=100.0, strike=110.0, premium=2.5, expiry_prices=[90.0, 100.0, 105.0, 110.0]
output
[-7.5, 2.5, 7.5, 12.5]
example 2
input
entry=100.0, strike=110.0, premium=2.5, expiry_prices=[95.0, 110.0, 120.0, 140.0]
output
[-2.5, 12.5, 12.5, 12.5]
constraints
  • entry, strike, premium > 0
  • 1 ≤ len(expiry_prices) ≤ 50
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 covered_call_pnl()
entry=100.0, strike=110.0, premium=2.5, expiry_prices=[90.0, 100.0, 105.0, 110.0]
expected
[-7.5, 2.5, 7.5, 12.5]

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