mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-02 23:41:27 +00:00
Convert all return fields to snake_case
This commit is contained in:
@@ -118,17 +118,17 @@ class CLASS_crypto(Container):
|
||||
|
||||
CryptoEOD
|
||||
---------
|
||||
adjClose : float
|
||||
adj_close : float
|
||||
Adjusted Close Price of the symbol.
|
||||
unadjustedVolume : float
|
||||
unadjusted_volume : float
|
||||
Unadjusted volume of the symbol.
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
change_percent : float
|
||||
Change \% in the price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
change_over_time : float
|
||||
Change \% in the price of the symbol over a period of time."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
|
||||
@@ -429,19 +429,19 @@ class CLASS_economy(Container):
|
||||
---------------
|
||||
date : datetime
|
||||
The date of the data.
|
||||
adjClose : float
|
||||
adj_close : float
|
||||
Adjusted Close Price of the symbol.
|
||||
unadjustedVolume : float
|
||||
unadjusted_volume : float
|
||||
Unadjusted volume of the symbol.
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
change_percent : float
|
||||
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_over_time : float
|
||||
Change \% in the price of the symbol over a period of time."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
|
||||
@@ -107,7 +107,7 @@ class CLASS_forex(Container):
|
||||
The symbol of the currency pair.
|
||||
currency : str
|
||||
The base currency of the currency pair.
|
||||
stockExchange : Optional[str]
|
||||
stock_exchange : Optional[str]
|
||||
The stock exchange of the currency pair.
|
||||
exchange_short_name : Optional[str]
|
||||
The short name of the stock exchange of the currency pair."""
|
||||
@@ -231,17 +231,17 @@ class CLASS_forex(Container):
|
||||
|
||||
ForexEOD
|
||||
--------
|
||||
adjClose : float
|
||||
adj_close : float
|
||||
Adjusted Close Price of the symbol.
|
||||
unadjustedVolume : float
|
||||
unadjusted_volume : float
|
||||
Unadjusted volume of the symbol.
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
change_percent : float
|
||||
Change \% in the price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
change_over_time : float
|
||||
Change \% in the price of the symbol over a period of time."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
|
||||
@@ -73,19 +73,19 @@ class CLASS_news(Container):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
pageSize : int
|
||||
page_size : int
|
||||
The number of results to return per page.
|
||||
displayOutput : Literal['headline', 'summary', 'full', 'all']
|
||||
display_output : Literal['headline', 'summary', 'full', 'all']
|
||||
The type of data to return.
|
||||
date : Optional[datetime]
|
||||
The date of the news to retrieve.
|
||||
dateFrom : Optional[datetime]
|
||||
date_from : Optional[datetime]
|
||||
The start date of the news to retrieve.
|
||||
dateTo : Optional[datetime]
|
||||
date_to : Optional[datetime]
|
||||
The end date of the news to retrieve.
|
||||
updatedSince : Optional[int]
|
||||
updated_since : Optional[int]
|
||||
The number of seconds since the news was updated.
|
||||
publishedSince : Optional[int]
|
||||
published_since : Optional[int]
|
||||
The number of seconds since the news was published.
|
||||
sort : Optional[Literal['published_at', 'updated_at', 'title', 'author', 'channel', 'ticker', 'topic', 'content_type']]
|
||||
The order in which to sort the news. Options are: published_at, updated_at, title, author, channel, ticker, topic, content_type.
|
||||
|
||||
@@ -185,17 +185,17 @@ class CLASS_stocks(Container):
|
||||
|
||||
StockEOD
|
||||
--------
|
||||
adjClose : float
|
||||
adj_close : float
|
||||
Adjusted Close Price of the symbol.
|
||||
unadjustedVolume : float
|
||||
unadjusted_volume : float
|
||||
Unadjusted volume of the symbol.
|
||||
change : float
|
||||
Change in the price of the symbol from the previous day.
|
||||
changePercent : float
|
||||
change_percent : float
|
||||
Change \% in the price of the symbol.
|
||||
label : str
|
||||
Human readable format of the date.
|
||||
changeOverTime : float
|
||||
change_over_time : float
|
||||
Change \% in the price of the symbol over a period of time."""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
@@ -288,17 +288,17 @@ class CLASS_stocks(Container):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
displayOutput : Literal['headline', 'summary', 'full', 'all']
|
||||
display_output : Literal['headline', 'summary', 'full', 'all']
|
||||
The type of data to return.
|
||||
date : Optional[datetime]
|
||||
The date of the news to retrieve.
|
||||
dateFrom : Optional[datetime]
|
||||
date_from : Optional[datetime]
|
||||
The start date of the news to retrieve.
|
||||
dateTo : Optional[datetime]
|
||||
date_to : Optional[datetime]
|
||||
The end date of the news to retrieve.
|
||||
updatedSince : Optional[int]
|
||||
updated_since : Optional[int]
|
||||
The number of seconds since the news was updated.
|
||||
publishedSince : Optional[int]
|
||||
published_since : Optional[int]
|
||||
The number of seconds since the news was published.
|
||||
sort : Optional[Literal['published_at', 'updated_at', 'title', 'author', 'channel', 'ticker', 'topic', 'content_type']]
|
||||
The order in which to sort the news. Options are: published_at, updated_at, title, author, channel, ticker, topic, content_type.
|
||||
|
||||
@@ -229,29 +229,29 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
BalanceSheet
|
||||
------------
|
||||
calendarYear : Optional[int]
|
||||
calendar_year : Optional[int]
|
||||
None
|
||||
link : Optional[str]
|
||||
None
|
||||
finalLink : Optional[str]
|
||||
final_link : Optional[str]
|
||||
None
|
||||
cashAndShortTermInvestments : Optional[int]
|
||||
cash_and_short_term_investments : Optional[int]
|
||||
None
|
||||
goodwillAndIntangibleAssets : Optional[int]
|
||||
goodwill_and_intangible_assets : Optional[int]
|
||||
None
|
||||
deferredRevenueNonCurrent : Optional[int]
|
||||
deferred_revenue_non_current : Optional[int]
|
||||
None
|
||||
totalInvestments : Optional[int]
|
||||
total_investments : Optional[int]
|
||||
None
|
||||
capitalLeaseObligations : Optional[int]
|
||||
capital_lease_obligations : Optional[int]
|
||||
None
|
||||
deferredTaxLiabilitiesNonCurrent : Optional[int]
|
||||
deferred_tax_liabilities_non_current : Optional[int]
|
||||
None
|
||||
totalNonCurrentLiabilities : Optional[int]
|
||||
total_non_current_liabilities : Optional[int]
|
||||
None
|
||||
totalDebt : Optional[int]
|
||||
total_debt : Optional[int]
|
||||
None
|
||||
netDebt : Optional[int]
|
||||
net_debt : Optional[int]
|
||||
None"""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
@@ -710,11 +710,11 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
CashFlowStatement
|
||||
-----------------
|
||||
calendarYear : Optional[int]
|
||||
calendar_year : Optional[int]
|
||||
None
|
||||
link : Optional[str]
|
||||
None
|
||||
finalLink : Optional[str]
|
||||
final_link : Optional[str]
|
||||
None"""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
@@ -1821,21 +1821,21 @@ class CLASS_stocks_fa(Container):
|
||||
|
||||
IncomeStatement
|
||||
---------------
|
||||
calendarYear : Optional[int]
|
||||
calendar_year : Optional[int]
|
||||
None
|
||||
grossProfitRatio : Optional[float]
|
||||
gross_profit_ratio : Optional[float]
|
||||
None
|
||||
ebitdaratio : Optional[float]
|
||||
None
|
||||
operatingIncomeRatio : Optional[float]
|
||||
operating_income_ratio : Optional[float]
|
||||
None
|
||||
incomeBeforeTaxRatio : Optional[float]
|
||||
income_before_tax_ratio : Optional[float]
|
||||
None
|
||||
netIncomeRatio : Optional[float]
|
||||
net_income_ratio : Optional[float]
|
||||
None
|
||||
link : Optional[str]
|
||||
None
|
||||
finalLink : Optional[str]
|
||||
final_link : Optional[str]
|
||||
None"""
|
||||
inputs = filter_inputs(
|
||||
provider_choices={
|
||||
@@ -2064,11 +2064,11 @@ class CLASS_stocks_fa(Container):
|
||||
The provider to use for the query.
|
||||
symbol : ConstrainedStrValue
|
||||
Symbol to get data for.
|
||||
transactionType : Optional[List[Literal['A-Award', 'C-Conversion', 'D-Return', 'E-ExpireShort', 'F-InKind', 'G-Gift', 'H-ExpireLong', 'I-Discretionary', 'J-Other', 'L-Small', 'M-Exempt', 'O-OutOfTheMoney', 'P-Purchase', 'S-Sale', 'U-Tender', 'W-Will', 'X-InTheMoney', 'Z-Trust']]]
|
||||
transaction_type : Optional[List[Literal['A-Award', 'C-Conversion', 'D-Return', 'E-ExpireShort', 'F-InKind', 'G-Gift', 'H-ExpireLong', 'I-Discretionary', 'J-Other', 'L-Small', 'M-Exempt', 'O-OutOfTheMoney', 'P-Purchase', 'S-Sale', 'U-Tender', 'W-Will', 'X-InTheMoney', 'Z-Trust']]]
|
||||
The type of the transaction.
|
||||
reportingCik : Optional[int]
|
||||
reporting_cik : Optional[int]
|
||||
The CIK of the reporting owner.
|
||||
companyCik : Optional[int]
|
||||
company_cik : Optional[int]
|
||||
The CIK of the company owner.
|
||||
page : Optional[int]
|
||||
The page number of the data to fetch.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import builtins
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from collections import OrderedDict
|
||||
@@ -308,6 +309,10 @@ class DocstringGenerator:
|
||||
field_mapping = mapping[model_name][provider.lower()][section_name]["fields"]
|
||||
fields = field_mapping.keys()
|
||||
|
||||
def _to_snake_case(string: str) -> str:
|
||||
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string)
|
||||
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
|
||||
|
||||
if len(fields) == 0:
|
||||
section_docstring += "All fields are standardized.\n"
|
||||
else:
|
||||
@@ -322,7 +327,7 @@ class DocstringGenerator:
|
||||
|
||||
field_description = field_mapping[field].field_info.description
|
||||
|
||||
section_docstring += f"{field} : {field_type}\n"
|
||||
section_docstring += f"{_to_snake_case(field)} : {field_type}\n"
|
||||
section_docstring += f"{padding}{field_description}\n"
|
||||
|
||||
if provider == "openbb" and section_name == "QueryParams":
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
import re
|
||||
|
||||
from pydantic import BaseModel, Extra
|
||||
|
||||
|
||||
def to_snake_case(string: str) -> str:
|
||||
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string)
|
||||
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
|
||||
|
||||
|
||||
class Data(BaseModel):
|
||||
"""The OpenBB Standardized Data Model."""
|
||||
|
||||
def dict(self, *args, **kwargs):
|
||||
original_dict = super().dict(*args, **kwargs)
|
||||
return {to_snake_case(k): v for k, v in original_dict.items()}
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.__class__.__name__}({', '.join([f'{k}={v}' for k, v in self.dict().items()])})"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user