Package: fds.sdk.FactSetEstimates
FactSet Estimates client library for PythonGain access to 20+ years of comprehensive estimates and statistics of over 250+ estimated metrics, including financial statement items, product segments, geosegments, and industry metrics. FactSet's consensus estimates are aggregated from a wide base of over 800+ contributors and cover over 19,000 active companies across 90+ countries. Data returned can be accessed on the data frequencies based on quarterly, fiscal years, and calendar years. FactSet Estimates updates on a real time basis intraday (every 5 minutes). Updating times vary based on earning season vs. non-earning season but the goal is to have the data available to the client within a few hours that FactSet receives updated information. Often times updates times can be much faster as FactSet has always been known as one of the fastest estimate providers in the market.This Python package is automatically generated by theOpenAPI Generatorproject:API version: 2.5.0Package version: 1.1.2Build package: org.openapitools.codegen.languages.PythonClientCodegenRequirementsPython >= 3.7InstallationPoetrypoetryaddfds.sdk.utilsfds.sdk.FactSetEstimates==1.1.2pippipinstallfds.sdk.utilsfds.sdk.FactSetEstimates==1.1.2UsageGenerate authentication credentials.Setup Python environment.Install and activate python 3.7+. If you're usingpyenv:pyenvinstall3.9.7
pyenvshell3.9.7(optional)Install poetry.Install dependencies.Run the following:fromfds.sdk.utils.authenticationimportConfidentialClientimportfds.sdk.FactSetEstimatesfromfds.sdk.FactSetEstimates.apiimportbroker_detail_apifromfds.sdk.FactSetEstimates.modelsimport*fromdateutil.parserimportparseasdateutil_parserfrompprintimportpprint# See configuration.py for a list of all supported configuration parameters.# Examples for each supported authentication method are below,# choose one that satisfies your use case.# (Preferred) OAuth 2.0: FactSetOAuth2# See https://github.com/FactSet/enterprise-sdk#oauth-20# for information on how to create the app-config.json file## The confidential client instance should be reused in production environments.# See https://github.com/FactSet/enterprise-sdk-utils-python#authentication# for more information on using the ConfidentialClient classconfiguration=fds.sdk.FactSetEstimates.Configuration(fds_oauth_client=ConfidentialClient('/path/to/app-config.json'))# Basic authentication: FactSetApiKey# See https://github.com/FactSet/enterprise-sdk#api-key# for information how to create an API key# configuration = fds.sdk.FactSetEstimates.Configuration(#     username='USERNAME-SERIAL',#     password='API-KEY'# )# Enter a context with an instance of the API clientwithfds.sdk.FactSetEstimates.ApiClient(configuration)asapi_client:# Create an instance of the API classapi_instance=broker_detail_api.BrokerDetailApi(api_client)# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.ids=["AAPL-USA"]# [str] | Security or Entity identifiers. FactSet Identifiers, tickers, CUSIP and SEDOL are accepted input. <p>***ids limit** =  3000 per request*</p> * Make Note - id limit of 3000 for defaults, otherwise the service is limited to a 30 second duration. This can be reached when increasing total number of metrics requested and depth of history. *# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.metrics=["SALES"]# [str] | Requested metrics. Use the /metrics endpoint to return a list of available estimate items. Note, the number of metrics you are allowed to supply is limited to 1 for now. **Top 10** most used metrics are **EPS, SALES, DPS, EBITDA,EBIT, PRICE_TGT, CFPS, BPS, NET_INC, and ASSETS**.  For more details, visit [Online Assistant Page #15034](https://oa.apps.factset.com/pages/15034).# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.start_date="2019-07-30"# str | Start date for point in time of estimates expressed in YYYY-MM-DD format. (optional)# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.end_date="2020-07-30"# str | End date for point in time of estimates expressed in YYYY-MM-DD format. (optional)# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.frequency="D"# str | Controls the frequency of the data returned.   * **D** = Daily   * **W** = Weekly, based on the last day of the week of the start date.   * **AM** = Monthly, based on the start date (e.g., if the start date is June 16, data is displayed for June 16, May 16, April 16 etc.).         * **AQ** = Quarterly, based on the start date.   * **AY** = Actual Annual, based on the start date.   (optional) if omitted the server will use the default value of "D"# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.periodicity="ANN"# str | The periodicity for the estimates requested, allowing you to fetch Quarterly, Semi-Annual, and Annual Estimates.   * **ANN** - Annual   * **QTR** - Quarterly   * **SEMI** - Semi-Annual   (optional) if omitted the server will use the default value of "ANN"# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.include_all=False# bool | Include All filter is used to identify included and excluded broker details from the consensus   By default the service would return only the brokers included in the consensus-   * **TRUE** = Returns all the brokers included and excluded in the consensus   * **FALSE** = Returns only the broker details included in the consensus     (optional) if omitted the server will use the default value of False# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.fiscal_period_start="2019"# str | Fiscal period start expressed in absolute date formats. Date that will fall back to most recent completed period during resolution.   * **Fiscal Quarter-end** - YYYY/FQ (e.g., 2019/1F, 2019/2F, 2019/3F, 2019/4F)   * **Fiscal Year-end** - YYYY (e.g. 2019)  (optional)# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.fiscal_period_end="2020"# str | Fiscal period start expressed in absolute date formats. Date that will fall back to most recent completed period during resolution.   * **Fiscal Quarter-end** - YYYY/FQ (e.g., 2019/1F, 2019/2F, 2019/3F, 2019/4F)   * **Fiscal Year-end** - YYYY (e.g. 2019)  (optional)# NOTE: The parameter variable defined below is just an example and may potentially contain non valid values. So please replace this with valid values.currency="USD"# str | Currency code for adjusting the data. Use 'ESTIMATE' as input value for the values in Estimate Currency. For a list of currency ISO codes, visit [Online Assistant Page #1470](https://oa.apps.factset.com/pages/1470). (optional)try:# Estimates detail data for fixed fiscal periods# example passing only required values which don't have defaults set# and optional valuesapi_response=api_instance.get_fixed_detail(ids,metrics,start_date=start_date,end_date=end_date,frequency=frequency,periodicity=periodicity,include_all=include_all,fiscal_period_start=fiscal_period_start,fiscal_period_end=fiscal_period_end,currency=currency)pprint(api_response)exceptfds.sdk.FactSetEstimates.ApiExceptionase:print("Exception when calling BrokerDetailApi->get_fixed_detail:%s\n"%e)# # Get response, http status code and response headers# try:#     # Estimates detail data for fixed fiscal periods#     api_response, http_status_code, response_headers = api_instance.get_fixed_detail_with_http_info(ids, metrics, start_date=start_date, end_date=end_date, frequency=frequency, periodicity=periodicity, include_all=include_all, fiscal_period_start=fiscal_period_start, fiscal_period_end=fiscal_period_end, currency=currency)#     pprint(api_response)#     pprint(http_status_code)#     pprint(response_headers)# except fds.sdk.FactSetEstimates.ApiException as e:#     print("Exception when calling BrokerDetailApi->get_fixed_detail: %s\n" % e)# # Get response asynchronous# try:#     # Estimates detail data for fixed fiscal periods#     async_result = api_instance.get_fixed_detail_async(ids, metrics, start_date=start_date, end_date=end_date, frequency=frequency, periodicity=periodicity, include_all=include_all, fiscal_period_start=fiscal_period_start, fiscal_period_end=fiscal_period_end, currency=currency)#     api_response = async_result.get()#     pprint(api_response)# except fds.sdk.FactSetEstimates.ApiException as e:#     print("Exception when calling BrokerDetailApi->get_fixed_detail: %s\n" % e)# # Get response, http status code and response headers asynchronous# try:#     # Estimates detail data for fixed fiscal periods#     async_result = api_instance.get_fixed_detail_with_http_info_async(ids, metrics, start_date=start_date, end_date=end_date, frequency=frequency, periodicity=periodicity, include_all=include_all, fiscal_period_start=fiscal_period_start, fiscal_period_end=fiscal_period_end, currency=currency)#     api_response, http_status_code, response_headers = async_result.get()#     pprint(api_response)#     pprint(http_status_code)#     pprint(response_headers)# except fds.sdk.FactSetEstimates.ApiException as e:#     print("Exception when calling BrokerDetailApi->get_fixed_detail: %s\n" % e)Using PandasTo convert an API response to a Pandas DataFrame, it is necessary to transform it first to a dictionary.importpandasaspdresponse_dict=api_response.to_dict()['data']simple_json_response=pd.DataFrame(response_dict)nested_json_response=pd.json_normalize(response_dict)DebuggingThe SDK uses the standard libraryloggingmodule.SettingdebugtoTrueon an instance of theConfigurationclass sets the log-level of related packages toDEBUGand enables additional logging in PythonsHTTP Client.Note: This prints out sensitive information (e.g. the full request and response). Use with care.importloggingimportfds.sdk.FactSetEstimateslogging.basicConfig(level=logging.DEBUG)configuration=fds.sdk.FactSetEstimates.Configuration(...)configuration.debug=TrueConfigure a ProxyYou can pass proxy settings to the Configuration class:proxy: The URL of the proxy to use.proxy_headers: a dictionary to pass additional headers to the proxy (e.g.Proxy-Authorization).importfds.sdk.FactSetEstimatesconfiguration=fds.sdk.FactSetEstimates.Configuration(# ...proxy="http://secret:password@localhost:5050",proxy_headers={"Custom-Proxy-Header":"Custom-Proxy-Header-Value"})Custom SSL CertificateTLS/SSL certificate verification can be configured with the following Configuration parameters:ssl_ca_cert: a path to the certificate to use for verification inPEMformat.verify_ssl: setting this toFalsedisables the verification of certificates.
Disabling the verification is not recommended, but it might be useful during
local development or testing.importfds.sdk.FactSetEstimatesconfiguration=fds.sdk.FactSetEstimates.Configuration(# ...ssl_ca_cert='/path/to/ca.pem')Documentation for API EndpointsAll URIs are relative tohttps://api.factset.com/contentClassMethodHTTP requestDescriptionBrokerDetailApiget_fixed_detailGET/factset-estimates/v2/fixed-detailEstimates detail data for fixed fiscal periodsBrokerDetailApiget_fixed_detail_for_listPOST/factset-estimates/v2/fixed-detailEstimates detail data for fixed fiscal periodsBrokerDetailApiget_rolling_detailGET/factset-estimates/v2/rolling-detailFactSet estimates detail data for rolling fiscal periodsBrokerDetailApiget_rolling_detail_for_listPOST/factset-estimates/v2/rolling-detailFactSet estimates detail data for rolling fiscal periodsConsensusApiget_fixed_consensusGET/factset-estimates/v2/fixed-consensusRetrieves consensus estimates for a requested list of ids and fixed fiscal periodsConsensusApiget_fixed_consensus_for_listPOST/factset-estimates/v2/fixed-consensusFactSet consensus estimates for fixed fiscal periodsConsensusApiget_rolling_consensusGET/factset-estimates/v2/rolling-consensusRetrieves consensus estimates for a requested list of ids and rolling fiscal periods.ConsensusApiget_rolling_consensus_for_listPOST/factset-estimates/v2/rolling-consensusRetrieves consensus estimates for a requested list of ids and rolling fiscal periodsDataItemsApiget_estimate_metricsGET/factset-estimates/v2/metricsAvailable Estimate metricsDataItemsApiget_estimate_metrics_for_listPOST/factset-estimates/v2/metricsAvailable Estimate metrics or ratios.RatingsApiget_consensus_ratingsGET/factset-estimates/v2/consensus-ratingsRatings consensus estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.RatingsApiget_consensus_ratings_for_listPOST/factset-estimates/v2/consensus-ratingsRatings consensus estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.RatingsApiget_detail_ratingsGET/factset-estimates/v2/detail-ratingsBroker Detail estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.RatingsApiget_detail_ratings_for_listPOST/factset-estimates/v2/detail-ratingsBroker Detail estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.SegmentsApiget_segmentsGET/factset-estimates/v2/segmentsRetrieves product & geographic segment estimates for a requested list of ids and fiscal periodsSegmentsApiget_segments_for_listPOST/factset-estimates/v2/segmentsRetrieves product segment estimates for a requested list of ids and fiscal periodsSurpriseApiget_surpriseGET/factset-estimates/v2/surpriseSurprise estimates for rolling fiscal periodsSurpriseApiget_surprise_for_listPOST/factset-estimates/v2/surpriseSurprise estimates for rolling fiscal periodsDocumentation For ModelsCategoryConsensusEstimateConsensusRatingsConsensusRatingsRequestConsensusRatingsResponseConsensusResponseDetailEstimateDetailRatingsDetailRatingsRequestDetailRatingsResponseDetailResponseErrorResponseErrorResponseSubErrorsFixedConsensusRequestFixedDetailRequestFrequencyIdsMetricMetricsMetricsRequestMetricsResponsePeriodicityPeriodicityDetailPeriodicitySurpriseRollingConsensusRequestRollingDetailRequestSegmentIdsSegmentTypeSegmentsEstimateSegmentsRequestSegmentsResponseStatisticSubcategorySurpriseSurpriseRequestSurpriseResponseDocumentation For AuthorizationFactSetApiKeyType: HTTP basic authenticationFactSetOAuth2Type: OAuthFlow: applicationAuthorization URL:Scopes: N/ANotes for Large OpenAPI documentsIf the OpenAPI document is large, imports in fds.sdk.FactSetEstimates.apis and fds.sdk.FactSetEstimates.models may fail with a
RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:Solution 1:
Use specific imports for apis and models like:from fds.sdk.FactSetEstimates.api.default_api import DefaultApifrom fds.sdk.FactSetEstimates.model.pet import PetSolution 2:
Before importing the package, adjust the maximum recursion limit as shown below:import sys
sys.setrecursionlimit(1500)
import fds.sdk.FactSetEstimates
from fds.sdk.FactSetEstimates.apis import *
from fds.sdk.FactSetEstimates.models import *ContributingPlease refer to thecontributing guide.CopyrightCopyright 2022 FactSet Research Systems IncLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.