Hi, I'm having problems trying to include time into my conditions.
variables are:
date, date_time (date with time), trade_price, bid_price, ask_price
conditions are:
- 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.
Some examples:
- 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.
data data_new1;
set data_timestamp1;
if price ^= "." then do;
if abs(bid_price-trade_price) < abs(ask_price-trade_price) then sell=1;
else buy=1;
end; run;
Appreciate any help I can get. Thanks in advance.
Message was edited by: adrian.waw