Post on 30-Oct-2015
Embed Size (px)
EQS FORMULA LANGUAGE
19 June 2012 Version: 2.2
Overview The Bloomberg Equity Screening Formula Language (hereafter the Language) can be used to create criteria in EQS and RV. The Formula Builder UI (In RV, 95 then select Custom Fields; in EQS 98) has wizards that can help you build and configure tokens described in the document. The various elements in the language can be used as building blocks for more complex expressions.
Custom Fields and Formulas The language can be used to create both custom fields and custom formulas. A custom field is created by stringing together multiple fields or modifying fields with arithmetic operators, trends, or dates (see custom field section below). A formula is a field with a condition. A field can be a custom field or an existing field ID, either a CalcRt ID or a field mnemonic. Parentheses may be used to group parts of formulas. With the exception of enumeration values, the Language is case-insensitive.
Custom field examples Description: Latest Filing Cash & Near Cash Items Latest Filing Total Debt (ST & LT Debt) As CalcRt ID: $BS010[lf] - $RR251[lf]
As Mnemonics: $BS_CASH_NEAR_CASH_ITEM[lf] - $SHORT_AND_LONG_TERM_DEBT[lf]
Description: Trailing 12 Month Free Cash Flow / Trailing 12 Month Net Income/Net Profit (Losses)
As CalcRt ID: $RR008[ttm] / $IS050[ttm]
As Mnemonics: $CF_FREE_CASH_FLOW:CQ[ttm] / $NET_INCOME:CQ[ttm]
Custom formula examples Description: (Latest Filing Cash & Near Cash Items Latest Filing Total Debt (ST & LT Debt)) * 2 < Current Market Cap As CalcRt ID: ($BS010[lf] - $RR251[lf]) * 2 < $RR913
As Mnemonics: ($BS_CASH_NEAR_CASH_ITEM[lf] -
$SHORT_AND_LONG_TERM_DEBT[lf]) * 2 < $MKT_CAP
Description: Accelerating Quarterly Sales Growth over the past four quarters As CalcRt ID: $RR033:Q > $RR033:Q-1 > $RR033:Q-2 > $RR033:Q-3
As Mnemonics: $SALES_GROWTH:Q > $SALES_GROWTH:Q-1 > $SALES_GROWTH:Q-2 >
Custom Fields A Custom Field can be displayed as a value in a result set or used to create a formula by applying a condition. Custom Fields can also be referenced from custom formulas. Custom Fields may include literal values such as numbers, dates, and strings, arithmetic operators such as +, -, *, /, and ^ (exponentiation), data functions, and trend functions. Use mm/dd/yyyy (12/31/2005) to specify dates. Enumerated values (e.g. ratings) are specified Aa2. Standard mathematical precedence rules apply: exponentiation precedes multiplication and division which precede addition and subtraction.
Custom Formulas Custom formulas are used to test whether a given security should be included in a result set. They can also be referenced from other formulas. Custom formulas may include logical operators such as =, =, and !=, as well as criteria functions ( see section below). Logical operators may be chained as in 1
Field Modifiers This section discusses field modifiers, which can be applied to Field IDs, including both
CalcRt IDs (e.g. $RR900) and Field Mnemonics (e.g. $PE_RATIO). Fields can be modified to account for specific relative and absolute period referencing as well as currency adjustments.
Q Quarter. Refers to the current fiscal quarter.
H Semi-Annual. Refers to the securitys current semi-annual period
Y Annual. Refers to the securitys current annual period.
C Calendar. Used in conjunction with Q/H/Y modifiers.
[LF] Latest filing. With this modifier, the securitys latest preferred period will be returned. So, if the security normally reports quarterly, the latest quarter will be used, or if the security normally reports semi-annually the latest semi-annual value will be used. This is useful for balance sheet items.
[WTD] Week to Date value**
[MTD] Month to Date value**
[QTD] Quarter to Date value**
[STD] Semi-Annual to Date value**
[YTD] Year to Date value**
[TTM] Trailing Twelve Month. Using the securitys preferred period, add values over the previous twelve months.
[FTM] Blended Forward Twelve Month value.
[CURRENCY=JPY] Set currency for the field. Any ISO 4217 currency code can be used.
yyyymmdd An absolute date in form of Year Month Date eg. 20101230*
* Applicable only to fields with daily values.
** Applicable only within Statistical Functions for fields with daily values
To modify a field to refer to a specific periodicity, append : and a modifier from the table above.
Description: Current Quarter P/E Ratio To modify a field to refer to a relative historical or future period, append a signed (positive or negative) period offset. Negative offsets refer to periods in the past (e.g. for fundamentals):
Description: P/E Ratio 1 quarter ago Positive offsets refer to the future (e.g. for estimates):
Description: Bloomberg Estimates P/E Ratio 1 quarter forward All the previous examples in this section are for fiscal referencing. For calendar
referencing, add C before the periodicity (e.g. $RR900:CY-1).
Description: Latest calendar year P/E Ratio To modify a field to refer to an absolute historical or future period, append : the year another : and an absolute period:
Description: P/E Ratio for fiscal fourth quarter 2005.
Once again, the quarter may be preceded by C for Calendar referencing:
Description: P/E Ratio for calendar fourth quarter 2005.
Description: Intraday P/E Ratio value
Description: P/E Ratio 1 day ago
Description: P/E Ratio 12 months ago
Description: P/E Ratio on 10/30/2010
To modify a field to calculate Trailing or Forward Twelve Month values, append [TTM] or [FTM] respectively.
Description: Trailing twelve month Sales/Revenue/Turnover.
To modify a field to use data from latest filings, append [LF]:
Description: Latest filing Total Assets To perform currency adjustment on a field, append a modifier. For example
[CURRENCY=JPY] (any ISO 4217 currency code may be used).
Description: Sales/Revenue/Turnover in United States Dollars
Function Mnemonics The following section discusses the various function mnemonics. Conditional functions can be used with fields to create a custom formula. Data and Trend Functions need a condition to create a formula. They can also be used for display only purposes.
Description: Filters securities if the expression returns N/A
Description: Filters out companies with N/A for P/E Ratio.
Example: HASDATA(AVG($PE_RATIO:2005:Q4, -4, growth))
Description: Filters out companies with N/A for average growth of P/E quarterly from FY2004:Q4 to FY2005:Q4
Description: Filters securities if the expression does not return N/A. This is the opposite
Example: ISNA ($PE_RATIO)
Description: Returns companies with N/A for P/E Ratio.
Example: ISNA(AVG($PE_RATIO:2005:Q4, -4, growth))
Description: Returns companies with N/A for average growth of P/E quarterly from FY2004:Q4 to FY2005:Q4
Description: Negates the expression.
Description: Filters out companies with N/A for P/E Ratio. Equivalent to
Example: NOT(ISNA(AVG($PE_RATIO:2005:Q4, -4, growth)))
Description: Filters out companies with N/A for average growth of P/E quarterly from FY2004:Q4 to FY2005:Q4. Equivalent to HASDATA(AVERAGEGROWTH($PE_RATIO:2005:Q4, -4))
Function: IF(logical_test, value_if_true, value_if_false)
Description: Returns one value if your logical test is true and another value if it is false. Parameters:
logical_test Any conditional expression using fields with modifiers, custom fields, and/or trend functions
value_if_true Any valid formula value_if_false Any valid formula
Example: IF(ISNA($PE_RATIO), 0, $PE_RATIO)
Description: Creates a custom field that will return P/E Ratio if it is not N/A otherwise it will return 0.
Description: Returns 1 if value of expression is available or 0 otherwise
Example: ISAVAILABLE ($PE_RATIO) Description: will return 1 is P/E exists or 0 otherwise
Description: Returns the actual value if the expression is not N.A, otherwise returns 0
Description: will return the value of P/E or 0 if P/E is not available
Description: Returns the current date. Parameters: N/A
Example: $EXPECTED_REPORT_DT = TODAY()
Description: Filter for companies that are reporting earnings today.
Example: $EXPECTED_REPORT_DT > TODAY() + 5
Description: Filter out companies that will not be reporting earnings within the next five days.
Function: DAYSBETWEEN(date1, d