Created
June 17, 2022 18:01
-
-
Save ti-ka/9260182bf35ac167bb9a55fac5648d07 to your computer and use it in GitHub Desktop.
Python fuction to plot the y value of option at expiration
This file contains 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
def option_fx(x, longShort: str, callPut: str, strike, cost): | |
s = strike | |
u = cost | |
if longShort == 'L': | |
if callPut == 'C': | |
return (0 if x < s else x - s) - u # Long call | |
else: | |
return (0 if x > s else s - x) - u # Long Put | |
else: | |
if callPut == 'C': | |
return (0 if x < s else s - x) + u # Short call | |
else: | |
return (0 if x > s else x - s) + u # Short Put |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment