Hi, I'm having problems trying to include time into my conditions.
date, date_time (date with time), trade_price, bid_price, ask_price
- when there is a trade price, we want to compare which (bid price OR ask price) is closer to trade price.
- When bid price is closer to the trade price, we will consider it as 'sell' and when ask price is closer to the trade price, we will consider it as 'buy'
- The age of the bid or ask price has to be at least 5 seconds and at most 30 minutes old to be considered.
- Suppose there are two bid and ask prices (5 seconds old and 6 seconds old). We will choose the latest quote which will be the 5sec bid and ask price and compared it to the current trade price.
-Suppose there is a bid/ask that happened 10 secs ago, and one that just occurred 4 secs ago, we will choose the 10 second bid/ask price to be compared. However in one second time, we will use the most recent bid/ask price (which was previously 4 seconds ago).
My problem is to include time into my argument. Heres my coding so far as i don't know how to include the above conditions.
if price ^= "." then do;
if abs(bid_price-trade_price) < abs(ask_price-trade_price) then sell=1;
Appreciate any help I can get. Thanks in advance.
Message was edited by: adrian.waw
You have the TIMEPART function and also possibly the LAG function to consider using, however I would expect that you have some other "BY variable list" to consider for each "item" with your analysis - that's not shown in your Excel file.
Suggested Google advanced search arguments, this topic/post:
timepart function site:sas.com
lag function site:sas.com
by group processing site:sas.com