7. Source Code References
Here you can look up source code
and docstrings in blackscholes
.
Table of contents
Black-Scholes-Merton
Black-76
Option Structures
- Straddle (
BlackScholesStraddleLong
,BlackScholesStraddleShort
) - Strangle (
BlackScholesStrangleLong
,BlackScholesStrangleShort
) - Butterfly (
BlackScholesButterflyLong
,BlackScholesButterflyShort
) - Iron Condor (
BlackScholesIronCondorLong
,BlackScholesIronCondorShort
) - Spreads (
BlackScholesBullSpread
,BlackScholesBearSpread
) - Iron Butterfly (
BlackScholesIronButterflyLong
,BlackScholesIronButterflyShort
)
MixIns
Black-Scholes-Merton
Call
Bases: BlackScholesBase
Calculate (European) call option prices and Greeks with the Black-Scholes-Merton formula.
:param S: Price of underlying asset
:param K: Strike price
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/call.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
charm()
Rate of change of delta over time (also known as delta decay).
Source code in blackscholes/call.py
74 75 76 77 78 79 80 81 82 |
|
delta()
Rate of change in option price
with respect to the forward price (1st derivative).
Note that this is the forward delta.
For the spot delta, use spot_delta
.
Source code in blackscholes/call.py
31 32 33 34 35 36 37 |
|
dual_delta()
1st derivative in option price with respect to strike price.
Source code in blackscholes/call.py
46 47 48 49 50 |
|
epsilon()
Change in option price with respect to underlying dividend yield.
Also known as psi.
Source code in blackscholes/call.py
69 70 71 72 |
|
in_the_money()
Naive Probability that call option will be in the money at maturity.
Source code in blackscholes/call.py
84 85 86 |
|
price()
Fair value of Black-Scholes call option.
Source code in blackscholes/call.py
24 25 26 27 28 29 |
|
rho()
Rate of change in option price with respect to the risk-free rate.
Source code in blackscholes/call.py
63 64 65 66 67 |
|
spot_delta()
Delta discounted for interest rates.
For the forward delta, use delta
.
Source code in blackscholes/call.py
39 40 41 42 43 44 |
|
theta()
Rate of change in option price with respect to time (i.e. time decay).
Source code in blackscholes/call.py
52 53 54 55 56 57 58 59 60 61 |
|
Put
Bases: BlackScholesBase
Class to calculate (European) call option prices and Greeks with the Black-Scholes-Merton formula.
:param S: Price of underlying asset
:param K: Strike price
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/put.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
charm()
Rate of change of delta over time (also known as delta decay).
Source code in blackscholes/put.py
75 76 77 78 79 80 81 82 83 |
|
delta()
Rate of change in option price
with respect to the forward price (1st derivative).
Note that this is the spot delta.
For the forward delta, use forward_delta
.
Source code in blackscholes/put.py
30 31 32 33 34 35 36 37 |
|
dual_delta()
1st derivative in option price with respect to strike price.
Source code in blackscholes/put.py
46 47 48 49 50 |
|
epsilon()
Change in option price with respect to underlying dividend yield.
Also known as psi.
Source code in blackscholes/put.py
70 71 72 73 |
|
in_the_money()
Naive Probability that put option will be in the money at maturity.
Source code in blackscholes/put.py
85 86 87 |
|
price()
Fair value of a Black-Scholes put option.
Source code in blackscholes/put.py
24 25 26 27 28 |
|
rho()
Rate of change in option price with respect to the risk-free rate.
Source code in blackscholes/put.py
64 65 66 67 68 |
|
spot_delta()
Delta discounted for interest rates.
For the forward delta, use delta
.
Source code in blackscholes/put.py
39 40 41 42 43 44 |
|
theta()
Rate of change in option price with respect to time (i.e. time decay).
Source code in blackscholes/put.py
52 53 54 55 56 57 58 59 60 61 62 |
|
Base class
Bases: ABC
, StandardNormalMixin
Base functionality to calculate (European) prices and Greeks with the Black-Scholes-Merton formula.
:param S: Price of underlying asset
:param K: Strike price
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/base.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
alpha()
Theta to gamma ratio. Also called "gamma rent". More info: "Dynamic Hedging" by Nassim Taleb, p. 178-181.
Source code in blackscholes/base.py
212 213 214 215 216 |
|
charm()
abstractmethod
Rate of change of delta over time (also known as delta decay).
Source code in blackscholes/base.py
133 134 135 136 |
|
color()
Rate of change of gamma over time.
Source code in blackscholes/base.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
delta()
abstractmethod
Rate of change in option price with respect to the forward price (1st derivative).
Source code in blackscholes/base.py
56 57 58 59 60 61 |
|
dual_delta()
abstractmethod
1st derivative of option price with respect to the strike price.
Source code in blackscholes/base.py
71 72 73 74 |
|
dual_gamma()
Rate of change in delta with respect to the strike price (2nd derivative).
Source code in blackscholes/base.py
86 87 88 89 90 91 92 93 94 |
|
epsilon()
abstractmethod
Change in option price with respect to underlying dividend yield.
Also known as psi.
Source code in blackscholes/base.py
110 111 112 113 114 |
|
gamma()
Rate of change in delta with respect to the underlying asset price (2nd derivative).
Source code in blackscholes/base.py
76 77 78 79 80 81 82 83 84 |
|
get_all_greeks()
Retrieve all Greeks for the Black-Scholes-Merton model implemented as a dictionary.
Source code in blackscholes/base.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
get_core_greeks()
Get the top 5 most well known Greeks. 1. Delta 2. Gamma 3. Vega 4. Theta 5. Rho
Source code in blackscholes/base.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
get_itm_proxies()
Get multiple ways of calculating probability of option being in the money.
Source code in blackscholes/base.py
235 236 237 238 239 |
|
in_the_money()
abstractmethod
Naive probability that option will be in the money at maturity.
Source code in blackscholes/base.py
51 52 53 54 |
|
lambda_greek()
Percentage change in option value per % change in asset price. Also called gearing.
Source code in blackscholes/base.py
123 124 125 126 127 |
|
phi()
2nd order partial derivative with respect to strike price.
Phi is used in the Breeden-Litzenberger formula.
Breeden-Litzenberger uses quoted option prices to estimate risk-neutral probabilities.
Source code in blackscholes/base.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
price()
abstractmethod
Fair value for option.
Source code in blackscholes/base.py
46 47 48 49 |
|
rho()
abstractmethod
Rate of change in option price with respect to the risk-free rate.
Source code in blackscholes/base.py
116 117 118 119 120 121 |
|
speed()
Rate of change in Gamma with respect to change in the underlying price.
Source code in blackscholes/base.py
175 176 177 |
|
spot_delta()
abstractmethod
Delta discounted for interest rates.
For the forward delta, use delta
.
Source code in blackscholes/base.py
63 64 65 66 67 68 69 |
|
theta()
abstractmethod
Rate of change in option price with respect to time (i.e. time decay).
Source code in blackscholes/base.py
102 103 104 105 106 107 108 |
|
ultima()
Sensitivity of vomma with respect to change in volatility.
3rd order derivative of option value to volatility.
Source code in blackscholes/base.py
201 202 203 204 205 206 207 208 209 210 |
|
vanna()
Sensitivity of delta with respect to change in volatility.
Source code in blackscholes/base.py
129 130 131 |
|
vega()
Rate of change in option price with respect to the volatility of the asset.
Source code in blackscholes/base.py
96 97 98 99 100 |
|
veta()
Rate of change in vega
with respect to time.
Source code in blackscholes/base.py
142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
vomma()
2nd order sensitivity to volatility.
Source code in blackscholes/base.py
138 139 140 |
|
zomma()
Rate of change of gamma with respect to changes in volatility.
Source code in blackscholes/base.py
179 180 181 |
|
Black76
Call
Bases: Black76Base
Calculate (European) call option prices and Greeks with the Black-76 formula.
:param F: Price of underlying futures contract
:param K: Strike price
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
Source code in blackscholes/call.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
delta()
Rate of change in option price with respect to the underlying futures price (1st derivative). Proxy for probability of the option expiring in the money.
Source code in blackscholes/call.py
110 111 112 113 114 115 |
|
price()
Fair value of a Black-76 call option.
Source code in blackscholes/call.py
104 105 106 107 108 |
|
rho()
Rate of change in option price with respect to the risk-free rate.
Source code in blackscholes/call.py
131 132 133 134 135 136 137 138 139 |
|
theta()
Rate of change in option price with respect to time (i.e. time decay).
Source code in blackscholes/call.py
117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
Put
Bases: Black76Base
Source code in blackscholes/put.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
delta()
Rate of change in option price with respect to the underlying futures price (1st derivative). Proxy for probability of the option expiring in the money.
Source code in blackscholes/put.py
100 101 102 103 104 105 |
|
price()
Fair value of a Black-76 put option.
Source code in blackscholes/put.py
94 95 96 97 98 |
|
rho()
Rate of change in option price with respect to the risk-free rate.
Source code in blackscholes/put.py
121 122 123 124 125 126 127 128 129 |
|
theta()
Rate of change in option price with respect to time (i.e. time decay).
Source code in blackscholes/put.py
107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
Base class
Bases: ABC
, StandardNormalMixin
Base functionality to calculate (European) prices and Greeks with the Black-76 formula.
This variant of the Black-Scholes-Merton model is often used for pricing options on futures and bonds.
:param F: Futures price
:param K: Strike price
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
Source code in blackscholes/base.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
alpha()
Theta to gamma ratio. Also called "gamma rent". More info: "Dynamic Hedging" by Nassim Taleb, p. 178-181.
Source code in blackscholes/base.py
352 353 354 355 356 |
|
delta()
abstractmethod
Rate of change in option price with respect to the futures price (1st derivative).
Source code in blackscholes/base.py
307 308 309 310 311 |
|
gamma()
Rate of change in delta with respect to the underlying stock price (2nd derivative).
Source code in blackscholes/base.py
313 314 315 316 317 318 319 320 321 |
|
get_all_greeks()
Retrieve all Greeks for the Black76 model implemented as a dictionary.
Source code in blackscholes/base.py
375 376 377 378 379 380 381 382 383 384 385 386 |
|
get_core_greeks()
Get the top 5 most well known Greeks. 1. Delta 2. Gamma 3. Vega 4. Theta 5. Rho
Source code in blackscholes/base.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|
price()
abstractmethod
Fair value for option.
Source code in blackscholes/base.py
302 303 304 305 |
|
rho()
abstractmethod
Rate of change in option price with respect to the risk-free rate.
Source code in blackscholes/base.py
337 338 339 340 341 342 |
|
theta()
abstractmethod
Rate of change in option price with respect to time (i.e. time decay).
Source code in blackscholes/base.py
329 330 331 332 333 334 335 |
|
vanna()
Sensitivity of delta with respect to change in volatility.
Source code in blackscholes/base.py
344 345 346 |
|
vega()
Rate of change in option price with respect to the volatility of underlying futures contract.
Source code in blackscholes/base.py
323 324 325 326 327 |
|
vomma()
2nd order sensitivity to volatility.
Source code in blackscholes/base.py
348 349 350 |
|
Straddle
Long
Bases: BlackScholesStructureBase
Create long straddle option structure.
- Long Straddle -> Put(K) + Call(K)
:param S: Price of underlying asset
:param K: Strike price
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/straddle.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
Short
Bases: BlackScholesStructureBase
Create straddle option structure.
- Short Straddle -> -Put(K) - Call(K)
:param S: Price of underlying asset
:param K: Strike price
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/straddle.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
Strangle
Long
Bases: BlackScholesStructureBase
Create long strangle option structure.
- Long strangle -> Put(K1) + Call(K2)
:param S: Price of underlying asset
:param K1: Strike price for put
:param K2: Strike price for call
It must hold that K1 < K2.
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/strangle.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
Short
Bases: BlackScholesStructureBase
Create short strangle option structure.
- Short strangle -> -Put(K1) - Call(K2)
:param S: Price of underlying asset
:param K1: Strike price for put
:param K2: Strike price for call
It must hold that K1 < K2.
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/strangle.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
Butterfly
Long
Bases: BlackScholesStructureBase
Create long butterfly option structure. - Long butterfly -> Call(K1) - 2 * Call(K2) + Call(K3)
:param S: Price of underlying asset
:param K1: Strike price for 1st option
:param K2: Strike price for 2nd option
:param K3: Strike price for 3rd option
It must hold that K1 < K2 < K3.
Additionally, it must hold that K2 - K1 = K3 - K2
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/butterfly.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
Short
Bases: BlackScholesStructureBase
Create short butterfly option structure.
- Short butterfly -> -Put(K1) + 2 * Put(K2) - Put(K3)
:param S: Price of underlying asset
:param K1: Strike price for 1st option
:param K2: Strike price for 2nd option
:param K3: Strike price for 3rd option
It must hold that K1 < K2 < K3.
Additionally, it must hold that K2 - K1 = K3 - K2
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/butterfly.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
Iron Condor
Long
Bases: BlackScholesStructureBase
Create long iron condor option structure.
- Long iron condor -> Put(K1) - Put(K2) - Call(K3) + Call(K4)
:param S: Price of underlying asset
:param K1: Strike price for 1st option
:param K2: Strike price for 2nd option
:param K3: Strike price for 3rd option
:param K4: Strike price for 3rd option
It must hold that K1 < K2 < K3 < K4.
Additionally, it must hold that K4 - K3 = K2 - K1
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/iron_condor.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
Short
Bases: BlackScholesStructureBase
Create short iron condor option structure.
- Short iron condor -> -Put(K1) + Put(K2) + Call(K3) - Call(K4)
:param S: Price of underlying asset
:param K1: Strike price for 1st option
:param K2: Strike price for 2nd option
:param K3: Strike price for 3rd option
:param K4: Strike price for 3rd option
It must hold that K1 < K2 < K3 < K4.
Additionally, it must hold that K4 - K3 = K2 - K1
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/iron_condor.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
Spreads
Bull Spread
Bases: BlackScholesStructureBase
Create bull spread option structure.
- Bull Spread -> Call(K1) - Call(K2)
:param S: Price of underlying asset
:param K1: Strike price for 1st call
:param K2: Strike price for 2nd call
It must hold that K1 < K2.
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/spread.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
Bear Spread
Bases: BlackScholesStructureBase
Create bear spread option structure.
- Bear Spread -> Put(K1) - Put(K2)
:param S: Price of underlying asset
:param K1: Strike price for 1st put
:param K2: Strike price for 2nd put
It must hold that K1 > K2.
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/spread.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
Iron Butterfly
Long
Bases: BlackScholesStructureBase
Create long iron butterfly option structure.
- Long iron butterfly -> - Put(K1) + Put(K2) + Call(K3) - Call(K4)
:param S: Price of underlying asset
:param K1: Strike price for 1st option
:param K2: Strike price for 2nd and 3rd option
:param K3: Strike price for 4th option
It must hold that K1 < K2 < K3.
Additionally, it must hold that K3 - K2 = K2 - K1 (equidistant strike prices)
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/iron_butterfly.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
Short
Bases: BlackScholesStructureBase
Create short iron butterfly option structure.
- Short iron butterfly -> Put(K1) - Put(K2) - Call(K3) + Call(K4)
:param S: Price of underlying asset
:param K1: Strike price for 1st option
:param K2: Strike price for 2nd and 3rd option
:param K3: Strike price for 4th option
It must hold that K1 < K2 < K3.
Additionally, it must hold that K3 - K2 = K2 - K1 (equidistant strike prices)
:param T: Time till expiration in years (1/12 indicates 1 month)
:param r: Risk-free interest rate (0.05 indicates 5%)
:param sigma: Volatility (standard deviation) of stock (0.15 indicates 15%)
:param q: Annual dividend yield (0.05 indicates 5% yield)
Source code in blackscholes/iron_butterfly.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
Mixins
Standard Normal Distribution
Fast PDF and CDF calculations for standard normal distribution.
Source code in blackscholes/base.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|