mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-02 07:23:25 +00:00
fmp balance
This commit is contained in:
@@ -1,45 +1,25 @@
|
||||
"""FMP Balance Sheet Fetcher."""
|
||||
|
||||
|
||||
from datetime import (
|
||||
date as dateType,
|
||||
datetime,
|
||||
)
|
||||
from typing import Any, Dict, List, Literal, Optional
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
from openbb_provider.models.balance_sheet import (
|
||||
BalanceSheetData,
|
||||
BalanceSheetQueryParams,
|
||||
)
|
||||
from pydantic import Field, NonNegativeInt, root_validator
|
||||
from pydantic import root_validator
|
||||
|
||||
from openbb_fmp.utils.helpers import create_url, get_data_many
|
||||
|
||||
|
||||
class FMPBalanceSheetQueryParams(QueryParams):
|
||||
class FMPBalanceSheetQueryParams(BalanceSheetQueryParams):
|
||||
"""FMP Balance Sheet QueryParams.
|
||||
|
||||
Source: https://financialmodelingprep.com/developer/docs/#Balance-Sheet
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : Optional[str]
|
||||
The symbol of the company if cik is not provided.
|
||||
cik : Optional[str]
|
||||
The CIK of the company if symbol is not provided.
|
||||
period : Literal["annual", "quarter"]
|
||||
The period of the balance sheet. Default is "annual".
|
||||
limit : Optional[NonNegativeInt]
|
||||
The limit of the balance sheet.
|
||||
"""
|
||||
|
||||
symbol: Optional[str]
|
||||
cik: Optional[str]
|
||||
period: Literal["annual", "quarter"] = Field(default="annual")
|
||||
limit: Optional[NonNegativeInt]
|
||||
|
||||
@root_validator()
|
||||
def check_symbol_or_cik(cls, values): # pylint: disable=no-self-argument
|
||||
@@ -48,60 +28,58 @@ class FMPBalanceSheetQueryParams(QueryParams):
|
||||
return values
|
||||
|
||||
|
||||
class FMPBalanceSheetData(Data):
|
||||
date: dateType
|
||||
symbol: str
|
||||
cik: Optional[int]
|
||||
reportedCurrency: Optional[str]
|
||||
fillingDate: Optional[dateType]
|
||||
acceptedDate: Optional[datetime]
|
||||
class FMPBalanceSheetData(BalanceSheetData):
|
||||
"""FMP Balance Sheet Data."""
|
||||
|
||||
class Config:
|
||||
fields = {
|
||||
"currency": "reportedCurrency",
|
||||
"filing_date": "fillingDate",
|
||||
"accepted_date": "acceptedDate",
|
||||
"cash_and_cash_equivalents": "cashAndCashEquivalents",
|
||||
"short_term_investments": "shortTermInvestments",
|
||||
"cash_and_short_term_investments": "cashAndShortTermInvestments",
|
||||
"net_receivables": "netReceivables",
|
||||
"tax_assets": "taxAssets",
|
||||
"other_current_assets": "otherCurrentAssets",
|
||||
"current_assets": "totalCurrentAssets",
|
||||
"long_term_investments": "longTermInvestments",
|
||||
"property_plant_equipment_net": "propertyPlantEquipmentNet",
|
||||
"intangible_assets": "intangibleAssets",
|
||||
"other_non_current_assets": "otherNonCurrentAssets",
|
||||
"noncurrent_assets": "totalNonCurrentAssets",
|
||||
"other_assets": "otherAssets",
|
||||
"assets": "totalAssets",
|
||||
"short_term_debt": "shortTermDebt",
|
||||
"tax_payables": "taxPayables",
|
||||
"account_payables": "accountPayables",
|
||||
"other_current_liabilities": "otherCurrentLiabilities",
|
||||
"deferred_revenue": "deferredRevenue",
|
||||
"current_liabilities": "totalCurrentLiabilities",
|
||||
"long_term_debt": "longTermDebt",
|
||||
"other_non_current_liabilities": "otherNonCurrentLiabilities",
|
||||
"noncurrent_liabilities": "totalNonCurrentLiabilities",
|
||||
"other_liabilities": "otherLiabilities",
|
||||
"liabilities": "totalLiabilities",
|
||||
"common_stock": "commonStock",
|
||||
"retained_earnings": "retainedEarnings",
|
||||
"accumulated_other_comprehensive_income_loss": "accumulatedOtherComprehensiveIncomeLoss",
|
||||
"total_stockholders_equity": "totalStockholdersEquity",
|
||||
"minority_interest": "minorityInterest",
|
||||
"total_equity": "totalEquity",
|
||||
"total_liabilities_and_stockholders_equity": "totalLiabilitiesAndStockholdersEquity",
|
||||
}
|
||||
|
||||
calendarYear: Optional[int]
|
||||
period: Optional[str]
|
||||
|
||||
cashAndCashEquivalents: Optional[int]
|
||||
shortTermInvestments: Optional[int]
|
||||
cashAndShortTermInvestments: Optional[int]
|
||||
netReceivables: Optional[int]
|
||||
inventory: Optional[int]
|
||||
otherCurrentAssets: Optional[int]
|
||||
totalCurrentAssets: Optional[int] = Field(alias="current_assets")
|
||||
|
||||
longTermInvestments: Optional[int]
|
||||
propertyPlantEquipmentNet: Optional[int]
|
||||
|
||||
goodwill: Optional[int]
|
||||
intangibleAssets: Optional[int]
|
||||
goodwillAndIntangibleAssets: Optional[int]
|
||||
taxAssets: Optional[int]
|
||||
otherNonCurrentAssets: Optional[int]
|
||||
|
||||
totalNonCurrentAssets: Optional[int] = Field(alias="noncurrent_assets")
|
||||
totalAssets: Optional[int] = Field(alias="assets")
|
||||
|
||||
accountPayables: Optional[int]
|
||||
otherCurrentLiabilities: Optional[int]
|
||||
deferredRevenue: Optional[int]
|
||||
shortTermDebt: Optional[int]
|
||||
taxPayables: Optional[int]
|
||||
totalCurrentLiabilities: Optional[int] = Field(alias="current_liabilities")
|
||||
|
||||
longTermDebt: Optional[int]
|
||||
deferredRevenueNonCurrent: Optional[int]
|
||||
deferredTaxLiabilitiesNonCurrent: Optional[int]
|
||||
otherNonCurrentLiabilities: Optional[int]
|
||||
totalNonCurrentLiabilities: Optional[int] = Field(alias="noncurrent_liabilities")
|
||||
totalLiabilities: Optional[int] = Field(alias="liabilities")
|
||||
|
||||
commonStock: Optional[int]
|
||||
retainedEarnings: Optional[int]
|
||||
accumulatedOtherComprehensiveIncomeLoss: Optional[int]
|
||||
othertotalStockholdersEquity: Optional[int]
|
||||
totalEquity: Optional[int]
|
||||
totalLiabilitiesAndStockholdersEquity: Optional[int]
|
||||
|
||||
# Leftovers below
|
||||
totalStockholdersEquity: Optional[int]
|
||||
minorityInterest: Optional[int]
|
||||
totalLiabilitiesAndTotalEquity: Optional[int]
|
||||
totalInvestments: Optional[int]
|
||||
netDebt: Optional[int]
|
||||
@@ -118,11 +96,7 @@ class FMPBalanceSheetFetcher(
|
||||
):
|
||||
@staticmethod
|
||||
def transform_query(params: Dict[str, Any]) -> FMPBalanceSheetQueryParams:
|
||||
transformed_params = params
|
||||
transformed_params["period"] = (
|
||||
"annual" if params.get("period", "") == "annually" else "quarter"
|
||||
)
|
||||
return FMPBalanceSheetQueryParams(**transformed_params)
|
||||
return FMPBalanceSheetQueryParams(**params)
|
||||
|
||||
@staticmethod
|
||||
def extract_data(
|
||||
|
||||
@@ -8,7 +8,7 @@ from openbb_provider.models.income_statement import (
|
||||
IncomeStatementData,
|
||||
IncomeStatementQueryParams,
|
||||
)
|
||||
from pydantic import Field, NonNegativeInt, root_validator
|
||||
from pydantic import Field, root_validator
|
||||
|
||||
from openbb_fmp.utils.helpers import create_url, get_data_many
|
||||
|
||||
|
||||
@@ -6,11 +6,10 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.models.key_metrics import KeyMetricsData, KeyMetricsQueryParams
|
||||
from pydantic import validator
|
||||
|
||||
from openbb_fmp.utils.helpers import create_url, get_data_many
|
||||
|
||||
from pydantic import validator
|
||||
|
||||
|
||||
class FMPKeyMetricsQueryParams(KeyMetricsQueryParams):
|
||||
"""FMP Key Metrics Query.
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import Literal, Optional, Union
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
from openbb_provider.models.income_statement import IncomeStatementQueryParams
|
||||
from pydantic import Field, NonNegativeInt, PositiveFloat, PositiveInt, validator
|
||||
from pydantic import Field, PositiveFloat, PositiveInt, validator
|
||||
|
||||
|
||||
class Timespan(str, Enum):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ###
|
||||
|
||||
|
||||
|
||||
from openbb_core.app.static.container import Container
|
||||
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ class CLASS_stocks_fa(Container):
|
||||
@validate_arguments
|
||||
def balance(
|
||||
self,
|
||||
symbol: Optional[str] = None,
|
||||
period: Literal["annual", "quarter"] = "annual",
|
||||
limit: Optional[pydantic.types.NonNegativeInt] = None,
|
||||
symbol: str,
|
||||
period: Literal["annually", "quarterly"] = "annually",
|
||||
limit: Optional[pydantic.types.NonNegativeInt] = 1,
|
||||
chart: bool = False,
|
||||
provider: Optional[Literal["fmp", "polygon"]] = None,
|
||||
**kwargs
|
||||
@@ -53,12 +53,12 @@ class CLASS_stocks_fa(Container):
|
||||
----------
|
||||
provider: Literal[fmp, polygon]
|
||||
The provider to use for the query.
|
||||
symbol : Optional[str]
|
||||
None
|
||||
period : Literal['annual', 'quarter']
|
||||
None
|
||||
symbol : ConstrainedStrValue
|
||||
Symbol to get data for.
|
||||
period : Literal['annually', 'quarterly']
|
||||
Period of the data to return (quarterly or annually).
|
||||
limit : Optional[NonNegativeInt]
|
||||
None
|
||||
The limit of the income statement.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -78,11 +78,69 @@ class CLASS_stocks_fa(Container):
|
||||
BalanceSheet
|
||||
------------
|
||||
date : date
|
||||
None
|
||||
Date of the income statement.
|
||||
symbol : str
|
||||
Symbol of the company.
|
||||
cik : Optional[int]
|
||||
Central Index Key.
|
||||
currency : Optional[str]
|
||||
Reporting currency.
|
||||
filing_date : Optional[date]
|
||||
Filling date.
|
||||
accepted_date : Optional[datetime]
|
||||
Accepted date.
|
||||
period : Optional[str]
|
||||
Period of the income statement.
|
||||
cash_and_cash_equivalents : Optional[int]
|
||||
None
|
||||
short_term_investments : Optional[int]
|
||||
None
|
||||
cash_and_short_term_investments : Optional[int]
|
||||
None
|
||||
net_receivables : Optional[int]
|
||||
None
|
||||
inventory : Optional[int]
|
||||
None
|
||||
other_current_assets : Optional[int]
|
||||
None
|
||||
current_assets : Optional[int]
|
||||
None
|
||||
long_term_investments : Optional[int]
|
||||
None
|
||||
property_plant_equipment_net : Optional[int]
|
||||
None
|
||||
other_non_current_assets : Optional[int]
|
||||
None
|
||||
noncurrent_assets : Optional[int]
|
||||
None
|
||||
assets : Optional[int]
|
||||
None
|
||||
account_payables : Optional[int]
|
||||
None
|
||||
other_current_liabilities : Optional[int]
|
||||
None
|
||||
deferred_revenue : Optional[int]
|
||||
None
|
||||
current_liabilities : Optional[int]
|
||||
None
|
||||
long_term_debt : Optional[int]
|
||||
None
|
||||
other_non_current_liabilities : Optional[int]
|
||||
None
|
||||
noncurrent_liabilities : Optional[int]
|
||||
None
|
||||
liabilities : Optional[int]
|
||||
None
|
||||
common_stock : Optional[int]
|
||||
None
|
||||
retained_earnings : Optional[int]
|
||||
None
|
||||
accumulated_other_comprehensive_income_loss : Optional[int]
|
||||
None
|
||||
total_equity : Optional[int]
|
||||
None
|
||||
total_liabilities_and_stockholders_equity : Optional[int]
|
||||
None
|
||||
|
||||
fmp
|
||||
===
|
||||
@@ -95,34 +153,8 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
BalanceSheet
|
||||
------------
|
||||
symbol : str
|
||||
None
|
||||
reportedCurrency : Optional[str]
|
||||
None
|
||||
fillingDate : Optional[date]
|
||||
None
|
||||
acceptedDate : Optional[datetime]
|
||||
None
|
||||
calendarYear : Optional[int]
|
||||
None
|
||||
period : Optional[str]
|
||||
None
|
||||
cashAndCashEquivalents : Optional[int]
|
||||
None
|
||||
shortTermInvestments : Optional[int]
|
||||
None
|
||||
cashAndShortTermInvestments : Optional[int]
|
||||
None
|
||||
netReceivables : Optional[int]
|
||||
None
|
||||
otherCurrentAssets : Optional[int]
|
||||
None
|
||||
totalCurrentAssets : Optional[int]
|
||||
None
|
||||
longTermInvestments : Optional[int]
|
||||
None
|
||||
propertyPlantEquipmentNet : Optional[int]
|
||||
None
|
||||
goodwill : Optional[int]
|
||||
None
|
||||
intangibleAssets : Optional[int]
|
||||
@@ -131,48 +163,16 @@ class CLASS_stocks_fa(Container):
|
||||
None
|
||||
taxAssets : Optional[int]
|
||||
None
|
||||
otherNonCurrentAssets : Optional[int]
|
||||
None
|
||||
totalNonCurrentAssets : Optional[int]
|
||||
None
|
||||
totalAssets : Optional[int]
|
||||
None
|
||||
accountPayables : Optional[int]
|
||||
None
|
||||
otherCurrentLiabilities : Optional[int]
|
||||
None
|
||||
deferredRevenue : Optional[int]
|
||||
None
|
||||
shortTermDebt : Optional[int]
|
||||
None
|
||||
taxPayables : Optional[int]
|
||||
None
|
||||
totalCurrentLiabilities : Optional[int]
|
||||
None
|
||||
longTermDebt : Optional[int]
|
||||
None
|
||||
deferredRevenueNonCurrent : Optional[int]
|
||||
None
|
||||
deferredTaxLiabilitiesNonCurrent : Optional[int]
|
||||
None
|
||||
otherNonCurrentLiabilities : Optional[int]
|
||||
None
|
||||
totalNonCurrentLiabilities : Optional[int]
|
||||
None
|
||||
totalLiabilities : Optional[int]
|
||||
None
|
||||
commonStock : Optional[int]
|
||||
None
|
||||
retainedEarnings : Optional[int]
|
||||
None
|
||||
accumulatedOtherComprehensiveIncomeLoss : Optional[int]
|
||||
None
|
||||
othertotalStockholdersEquity : Optional[int]
|
||||
None
|
||||
totalEquity : Optional[int]
|
||||
None
|
||||
totalLiabilitiesAndStockholdersEquity : Optional[int]
|
||||
None
|
||||
totalStockholdersEquity : Optional[int]
|
||||
None
|
||||
minorityInterest : Optional[int]
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
"""Balance Sheet Data Model."""
|
||||
|
||||
|
||||
from datetime import date as dateType
|
||||
from datetime import (
|
||||
date as dateType,
|
||||
datetime,
|
||||
)
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.models.base import FinancialStatementQueryParams
|
||||
|
||||
@@ -11,95 +16,40 @@ from openbb_provider.models.base import FinancialStatementQueryParams
|
||||
|
||||
|
||||
class BalanceSheetQueryParams(FinancialStatementQueryParams):
|
||||
"""Cash flow statement query.
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : str
|
||||
The symbol of the company.
|
||||
period : Literal["annually", "quarterly"]
|
||||
The period of the balance sheet.
|
||||
"""
|
||||
"""Cash flow statement query."""
|
||||
|
||||
|
||||
class BalanceSheetData(Data):
|
||||
"""Return Balance Sheet Data.
|
||||
"""Return Balance Sheet Data."""
|
||||
|
||||
Returns
|
||||
-------
|
||||
date : date
|
||||
The date of the balance sheet.
|
||||
cik : Optional[int]
|
||||
The CIK of the company.
|
||||
cash_and_cash_equivalents : Optional[int]
|
||||
The cash and cash equivalents of the balance sheet.
|
||||
short_term_investments : Optional[int]
|
||||
The short term investments of the balance sheet.
|
||||
cash_and_short_term_investments : Optional[int]
|
||||
The cash and short term investments of the balance sheet.
|
||||
net_receivables : Optional[int]
|
||||
The net receivables of the balance sheet.
|
||||
inventory : Optional[int]
|
||||
The inventory of the balance sheet.
|
||||
other_current_assets : Optional[int]
|
||||
The other current assets of the balance sheet.
|
||||
current_assets : Optional[int]
|
||||
The current assets of the balance sheet.
|
||||
long_term_investments : Optional[int]
|
||||
The long term investments of the balance sheet.
|
||||
property_plant_equipment_net : Optional[int]
|
||||
The property plant equipment net of the balance sheet.
|
||||
other_non_current_assets : Optional[int]
|
||||
The other non current assets of the balance sheet.
|
||||
noncurrent_assets : Optional[int]
|
||||
The non current assets of the balance sheet.
|
||||
assets : Optional[int]
|
||||
The assets of the balance sheet.
|
||||
accounts_payable : Optional[int]
|
||||
The accounts payable of the balance sheet.
|
||||
other_current_liabilities : Optional[int]
|
||||
The other current liabilities of the balance sheet.
|
||||
deferred_revenue : Optional[int]
|
||||
The deferred revenue of the balance sheet.
|
||||
current_liabilities : Optional[int]
|
||||
The current liabilities of the balance sheet.
|
||||
long_term_debt : Optional[int]
|
||||
The long term debt of the balance sheet.
|
||||
other_non_current_liabilities : Optional[int]
|
||||
The other non current liabilities of the balance sheet.
|
||||
noncurrent_liabilities : Optional[int]
|
||||
The non current liabilities of the balance sheet.
|
||||
liabilities : Optional[int]
|
||||
The liabilities of the balance sheet.
|
||||
common_stock : Optional[int]
|
||||
The common stock of the balance sheet.
|
||||
retained_earnings : Optional[int]
|
||||
The retained earnings of the balance sheet.
|
||||
accumulated_other_comprehensive_income_loss : Optional[int]
|
||||
The accumulated other comprehensive income loss of the balance sheet.
|
||||
total_equity : Optional[int]
|
||||
The total equity of the balance sheet.
|
||||
total_liabilities_and_stockholders_equity : Optional[int]
|
||||
The total liabilities and stockholders equity of the balance sheet.
|
||||
"""
|
||||
|
||||
date: dateType
|
||||
cik: Optional[int]
|
||||
date: dateType = Field(description="Date of the income statement.")
|
||||
symbol: str = Field(description="Symbol of the company.")
|
||||
cik: Optional[int] = Field(description="Central Index Key.")
|
||||
currency: Optional[str] = Field(description="Reporting currency.")
|
||||
filing_date: Optional[dateType] = Field(description="Filling date.")
|
||||
accepted_date: Optional[datetime] = Field(description="Accepted date.")
|
||||
period: Optional[str] = Field(description="Period of the income statement.")
|
||||
|
||||
cash_and_cash_equivalents: Optional[int]
|
||||
short_term_investments: Optional[int]
|
||||
cash_and_short_term_investments: Optional[int]
|
||||
net_receivables: Optional[int]
|
||||
tax_assets: Optional[int]
|
||||
inventory: Optional[int]
|
||||
other_current_assets: Optional[int]
|
||||
current_assets: Optional[int]
|
||||
|
||||
long_term_investments: Optional[int]
|
||||
property_plant_equipment_net: Optional[int]
|
||||
goodwill: Optional[int]
|
||||
intangible_assets: Optional[int]
|
||||
other_non_current_assets: Optional[int]
|
||||
noncurrent_assets: Optional[int]
|
||||
other_assets: Optional[int]
|
||||
assets: Optional[int]
|
||||
|
||||
short_term_debt: Optional[int]
|
||||
tax_payables: Optional[int]
|
||||
account_payables: Optional[int]
|
||||
other_current_liabilities: Optional[int]
|
||||
deferred_revenue: Optional[int]
|
||||
@@ -108,10 +58,13 @@ class BalanceSheetData(Data):
|
||||
long_term_debt: Optional[int]
|
||||
other_non_current_liabilities: Optional[int]
|
||||
noncurrent_liabilities: Optional[int]
|
||||
other_liabilities: Optional[int]
|
||||
liabilities: Optional[int]
|
||||
|
||||
common_stock: Optional[int]
|
||||
retained_earnings: Optional[int]
|
||||
accumulated_other_comprehensive_income_loss: Optional[int]
|
||||
total_stockholders_equity: Optional[int]
|
||||
minority_interest: Optional[int]
|
||||
total_equity: Optional[int]
|
||||
total_liabilities_and_stockholders_equity: Optional[int]
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
from datetime import date as dateType
|
||||
from typing import Literal, Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
from openbb_provider.descriptions import DATA_DESCRIPTIONS, QUERY_DESCRIPTIONS
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
from openbb_provider.descriptions import QUERY_DESCRIPTIONS, DATA_DESCRIPTIONS
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class KeyMetricsQueryParams(QueryParams, BaseSymbol):
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
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
|
||||
from openbb_provider.descriptions import QUERY_DESCRIPTIONS
|
||||
|
||||
from pydantic import Field
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
|
||||
|
||||
class StockMultiplesQueryParams(QueryParams, BaseSymbol):
|
||||
|
||||
Reference in New Issue
Block a user