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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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