Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculating volatility changes around certain dates

    Hi,

    I use Stata 15.1. Below you find an example of my dataset. It shows daily volatilities (dailyvol) of stock options around Board meetings (BM_date). For each cusip8 (companycode) i want to calculate natural log of volatility change around each board meeting date (BM). I want the volatility change for BM date +/- 3 working days, so [-3, 0] and [0, +3]. My problem is, that for some BM dates i have volatilities for more than +/- 3 days. How do I get rid of those resp. not include them in my calculation?

    The reason why i sometimes have more dates than +/-3 days is because dates of weekends are excluded and i wanted to make sure to have at least 1+/-3 days.


    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double date float dailyvol str10 cusip8 float BM_date
    17534 .44226915 "00095710"     .
    17535  .4248003 "00095710"     .
    17538  .4220365 "00095710"     .
    17539  .3954133 "00095710" 17539
    17540  .4027982 "00095710"     .
    17541  .4016385 "00095710"     .
    17542  .4114357 "00095710"     .
    16553 .21328777 "00105510"     .
    16554   .217566 "00105510"     .
    16555  .2024301 "00105510"     .
    16558 .19593915 "00105510" 16558
    16559 .19071697 "00105510"     .
    16560 .17855527 "00105510"     .
    16561  .1898091 "00105510"     .
    16562  .2194917 "00105510"     .
    16841 .17691123 "00105510"     .
    16842 .18262903 "00105510"     .
    16845 .17993557 "00105510"     .
    16846 .17641973 "00105510" 16846
    16847  .1678104 "00105510"     .
    end
    format %d date
    format %td BM_date
    ------------------ copy up to and including the previous line ------------------

  • #2
    Well, your post poses three separate challenges. I can give you the outlines of how to approach each.

    1. Your dates are difficult to work with because of weekends. Stata has business calendars. In my line of work, these issues don't come up, so I don't actually use these myself and can't give you specific code. But read -help datetime_business_calendars- and the chapter of the PDF manuals installed with your Stata that is linked to from that help file. That will enable you to change from Julian calendar dates to business calendar dates, so that a Friday, Monday, and Tuesday (for one example) will be represented as three consecutive numbers. Then you don't have to worry about the weekends issue.

    2. Definition of "change in volatility." Perhaps there is a standard definition of this in your field, and perhaps others from that discipline on this Forum will chime in with help on this. All I can offer you is that if you give a concrete operational definition (i.e. a formula or a very tight verbal description) of how you would calculate this from the volatility data shown, I would probably be able to show you code that implements that. But I don't know what is meant by "change in" anything when there are 6 values to conside: the range? the standard deviation? the first minus the last? something else?

    3. Restricting whatever calculations define #2 to observations within 3 (business) days of the index date can be accomplished in several ways. If the calculation of "change in" is a simple standard statistic, such as, say the standard deviation over that period, then it is most easily done with Robert Picard, Nick Cox, & Roberto Ferrer's -rangestat- command (which you must install from SSC if you do not already have it.) So, assuming it is the standard deviation you want, and you have already changed your dates to business dates:

    Code:
    gen high = BM_date + 3
    gen low = BM_date - 3
    replace high = 1 if missing(BM_date)
    replace low = 0 if missing(BM_date)
    format high low %td
    rangestat (sd) dailyvol, by(cusip8) interval(date low high)
    If the definition of change in volatility is not something that comes from a simple statistic that -rangestat- can calculated (or can be calculated from those, like range = max - min), then it may be a bit more complicated, but without knowing just what it is, it isn't possible to advise you further.

    Comment

    Working...
    X