LIVE·WAITING…
connecting to the live quote stream…
--:--:--UTC
#47
Wheel cash-flow ledger
mediumTradingacceptance —~30 min
Implement wheel_ledger(events) — the net cash of a wheel campaign. Events are lists: ["put", premium] (sold a put, receive premium), ["assign", strike, shares] (put assigned, pay strike·shares), ["call", premium] (sold a covered call, receive premium), ["called_away", strike, shares] (shares called away, receive strike·shares). Sum every flow.
The wheel is premium in, stock in, premium in, stock out — a ledger, not a strategy, until you can add it up. The workbench's wheel bot backtests exactly these flows. Return the net cash rounded to 4 decimal places.
example 1
input
events=[["put", 150.0], ["put", 120.0]]
output
270
example 2
input
events=[["put", 200.0], ["assign", 50.0, 100], ["call", 90.0], ["called_away", 52.0, 100]]
output
490
note
Assigned at 50, called away at 52 — the shares came back as cash.
constraints
- 1 ≤ len(events) ≤ 200
- event names are exactly the four above
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 wheel_ledger()
events=[["put", 150.0], ["put", 120.0]]
expected
270
the judge calls wheel_ledger() 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