Hello all,
I am need of some help in calculating the returns of a derivative strategy know as a straddle (involves simultaneously buying both a put and call option for the underlying stock with the same strike price and same expiration date). My dataset looks like this:
What I want to be able to do is to generate a new variable called "straddle_returns" which can be expressed as straddle_returns= [(C_{t+1}+P_{t+1})-(C_t+P_t)]/(C_t+P_t), where C and P are call and put option prices. To generate this formula, I would need to match observations with the same secid, same datadate, same exdate, same nstrike_price (the strike price of the option), but a different cp_flag (one observation has a cp_flag equal to "C" and the other to "P"). And then the variable "option_price" serves as the option price of the observation (either the price of the call or put, depending on the cp_flag). Anyone know how this could be coded?
It is possible that there are multiple pairs of straddles on the same stock over the same holding period, and that is okay.
I am need of some help in calculating the returns of a derivative strategy know as a straddle (involves simultaneously buying both a put and call option for the underlying stock with the same strike price and same expiration date). My dataset looks like this:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double secid long(datadate exdate) float nstrike_price str2 cp_flag float option_price 101475 14111 14141 55 "C" 2.71875 101475 14111 14141 55 "P" 4.625 101475 14139 14169 55 "P" 3.4375 101475 14139 14169 55 "C" 4 101475 14144 14204 60 "C" 4.5625 101475 14144 14204 60 "P" 5.375 101475 14174 14204 60 "P" 5.0625 101475 14174 14204 60 "C" 2.3125 101475 14202 14232 65 "C" 3.25 101475 14230 14260 60 "P" 3.1875 101475 14230 14260 60 "C" 3.8125 101475 14235 14295 65 "P" 7.875 101475 14235 14295 60 "C" 5.25 101475 14235 14295 65 "C" 3.25 101475 14235 14295 60 "P" 4.8125 101475 14265 14295 80 "C" 5.5 101475 14265 14295 85 "C" 3.25 101475 14265 14295 80 "P" 4.1875 101475 14293 14323 75 "P" 5.6875 101475 14293 14323 75 "C" 3.75 101475 14321 14351 75 "C" 3.5625 101475 14326 14386 70 "C" 5.75 101475 14326 14386 70 "P" 6.75 101475 14326 14386 75 "C" 3.8125 101475 14326 14386 75 "P" 9.875 101475 14354 14414 35 "C" 1.78125 101475 14356 14386 32.5 "C" 1.53125 101475 14356 14386 30 "C" 2.625 101475 14356 14386 32.5 "P" 3.125 101475 14356 14386 30 "P" 1.71875 101475 14384 14414 30 "P" 1.90625 101475 14412 14442 25 "P" 1.71875 101475 14417 14477 25 "P" 1.96875 101475 14417 14477 25 "C" 3 101475 14445 14505 30 "C" 2.0625 101475 14447 14477 30 "C" 1.25 101475 14447 14477 30 "P" 2.875 101475 14475 14505 30 "C" 1.15625 101475 14503 14533 25 "P" 1.78125 101475 14508 14568 25 "C" 1.40625 101475 14508 14568 25 "P" 3 101475 14508 14568 22.5 "P" 1.59375 101475 14538 14568 17.5 "P" 1.5625 101475 14566 14596 15 "P" 2.03125 101475 14566 14596 15 "C" 1 101475 14599 14659 15 "P" 2.875 101475 14599 14659 15 "C" 1 101475 14629 14659 20 "C" 1.84375 101475 14629 14659 20 "P" 1.59375 101475 14657 14687 17.5 "C" 1.15625 101475 14657 14687 17.5 "P" 1.78125 101475 14690 14750 17.5 "P" 2.78125 101475 14690 14750 17.5 "C" 1.4375 101475 14692 14722 15 "P" 1.15625 101475 14692 14722 15 "C" 1.34375 101475 14720 14750 17.5 "C" 1.84375 101475 14720 14750 17.5 "P" 1.25 101475 14748 14778 20 "C" 1.71875 101475 14753 14813 22.5 "C" 2.46875 101475 14781 14841 30 "C" 2.78125 101475 14783 14813 30 "P" 2.9375 101475 14783 14813 30 "C" 1.15625 101475 14811 14841 30 "P" 1.75 101475 14811 14841 30 "C" 2.59375 101475 14872 14932 40 "C" 2.75 101475 14874 14904 40 "C" 2.3125 101475 14902 14932 45 "P" 3.5 101475 14902 14932 45 "C" 2.84375 101475 14930 14960 45 "C" 3.5625 101475 14963 15023 50 "P" 5.3125 101475 14963 15023 50 "C" 4.875 101475 14963 15023 55 "C" 3 101475 14965 14995 50 "C" 2.71875 101475 14965 14995 50 "P" 4.3125 101475 14993 15023 45 "P" 3.5 101475 14993 15023 45 "C" 3.6875 101475 15021 15051 55 "C" 3.05 101475 15021 15051 55 "P" 4.95 101475 15054 15114 45 "P" 3.35 101475 15054 15114 45 "C" 4 101475 15056 15086 45 "P" 2.95 101475 15056 15086 45 "C" 1.625 101475 15084 15114 50 "P" 2.2 101475 15112 15142 55 "C" 3.05 101475 15117 15177 55 "C" 3.6 101475 15145 15205 60 "C" 2.525 101475 15145 15205 60 "P" 3.75 101475 15210 15240 60 "C" 2.85 101475 15210 15240 60 "P" 1.75 101475 15236 15296 65 "P" 4.2 101475 15236 15296 65 "C" 3.9 101475 15238 15268 65 "P" 2.7 101475 15238 15268 65 "C" 3.5 101475 15266 15296 70 "C" 2.85 101475 15266 15296 70 "P" 2.8 101475 15271 15331 70 "C" 3.9 101475 15299 15359 60 "C" 3.75 101475 15327 15387 60 "C" 4.15 101475 15327 15387 60 "P" 3.8 101475 15329 15359 60 "P" 1.975 end format %td datadate format %td exdate label var secid "Security ID" label var datadate "The Date of this Price" label var exdate "Expiration Date of the Option" label var cp_flag "C=Call, P=Put"
It is possible that there are multiple pairs of straddles on the same stock over the same holding period, and that is okay.