fix(api): scale covered-call premium to the 100-share contract (#32)#39
Open
bradsmithmba wants to merge 1 commit into
Open
fix(api): scale covered-call premium to the 100-share contract (#32)#39bradsmithmba wants to merge 1 commit into
bradsmithmba wants to merge 1 commit into
Conversation
_create_covered_call() added a per-share option premium to 100-share dollar
quantities:
max_profit = premium + (strike - current_price) * 100
max_loss = (current_price * 100) - premium
premium is per share, while the other terms are totals for the 100 shares a
covered call is written against, so both figures were off by premium * 99.
For premium=$2.50, strike=$105, price=$100 the old code reported max_profit
$502.50 and max_loss $9,997.50 instead of $750 and $9,750.
Scale the premium to the contract so all terms are total dollars:
max_profit = (premium + strike - current_price) * 100
max_loss = (current_price - premium) * 100
Closes cloudtrainerwork#32
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_create_covered_call()added a per-share option premium to 100-share dollar quantities:The premium is per share; the other terms are totals for the 100 shares a covered call is written against. Both figures were therefore off by
premium * 99.Closes #32.
Example (premium=$2.50, strike=$105, price=$100)
Fix
Interaction with #13 (PR #29)
PR #29 changed this strategy's
profit_risk_ratiotomax_profit / max_loss. This PR fixes themax_profit/max_lossinputs that ratio consumes. They touch different lines in the same function and merge cleanly; together they make the covered-call ranking correct.🤖 Generated with Claude Code