Você está na página 1de 19

EQS <GO> FORMULA LANGUAGE REFERENCE

24 November 2010 Version: 1.1

Overview
The Bloomberg Equity Screening Formula Language (hereafter the Language) can be used to create criteria in EQS<GO> and RV<GO>. The Formula Builder UI (In RV, 95<GO> then select Custom Fields; in EQS 98<GO>) 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 > $SALES_GROWTH:Q-3

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 <= A <= 2. Multiple conditions can be joined together by AND or OR. AND has higher precedence than OR, so the formula A OR B AND C is evaluated as A OR (B AND C).

Note:

RV only supports Custom Fields while EQS support both Custom Fields and Formulae.

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. Modifier
D W M Q H Y C [LF]

Definition Daily* Weekly* Monthly* Quarter. Refers to the current fiscal quarter. Semi-Annual. Refers to the securitys current semi-annual period Annual. Refers to the securitys current annual period. Calendar. Used in conjunction with Q/H/Y modifiers. 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 semiannually the latest semi-annual value will be used. This is useful for balance sheet items.

[WTD] [MTD] [QTD] [STD] [YTD] [TTM] [FTM] [CURRENCY=JPY] yyyymmdd

Week to Date value** Month to Date value** Quarter to Date value** Semi-Annual to Date value** Year to Date value** Trailing Twelve Month. Using the securitys preferred period, add values over the previous twelve months. Blended Forward Twelve Month value. Set currency for the field. Any ISO 4217 currency code can be used. 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. Example: $PE_RATIO:Q 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): Example: $PE_RATIO:Q-1 Description: P/E Ratio 1 quarter ago Positive offsets refer to the future (e.g. for estimates): Example: $BEST_PE_RATIO:Q+1 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). Example: $PE_RATIO: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: Example: $PE_RATIO:2005:Q4 Description: P/E Ratio for fiscal fourth quarter 2005. Once again, the quarter may be preceded by C for Calendar referencing: Example: $PE_RATIO:2005:CQ4 Description: P/E Ratio for calendar fourth quarter 2005. Example: $PE_RATIO:D Description: Intraday P/E Ratio value Example: $PE_RATIO:D-1 Description: P/E Ratio 1 day ago Example: $PE_RATIO:M-12 Description: P/E Ratio 12 months ago

Example: $PE_RATIO:20101030 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. Example: $SALES_REV_TURN[TTM] Description: Trailing twelve month Sales/Revenue/Turnover. To modify a field to use data from latest filings, append [LF]: Example: $BS_TOT_ASSET[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). Example: $SALES_REV_TURN[CURRENCY=USD] 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.

Conditional Functions
Function: HASDATA(expression) Description: Filters securities if the expression returns N/A Example: HASDATA($PE_RATIO) 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

Function: ISNA(expression) Description: Filters securities if the expression does not return N/A. This is the opposite of HASDATA() 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

Function: NOT(expression) Description: Negates the expression. Example: NOT(ISNA($PE_RATIO)) Description: Filters out companies with N/A for P/E Ratio. Equivalent to HASDATA($PE_RATIO). 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),$PE_RATIO, 0) Description: Creates a custom field that will return P/E Ratio if it is not N/A otherwise it will return 0.

Function: ISAVAILABLE(expression) 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 Function: ZEROIFNA(expression) Description: Returns the actual value if the expression is not N.A, otherwise returns 0 Example: ZEROIFNA($PE_RATIO) Description: will return the value of P/E or 0 if P/E is not available

Date Functions
Function: TODAY() 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, date2) Description: Returns the actual number of days between start and end dates. Parameters: date1, date2 Can be a date field or TODAY() or an actual date in form mm/dd/yyyy Example: DaysBetween($EXPECTED_REPORT_DT, TODAY()) Description: Number of days between Earnings Report Date and today (note that if Earnings report date is before today then value returned is negative) Example: DaysBetween($EXPECTED_REPORT_DT, 12/22/2010) Description: Number of days between Earnings Report Date and Dec 22 2010

10

Mathematical Functions
The Syntax is
Function(expression)

The supported functions are listed in the table below. Function Definition ABS Returns the absolute value of an expression. LOG Returns the base 10 logarithm of an expression. LN Returns the natural logarithm of an expression. EXP Returns the exponential of an expression. ROUND Rounds to the nearest integer. SQRT Square root of a number. COS Cosine . SIN Sine. TAN Tangent. COSH Hyperbolic Cosine. SINH Hyperbolic Sine. TANH Hyperbolic Tangent. Example: ABS($PE_RATIO) Description: Returns the absolute value of P/E Ratio. Example: LOG($PE_RATIO) Description: Returns the base 10 logarithm of P/E Ratio. Example: LN($PE_RATIO) Description: Returns the natural logarithm of P/E Ratio. Example: EXP(LN($PE_RATIO+1)) Description: Returns P/E Ratio+1. Example: Round($PE_RATIO) Description: Rounds P/E Ratio to nearest whole number Example: Sqrt(Sin($PE_RATIO)) Description: Square root of Sine of P/E Ratio

11

Ranking Functions
Rank functions are used to compute numerical ranks for an expression. Ranks can be computed on the set of securities in the universe or the funneled set of securities from the previous criteria. Function:
RANK(expression [, lower_is_better] [, is_funneled] [, break_ties])

Description: Computes rank for each security based on the expression value Parameters: expression arithmetic expression lower_is_better Optional. pass Y if you want lower values to get higher ranks. is_funneled - Optional. pass Y if you want the rank to be computed on the entire universe break_ties Optional. pass Y if you want the ranks to be always unique Example: RANK($PE_RATIO) Description: Rank of P/E Ratio Example: RANK($PE_RATIO, Y, Y) Description: Rank of P/E Ratio with lower values getting better ranks and computed on the entire universe.

12

Function:
PERCENTILERANK(expression [, lower_is_better] [,break_ties] [, num_buckets]) [, is_funneled]

Description: Computes the percentile Rank for each security based on the expression value Parameters: Expression arithmetic expression lower_is_better Optional. pass Y if you want lower values to get higher ranks is_funneled - Optional. pass Y if you want the rank to be computed on the entire universe break_ties Optional. pass Y if you want the ranks to be always unique num_buckets Optional. Number of buckets to use. 100 is percentile and used by default. 10 is decile, 4 is quartile and 5 is quintile.

Example: PERCENTILERANK($PE_RATIO) Description: Percentile Rank of P/E Ratio Example: PERCENTILERANK($PE_RATIO, Y, Y) Description: Percentile Rank of P/E Ratio with lower values getting better ranks and computed on the entire universe. Example: PERCENTILERANK($PE_RATIO, Y, Y, N, 10) Description: Decile Rank of P/E Ratio with lower values getting better ranks and computed on the entire universe.

13

Function: PERCENTOFTOTAL(expression [, is_funneled]) Description: Computes percent of securitys value for the expression to the total of the expression for the security set Parameters: expression arithmetic expression is_funneled - Optional. pass Y if you want the rank to be computed on the entire universe Example: PERCENTOFTOTAL($PE_RATIO) Description: P/E Ratio of a security as percentage of total P/E Ratio of securities from previous screening criteria Example: PRECENTOFTOTAL($PE_RATIO, Y) Description: P/E Ratio of a security as percentage of total P/E Ratio of securities in the screening universe

14

Statistical Functions
Use these functions to compute statistics on time series data. The syntax for all statistic functions is
Statistical_Function(field, number_of_periods [, granularity] [, stats_options])

Parameters: field A time series field. eg. Fundamentals, Estimates, Price Ratio fields, Price, Volume. See the section Field Modifiers on how to configure fields. number_of_periods Number of historical periods of data to look at. To look at future periods use a negative number. granularity Granularity of values. Use D for daily, W for weekly, M for monthly, Q for Quarterly, S for Semi-annually and Y for Yearly If no granularity is unspecified, the same granularity is used as the periodicity. stats_options The following options can be applied on the statistical functions. fillNA if a period is NA, backfill with previous value expsmooth=factor exponentially smooth by the factor specified. factor should be a number between 0 and 1. (applicable only on daily time series fields such as P/E Ratio) growth compute the statistical function on growth of values annualize Apply annualization on values (applicable only on daily timeseries) positive Used with the Count function to count the number of positive values negative Used with the Count function to count the number of negative values

15

The following table lists the statistical functions supported in EQS Function
MIN MAX SUM AVG GEOMETRICAVG HARMONICAVG MEDIAN MODE COUNT VOLATILITY STDDEV ALPHA BETA PERCENTILEINHISTORY R-SQUARED PRDVSPRDGROWTH COMPANNGROWTHRATE

Definition Minimum value in the time series. Maximum value in the time series. Sum of values in the time series. Arithmetic average of values in the time series. Geometric average of values in the time series. Harmonic average of values in the time series. Median value in the time series. Most frequent value in the time series. Count the number of positive or negative values in time series. Compute the volatility of values in time series. Value of the Standard deviation. Alpha value of time series. Beta value of time series. Percentile of the latest value compared to the other values in the time series. R-Squared. Growth from start period to end period. CAGR(Compounded Annual Growth Rate) from start period to end period.

Example:
MIN($PE_RATIO:Q, 10)

Description: Minimum Quarterly P/E Ratio over last 10 quarters Example:


MIN($PE_RATIO:Q, 10, growth)

Description: Minimum Quarterly P/E Ratio growth over last 10 quarters Example:
AVG($PE_RATIO:W, 10, D, expsmooth=0.5, growth, fillNA)

Description: Minimum Daily P/E Ratio growth over last 10 weeks smoothed with an exponential smoothing factor of 0.5 and filling NA values with previous value Example:
PERCENTILEINHISTORY($PE_RATIO:20100101, 20100630, D)

Description: What percentile does P/E Ratio for 20100630 fall in compared to P/E Ratio values between 01/01/2010 and 06/30/2010

16

Formula References
Fields and Formulas can refer to existing user custom fields or formulas, by using a @ or # followed by an identifier, created by the program. Formulas are referenced using @ and fields are referenced using #. In either case, the reference operator is followed by an identifier for the referenced formula. Formulas may contain references to either fields or other formulas; Fields may only contain references to other fields. Circular references are not allowed. For example, if a user has a custom field that is named 5YMinGr with a corresponding identifier of 210 and they want to divide it by 10, they can reference this by typing #210/10

17

Appendix Deprecated Functions


INDECILE
Old Function: INDECILE(expression, outliers, min_decile, max_decile) Description: Filters securities to those that are within the min_decile and max_decile, inclusive. New Function: See section on Ranking Old Example:
INDECILE($PE_RATIO, 2 , 1, 10)

Functions

New Example:
1 PERCENTILERANK($PE_RATIO, N, N, N, 10) 10

Description: Securities within 0%-100% deciles of P/E Ratio.

Old Example:
INDECILE( AVERAGEGROWTH($PE_RATIO:2005:Q4, -4), 0, 5, 10)

New Example:
5 PERCENTILERANK(AVG($PE_RATIO:2005:Q4, 4, growth),N,N,N, 10) 10

Description: Securities within 40%-100% deciles of the average growth of P/E quarterly from FY2004:Q4 to FY2005:Q4

18

Trend Functions These are replaced by Statistical Functions


Old Example
TOTALGROWTH( $PE_RATIO:Q, -2) AVERAGEGROWTH( $PE_RATIO:Q, -2) CAGR($PE_RATIO:Q, -2)

New Example
PRDVSPRDGROWTH($RR900 :Q, 2) AVG($PE_RATIO:Q, 2, growth) COMPANNGROWTHRATE($PE _RATIO:Q, 2) GEOMETRICAVG( $PE_RATIO:Q, 2, growth) MAX($PE_RATIO:Q, 2, growth) COUNT( $PE_RATIO:Q, 2, growth, positive) COUNT( $PE_RATIO:Q, 2, growth, negative) AVG ( $PE_RATIO:Q, 2) GEOMETRICAVG ( $PE_RATIO:Q, 2) MIN($PE_RATIO:Q, -2) MAX($PE_RATIO:Q, -2) COUNT( $PE_RATIO:Q, 2, positive) COUNT( $PE_RATIO:Q, 2, negative)

Description Total growth from begin period to end period. Arithmetic mean of period to period growth. Compound Annual Growth Rate. Geometric mean of period to period growth. Maximum period to period growth value. Number of positive growth periods. Number of negative growth periods. Arithmetic mean of periods. Geometric mean of periods. Minimum period value. Maximum period value. Number of positive periods. Number of negative periods.

GEOMEANGROWTH($PE_RAT IO:Q, -2) MAXGROWTH( $PE_RATIO:Q, -2) POSGROWTHCOUNT($PE_RA TIO:Q, -2) NEGGROWTHCOUNT($PE_RA TIO:Q, -2) AVERAGEVALUE( $PE_RATIO:Q, -2) GEOMEANVALUE( $PE_RATIO:Q, -2) MINVALUE( $PE_RATIO:Q, -2) MAXVALUE( $PE_RATIO:Q, -2) POSVALUECOUNT( $PE_RATIO:Q, -2) NEGVALUECOUNT( $PE_RATIO:Q, -2)

19