import yfinance as yf # from yahooquery import Ticker async def get_financial_info(ticker: str): """ yfinance api 이용 """ company = yf.Ticker(ticker) info = company.info income = company.income_stmt balance = company.balance_sheet cashflow = company.cash_flow return { # 시가총액 "market_cap": info.get("marketCap"), # 현재주가 "current_price": info.get("currentPrice"), # 매출 "revenue": income.loc["Total Revenue"].iloc[0], # 손익계산 "operating_income": income.loc["Operating Income"].iloc[0], # 순이익 "net_income": income.loc["Net Income"].iloc[0], # 총자산 "total_assets": balance.loc["Total Assets"].iloc[0], # 총부채 "total_debt": balance.loc["Total Debt"].iloc[0], # 현금흐름 "free_cash_flow": cashflow.loc["Free Cash Flow"].iloc[0], # per "pe_ratio": info.get("trailingPE"), # pbr "pb_ratio": info.get("priceToBook"), }