Bloomberg EQS

Embed Size (px)

Citation preview

  • 1

    EQS FORMULA LANGUAGE

    REFERENCE

    19 June 2012 Version: 2.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.

  • 3

    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

  • 4

    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

  • 5

    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 Definition

    D Daily*

    W Weekly*

    M Monthly*

    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

  • 6

    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

  • 7

    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

  • 8

    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

  • 9

    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), 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.

    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

  • 10

    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

  • 11

    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

  • 12

    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.

  • 13

    Function: PERCENTILERANK(expression [, lower_is_better] [, is_funneled]

    [,break_ties] [, num_buckets])

    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.

    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

    Relative Screening Functions Relative Screening functions are used to compute numerical values relative to a provided benchmark. These formulas can be created in the Formula window in Advanced Screening Mode by selecting Relative Screening from the dropdown for Function. That is the recommended method for formula creation. Relative Screening is only supported on regions and sectors.

    Function: RELATIVEPERCENTILEVALUE (hierarchy, hierarchy_level, expression,

    percentile, universe, screen_criteria)

    Description: Computes the value at the nth percentile for the relative sector/region Parameters:

    hierarchy hierarchy type for relation hierarchy_level depth of hierarchy traversal expression arithmetic expression percentile depth of hierarchy traversal universe universe list to use for relative screening screen_criteria - criteria to filter the universe list

    Example: $RR900 > relativePercentileValue("HCLASS.GICS", 3, $RR900, 50, "","$RR913[currency=USD] > 250E6")

    Description: P/E is greater than the 50th percentile of securities in the same GICS Industry with market cap larger than 250M.

    Example: $RR903 < relativePercentileValue("MARKET.ALL", 1, $RR903, 30, "","$RR913[currency=USD] > 250E6")

    Description: P/B is less than the 30th percentile of securities in the same region with market cap larger than 250M

  • 15

    Function: Relative_Aggregate_Func(hierarchy, hierarchy_level, expression,

    universe, screen_criteria)

    Description: Computes a relative value for the region/sector hierarchy based on the following function definitions Parameters:

    hierarchy hierarchy type for relation hierarchy_level depth of hierarchy traversal expression arithmetic expression universe universe list to use for relative screening screen_criteria - criteria to filter the universe list

    Function Definition

    RELATIVEMIN Minimum value of the relative hierarchy.

    RELATIVEMAX Maximum value of the relative hierarchy.

    RELATIVEMEDIAN Median value of the relative hierarchy.

    RELATIVESUM Sum of values of the relative hierarchy.

    RELATIVEAVERAGE Average value of the relative hierarchy.

    RELATIVEWEIGHTEDAVERAGE Market Cap Weighted Average value of the relative hierarchy.

    Example: $RR900 > relativeWeightedAverage("HCLASS.GICS", 1, $RR900, "COUNTRY","$RR913[currency=USD] > 250E6")

    Description: P/E is greater than the Weighted Average of P/E of securities in the same country and GICS sector with a market cap larger than 250M.

    Example: $RR903 < relativeMedian("HCLASS.JICS", 1, $RR903, ("IDXHIE.EI09SPX" OR "IDXHIE.EI09TWSE"),"$RR913[currency=USD] >

    50E6")

    Description: P/B is less than the Median of P/B of securities in the same JICS sector, in either the SPX or TAIEX Index with a market cap larger than 50M.

    Example: $RR251[LF] < relativeAverage("HCLASS.GICS", 1, $RR251[LF], "UNIV","$RR913[currency=USD] > 250E6", Y)

    Description: Debt is less than the Average of Debt of securities in the current universe in same GICS sector with market cap larger than 250M.

  • 16

    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

  • 17

    The following table lists the statistical functions supported in EQS

    Function Definition

    MIN Minimum value in the time series.

    MAX Maximum value in the time series.

    SUM Sum of values in the time series.

    AVG Arithmetic average of values in the time series.

    GEOMETRICAVG Geometric average of values in the time series.

    HARMONICAVG Harmonic average of values in the time series.

    MEDIAN Median value in the time series.

    MODE Most frequent value in the time series.

    COUNT Count the number of positive or negative values in time series.

    VOLATILITY Compute the volatility of values in time series.

    STDDEV Value of the Standard deviation.

    ALPHA Alpha value of time series.

    BETA Beta value of time series.

    PERCENTILEINHISTORY Percentile of the latest value compared to the other values in the time series.

    R-SQUARED R-Squared.

    PRDVSPRDGROWTH Growth from start period to end period.

    COMPANNGROWTHRATE 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

  • 18

    Function: ZSCORE (expression [, is_funneled], [truncate, winsorize] )

    Description: Calculates the ZScore for the given expression Parameters:

    expression arithmetic expression is_funneled - Optional. pass Y if you want ZScore to be computed on the entire universe

    truncate - Optional. The positive number of standard deviations away from the data

    mean that should be returned as N/A.

    winsorize - Optional. The positive number of standard deviations away from the

    datas mean that should be returned as the expected value at this number of standard deviations.

    Example: zscore($RR900)

    Description: ZScore of P/E of the current securities in funneled list of securities

    Example: zscore($RR903,Y)

    Description: ZScore of P/B of the current securities on the entire universe

    Example: zscore($RR900,Y,3.5,2)

    Description: Value of P/B of the current securities on the entire universe; truncating on 3.5 standard deviations and winsorizing on 2 standard deviations.

    Example: zscore($RR900,Y,3,3.5)

    Description: Value of P/B of the current securities on the entire universe; truncating on 3 standard deviations. This will force no winsorizing to happen since the winsorize value is greater than the truncate value.

  • 19

    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

  • 20

    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 Functions Old Example: INDECILE($PE_RATIO, 2 , 1, 10)

    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

  • 21

    Trend Functions These are replaced by Statistical Functions

    Old Example New Example Description

    TOTALGROWTH(

    $PE_RATIO:Q, -2)

    PRDVSPRDGROWTH($RR900

    :Q, 2) Total growth from begin period to end period.

    AVERAGEGROWTH(

    $PE_RATIO:Q, -2)

    AVG($PE_RATIO:Q, 2,

    growth) Arithmetic mean of period to period growth.

    CAGR($PE_RATIO:Q, -2) COMPANNGROWTHRATE($PE

    _RATIO:Q, 2) Compound Annual Growth Rate.

    GEOMEANGROWTH($PE_RAT

    IO:Q, -2)

    GEOMETRICAVG(

    $PE_RATIO:Q, 2,

    growth)

    Geometric mean of period to period growth.

    MAXGROWTH(

    $PE_RATIO:Q, -2)

    MAX($PE_RATIO:Q, 2,

    growth) Maximum period to period growth value.

    POSGROWTHCOUNT($PE_RA

    TIO:Q, -2)

    COUNT( $PE_RATIO:Q,

    2, growth, positive) Number of positive growth periods.

    NEGGROWTHCOUNT($PE_RA

    TIO:Q, -2)

    COUNT( $PE_RATIO:Q,

    2, growth, negative) Number of negative growth periods.

    AVERAGEVALUE(

    $PE_RATIO:Q, -2)

    AVG ( $PE_RATIO:Q, 2) Arithmetic mean of periods.

    GEOMEANVALUE(

    $PE_RATIO:Q, -2)

    GEOMETRICAVG (

    $PE_RATIO:Q, 2) Geometric mean of periods.

    MINVALUE(

    $PE_RATIO:Q, -2)

    MIN($PE_RATIO:Q, -2) Minimum period value.

    MAXVALUE(

    $PE_RATIO:Q, -2)

    MAX($PE_RATIO:Q, -2) Maximum period value.

    POSVALUECOUNT(

    $PE_RATIO:Q, -2)

    COUNT( $PE_RATIO:Q,

    2, positive) Number of positive periods.

    NEGVALUECOUNT(

    $PE_RATIO:Q, -2)

    COUNT( $PE_RATIO:Q,

    2, negative) Number of negative periods.