FA-61663 / Options payoff and settlement / Member archive
FIFO realized P&L for option trades: closing a short lot books the price change with the long sign · case 03
Buying back a short option at a lower premium records a loss.
Case contract
Inputs trades [side B/S, contracts, premium], multiplier and fee per contract. Positions may be long or short. Each trade first closes opposite-direction lots oldest first; realized P&L per matched contract is (close - open) for long lots and (open - close) for short lots, times the multiplier. Any remainder opens a new lot in the trade direction. Fees = contracts traded * fee. Work in cents; return [net position, realized, fees].
Why this case matters
Option expiry, exercise and settlement engines move cash and shares; a wrong branch misstates obligations.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression short lot pnl sign 1 | [3, -1660.0, 17.0] | [3, -770.0, 17.0] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗