Conditions can be constructed in four ways:
Comparing one attribute to another.
Comparing a date to a pattern.
Comparing a time to a pattern
A condition macro.
Comparing one attribute to another is the most obvious condition available. The comparison is made using one of the seven following conditional operators. Each operator has logical modifiers associated with it. The modifiers “is” or “is not”, can be used with operator 1-5, and the modifiers “does” or “does not”, are for use with operators 6 and 7. If there is shorthand for the statement, it will follow in parentheses.
more than (>)
at least (>=)
less than (<)
at most (<=)
exactly (==)
crosses above
crosses below
The general form for this type condition is <attribute> <conditional operator> <attribute>.
Examples of comparing attributes:
Close of US is more than Close of US 1 day ago
Close of US is not more than Close of US 1 day ago
Close of US is exactly High of US
Low of US >= 1 week High of US 1 week ago
Close of IBM crosses above 50 day average of IBM
Close of IBM does not cross above 50 day average of IBM
Note the difference of these two statements:
Close of IBM is more than 50 day average of IBM
Close of IBM crosses above 50 day average of IBM
The point to be made here is that when “crosses above” is used, there is a single day when the condition is true. The day when the close is above the average, but it was not the day before. This would be useful in evaluating the effect of IBM crossing above its average by showing using the following attribute.
move from today to 1 week later of close of IBM
By using the “crosses above” statement, there will be 1 number returned for each time the close crosses above the average. If we had used the “is more than” operator, there would be a number showed each day IBM closed above its average, so that the event being studied would no longer be “when IBM closed above its average”.
A date comparison always begins with the statement Date is, or Date is not and is followed by the pattern to match.
The following patterns are available.
Date is mm/dd/yyyy
Any of the 3 tokens can be either a number, a variable, or the wild card “_”, (which is always true).
Examples:
Date is 8/2/1999
Date is 8/myVar/1999
Date is 8/2/_ (matches Aug. 2nd every year)
Date is date:DateVar
DateVar contains the Julian date to be matched. The Julian date can be calculated using the construct date function as follows.. DateVar = construct_date( 8, 2, 1999 ). Then the date comparison Date is date:DateVar can be made.
Date is date:myDateVar
Date is from <date> to <date>
Where <date> is any valid date created using the patterns outlined in this section.
Date is from 1/1/1999 to 3/1/1999
Date is from 8/2/_ to date:dateVar
Date is <calendar name>
Where <calendar name> is any weekday name (Monday to Sunday), month name (January to December), quarter (1st to 4th), and year.
Date is Monday
Date is January
Date is 3rd Quarter
Date is 1999
Date is <special day>
Where <special day> are date patterns that are pre-loaded into the MIM.
Date is New Years Day
Date is Labor Day
Date is in <date file>
Where date file is the path to any ASCII file containing dates of the format yyyymmdd or mm/dd/yy. LIM updates 2900+ date files each day which describe events from treasury auctions to phases of the moon. These files can be found at /home/lim/dates.
Date is in “/home/lim/dates/user/opc_meet.date”
Date is in “/home/lim/dates/user/m_supply.rpt”
Date is <symbol specific date>
Where <symbol specific date> is a combination of a symbol, and an event name. The valid event names are Expiration, First data, Last data, Ex dividend, Release, and Split. The event name may be followed by the word “day” to improve readability, and case is optional.
Date is US Expiration
Date is US expiration day
Date is US first data day
Date is <time period> <boundary>
Where <time period> is a standard time period and boundary is either open or close.
Date is weekly open
Date is day open
Date is nth [to last] <small period> of <big period>
Where nth is the number of small periods to count from the big period boundary. <small period> is the day, week, or any day name from Monday to Sunday. <big period> is week, month, quarter, year, or any month name from January to December. This (for example) will count the number of days to some larger time boundary, and use of the optional “to last” syntax reverses the direction of counting.
Date is 1st day of the week
Date is 3rd to last week of the year
Date is within n <time period>
Where time period is a standard time period.
Date is within 1 week
Date is within 9 months
This is perhaps not obvious after all the definitions that have gone before. The offset is relative to the actual date at the time the query is run, such that since I am writing this on January 8, 2000, when I use the condition Date is within 1 week, then the results will be different (by one day) than if I ran the query 1 day later.
A time comparison always begins with the statement Time is, or Time is not and is followed by the pattern to match. The following patterns are available.
Time is hh[:]mm [am|pm]
Time is from <time> to <time>
Time is <time period> <boundary>
Time is [first|last] N <time period> of trading
Time is time:timeVar
Time is <system variable>
Time is <symbol specific time>
IF-THEN-ELSE statements use the general form:
IF <condition> THEN <condition> ELSE <condition> ENDIF
Where <condition> is any legal condition outlined within this chapter.