FAILURE MAP
← Case archive

FA-61673 / Options payoff and settlement / Member archive

FIFO realized P&L for option trades: the excess of a flipping trade is dropped · case 03

Selling more than the long position closes it but never opens the short.

Member previewVariant 3 · 3 implementations · 8 checks per implementation

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 fixture

This sample comes from the broken implementation of a controlled reproducer.

Boundary fixtureActualExpectedOutcome
regression position flip remainder 1[0, 530.0, 17.0][3, 1325.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 ↗