implemented getting specific financial statement for multiple companies; fixed tests
This commit is contained in:
@ -90,28 +90,43 @@ async def _get_financial_statement(statement: str, ticker_symbol: str, quarterly
|
||||
return extract_all_data(soup)
|
||||
|
||||
|
||||
async def get_balance_sheet(ticker_symbol: str, quarterly: bool = False,
|
||||
async def get_balance_sheet(*ticker_symbols: str, quarterly: bool = False,
|
||||
session: ClientSession = None) -> ResultDict:
|
||||
"""
|
||||
Returns data from the balance sheet of the specified company.
|
||||
"""
|
||||
return await _get_financial_statement(constants.BS, ticker_symbol, quarterly, session)
|
||||
if len(ticker_symbols) == 1:
|
||||
return await _get_financial_statement(constants.BS, ticker_symbols[0], quarterly, session)
|
||||
return {
|
||||
sym: await _get_financial_statement(constants.BS, sym, quarterly, session)
|
||||
for sym in ticker_symbols
|
||||
}
|
||||
|
||||
|
||||
async def get_income_statement(ticker_symbol: str, quarterly: bool = False,
|
||||
async def get_income_statement(*ticker_symbols: str, quarterly: bool = False,
|
||||
session: ClientSession = None) -> ResultDict:
|
||||
"""
|
||||
Returns data from the income statement of the specified company.
|
||||
"""
|
||||
return await _get_financial_statement(constants.IS, ticker_symbol, quarterly, session)
|
||||
if len(ticker_symbols) == 1:
|
||||
return await _get_financial_statement(constants.IS, ticker_symbols[0], quarterly, session)
|
||||
return {
|
||||
sym: await _get_financial_statement(constants.IS, sym, quarterly, session)
|
||||
for sym in ticker_symbols
|
||||
}
|
||||
|
||||
|
||||
async def get_cash_flow_statement(ticker_symbol: str, quarterly: bool = False,
|
||||
async def get_cash_flow_statement(*ticker_symbols: str, quarterly: bool = False,
|
||||
session: ClientSession = None) -> ResultDict:
|
||||
"""
|
||||
Returns data from the cash flow statement of the specified company.
|
||||
"""
|
||||
return await _get_financial_statement(constants.CF, ticker_symbol, quarterly, session)
|
||||
if len(ticker_symbols) == 1:
|
||||
return await _get_financial_statement(constants.CF, ticker_symbols[0], quarterly, session)
|
||||
return {
|
||||
sym: await _get_financial_statement(constants.CF, sym, quarterly, session)
|
||||
for sym in ticker_symbols
|
||||
}
|
||||
|
||||
|
||||
async def get_company_financials(*ticker_symbols: str, quarterly: bool = False,
|
||||
@ -121,14 +136,14 @@ async def get_company_financials(*ticker_symbols: str, quarterly: bool = False,
|
||||
"""
|
||||
if len(ticker_symbols) == 1:
|
||||
return {
|
||||
constants.BS: await get_balance_sheet(ticker_symbols[0], quarterly, session),
|
||||
constants.IS: await get_income_statement(ticker_symbols[0], quarterly, session),
|
||||
constants.CF: await get_cash_flow_statement(ticker_symbols[0], quarterly, session)
|
||||
constants.BS: await get_balance_sheet(ticker_symbols[0], quarterly=quarterly, session=session),
|
||||
constants.IS: await get_income_statement(ticker_symbols[0], quarterly=quarterly, session=session),
|
||||
constants.CF: await get_cash_flow_statement(ticker_symbols[0], quarterly=quarterly, session=session)
|
||||
}
|
||||
return {
|
||||
sym: {
|
||||
constants.BS: await get_balance_sheet(sym, quarterly, session),
|
||||
constants.IS: await get_income_statement(sym, quarterly, session),
|
||||
constants.CF: await get_cash_flow_statement(sym, quarterly, session)
|
||||
constants.BS: await get_balance_sheet(sym, quarterly=quarterly, session=session),
|
||||
constants.IS: await get_income_statement(sym, quarterly=quarterly, session=session),
|
||||
constants.CF: await get_cash_flow_statement(sym, quarterly=quarterly, session=session)
|
||||
} for sym in ticker_symbols
|
||||
}
|
||||
|
Reference in New Issue
Block a user