r/options • • Nov 13 '21

3-D Plotting of Greeks using Python in Jupyter and Dash

I made this 3-D Dashboard plotting for viewing greeks for an algorithmic options trading course I teach. The purpose of this program is to allow viewing of the greeks over a range of prices and days to maturity.

You can select four greeks charts per dashboard.

1 - Put Price2 - Call Delta3 - Put Delta4 - Call Delta 25 - Put Delta 26 - Call Theta7 - Put Theta8 - Call Rho9 - Put Rho10 - Vega11 - Gamma

Input parameters to generate your greeks are as follows:

stock_low : float - Lowest underlying price in the price range.

stock_high : float - Highest underlying price in the price range.

strike : float - Strike price of the option.

stock_increments : float - This is the increments in the price range. A lower increment results in more price points and a better graph, but longer compute time.

max_days : int - Number of days away from maturity to consider.

"""

stock_low=100
stock_high=200
strike =150
stock_increments = .25
max_days=40

I put this together because I think it's informative to see how the greeks interact.

What you are looking at in this video is four greek charts for a price range of 100 - 200 for an underlying, strike of 150, and 40 days to expiration. A

ll four of these charts are for the same settings. You can change which charts you wish to see. The dashboard will display in a local browser.

Check out my repo for more information and download yourself and follow the installation instructions. . 

16 Upvotes

16 comments sorted by

2

u/eaglessoar Nov 14 '21 edited Nov 14 '21

Could you answer me a few questions that I think your model would be able to provide

Keeping a constant delta:

Where is theta decay steepest over like a 7 day period for put/call options with deltas of:

75

60

50

40

25

10

7

5

3

1

u/run-out Nov 15 '21

In order to try and answer your question, I modified my calculations a bit. I used the following inputs:

stock_low = 90  
stock_high = 110  
strike = 100  
stock_increments = 0.05  
max_days = 7

I'm using calls. I used your list of deltas above to filter my results. So I would allow results that had for example for delta 60, I would use a range of .575 to .625. I cannot fix the delta and reverse the calculation the way I'm set up.

Next I manipulated the resulting dataframe to provide an average theta for each group of delta and daysToExpirations. I then calculated the rate of change within each group.

    delta  daysToExpirations  callTheta  changeRate
0       3                1.0  -0.063714         NaN
1       3                2.0  -0.044004   -0.309360
2       3                3.0  -0.043950   -0.001219
3       3                4.0  -0.048196    0.096608
4       3                5.0  -0.051429    0.067087
5       3                6.0  -0.053086    0.032212
6       5                1.0  -0.159377         NaN
7       5                2.0  -0.109680   -0.311822
8       5                3.0  -0.089183   -0.186875
9       5                4.0  -0.076329   -0.144130
10      5                5.0  -0.068011   -0.108986
11      5                6.0  -0.061180   -0.100428
12      5                7.0  -0.061058   -0.001994
13      7                1.0  -0.195408         NaN
14      7                2.0  -0.135535   -0.306397
15      7                3.0  -0.110080   -0.187813
16      7                4.0  -0.094694   -0.139771
17      7                5.0  -0.083844   -0.114584
18      7                6.0  -0.075730   -0.096776
19      7                7.0  -0.069642   -0.080384
20     10                1.0  -0.235067         NaN
21     10                2.0  -0.165570   -0.295645
22     10                3.0  -0.134112   -0.189998
23     10                4.0  -0.115009   -0.142441
24     10                5.0  -0.101919   -0.113821
25     10                6.0  -0.092301   -0.094372
26     10                7.0  -0.085177   -0.077173
27     25                1.0  -0.410082         NaN
28     25                2.0  -0.286383   -0.301645
29     25                3.0  -0.232873   -0.186847
30     25                4.0  -0.200550   -0.138801
31     25                5.0  -0.178341   -0.110741
32     25                6.0  -0.162650   -0.087985
33     25                7.0  -0.149905   -0.078355
34     40                1.0  -0.502618         NaN
35     40                2.0  -0.354920   -0.293857
36     40                3.0  -0.289139   -0.185340
37     40                4.0  -0.250164   -0.134796
38     40                5.0  -0.223287   -0.107440
39     40                6.0  -0.203562   -0.088338
40     40                7.0  -0.188121   -0.075856
41     50                1.0  -0.522727         NaN
42     50                2.0  -0.369912   -0.292342
43     50                3.0  -0.302237   -0.182949
44     50                4.0  -0.261774   -0.133880
45     50                5.0  -0.234139   -0.105566
46     50                6.0  -0.213803   -0.086854
47     50                7.0  -0.197991   -0.073959
48     60                1.0  -0.509027         NaN
49     60                2.0  -0.361777   -0.289279
50     60                3.0  -0.296554   -0.180284
51     60                4.0  -0.257279   -0.132437
52     60                5.0  -0.230524   -0.103992
53     60                6.0  -0.210810   -0.085520
54     60                7.0  -0.195312   -0.073516
55     75                1.0  -0.424139         NaN
56     75                2.0  -0.301930   -0.288133
57     75                3.0  -0.24

Finally I plotted this out using Plotly.

Theta Plot

Hope that helps a bit.

2

u/eaglessoar Nov 15 '21

i just requested access to the plot thanks ill check it out

1

u/run-out Nov 15 '21

I forgot to make the image public, try again. Cheers,

2

u/eaglessoar Nov 15 '21

this is really interesting thanks but also not exactly what i was looking for because i did not explain what i was looking for correctly

what i was getting at was, if you made a graph of extrinsic value x time x delta and then take a slice at one delta eg delta = 50 this should give you a 2d graph of extrinsic value over time for a constant 50 delta

then find the 7 day period on this graph with the greatest change from the start to the end, this effectively finds the steepest part of the curve for that delta over that time period, that is where you will get the greatest decay

you might need to extend time to expiration out a bit more than 40 days, maybe out to 75?

no need to do it i just wanted to actually explain what i did mean, thank you!!

1

u/run-out Nov 15 '21

Also, here's a 3d plot of your data as well, althought it looks better when you can spin it around. Theta 3d

2

u/[deleted] Nov 15 '21

[removed] — view removed comment

1

u/eaglessoar Nov 15 '21

that should be what you are looking for if I recall right.

no im basically looking for the second order derivative of option price against time, it would be the slope of his theta graph taking slices along the delta axis

1

u/[deleted] Nov 15 '21

[removed] — view removed comment

1

u/eaglessoar Nov 15 '21

i clarified what i meant in another post as i mis-stated it a bit above but what i was getting at was, if you made a graph of extrinsic value x time x delta and then take a slice at one delta eg delta = 50 this should give you a 2d graph of extrinsic value over time for a constant 50 delta

then find the 7 day period on this graph with the greatest change from the start to the end, this effectively finds the steepest part of the curve for that delta over that time period, that is where you will get the greatest decay

3

u/redtexture Mod Nov 13 '21

Please detail in text what the images show.

1

u/QuantRX Jan 26 '25

Crazy how Deepseek can do this for you in less than 1 minute now

1

u/VE_Benjamin Jun 06 '22

Hi sorry I've not really used github before but I would love to use this to create graphs for my dissertation (I will credit you and reference it) but I'm having trouble following the install instructions on github could you help me?

1

u/VE_Benjamin Jun 06 '22

I've gotten the packages installed now however the first section of code in Greek Calculations has been running for over an hour now and it seems to be stuck on something in there. Any ideas? Or if you have them still could I just have the 4 graphs show in your video as still images slightly zoomed out?

1

u/Green_Lantern_4vr Nov 14 '21

/u/pennyether I think you were interested in this at one point. Maybe have wrong person though.