company financials returned as separate dicts; test fix
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import Union, List
|
||||
from typing import Union, List, Dict
|
||||
|
||||
from aiohttp.client import ClientSession
|
||||
from bs4 import BeautifulSoup
|
||||
@ -63,7 +63,7 @@ def extract_row_data(tr: Tag) -> tuple[str, tuple[int]]:
|
||||
item_name = str(tr.td.div.string).strip()
|
||||
data_div = tr.find_all('td')[-1].div.div
|
||||
values_str: str = data_div.attrs['data-chart-data']
|
||||
values = tuple(int(float(s)) for s in values_str.split(','))
|
||||
values = tuple(int(float(s if s != '' else 0)) for s in values_str.split(','))
|
||||
return item_name, values
|
||||
|
||||
|
||||
@ -115,11 +115,12 @@ async def get_cash_flow_statement(ticker_symbol: str, quarterly: bool = False,
|
||||
|
||||
|
||||
async def get_company_financials(ticker_symbol: str, quarterly: bool = False,
|
||||
session: ClientSession = None) -> ResultDict:
|
||||
session: ClientSession = None) -> Dict[str, ResultDict]:
|
||||
"""
|
||||
Returns all fundamentals (balance sheet, income statement and cash flow statement) of the specified company.
|
||||
"""
|
||||
financials = await get_balance_sheet(ticker_symbol, quarterly, session)
|
||||
financials.update(await get_income_statement(ticker_symbol, quarterly, session))
|
||||
financials.update(await get_cash_flow_statement(ticker_symbol, quarterly, session))
|
||||
return financials
|
||||
return {
|
||||
constants.BS: await get_balance_sheet(ticker_symbol, quarterly, session),
|
||||
constants.IS: await get_income_statement(ticker_symbol, quarterly, session),
|
||||
constants.CF: await get_cash_flow_statement(ticker_symbol, quarterly, session)
|
||||
}
|
||||
|
Reference in New Issue
Block a user