from __future__ import annotations
from typing import List
import pandas as pd
import pandasmore as pdm
from finsets.wrds import wrds_api
ibes_ltg
The Forecast Period End Date (fpedats
) is the ending month and year of the fiscal period to which the estimate applies (unless you’re asking for a long-term-growth estimate, in which case the horizon is 3-5 years, so no explicity fiscal period is applicable).
The Activation Date (actdats
) is the date that the forecast/actual was recorded by Thomson Reuters.
The Announce Date (anndats
) is the date that the forecast/actual was reported.
The Review Date (revdats
) is most recent date that an estimate was confirmed as accurate.
The Forecast Period Indicator (fpi
) contains information about the horizon (how far into the future we are estimating). Key values: ‘0’ for LTG, ‘1’-‘5’ for 1 to 5 years in the future, ‘6’-‘9’ for 1 to 4 quarters in the future. Farther horizons are available but they are extremely poorly populated.
Note that for Long Term Growth (LTG) estimates (fpi='0'
), you must NOT select “Forecast Period End Date” as the Date Variable or the query will not return any estimates.
TICKER
is the IBES ticker, which is not necessarily the same as the offical ticker of the firm.
It is possible for a contributing broker to provide multiple revisions to an estimate on the same day. In this scenario, all estimates are available in the Detail history files and only the most current estimate is included in the mean.
The Brokers (estimator
) and Analysts (analys
) are provided under numeric codes.
Estimate Revisions
There are estimates which are dated “after” the announcement date. We have no explanation other than the entry is in error.
Announcement of earnings will increment the FPI variable by 1 in all IBES records for which review date (REVDATS)> report date (ANNDATS_ACT)
If at the time of the next review date the analyst at the same brokerage changes her forecast for the same (TICKER, ANNDATS, FPEDATS, FPI, MEASURE, USFIRM) combination, IBES will add a new observation. If the forecast remains unchanged, IBES will not add new observations, but will adjust the review date accordingly (REVDATS)
= 'Refinitiv via WRDS'
PROVIDER = 'https://wrds-www.wharton.upenn.edu/pages/get-data/ibes-thomson-reuters/ibes-academic/unadjusted-detail/history/'
URL = 'ibes'
LIBRARY = 'detu_epsus'
TABLE = 'wrdsapps_link_crsp_ibes'
LINK_LIBRARY = 'ibcrsphist'
LINK_TABLE = 'M'
FREQ = 1925
MIN_YEAR = None
MAX_YEAR = 'permno'
ENTITY_ID_IN_RAW_DSET = 'permno'
ENTITY_ID_IN_CLEAN_DSET = 'date'
TIME_VAR_IN_RAW_DSET = f'{FREQ}date' TIME_VAR_IN_CLEAN_DSET
list_all_vars
list_all_vars ()
Collects names of all available variables from WRDS f{LIBRARY}.{TABLE}
= list_all_vars() all_vars
all_vars.name.count()
21
default_raw_vars
default_raw_vars ()
parse_varlist
parse_varlist (vars:Union[List[str],str]=None, required_vars:List[str]=[], prefix:str='a.')
Adds required variables to requested variables, validates them, and builds the SQL string with their names
Type | Default | Details | |
---|---|---|---|
vars | List[str] | str | None | list of variables requested by user |
required_vars | List[str] | [] | list of variables that will get downloaded, even if not in vars |
prefix | str | a. | string to add in front of each variable name when we build the SQL string of variable names |
Returns | str |
'value','fpi']) parse_varlist([
'a.value,a.fpi'
get_raw_data
get_raw_data (vars:List[str]=None, required_vars:List[str]=['ticker', 'anndats'], nrows:int=None, start_date:str=None, end_date:str=None, permno_match_score:tuple=(1,))
Downloads vars
from start_date
to end_date
from WRDS ibes.detu_epsus
library and adds PERMNO from CRSP
Type | Default | Details | |
---|---|---|---|
vars | List[str] | None | If None, downloads default_raw_vars ; permno , ticker , and anndats added by default |
required_vars | List[str] | [‘ticker’, ‘anndats’] | list of variables that will get downloaded, even if not in vars |
nrows | int | None | Number of rows to download. If None, full dataset will be downloaded |
start_date | str | None | Start date in MM/DD/YYYY format |
end_date | str | None | End date in MM/DD/YYYY format; if None, defaults to current date |
permno_match_score | tuple | (1,) | accuracy of permno-ibes link. 1-6. 1 is best. use >1 with caution. |
Returns | pd.DataFrame |
= get_raw_data(start_date='01/01/2019', end_date='01/01/2022', nrows=1)
ltg ltg.head()
ticker | anndats | value | fpi | fpedats | revdats | actdats | estimator | analys | permno | ||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0001 | 2019-01-04 | -174.4 | 0 | None | 2019-01-04 | 2019-01-04 | 183.0 | 48368.0 | D | 14392.0 |