BookmarkSubscribeRSS Feed
RemusWayne
Calcite | Level 5
CASE we want write loop to pick data. Every day has many data we just simple the data as follow.

When DATE is 2008/1/2, find the minimum value of the absolute value of SETTLE PRICE minus STRIKE PRICE.
Then, there are two data left, and that is what we need to buy. A CALL and a PUT (they both have the same EXDATE and STRIKE PRICE)

1/3 we buy the call and put that strike price = 22.5


Data data1;
Input Date Exdate CP_FLAG Bid Ask Volum Strike_Price Settle_Price
format date yymmdd10. exdate :yymmdd10. ;
datalines;
2008/1/2 2008/1/16 C 2.3 2.6 2000 27.0 23.15
2008/1/2 2008/1/16 P 2.1 2.7 3000 27.0 23.15
2008/1/2 2008/1/16 C 2.4 2.5 5528 22.5 23.15
2008/1/2 2008/1/16 P 1.1 1.2 5617 22.5 23.15
Set an ASSET ACCOUNT (the value of the option we hold is the mid price of bid and ask)

When date comes to 2008/1/3;we still have to find the minimum value of absolute value of SETTLE PRICE minus STRIKE PRICE.
And the data we left are showed as follow:

Datalines;
2008/1/2 2008/1/16 C 2.47 2.5 528 22.5 23.15
2008/1/2 2008/1/16 P 1.10 1.2 617 22.5 23.15
1008/1/3 2008/1/16 C 1,99 2.0 756 25.0 23.42
2008/1/3 2008/1/16 P 2.99 3.0 654 25.0 23.42
2008/1/3 2008/1/16 C 2.05 2.2 783 22.5 23.42
2008/1/3 2008/1/16 P 1.20 1.2 150 22.5 23.42

Compared with the data left in 2008/1/2, on 1/3 we buy the call and put that strike price is 22.5
because
Minimum ABS(strike price-settle price)= 22.5-13.42 not
25-23.42

Message was edited by: RemusWayne

Message was edited by: RemusWayne Message was edited by: RemusWayne
1 REPLY 1
Ksharp
Super User
After spending ten minutes,Finally understand somewhat you post.

1008/1/3 2008/1/16 C 1,99 2.0 756 25.0 23.42


Minimum ABS(strike price-settle price)= 22.5 13.42



You can use sql 's Cartestian Product to get it easily.


[pre]
Data data1;
input Date : yymmdd10. Exdate : yymmdd10. CP_FLAG $ Bid Ask Volum Strike_Price Settle_Price ;
format date yymmdd10. exdate :yymmdd10. ;
datalines;
2008/1/2 2008/1/16 C 2.3 2.6 2000 27.0 23.15
2008/1/2 2008/1/16 P 2.1 2.7 3000 27.0 23.15
2008/1/2 2008/1/16 C 2.4 2.5 5528 22.5 23.15
2008/1/2 2008/1/16 P 1.1 1.2 5617 22.5 23.15
2008/1/3 2008/1/16 C 1.99 2.0 756 25.0 23.42
2008/1/3 2008/1/16 P 2.99 3.0 654 25.0 23.42
2008/1/3 2008/1/16 C 2.05 2.2 783 22.5 23.42
2008/1/3 2008/1/16 P 1.20 1.2 150 22.5 23.42
;
run;
proc sql;
create table want as
select *
from data1
group by date
having abs(strike_price-settle_price)=min(abs(strike_price-settle_price))
;
run;
[/pre]


So weird , Why my post is always truncated.


Ksharp

Message was edited by: Ksharp Message was edited by: Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 592 views
  • 0 likes
  • 2 in conversation