I will face one of the four situation below every trading day.
1. Keep the old contract and no need to buy a new contract.
2. Sell the old contract ,and buy a new contract with a new strike price.
3. When exdate minus date equal seven, I sell the old contract and buy a new contract with the same strike price.
4. Same as three, but the nearest At-The-Money has the different strike price ,so I sell the old contract and buy a new one with the new strike price.
How can I combine the four situations into one code?
Data data1;
input Date : yymmdd10. Exdate : yymmdd10. CP_FLAG $ Volum Strike_Price Settle_Price ;
format date yymmdd10. exdate :yymmdd10. ;
datalines;
2008/1/2 2008/1/16 C 200 27.0 23.15
2008/1/2 2008/1/16 P 300 27.0 23.15
2008/1/2 2008/1/16 C 552 22.5 23.15
2008/1/2 2008/1/16 P 561 22.5 23.15
2008/1/3 2008/1/16 C 756 25.0 23.42
2008/1/3 2008/1/16 P 654 25.0 23.42
2008/1/3 2008/1/16 C 783 22.5 23.42
2008/1/3 2008/1/16 P 150 22.5 23.42
2008/1/4 2008/1/16 C 276 22.5 27.00
2008/1/4 2008/1/16 P 246 22.5 27.00
2008/1/4 2008/1/16 C 276 25.0 27.00
2008/1/4 2008/1/16 P 221 25.0 27.00
2008/1/4 2008/1/16 C 344 27.5 27.00
2008/1/4 2008/1/16 P 476 27.5 27.00
2008/1/5 2008/1/16 C 222 22.5 24.00
2008/1/5 2008/1/16 P 343 22.5 24.00
2008/1/5 2008/1/16 C 768 25.0 24.00
2008/1/5 2008/1/16 P 343 25.0 24.00
2008/1/5 2008/1/16 C 213 27.5 24.00
2008/1/5 2008/1/16 P 343 27.5 24.00
.
.
.
data for question 3
2008/1/9 2008/1/16 C 393 27.5 24.10
2008/1/9 2008/1/16 P 493 27.5 24.10
2008/1/9 2008/2/15 C 293 25.5 24.10
2008/1/9 2008/2/15 P 693 25.5 24.10
2008/1/9 2008/2/15 C 293 27.5 24.10
2008/1/9 2008/2/15 P 593 27.5 24.10
data for question 4
2008/1/9 2008/1/16 C 393 27.5 29.10
2008/1/9 2008/1/16 P 493 27.5 29.10
2008/1/9 2008/2/15 C 293 27.5 29.10
2008/1/9 2008/2/15 P 693 27.5 29.10
2008/1/9 2008/2/15 C 293 30.0 29.10
2008/1/9 2008/2/15 P 593 30.0 29.10
According to my previous question, i select contract when min{ABS(strike_price-settle_price)}.
Question1: At 1/4 i should choice the contract which has strike_price for 27.5.
The MIN{ABS()} only 0.5. I also want keep the contract that has strike_price for
22.5 at 1/4. When I buy new contract I should sell old contract at 1/4.
Can I keep the contract that has old strike_price and old exdate every time when i buy new contract.
Question2:
If settle price not bigger than previous maximum strike_price like 1/5, i just keep the contract which has old strike_price and old exdate at new date.
At 1/5 i just retain the data
2008/1/5 2008/1/16 C 213 27.5 24.00
2008/1/5 2008/1/16 P 343 27.5 24.00
Question3:
If the date is seven days before Exdate.(date=2008/1/9 exdate=2008/1/16)
No matter settle_price bigger than previous maximum strike_price.
I need to change the contract that i hold to the new contract which has new exdate at next month. At 1/9 i want
the data like example below
2008/1/9 2008/1/16 C 393 27.5 24.10
2008/1/9 2008/1/16 P 493 27.5 24.10
2008/1/9 2008/2/15 C 293 27.5 24.10
2008/1/9 2008/2/15 P 593 27.5 24.10
Question(4)
If settle_price > previous maximum strike_price at 1/9
We buy the new contract that has new strike_price with exdate an next month.
I want the data as follows.
2008/1/9 2008/1/16 C 393 27.5 29.10
2008/1/9 2008/1/16 P 493 27.5 29.10
2008/1/9 2008/2/15 C 293 30.0 29.10
2008/1/9 2008/2/15 P 593 30.0 29.10
I know this question is very complex.
But plz help. Thank you very very very very much.
To SAS HERO
Message was edited by: RemusWayne