Repository navigation
Remove the extra contract unit from the assignment exercise estimate - #10233
Conversation
DefaultOptionAssignmentModel.EstimateArbitragePnL takes the underlying quantity from GetExerciseQuantity, which already includes the contract unit, and then multiplied the exercise proceeds by ContractUnitOfTrade again. For a 100-share contract this inflated the gross exercise proceeds 100 times, so eligible short options could be assigned early even when selling was worth more than exercising. Drop the extra factor; contracts with a unit of 1 are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019TTGAv6fe859ebbCLLfLHP Signed-off-by: Jackmeson1 <130693642+Jackmeson1@users.noreply.github.com>
There was a problem hiding this comment.
Approved. GetExerciseQuantity already multiplies by ContractUnitOfTrade, so dropping the second factor is the right fix. The exercise side now matches the selling side for calls and puts, and contracts with a unit of 1 behave as before.
What I checked:
- With master's model, the new test's two unit-100 time-value cases fail (expected 0, actual 1). All 10
DefaultOptionAssignmentModelTestspass with the change. - I ran my own backtest: 20 short SPY options expiring 2024-03-15, 5–15% in the money, zero fees, 2024-03-12 to 2024-03-14. On master all 20 were assigned at the first check, every one while its bid was above its exercise value (e.g. the 440 call, bid 73.45 vs 73.44). With the change 18 were assigned, none with time value left.
Not covered here, and the same before and after this change: futures options are never assigned early because the exercise side leaves out the future's multiplier. That is now #10234.
I set risk:low: it's a one-line fix that is easy to revert, CI is green, the new tests fail without it, and the end-to-end runs show only the incorrect assignments go away.
There was a problem hiding this comment.
Approved. GetExerciseQuantity already includes the contract unit; removing the second multiplication corrects the exercise estimate without changing fees, settlement handling or eligibility filters.
Independent verification:
- All 100 assignment-model and portfolio-manager tests pass. Substituting master's model makes exactly the two new unit-100 time-value cases fail; restoring this change passes all 10 assignment-model cases.
- Tested end to end with eight short SPY calls and puts expiring March 15, 2024, over March 12–14, with zero fees. Master assigns a 440 call despite its bid of 73.45 exceeding its exercise value of 73.44. With this change, all seven assignments pass the exercise-value assertion, and 56 assignment checks preserve options with time value.
No blocking findings.
Description
DefaultOptionAssignmentModel.EstimateArbitragePnLmultiplied the gross exercise proceeds byContractUnitOfTrade, but the underlying quantity it multiplies already comes fromOption.GetExerciseQuantity, which includes that factor. For a standard 100-share contract the exercise side was 100 times too large, so short deep in-the-money American options inside the model's four-day window were assigned even when selling the option was worth more than exercising it.This removes the extra factor. The option-value terms, fees, settlement handling and the deep-in-the-money and expiry filters are unchanged; contracts with a unit of 1, which the existing tests use, behave as before.
The fix is the commit from #9943 by @Jackmeson1, cherry-picked with its authorship kept.
Related Issue
Closes #9942
Motivation and Context
The model is meant to simulate early assignment only when the option has close to no time value left. With the double-counted unit it assigned nearly every eligible standard equity option.
Requires Documentation Change
No.
How Has This Been Tested?
DefaultOptionAssignmentModelTests.SimulatesAssignmentWithContractUnitOfTrade(8 cases): calls and puts, units 100 and 1, zero fees, three days before expiry, 15% in the money. An option bid above the exercise-and-close value (31.50 vs 29.99) must not be assigned, one below it (29.50) must. The two unit-100 time-value cases fail on master (expected 0, actual 1) and all eight pass with the fix.TestCategory!=TravisExclude&TestCategory!=ResearchRegressionTests): 39999 passed, 112 skipped, 0 failed.Types of changes