mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-05 17:01:58 +00:00
refactored AnalystEstimates
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
"""FMP Analyst Estimates fetcher."""
|
||||
|
||||
|
||||
from datetime import date as dateType
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.helpers import data_transformer
|
||||
from openbb_provider.models.analyst_estimates import (
|
||||
@@ -16,44 +14,38 @@ from openbb_fmp.utils.helpers import create_url, get_data_many
|
||||
|
||||
|
||||
class FMPAnalystEstimatesQueryParams(AnalystEstimatesQueryParams):
|
||||
"""FMP Analysts Estimates query.
|
||||
"""FMP Analysts Estimates Query.
|
||||
|
||||
Source: https://site.financialmodelingprep.com/developer/docs/analyst-estimates-api/
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : str
|
||||
The symbol of the company.
|
||||
period: Literal["quarter", "annual"]
|
||||
The period of the analyst estimates.
|
||||
limit : int
|
||||
The limit number of the amount of returned estimates.
|
||||
"""
|
||||
|
||||
|
||||
class FMPAnalystEstimatesData(Data):
|
||||
symbol: str
|
||||
date: dateType
|
||||
estimatedRevenueLow: int
|
||||
estimatedRevenueHigh: int
|
||||
estimatedRevenueAvg: int
|
||||
estimatedEbitdaLow: int
|
||||
estimatedEbitdaHigh: int
|
||||
estimatedEbitdaAvg: int
|
||||
estimatedEbitLow: int
|
||||
estimatedEbitHigh: int
|
||||
estimatedEbitAvg: int
|
||||
estimatedNetIncomeLow: int
|
||||
estimatedNetIncomeHigh: int
|
||||
estimatedNetIncomeAvg: int
|
||||
estimatedSgaExpenseLow: int
|
||||
estimatedSgaExpenseHigh: int
|
||||
estimatedSgaExpenseAvg: int
|
||||
estimatedEpsAvg: float
|
||||
estimatedEpsHigh: float
|
||||
estimatedEpsLow: float
|
||||
numberAnalystEstimatedRevenue: int
|
||||
numberAnalystsEstimatedEps: int
|
||||
class FMPAnalystEstimatesData(AnalystEstimatesData):
|
||||
"""FMP Analyst Estimates Data."""
|
||||
|
||||
class Config:
|
||||
fields = {
|
||||
"estimated_revenue_low": "estimatedRevenueLow",
|
||||
"estimated_revenue_high": "estimatedRevenueHigh",
|
||||
"estimated_revenue_avg": "estimatedRevenueAvg",
|
||||
"estimated_ebitda_low": "estimatedEbitdaLow",
|
||||
"estimated_ebitda_high": "estimatedEbitdaHigh",
|
||||
"estimated_ebitda_avg": "estimatedEbitdaAvg",
|
||||
"estimated_ebit_low": "estimatedEbitLow",
|
||||
"estimated_ebit_high": "estimatedEbitHigh",
|
||||
"estimated_ebit_avg": "estimatedEbitAvg",
|
||||
"estimated_net_income_low": "estimatedNetIncomeLow",
|
||||
"estimated_net_income_high": "estimatedNetIncomeHigh",
|
||||
"estimated_net_income_avg": "estimatedNetIncomeAvg",
|
||||
"estimated_sga_expense_low": "estimatedSgaExpenseLow",
|
||||
"estimated_sga_expense_high": "estimatedSgaExpenseHigh",
|
||||
"estimated_sga_expense_avg": "estimatedSgaExpenseAvg",
|
||||
"estimated_eps_avg": "estimatedEpsAvg",
|
||||
"estimated_eps_high": "estimatedEpsHigh",
|
||||
"estimated_eps_low": "estimatedEpsLow",
|
||||
"number_analyst_estimated_revenue": "numberAnalystEstimatedRevenue",
|
||||
"number_analysts_estimated_eps": "numberAnalystsEstimatedEps",
|
||||
}
|
||||
|
||||
|
||||
class FMPAnalystEstimatesFetcher(
|
||||
@@ -79,6 +71,8 @@ class FMPAnalystEstimatesFetcher(
|
||||
if credentials:
|
||||
api_key = credentials.get("fmp_api_key")
|
||||
|
||||
query.period = "quarter" if query.period == "quarterly" else "annual"
|
||||
|
||||
url = create_url(
|
||||
3, f"analyst-estimates/{query.symbol}", api_key, query, ["symbol"]
|
||||
)
|
||||
|
||||
@@ -6,95 +6,51 @@ from typing import Literal
|
||||
|
||||
from openbb_provider.abstract.data import Data, QueryParams
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
from openbb_provider.metadata import DESCRIPTIONS
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class AnalystEstimatesQueryParams(QueryParams, BaseSymbol):
|
||||
"""Analyst Estimates query.
|
||||
"""Analyst Estimates query."""
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : str
|
||||
The symbol of the company.
|
||||
period : Literal["quarter", "annual"]
|
||||
The period of the analyst estimates.
|
||||
limit : int
|
||||
The limit of the analyst estimates.
|
||||
"""
|
||||
|
||||
period: Literal["quarter", "annual"] = "annual"
|
||||
limit: int = 30
|
||||
period: Literal["quarterly", "annually"] = Field(
|
||||
default="annually", description=DESCRIPTIONS.get("period", "")
|
||||
)
|
||||
limit: int = Field(default=30, description=DESCRIPTIONS.get("limit", ""))
|
||||
|
||||
|
||||
class AnalystEstimatesData(Data, BaseSymbol):
|
||||
"""Analyst estimates data.
|
||||
"""Analyst estimates data."""
|
||||
|
||||
Returns
|
||||
-------
|
||||
symbol : str
|
||||
The symbol of the asset.
|
||||
date : date
|
||||
The date of the analyst estimates.
|
||||
estimated_revenue_low : int
|
||||
The estimated revenue low of the analyst estimates.
|
||||
estimated_revenue_high : int
|
||||
The estimated revenue high of the analyst estimates.
|
||||
estimated_revenue_avg : int
|
||||
The estimated revenue average of the analyst estimates.
|
||||
estimated_ebitda_low : int
|
||||
The estimated EBITDA low of the analyst estimates.
|
||||
estimated_ebitda_high : int
|
||||
The estimated EBITDA high of the analyst estimates.
|
||||
estimated_ebitda_avg : int
|
||||
The estimated EBITDA average of the analyst estimates.
|
||||
estimated_ebit_low : int
|
||||
The estimated EBIT low of the analyst estimates.
|
||||
estimated_ebit_high : int
|
||||
The estimated EBIT high of the analyst estimates.
|
||||
estimated_ebit_avg : int
|
||||
The estimated EBIT average of the analyst estimates.
|
||||
estimated_net_income_low : int
|
||||
The estimated net income low of the analyst estimates.
|
||||
estimated_net_income_high : int
|
||||
The estimated net income high of the analyst estimates.
|
||||
estimated_net_income_avg : int
|
||||
The estimated net income average of the analyst estimates.
|
||||
estimated_sga_expense_low : int
|
||||
The estimated SGA expense low of the analyst estimates.
|
||||
estimated_sga_expense_high : int
|
||||
The estimated SGA expense high of the analyst estimates.
|
||||
estimated_sga_expense_avg : int
|
||||
The estimated SGA expense average of the analyst estimates.
|
||||
estimated_eps_avg : float
|
||||
The estimated EPS average of the analyst estimates.
|
||||
estimated_eps_high : float
|
||||
The estimated EPS high of the analyst estimates.
|
||||
estimated_eps_low : float
|
||||
The estimated EPS low of the analyst estimates.
|
||||
number_analyst_estimated_revenue : int
|
||||
The number of analysts who estimated revenue of the analyst estimates.
|
||||
number_analysts_estimated_eps : int
|
||||
The number of analysts who estimated EPS of the analyst estimates.
|
||||
"""
|
||||
|
||||
symbol: str
|
||||
date: dateType
|
||||
estimated_revenue_low: int
|
||||
estimated_revenue_high: int
|
||||
estimated_revenue_avg: int
|
||||
estimated_ebitda_low: int
|
||||
estimated_ebitda_high: int
|
||||
estimated_ebitda_avg: int
|
||||
estimated_ebit_low: int
|
||||
estimated_ebit_high: int
|
||||
estimated_ebit_avg: int
|
||||
estimated_net_income_low: int
|
||||
estimated_net_income_high: int
|
||||
estimated_net_income_avg: int
|
||||
estimated_sga_expense_low: int
|
||||
estimated_sga_expense_high: int
|
||||
estimated_sga_expense_avg: int
|
||||
estimated_eps_avg: float
|
||||
estimated_eps_high: float
|
||||
estimated_eps_low: float
|
||||
number_analyst_estimated_revenue: int
|
||||
number_analysts_estimated_eps: int
|
||||
date: dateType = Field(description=DESCRIPTIONS.get("date", ""))
|
||||
estimated_revenue_low: int = Field(description="The estimated revenue low.")
|
||||
estimated_revenue_high: int = Field(description="The estimated revenue high.")
|
||||
estimated_revenue_avg: int = Field(description="The estimated revenue average.")
|
||||
estimated_ebitda_low: int = Field(description="The estimated EBITDA low.")
|
||||
estimated_ebitda_high: int = Field(description="The estimated EBITDA high.")
|
||||
estimated_ebitda_avg: int = Field(description="The estimated EBITDA average.")
|
||||
estimated_ebit_low: int = Field(description="The estimated EBIT low.")
|
||||
estimated_ebit_high: int = Field(description="The estimated EBIT high.")
|
||||
estimated_ebit_avg: int = Field(description="The estimated EBIT average.")
|
||||
estimated_net_income_low: int = Field(description="The estimated net income low.")
|
||||
estimated_net_income_high: int = Field(description="The estimated net income high.")
|
||||
estimated_net_income_avg: int = Field(
|
||||
description="The estimated net income average."
|
||||
)
|
||||
estimated_sga_expense_low: int = Field(description="The estimated SGA expense low.")
|
||||
estimated_sga_expense_high: int = Field(
|
||||
description="The estimated SGA expense high."
|
||||
)
|
||||
estimated_sga_expense_avg: int = Field(
|
||||
description="The estimated SGA expense average."
|
||||
)
|
||||
estimated_eps_avg: float = Field(description="The estimated EPS average.")
|
||||
estimated_eps_high: float = Field(description="The estimated EPS high.")
|
||||
estimated_eps_low: float = Field(description="The estimated EPS low.")
|
||||
number_analyst_estimated_revenue: int = Field(
|
||||
description="The number of analysts who estimated revenue."
|
||||
)
|
||||
number_analysts_estimated_eps: int = Field(
|
||||
description="The number of analysts who estimated EPS."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user