mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-12-01 05:33:37 +00:00
* Move openbb_provider * Add lock file for provider core * Move sdk core * Move openbb-provider readme text to the correct location * Move data providers code * Remove decoupling leftovers * Lower the supported python version to 3.8 * Move sdk extensions * Rename provider imports * Update openbb pyproject toml * Fix import statements after the move * Update lock files * Change ignored path for the static assets * Add obb mascot * Fix providers not being available in the openbb package * Remove providers extension in favor of the coverage router in sdk core * username is optional * linting * Change openbb_sdk_core to openbb_core * Bump ruff pre-commit to latest version * Bump ruff to latest in github actions * Make ruff and pylint lint only the code in diff in GHA * Attempt to fix broken linting action * Attempt to fix the broken linting action II * Lint code with pre-commit * Revert all changes to github actions * Revert to using ruff 0.0.256 * Use dot for local imports * Re-commit lost forex pairs * Fix fmp's typo that made it to the openbb data points * Add other_investing_activities field that has a typo in fmp's api --------- Co-authored-by: montezdesousa <montezdesousa@gmail.com> Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
90 lines
2.5 KiB
Python
90 lines
2.5 KiB
Python
"""FMP Executive Compensation Fetcher."""
|
|
|
|
# IMPORT STANDARD
|
|
from datetime import (
|
|
date as dateType,
|
|
datetime,
|
|
)
|
|
from typing import Dict, List, Optional
|
|
|
|
from openbb_provider.model.abstract.data import Data
|
|
|
|
# IMPORT INTERNAL
|
|
from openbb_provider.model.data.executive_compensation import (
|
|
ExecutiveCompensationData,
|
|
ExecutiveCompensationQueryParams,
|
|
)
|
|
from openbb_provider.provider.abstract.fetcher import Fetcher
|
|
from openbb_provider.provider.provider_helpers import data_transformer
|
|
|
|
# IMPORT THIRD-PARTY
|
|
from pydantic import validator
|
|
|
|
from .helpers import create_url, get_data_many
|
|
|
|
# This part is only provided by FMP and not by the other providers for now.
|
|
|
|
|
|
class FMPExecutiveCompensationQueryParams(ExecutiveCompensationQueryParams):
|
|
"""FMP Executive Compensation query.
|
|
|
|
Source: https://site.financialmodelingprep.com/developer/docs/executive-compensation-api/
|
|
|
|
Parameter
|
|
---------
|
|
symbol : str
|
|
The symbol of the company.
|
|
"""
|
|
|
|
|
|
class FMPExecutiveCompensationData(Data):
|
|
cik: Optional[str]
|
|
symbol: str
|
|
filingDate: dateType
|
|
acceptedDate: dateType
|
|
nameAndPosition: str
|
|
year: int
|
|
salary: float
|
|
bonus: float
|
|
stock_award: float
|
|
incentive_plan_compensation: float
|
|
all_other_compensation: float
|
|
total: float
|
|
url: str
|
|
|
|
@validator("acceptedDate", pre=True)
|
|
def convert_accepted_date(cls, v): # pylint: disable=E0213
|
|
return datetime.strptime(v, "%Y-%m-%d %H:%M:%S")
|
|
|
|
@validator("filingDate", pre=True)
|
|
def convert_filing_date(cls, v): # pylint: disable=E0213
|
|
return datetime.strptime(v, "%Y-%m-%d")
|
|
|
|
|
|
class FMPExecutiveCompensationFetcher(
|
|
Fetcher[ # type: ignore
|
|
ExecutiveCompensationQueryParams,
|
|
ExecutiveCompensationData,
|
|
FMPExecutiveCompensationQueryParams,
|
|
FMPExecutiveCompensationData,
|
|
]
|
|
):
|
|
@staticmethod
|
|
def transform_query(
|
|
query: ExecutiveCompensationQueryParams, extra_params: Optional[Dict] = None
|
|
) -> FMPExecutiveCompensationQueryParams:
|
|
return FMPExecutiveCompensationQueryParams.parse_obj(query)
|
|
|
|
@staticmethod
|
|
def extract_data(
|
|
query: FMPExecutiveCompensationQueryParams, api_key: str
|
|
) -> List[FMPExecutiveCompensationData]:
|
|
url = create_url(4, "governance/executive_compensation", api_key, query)
|
|
return get_data_many(url, FMPExecutiveCompensationData)
|
|
|
|
@staticmethod
|
|
def transform_data(
|
|
data: List[FMPExecutiveCompensationData],
|
|
) -> List[ExecutiveCompensationData]:
|
|
return data_transformer(data, ExecutiveCompensationData)
|