mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-14 05:14:19 +00:00
Merge branch 'feature/provider_refactoring' of https://github.com/OpenBB-finance/OpenBBTerminal into feature/provider_refactoring
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
"""FMP Historical Dividends fetcher."""
|
||||
|
||||
from datetime import (
|
||||
date as dateType,
|
||||
datetime,
|
||||
)
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.models.historical_dividends import (
|
||||
HistoricalDividendsData,
|
||||
@@ -21,34 +19,29 @@ class FMPHistoricalDividendsQueryParams(HistoricalDividendsQueryParams):
|
||||
"""FMP Historical Dividends query.
|
||||
|
||||
Source: https://site.financialmodelingprep.com/developer/docs/#Historical-Dividends
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : str
|
||||
The symbol of the company.
|
||||
"""
|
||||
|
||||
|
||||
class FMPHistoricalDividendsData(Data):
|
||||
class FMPHistoricalDividendsData(HistoricalDividendsData):
|
||||
"""FMP Historical Dividends data."""
|
||||
|
||||
date: dateType
|
||||
label: str
|
||||
adjDividend: float
|
||||
dividend: float
|
||||
recordDate: Optional[dateType]
|
||||
paymentDate: Optional[dateType]
|
||||
declarationDate: Optional[dateType]
|
||||
class Config:
|
||||
fields = {
|
||||
"adj_dividend": "adjDividend",
|
||||
"record_date": "recordDate",
|
||||
"payment_date": "paymentDate",
|
||||
"declaration_date": "declarationDate",
|
||||
}
|
||||
|
||||
@validator("declarationDate", pre=True)
|
||||
@validator("declarationDate", pre=True, check_fields=False)
|
||||
def declaration_date_validate(cls, v: str): # pylint: disable=E0213
|
||||
return datetime.strptime(v, "%Y-%m-%d") if v else None
|
||||
|
||||
@validator("recordDate", pre=True)
|
||||
@validator("recordDate", pre=True, check_fields=False)
|
||||
def record_date_validate(cls, v: str): # pylint: disable=E0213
|
||||
return datetime.strptime(v, "%Y-%m-%d") if v else None
|
||||
|
||||
@validator("paymentDate", pre=True)
|
||||
@validator("paymentDate", pre=True, check_fields=False)
|
||||
def payment_date_validate(cls, v: str): # pylint: disable=E0213
|
||||
return datetime.strptime(v, "%Y-%m-%d") if v else None
|
||||
|
||||
|
||||
@@ -9,11 +9,10 @@ from openbb_provider.models.historical_stock_splits import (
|
||||
HistoricalStockSplitsData,
|
||||
HistoricalStockSplitsQueryParams,
|
||||
)
|
||||
from pydantic import validator
|
||||
|
||||
from openbb_fmp.utils.helpers import create_url, get_data_many
|
||||
|
||||
from pydantic import validator
|
||||
|
||||
|
||||
class FMPHistoricalStockSplitsQueryParams(HistoricalStockSplitsQueryParams):
|
||||
"""FMP Historical Stock Splits Query.
|
||||
|
||||
@@ -23,7 +23,7 @@ class CLASS_crypto(Container):
|
||||
provider: Optional[Literal["fmp", "polygon"]] = None,
|
||||
**kwargs
|
||||
) -> CommandOutput[typing.List]:
|
||||
"""Crypto Intraday Price.
|
||||
r"""Crypto Intraday Price.
|
||||
|
||||
|
||||
openbb
|
||||
@@ -88,13 +88,13 @@ class CLASS_crypto(Container):
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
Change \\% in the price of the symbol.
|
||||
Change \% in the price of the symbol.
|
||||
vwap : float
|
||||
Volume Weighted Average Price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
Change \\% in the price of the symbol over a period of time.
|
||||
Change \% in the price of the symbol over a period of time.
|
||||
|
||||
polygon
|
||||
=======
|
||||
|
||||
@@ -301,7 +301,7 @@ class CLASS_economy(Container):
|
||||
provider: Optional[Literal["fmp", "polygon"]] = None,
|
||||
**kwargs
|
||||
) -> CommandOutput[typing.List]:
|
||||
"""Get OHLCV data for an index.
|
||||
r"""Get OHLCV data for an index.
|
||||
|
||||
|
||||
openbb
|
||||
@@ -366,13 +366,13 @@ class CLASS_economy(Container):
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
Change \\% in the price of the symbol.
|
||||
Change \% in the price of the symbol.
|
||||
vwap : float
|
||||
Volume Weighted Average Price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
Change \\% in the price of the symbol over a period of time.
|
||||
Change \% in the price of the symbol over a period of time.
|
||||
|
||||
polygon
|
||||
=======
|
||||
|
||||
@@ -137,7 +137,7 @@ class CLASS_forex(Container):
|
||||
provider: Optional[Literal["fmp", "polygon"]] = None,
|
||||
**kwargs
|
||||
) -> CommandOutput[typing.List]:
|
||||
"""Forex Intraday Price.
|
||||
r"""Forex Intraday Price.
|
||||
|
||||
|
||||
openbb
|
||||
@@ -201,13 +201,13 @@ class CLASS_forex(Container):
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
Change \\% in the price of the symbol.
|
||||
Change \% in the price of the symbol.
|
||||
vwap : Optional[float]
|
||||
Volume Weighted Average Price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
Change \\% in the price of the symbol over a period of time.
|
||||
Change \% in the price of the symbol over a period of time.
|
||||
|
||||
polygon
|
||||
=======
|
||||
|
||||
@@ -90,7 +90,7 @@ class CLASS_stocks(Container):
|
||||
provider: Optional[Literal["fmp", "polygon"]] = None,
|
||||
**kwargs
|
||||
) -> CommandOutput[typing.List]:
|
||||
"""Load stock data for a specific ticker.
|
||||
r"""Load stock data for a specific ticker.
|
||||
|
||||
|
||||
openbb
|
||||
@@ -124,6 +124,8 @@ class CLASS_stocks(Container):
|
||||
|
||||
StockEOD
|
||||
--------
|
||||
date : datetime
|
||||
The date of the data.
|
||||
open : PositiveFloat
|
||||
The open price of the symbol.
|
||||
high : PositiveFloat
|
||||
@@ -134,6 +136,8 @@ class CLASS_stocks(Container):
|
||||
The close price of the symbol.
|
||||
volume : PositiveFloat
|
||||
The volume of the symbol.
|
||||
vwap : PositiveFloat
|
||||
Volume Weighted Average Price of the symbol.
|
||||
|
||||
fmp
|
||||
===
|
||||
@@ -146,8 +150,6 @@ class CLASS_stocks(Container):
|
||||
|
||||
StockEOD
|
||||
--------
|
||||
date : datetime
|
||||
The date of the data.
|
||||
adjClose : float
|
||||
Adjusted Close Price of the symbol.
|
||||
unadjustedVolume : float
|
||||
@@ -155,13 +157,11 @@ class CLASS_stocks(Container):
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
Change \\% in the price of the symbol.
|
||||
vwap : float
|
||||
Volume Weighted Average Price of the symbol.
|
||||
Change \% in the price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
Change \\% in the price of the symbol over a period of time.
|
||||
Change \% in the price of the symbol over a period of time.
|
||||
|
||||
polygon
|
||||
=======
|
||||
@@ -182,12 +182,8 @@ class CLASS_stocks(Container):
|
||||
|
||||
StockEOD
|
||||
--------
|
||||
t : datetime
|
||||
The timestamp of the data.
|
||||
n : PositiveInt
|
||||
The number of transactions for the symbol in the time period.
|
||||
vw : PositiveFloat
|
||||
The volume weighted average price of the symbol."""
|
||||
The number of transactions for the symbol in the time period."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
"provider": provider,
|
||||
|
||||
@@ -1313,11 +1313,23 @@ class CLASS_stocks_fa(Container):
|
||||
HistoricalEmployees
|
||||
-------------------
|
||||
symbol : ConstrainedStrValue
|
||||
None
|
||||
Symbol to get data for.
|
||||
cik : int
|
||||
None
|
||||
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 : str
|
||||
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
|
||||
None
|
||||
The source URL which retrieves this data for the company.
|
||||
|
||||
fmp
|
||||
===
|
||||
@@ -1329,18 +1341,7 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
HistoricalEmployees
|
||||
-------------------
|
||||
acceptanceTime : datetime
|
||||
None
|
||||
periodOfReport : date
|
||||
None
|
||||
companyName : str
|
||||
None
|
||||
formType : str
|
||||
None
|
||||
filingDate : date
|
||||
None
|
||||
employeeCount : int
|
||||
None"""
|
||||
All fields are standardized."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
"provider": provider,
|
||||
@@ -2307,11 +2308,6 @@ class CLASS_stocks_fa(Container):
|
||||
def mgmt(
|
||||
self,
|
||||
symbol: str,
|
||||
key_executive_name: Optional[str] = None,
|
||||
key_executive_title: Optional[str] = None,
|
||||
key_executive_title_since: Optional[datetime.datetime] = None,
|
||||
key_executive_year_born: Optional[datetime.datetime] = None,
|
||||
key_executive_gender: Optional[str] = None,
|
||||
chart: bool = False,
|
||||
provider: Optional[Literal["fmp"]] = None,
|
||||
**kwargs
|
||||
@@ -2328,16 +2324,6 @@ class CLASS_stocks_fa(Container):
|
||||
The provider to use for the query.
|
||||
symbol : ConstrainedStrValue
|
||||
Symbol to get data for.
|
||||
key_executive_name : Optional[str]
|
||||
None
|
||||
key_executive_title : Optional[str]
|
||||
None
|
||||
key_executive_title_since : Optional[datetime]
|
||||
None
|
||||
key_executive_year_born : Optional[datetime]
|
||||
None
|
||||
key_executive_gender : Optional[str]
|
||||
None
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -2356,12 +2342,20 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
KeyExecutives
|
||||
-------------
|
||||
name : str
|
||||
None
|
||||
title : str
|
||||
None
|
||||
Designation of the key executive.
|
||||
name : str
|
||||
Name of the key executive.
|
||||
pay : Optional[int]
|
||||
Pay of the key executive.
|
||||
currency_pay : str
|
||||
The currency of the pay.
|
||||
gender : Optional[str]
|
||||
None
|
||||
Gender of the key executive.
|
||||
year_born : Optional[str]
|
||||
Birth year of the key executive.
|
||||
title_since : Optional[int]
|
||||
Date the tile was held since.
|
||||
|
||||
fmp
|
||||
===
|
||||
@@ -2373,21 +2367,13 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
KeyExecutives
|
||||
-------------
|
||||
titleSince : Optional[datetime]
|
||||
None
|
||||
yearBorn : Optional[datetime]
|
||||
None"""
|
||||
All fields are standardized."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
"provider": provider,
|
||||
},
|
||||
standard_params={
|
||||
"symbol": symbol,
|
||||
"key_executive_name": key_executive_name,
|
||||
"key_executive_title": key_executive_title,
|
||||
"key_executive_title_since": key_executive_title_since,
|
||||
"key_executive_year_born": key_executive_year_born,
|
||||
"key_executive_gender": key_executive_gender,
|
||||
},
|
||||
extra_params=kwargs,
|
||||
chart=chart,
|
||||
@@ -3294,13 +3280,13 @@ class CLASS_stocks_fa(Container):
|
||||
HistoricalStockSplits
|
||||
---------------------
|
||||
date : date
|
||||
None
|
||||
The date of the data.
|
||||
label : str
|
||||
None
|
||||
The label of the historical stock splits.
|
||||
numerator : float
|
||||
None
|
||||
The numerator of the historical stock splits.
|
||||
denominator : float
|
||||
None
|
||||
The denominator of the historical stock splits.
|
||||
|
||||
fmp
|
||||
===
|
||||
|
||||
@@ -4,46 +4,32 @@
|
||||
from datetime import date as dateType
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
|
||||
|
||||
class HistoricalDividendsQueryParams(QueryParams, BaseSymbol):
|
||||
"""Historical dividends query.
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : str
|
||||
The symbol of the company.
|
||||
"""
|
||||
"""Historical dividends query."""
|
||||
|
||||
|
||||
class HistoricalDividendsData(Data):
|
||||
"""Historical dividends data.
|
||||
"""Historical dividends data."""
|
||||
|
||||
Returns
|
||||
-------
|
||||
date : date
|
||||
The date of the historical dividends.
|
||||
label : str
|
||||
The label of the historical dividends.
|
||||
adj_dividend : float
|
||||
The adjusted dividend of the historical dividends.
|
||||
dividend : float
|
||||
The dividend of the historical dividends.
|
||||
record_date : date
|
||||
The record date of the historical dividends.
|
||||
payment_date : date
|
||||
The payment date of the historical dividends.
|
||||
declaration_date : date
|
||||
The declaration date of the historical dividends.
|
||||
"""
|
||||
|
||||
date: dateType
|
||||
label: str
|
||||
adj_dividend: float
|
||||
dividend: float
|
||||
record_date: Optional[dateType]
|
||||
payment_date: Optional[dateType]
|
||||
declaration_date: Optional[dateType]
|
||||
date: dateType = Field(description="The date of the historical dividends.")
|
||||
label: str = Field(description="The label of the historical dividends.")
|
||||
adj_dividend: float = Field(
|
||||
description="The adjusted dividend of the historical dividends."
|
||||
)
|
||||
dividend: float = Field(description="The dividend of the historical dividends.")
|
||||
record_date: Optional[dateType] = Field(
|
||||
description="The record date of the historical dividends."
|
||||
)
|
||||
payment_date: Optional[dateType] = Field(
|
||||
description="The payment date of the historical dividends."
|
||||
)
|
||||
declaration_date: Optional[dateType] = Field(
|
||||
description="The declaration date of the historical dividends."
|
||||
)
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
from datetime import date as dateType
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
from openbb_provider.metadata import DATA_DESCRIPTIONS
|
||||
|
||||
from pydantic import Field
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
|
||||
|
||||
class HistoricalStockSplitsQueryParams(QueryParams, BaseSymbol):
|
||||
|
||||
Reference in New Issue
Block a user