diff --git a/openbb_sdk/extensions/stocks/openbb_stocks/fa/fa_router.py b/openbb_sdk/extensions/stocks/openbb_stocks/fa/fa_router.py index 3a560fdd4f5..a6f38954f6c 100644 --- a/openbb_sdk/extensions/stocks/openbb_stocks/fa/fa_router.py +++ b/openbb_sdk/extensions/stocks/openbb_stocks/fa/fa_router.py @@ -60,10 +60,15 @@ def earning( return CommandOutput(results=Query(**locals()).execute()) -@router.command -def emp() -> CommandOutput[Empty]: # type: ignore +@router.command(query="HistoricalEmployees") +def emp( + cc: CommandContext, + provider_choices: ProviderChoices, + standard_params: StandardParams, + extra_params: ExtraParams, +) -> CommandOutput[BaseModel]: """Number of Employees.""" - return CommandOutput(results=Empty()) + return CommandOutput(results=Query(**locals()).execute()) @router.command(query="AnalystEstimates") diff --git a/openbb_sdk/providers/fmp/openbb_fmp/historical_employees.py b/openbb_sdk/providers/fmp/openbb_fmp/historical_employees.py new file mode 100644 index 00000000000..59d343b1677 --- /dev/null +++ b/openbb_sdk/providers/fmp/openbb_fmp/historical_employees.py @@ -0,0 +1,73 @@ +"""FMP Historical Employees fetcher.""" + +# IMPORT STANDARD +from datetime import date, datetime +from typing import Dict, List, Optional + +# IMPORT INTERNAL +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.historical_employees import ( + HistoricalEmployeesData, + HistoricalEmployeesQueryParams, +) + +# IMPORT THIRD-PARTY +from pydantic import Field + +from .helpers import create_url, get_data_many + + +class FMPHistoricalEmployeesQueryParams(HistoricalEmployeesQueryParams): + """FMP Historical Employees query. + + Source: https://site.financialmodelingprep.com/developer/docs/historical-numer-of-employees-api/ + + Parameter + --------- + symbol : str + The symbol of the company. + """ + + +class FMPHistoricalEmployeesData(Data): + symbol: str = Field(min_length=1) + cik: int + acceptanceTime: datetime = Field(alias="acceptance_time") + periodOfReport: date = Field(alias="period_of_report") + companyName: str = Field(alias="company_name") + formType: str = Field(alias="form_type") + filingDate: date = Field(alias="filing_date") + employeeCount: int = Field(alias="employee_count") + source: str + + +class FMPHistoricalEmployeesFetcher( + Fetcher[ + HistoricalEmployeesQueryParams, + HistoricalEmployeesData, + FMPHistoricalEmployeesQueryParams, + FMPHistoricalEmployeesData, + ] +): + @staticmethod + def transform_query( + query: HistoricalEmployeesQueryParams, extra_params: Optional[Dict] = None + ) -> FMPHistoricalEmployeesQueryParams: + return FMPHistoricalEmployeesQueryParams( + symbol=query.symbol, **extra_params or {} + ) + + @staticmethod + def extract_data( + query: FMPHistoricalEmployeesQueryParams, api_key: str + ) -> List[FMPHistoricalEmployeesData]: + url = create_url(4, "historical/employee_count", api_key, query) + return get_data_many(url, FMPHistoricalEmployeesData) + + @staticmethod + def transform_data( + data: List[FMPHistoricalEmployeesData], + ) -> List[HistoricalEmployeesData]: + return data_transformer(data, HistoricalEmployeesData) diff --git a/openbb_sdk/providers/fmp/openbb_fmp/provider.py b/openbb_sdk/providers/fmp/openbb_fmp/provider.py index 1aeffe07820..7e4a58046ef 100644 --- a/openbb_sdk/providers/fmp/openbb_fmp/provider.py +++ b/openbb_sdk/providers/fmp/openbb_fmp/provider.py @@ -25,6 +25,7 @@ from .forex_pairs import FMPForexPairsFetcher from .forex_price import FMPForexPriceFetcher from .global_news import FMPGlobalNewsFetcher from .historical_dividends import FMPHistoricalDividendsFetcher +from .historical_employees import FMPHistoricalEmployeesFetcher from .historical_stock_splits import FMPHistoricalStockSplitsFetcher from .income_statement import FMPIncomeStatementFetcher from .institutional_ownership import FMPInstitutionalOwnershipFetcher @@ -92,5 +93,6 @@ fmp_provider = Provider( FMPForexPairsFetcher, FMPStockPeersFetcher, FMPStockMultiplesFetcher, + FMPHistoricalEmployeesFetcher, ], ) diff --git a/openbb_sdk/sdk/provider/openbb_provider/models/historical_employees.py b/openbb_sdk/sdk/provider/openbb_provider/models/historical_employees.py new file mode 100644 index 00000000000..4d47a09b8d8 --- /dev/null +++ b/openbb_sdk/sdk/provider/openbb_provider/models/historical_employees.py @@ -0,0 +1,53 @@ +"""Historical Employees data model.""" + + +from datetime import date, datetime + +from openbb_provider.abstract.data import Data, QueryParams +from openbb_provider.models.base import BaseSymbol + + +class HistoricalEmployeesQueryParams(QueryParams, BaseSymbol): + """Historical Employees query model. + + Parameter + --------- + symbol : str + The symbol of the company. + """ + + +class HistoricalEmployeesData(Data): + """Historical Employees data. + + Returns + ------- + symbol : str + The symbol of the company to retrieve the historical employees of. + cik : int + The CIK of the company to retrieve the historical employees of. + acceptance_time : datetime + The time of acceptance of the company employee. + period_of_report : date + The date of reporting of the company employee. + company_name : str + The registered name of the company to retrieve the historical employees of. + form_type : float + The form type of the company employee. + filing_date : date + The filing date of the company employee + employee_count : int + The count of employees of the company. + source : str + The source URL which retrieves this data for the company. + """ + + symbol: str + cik: int + acceptance_time: datetime + period_of_report: date + company_name: str + form_type: str + filing_date: date + employee_count: int + source: str