This commit is contained in:
tehcoderer
2023-11-29 22:40:06 -05:00
parent dfb007463e
commit be1aaa09a7
12 changed files with 43 additions and 35 deletions

View File

@@ -116,4 +116,3 @@ class IncomeStatementGrowthData(Data):
if isinstance(v, str):
return v.upper()
return ",".join([symbol.upper() for symbol in list(v)]) if v else None
return ",".join([symbol.upper() for symbol in list(v)]) if v else None

View File

@@ -71,6 +71,7 @@ class ClientSession(aiohttp.ClientSession):
super().__init__(*args, **kwargs)
# pylint: disable=unused-argument
def __del__(self, _warnings: Any = warnings) -> None:
"""Close the session."""
if not self.closed:

View File

@@ -9,8 +9,11 @@ from openbb_core.provider.standard_models.equity_historical import (
EquityHistoricalData,
EquityHistoricalQueryParams,
)
from openbb_core.provider.utils.client import ClientResponse
from openbb_core.provider.utils.helpers import async_requests, get_querystring
from openbb_core.provider.utils.helpers import (
ClientResponse,
async_requests,
get_querystring,
)
from openbb_fmp.utils.helpers import get_interval
from pydantic import Field, NonNegativeInt

View File

@@ -7,8 +7,7 @@ from openbb_core.provider.standard_models.equity_valuation_multiples import (
EquityValuationMultiplesData,
EquityValuationMultiplesQueryParams,
)
from openbb_core.provider.utils.client import ClientResponse
from openbb_core.provider.utils.helpers import async_requests
from openbb_core.provider.utils.helpers import ClientResponse, async_requests
from openbb_fmp.utils.helpers import create_url

View File

@@ -10,9 +10,13 @@ from openbb_core.provider.standard_models.fred_series import (
SeriesData,
SeriesQueryParams,
)
from openbb_core.provider.utils.client import ClientResponse, ClientSession
from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS
from openbb_core.provider.utils.helpers import async_requests, get_querystring
from openbb_core.provider.utils.helpers import (
ClientResponse,
ClientSession,
async_requests,
get_querystring,
)
from pydantic import Field
_warn = warnings.warn

View File

@@ -120,14 +120,15 @@ class IntrinioBalanceSheetFetcher(
period_type = "FY" if query.period == "annual" else "QTR"
base_url = "https://api-v2.intrinio.com"
fundamentals_url_params = f"statement_code={statement_code}&type={period_type}"
fundamentals_url = (
f"{base_url}/companies/{query.symbol}/fundamentals?"
f"{fundamentals_url_params}&api_key={api_key}"
f"statement_code={statement_code}&type={period_type}&api_key={api_key}"
)
fundamentals_data = (await get_data_one(fundamentals_url, **kwargs)).get(
"fundamentals", []
)
fundamentals_response = await get_data_one(fundamentals_url, **kwargs)
fundamentals_data = fundamentals_response.get("fundamentals", [])
fiscal_periods = [
f"{item['fiscal_year']}-{item['fiscal_period']}"
for item in fundamentals_data

View File

@@ -117,14 +117,14 @@ class IntrinioCashFlowStatementFetcher(
period_type = "FY" if query.period == "annual" else "QTR"
base_url = "https://api-v2.intrinio.com"
fundamentals_url_params = f"statement_code={statement_code}&type={period_type}"
fundamentals_url = (
f"{base_url}/companies/{query.symbol}/fundamentals?"
f"{fundamentals_url_params}&api_key={api_key}"
f"statement_code={statement_code}&type={period_type}&api_key={api_key}"
)
fundamentals_data = (await get_data_one(fundamentals_url, **kwargs)).get(
"fundamentals", []
)
fundamentals_response = await get_data_one(fundamentals_url, **kwargs)
fundamentals_data = fundamentals_response.get("fundamentals", [])
fiscal_periods = [
f"{item['fiscal_year']}-{item['fiscal_period']}"

View File

@@ -120,14 +120,14 @@ class IntrinioIncomeStatementFetcher(
data_tags = ["ebit", "ebitda", "ebitdamargin"]
base_url = "https://api-v2.intrinio.com"
fundamentals_url_params = f"statement_code={statement_code}&type={period_type}"
fundamentals_url = (
f"{base_url}/companies/{query.symbol}/fundamentals?"
f"{fundamentals_url_params}&api_key={api_key}"
f"statement_code={statement_code}&type={period_type}&api_key={api_key}"
)
fundamentals_data = (await get_data_one(fundamentals_url, **kwargs)).get(
"fundamentals", []
)
fundamentals_response = await get_data_one(fundamentals_url, **kwargs)
fundamentals_data = fundamentals_response.get("fundamentals", [])
fiscal_periods = [
f"{item['fiscal_year']}-{item['fiscal_period']}"
@@ -142,9 +142,8 @@ class IntrinioIncomeStatementFetcher(
statement_data = await response.json()
calculations_url = f"{base_url}/fundamentals/{intrinio_id}/standardized_financials?api_key={api_key}"
calculations_response = await session.get(calculations_url)
calculations_data = await session.get_json(calculations_url)
calculations_data = await calculations_response.json()
calculations_data = [
item
for item in calculations_data.get("standardized_financials", [])

View File

@@ -49,6 +49,7 @@ class IntrinioOptionsChainsData(OptionsChainsData):
# only pass it to the parser if it is not a datetime object
if isinstance(v, str):
return parser.parse(v)
return v
class IntrinioOptionsChainsFetcher(

View File

@@ -166,8 +166,7 @@ class NasdaqCalendarEarningsFetcher(
r_json["data"]["asOf"], "%a, %b %d, %Y"
).date()
if len(response) > 0:
[d.update({"date": _as_of_date}) for d in response]
data.extend(response)
data.extend([{**d, "date": _as_of_date} for d in response])
with ThreadPoolExecutor() as executor:
executor.map(get_calendar_data, dates)

View File

@@ -145,10 +145,8 @@ class NasdaqCalendarIpoFetcher(
dates = sorted(
list(
set(
[
date.strftime("%Y-%m")
for date in date_range(query.start_date, query.end_date)
]
date.strftime("%Y-%m")
for date in date_range(query.start_date, query.end_date)
)
)
)

View File

@@ -9,7 +9,7 @@ from openbb_core.provider.standard_models.economic_calendar import (
EconomicCalendarData,
EconomicCalendarQueryParams,
)
from openbb_core.provider.utils.helpers import make_request
from openbb_core.provider.utils.helpers import ClientResponse, async_request
from openbb_tradingeconomics.utils import url_generator
from openbb_tradingeconomics.utils.countries import country_list
from pandas import to_datetime
@@ -108,7 +108,7 @@ class TEEconomicCalendarFetcher(
return TEEconomicCalendarQueryParams(**params)
@staticmethod
def extract_data(
async def extract_data_async(
query: TEEconomicCalendarQueryParams,
credentials: Optional[Dict[str, str]],
**kwargs: Any,
@@ -133,10 +133,14 @@ class TEEconomicCalendarFetcher(
"No url generated. Check combination of input parameters."
)
url = f"{url}{api_key}"
response = make_request(url, **kwargs)
if response.status_code != 200:
raise RuntimeError(f"Error in TE request -> {response.text}")
return response.json()
async def callback(response: ClientResponse, _: Any) -> List[Dict]:
"""Return the response."""
if response.status != 200:
raise RuntimeError(f"Error in TE request -> {await response.text()}")
return await response.json()
return await async_request(url, response_callback=callback, **kwargs)
@staticmethod
def transform_data(