Skip to main content

FactSet Estimates client library for Python

Project description

FactSet

FactSet Estimates client library for Python

PyPi Apache-2 license

Gain 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 the OpenAPI Generator project:

  • API version: 2.3.0
  • Package version: 0.20.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements

  • Python >= 3.6

Installation

Poetry

poetry add fds.sdk.utils fds.sdk.FactSetEstimates

pip

pip install fds.sdk.utils fds.sdk.FactSetEstimates

Usage

  1. Generate authentication credentials.
  2. Setup Python environment.
    1. Install and activate python 3.6+. If you're using pyenv:

      pyenv install 3.9.7
      pyenv shell 3.9.7
      
    2. (optional) Install poetry.

  3. Install dependencies.
  4. Run the following:
from fds.sdk.utils.authentication import ConfidentialClient
import fds.sdk.FactSetEstimates
from fds.sdk.FactSetEstimates.api import broker_detail_api
from fds.sdk.FactSetEstimates.model.detail_response import DetailResponse
from fds.sdk.FactSetEstimates.model.error_response import ErrorResponse
from fds.sdk.FactSetEstimates.model.fixed_detail_request import FixedDetailRequest
from fds.sdk.FactSetEstimates.model.rolling_detail_request import RollingDetailRequest
from pprint import pprint

# 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
# See https://github.com/FactSet/enterprise-sdk-utils-python#authentication
# for more information on using the ConfidentialClient class
configuration = 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 client
with fds.sdk.FactSetEstimates.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = broker_detail_api.BrokerDetailApi(api_client)
    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. * 
    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). 
    start_date = "2019-07-30" # str | Start date for point in time of estimates expressed in YYYY-MM-DD format. (optional)
    end_date = "2020-07-30" # str | End date for point in time of estimates expressed in YYYY-MM-DD format. (optional)
    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) (default to "D")
    periodicity = "ANN" # str | The periodicity for the estimates requested, allowing you to fetch Quarterly, Semi-Annual, Annual, and NTMA/LTMA Estimates.   * **ANN** - Annual   * **QTR** - Quarterly   * **SEMI** - Semi-Annual   (optional) (default to "ANN")
    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) (default to False)
    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)
    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)
    currency = "USD" # str | Currency code for adjusting the data. For a list of currency ISO codes, visit [Online Assistant Page #1470](https://oa.apps.factset.com/pages/1470). (optional)

    # Get response
    try:
        # Estimates detail data for fixed fiscal periods
        api_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)
    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
    # 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)

Documentation for API Endpoints

All URIs are relative to https://api.factset.com/content

Class Method HTTP request Description
BrokerDetailApi get_fixed_detail GET /factset-estimates/v2/fixed-detail Estimates detail data for fixed fiscal periods
BrokerDetailApi get_fixed_detail_for_list POST /factset-estimates/v2/fixed-detail Estimates detail data for fixed fiscal periods
BrokerDetailApi get_rolling_detail GET /factset-estimates/v2/rolling-detail FactSet estimates detail data for rolling fiscal periods
BrokerDetailApi get_rolling_detail_for_list POST /factset-estimates/v2/rolling-detail FactSet estimates detail data for rolling fiscal periods
ConsensusApi get_fixed_consensus GET /factset-estimates/v2/fixed-consensus Retrieves consensus estimates for a requested list of ids and fixed fiscal periods
ConsensusApi get_fixed_consensus_for_list POST /factset-estimates/v2/fixed-consensus FactSet consensus estimates for fixed fiscal periods
ConsensusApi get_rolling_consensus GET /factset-estimates/v2/rolling-consensus Retrieves consensus estimates for a requested list of ids and rolling fiscal periods.
ConsensusApi get_rolling_consensus_for_list POST /factset-estimates/v2/rolling-consensus Retrieves consensus estimates for a requested list of ids and rolling fiscal periods
DataItemsApi get_estimate_metrics GET /factset-estimates/v2/metrics Available Estimate metrics
DataItemsApi get_estimate_metrics_for_list POST /factset-estimates/v2/metrics Available Estimate metrics or ratios.
RatingsApi get_consensus_ratings GET /factset-estimates/v2/consensus-ratings Ratings consensus estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.
RatingsApi get_consensus_ratings_for_list POST /factset-estimates/v2/consensus-ratings Ratings consensus estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.
RatingsApi get_detail_ratings GET /factset-estimates/v2/detail-ratings Broker Detail estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.
RatingsApi get_detail_ratings_for_list POST /factset-estimates/v2/detail-ratings Broker Detail estimates to fetch Buy, Overweight, Hold, Underweight, and Sell.
SegmentsApi get_segments GET /factset-estimates/v2/segments Retrieves product & geographic segment estimates for a requested list of ids and fiscal periods
SegmentsApi get_segments_for_list POST /factset-estimates/v2/segments Retrieves product segment estimates for a requested list of ids and fiscal periods
SurpriseApi get_surprise GET /factset-estimates/v2/surprise Surprise estimates for rolling fiscal periods
SurpriseApi get_surprise_for_list POST /factset-estimates/v2/surprise Surprise estimates for rolling fiscal periods

Documentation For Models

Documentation For Authorization

FactSetApiKey

  • Type: HTTP basic authentication

FactSetOAuth2

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes: N/A

Notes for Large OpenAPI documents

If 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 DefaultApi
  • from fds.sdk.FactSetEstimates.model.pet import Pet

Solution 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 *

Contributing

Please refer to the contributing guide.

Copyright

Copyright 2022 FactSet Research Systems Inc

Licensed 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 at

http://www.apache.org/licenses/LICENSE-2.0

Unless 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

fds.sdk.FactSetEstimates-0.20.0-py3-none-any.whl (193.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page