728x90
반응형
# yahoo_fin
- 링크 : pypi.org/project/yahoo-fin/
- 문서 : theautomatic.net/yahoo_fin-documentation/
- 용도 : 야후 파이낸스(finance.yahoo.com/) 사이트에서 데이터 스크랩할 수 있는 함수 제공
# Modules
. stock_info
. options
. news
# Methods
[Module] stock_info
get_market_status get_live_price get_premarket_price get_postmarket_price get_next_earnings_date get_top_crypto get_futures get_currencies get_quote_data get_quote_table get_stats get_stats_valuation get_data get_dividends get_splits get_financials get_balance_sheet get_cash_flow get_income_statement get_earnings get_earnings_for_date get_earnings_in_date_range get_earnings_history get_analysts_info get_holders get_day_losers get_day_gainers get_day_most_active get_undervalued_large_caps tickers_dow tickers_ftse100 tickers_ftse250 tickers_ibovespa tickers_nasdaq tickers_nifty50 tickers_niftybank tickers_other tickers_sp500 |
시장 상태 확인 ("PRE", "OPEN", "POST", "CLOSED") 실시간 주가 프리장 주가 애프터장 주가 다가오는 earning date (Markets-Cryptocurrencies) 시가총액에 따른 top100 암호화폐 (Markets-Futures) 선물 가격 테이블 가져오기 (Markets-currencies) 테이블 가져오기 ['ticker']=회사명, 실시간가격, 50일,200일 평균 등 70여 데이터 (Ticker) 티커 검색/선택하면 나오는 테이블 정보 (Ticker-Statistics) Valuation Measures 제외하고 전체 (Ticker-Statistics) Valuation Measures (Ticker-Historical Data-Historical Prices) 시가,고가,저가,종가,조정종가,볼륨,티커 (Ticker-Historical Data-Dividends Only) 배당일, 배당금 (Ticker-Historical Data-Stock Split) 액면분할 날짜, 비율 (Ticker-Financials-Balance sheets,Cash flow,Income statements) 3개 전체 (Ticker-Financials-Balance sheet) (Ticker-Financials-Cash flow) (Ticker-Financials-Income statement) (Ticker-Financials-Income statement) earnings (최근 4분기) (Ticker-Financials-Income statement) ['ticker'] (특정 date) (Ticker-Financials-Income statement) ['ticker'] (start_date~end_date) (Ticker-Financials-Income statement) earnings (20년) (Ticker-Analysts) (Ticker-Holders) (주어진 거래일에) 가장 큰 수익 낸 top 100 주식 (주어진 거래일에) 가장 실적 낮은 top 100 주식 (주어진 거래일에) 가장 활발한 top 100 주식 large cap 중 저평가 된 top100 회사 [사용불가] 다우존스 100개 회사 250개 회사 75개 회사 4364개 회사 30개 회사 12개 회사 5782개 회사 505개 회사 |
get_quote_data()
{'language': 'en-US', 'region': 'US', 'quoteType': 'EQUITY', 'quoteSourceName': 'Nasdaq Real Time Price', 'triggerable': True, 'currency': 'USD', 'marketState': 'PRE', 'exchange': 'NMS', 'shortName': 'Microsoft Corporation', 'longName': 'Microsoft Corporation', 'messageBoardId': 'finmb_21835', 'exchangeTimezoneName': 'America/New_York', 'exchangeTimezoneShortName': 'EDT', 'gmtOffSetMilliseconds': -14400000, 'market': 'us_market', 'esgPopulated': False, 'earningsTimestamp': 1611677285, 'earningsTimestampStart': 1619553600, 'earningsTimestampEnd': 1620072000, 'trailingAnnualDividendRate': 2.14, 'trailingPE': 35.34218, 'trailingAnnualDividendYield': 0.009002566, 'epsTrailingTwelveMonths': 6.707, 'epsForward': 8.08, 'epsCurrentYear': 7.4, 'priceEpsCurrentYear': 32.032433, 'sharesOutstanding': 7560500224, 'bookValue': 17.259, 'fiftyDayAverage': 237.08089, 'fiftyDayAverageChange': -0.040893555, 'fiftyDayAverageChangePercent': -0.00017248778, 'twoHundredDayAverage': 220.19507, 'twoHundredDayAverageChange': 16.844925, 'twoHundredDayAverageChangePercent': 0.07650001, 'marketCap': 1787807662080, 'forwardPE': 29.336634, 'priceToBook': 13.7342825, 'sourceInterval': 15, 'exchangeDataDelayedBy': 0, 'tradeable': False, 'firstTradeDateMilliseconds': 511108200000, 'priceHint': 2, 'preMarketChange': -3.369995, 'preMarketChangePercent': -1.4216989, 'preMarketTime': 1616068930, 'preMarketPrice': 233.67, 'regularMarketChange': -0.6700134, 'regularMarketChangePercent': -0.2818617, 'regularMarketTime': 1616011202, 'regularMarketPrice': 237.04, 'regularMarketDayHigh': 238.55, 'regularMarketDayRange': '233.23 - 238.55', 'regularMarketDayLow': 233.23, 'regularMarketVolume': 29562100, 'regularMarketPreviousClose': 237.71, 'bid': 0.0, 'ask': 0.0, 'bidSize': 32, 'askSize': 8, 'fullExchangeName': 'NasdaqGS', 'financialCurrency': 'USD', 'regularMarketOpen': 236.15, 'averageDailyVolume3Month': 29504564, 'averageDailyVolume10Day': 29187057, 'fiftyTwoWeekLowChange': 104.51999, 'fiftyTwoWeekLowChangePercent': 0.788711, 'fiftyTwoWeekRange': '132.52 - 246.13', 'fiftyTwoWeekHighChange': -9.090012, 'fiftyTwoWeekHighChangePercent': -0.03693175, 'fiftyTwoWeekLow': 132.52, 'fiftyTwoWeekHigh': 246.13, 'dividendDate': 1615420800, 'displayName': 'Microsoft', 'symbol': 'MSFT'}
# 풀어서 정리하면 아래와 같은 구조를 가진다.
{'language': 'en-US',
'region': 'US',
'quoteType': 'EQUITY',
'quoteSourceName': 'Nasdaq Real Time Price',
'triggerable': True,
'currency': 'USD',
'marketState': 'PRE',
'exchange': 'NMS',
'shortName': 'Microsoft Corporation',
'longName': 'Microsoft Corporation',
'messageBoardId': 'finmb_21835',
'exchangeTimezoneName': 'America/New_York',
'exchangeTimezoneShortName': 'EDT',
'gmtOffSetMilliseconds': -14400000,
'market': 'us_market',
'esgPopulated': False,
'earningsTimestamp': 1611677285,
'earningsTimestampStart': 1619553600,
'earningsTimestampEnd': 1620072000,
'trailingAnnualDividendRate': 2.14,
'trailingPE': 35.34218,
'trailingAnnualDividendYield': 0.009002566,
'epsTrailingTwelveMonths': 6.707,
'epsForward': 8.08,
'epsCurrentYear': 7.4,
'priceEpsCurrentYear': 32.032433,
'sharesOutstanding': 7560500224,
'bookValue': 17.259,
'fiftyDayAverage': 237.08089,
'fiftyDayAverageChange': -0.040893555,
'fiftyDayAverageChangePercent': -0.00017248778,
'twoHundredDayAverage': 220.19507,
'twoHundredDayAverageChange': 16.844925,
'twoHundredDayAverageChangePercent': 0.07650001,
'marketCap': 1787807662080,
'forwardPE': 29.336634,
'priceToBook': 13.7342825,
'sourceInterval': 15,
'exchangeDataDelayedBy': 0,
'tradeable': False,
'firstTradeDateMilliseconds': 511108200000,
'priceHint': 2,
'preMarketChange': -3.369995,
'preMarketChangePercent': -1.4216989,
'preMarketTime': 1616068930,
'preMarketPrice': 233.67,
'regularMarketChange': -0.6700134,
'regularMarketChangePercent': -0.2818617,
'regularMarketTime': 1616011202,
'regularMarketPrice': 237.04,
'regularMarketDayHigh': 238.55,
'regularMarketDayRange': '233.23 - 238.55',
'regularMarketDayLow': 233.23,
'regularMarketVolume': 29562100,
'regularMarketPreviousClose': 237.71,
'bid': 0.0,
'ask': 0.0,
'bidSize': 32,
'askSize': 8,
'fullExchangeName': 'NasdaqGS',
'financialCurrency': 'USD',
'regularMarketOpen': 236.15,
'averageDailyVolume3Month': 29504564,
'averageDailyVolume10Day': 29187057,
'fiftyTwoWeekLowChange': 104.51999,
'fiftyTwoWeekLowChangePercent': 0.788711,
'fiftyTwoWeekRange': '132.52 - 246.13',
'fiftyTwoWeekHighChange': -9.090012,
'fiftyTwoWeekHighChangePercent': -0.03693175,
'fiftyTwoWeekLow': 132.52,
'fiftyTwoWeekHigh': 246.13,
'dividendDate': 1615420800,
'displayName': 'Microsoft',
'symbol': 'MSFT'}
get_quote_table()
{'1y Target Est': 272.71, '52 Week Range': '132.52 - 246.13', 'Ask': '0.00 x 800', 'Avg. Volume': 29504564.0, 'Beta (5Y Monthly)': 0.81, 'Bid': '0.00 x 3200', "Day's Range": '233.23 - 238.55', 'EPS (TTM)': 6.71, 'Earnings Date': 'Apr 27, 2021 - May 03, 2021', 'Ex-Dividend Date': 'Feb 17, 2021', 'Forward Dividend & Yield': '2.24 (0.95%)', 'Market Cap': '1.788T', 'Open': 236.15, 'PE Ratio (TTM)': 35.34, 'Previous Close': 237.71, 'Quote Price': 237.0399932861328, 'Volume': 29562100.0}
# 풀어서 정리하면 아래와 같은 구조를 가진다.
{'1y Target Est': 272.71,
'52 Week Range': '132.52 - 246.13',
'Ask': '0.00 x 800',
'Avg. Volume': 29504564.0,
'Beta (5Y Monthly)': 0.81,
'Bid': '0.00 x 3200',
"Day's Range": '233.23 - 238.55',
'EPS (TTM)': 6.71,
'Earnings Date': 'Apr 27, 2021 - May 03, 2021',
'Ex-Dividend Date': 'Feb 17, 2021',
'Forward Dividend & Yield': '2.24 (0.95%)',
'Market Cap': '1.788T',
'Open': 236.15,
'PE Ratio (TTM)': 35.34,
'Previous Close': 237.71,
'Quote Price': 237.0399932861328,
'Volume': 29562100.0}
get_stats()
Ticker - Statistics 페이지
Trading Information
- Stock Price History (0-6)
- Share Statistics (7-17)
- Dividends & Splits (18-27)
Financial Highlights
- Fiscal Year (28-29)
- Profitability (30-31)
- Management Effectiveness (32-33)
- Income Statement (34-41)
- Balance Sheet (42-47)
- Cash Flow Statement (48-49)
Attribute Value
0 Beta (5Y Monthly) 0.81
1 52-Week Change 3 66.57%
2 S&P500 52-Week Change 3 65.26%
3 52 Week High 3 246.13
4 52 Week Low 3 132.52
5 50-Day Moving Average 3 237.08
6 200-Day Moving Average 3 220.20
7 Avg Vol (3 month) 3 29.5M
8 Avg Vol (10 day) 3 29.19M
9 Shares Outstanding 5 7.56B
10 Float 7.43B
11 % Held by Insiders 1 0.06%
12 % Held by Institutions 1 71.84%
13 Shares Short (Feb 25, 2021) 4 41.63M
14 Short Ratio (Feb 25, 2021) 4 1.36
15 Short % of Float (Feb 25, 2021) 4 0.55%
16 Short % of Shares Outstanding (Feb 25, 2021) 4 0.55%
17 Shares Short (prior month Jan 28, 2021) 4 44.53M
18 Forward Annual Dividend Rate 4 2.24
19 Forward Annual Dividend Yield 4 0.95%
20 Trailing Annual Dividend Rate 3 2.14
21 Trailing Annual Dividend Yield 3 0.90%
22 5 Year Average Dividend Yield 4 1.68
23 Payout Ratio 4 31.15%
24 Dividend Date 3 Mar 10, 2021
25 Ex-Dividend Date 4 Feb 16, 2021
26 Last Split Factor 2 2:1
27 Last Split Date 3 Feb 17, 2003
28 Fiscal Year Ends Jun 29, 2020
29 Most Recent Quarter (mrq) Dec 30, 2020
30 Profit Margin 33.47%
31 Operating Margin (ttm) 39.24%
32 Return on Assets (ttm) 12.81%
33 Return on Equity (ttm) 42.70%
34 Revenue (ttm) 153.28B
35 Revenue Per Share (ttm) 20.23
36 Quarterly Revenue Growth (yoy) 16.70%
37 Gross Profit (ttm) 96.94B
38 EBITDA 71.69B
39 Net Income Avi to Common (ttm) 51.31B
40 Diluted EPS (ttm) 6.71
41 Quarterly Earnings Growth (yoy) 32.70%
42 Total Cash (mrq) 131.99B
43 Total Cash Per Share (mrq) 17.5
44 Total Debt (mrq) 82.78B
45 Total Debt/Equity (mrq) 63.56
46 Current Ratio (mrq) 2.58
47 Book Value Per Share (mrq) 17.26
48 Operating Cash Flow (ttm) 68.03B
49 Levered Free Cash Flow (ttm) 34.79B
get_stats_valuation()
Ticker - Statistics 페이지
Valuation Measures (0-8)
0 1
0 Market Cap (intraday) 5 1.79T
1 Enterprise Value 3 1.74T
2 Trailing P/E 35.34
3 Forward P/E 1 29.34
4 PEG Ratio (5 yr expected) 1 1.90
5 Price/Sales (ttm) 11.66
6 Price/Book (mrq) 13.73
7 Enterprise Value/Revenue 3 11.38
8 Enterprise Value/EBITDA 6 24.32
get_data()
open high low close adjclose volume ticker
1986-03-13 0.088542 0.101563 0.088542 0.097222 0.061751 1031788800 MSFT
1986-03-14 0.097222 0.102431 0.097222 0.100694 0.063956 308160000 MSFT
1986-03-17 0.100694 0.103299 0.100694 0.102431 0.065059 133171200 MSFT
1986-03-18 0.102431 0.103299 0.098958 0.099826 0.063405 67766400 MSFT
1986-03-19 0.099826 0.100694 0.097222 0.098090 0.062302 47894400 MSFT
... ... ... ... ... ... ... ...
2021-03-11 234.960007 239.169998 234.309998 237.130005 237.130005 29896000 MSFT
2021-03-12 234.009995 235.820007 233.229996 235.750000 235.750000 22647900 MSFT
2021-03-15 234.960007 235.190002 231.809998 234.809998 234.809998 26034900 MSFT
2021-03-16 236.279999 240.059998 235.940002 237.710007 237.710007 27717700 MSFT
2021-03-17 236.149994 238.550003 233.229996 237.039993 237.039993 29500700 MSFT
[8825 rows x 7 columns]
get_dividends()
Ticker-Historical Data-Dividends Only (기본: 전체일자로 조회)
배당일, 배당금
dividend ticker
1984-03-26 0.116667 T
1984-06-25 0.116667 T
1984-09-24 0.116667 T
1985-01-04 0.116667 T
1985-04-03 0.125000 T
... ... ...
2020-01-09 0.520000 T
2020-04-08 0.520000 T
2020-07-09 0.520000 T
2020-10-08 0.520000 T
2021-01-08 0.520000 T
get_earnings()
{'quarterly_results': date actual estimate
0 1Q2020 1.40 1.26
1 2Q2020 1.46 1.34
2 3Q2020 1.82 1.54
3 4Q2020 2.03 1.64, 'yearly_revenue_earnings': date revenue earnings
0 2017 96571000000 25489000000
1 2018 110360000000 16571000000
2 2019 125843000000 39240000000
3 2020 143015000000 44281000000, 'quarterly_revenue_earnings': date revenue earnings
0 1Q2020 35021000000 10752000000
1 2Q2020 38033000000 11202000000
2 3Q2020 37154000000 13893000000
3 4Q2020 43076000000 15463000000}
get_earnings_for_date()
[{'ticker': 'BWLA', 'companyshortname': 'Bowl America Incorporated', 'startdatetime': '2021-02-09T00:00:00.000Z', 'startdatetimetype': 'TNS', 'epsestimate': None, 'epsactual': None, 'epssurprisepct': None, 'timeZoneShortName': 'UTC', 'gmtOffsetMilliSeconds': 0, 'quoteType': 'EQUITY'},
...]
# 풀어보면 아래와 같은 구조임.
[{
'ticker': 'BWLA',
'companyshortname': 'Bowl America Incorporated',
'startdatetime': '2021-02-09T00:00:00.000Z',
'startdatetimetype': 'TNS',
'epsestimate': None,
'epsactual': None,
'epssurprisepct': None,
'timeZoneShortName': 'UTC',
'gmtOffsetMilliSeconds': 0,
'quoteType': 'EQUITY'
},
{'ticker': 'AVNT',
'companyshortname':
'Avient Corporation',
'startdatetime': '2021-02-09T00:00:00.000Z',
'startdatetimetype': 'TNS',
'epsestimate': 0.46,
'epsactual': 0.52,
'epssurprisepct': 14.29,
'timeZoneShortName': 'EDT',
'gmtOffsetMilliSeconds': 0,
'quoteType': 'EQUITY'
},
{...}
...]
get_analysts()
{'Earnings Estimate': Earnings Estimate Current Qtr. (Mar 2021) Next Qtr. (Jun 2021) Current Year (2021) Next Year (2022)
0 No. of Analysts 26.00 26.00 32.00 31.00
1 Avg. Estimate 1.77 1.78 7.40 8.08
2 Low Estimate 1.69 1.68 7.10 7.23
3 High Estimate 1.93 1.98 7.73 9.03
4 Year Ago EPS 1.40 1.46 5.76 7.40, 'Revenue Estimate': Revenue Estimate Current Qtr. (Mar 2021) Next Qtr. (Jun 2021) Current Year (2021) Next Year (2022)
0 No. of Analysts 24 24 29 29
1 Avg. Estimate 41.03B 43.01B 164.19B 182.71B
2 Low Estimate 40.54B 41.17B 161.94B 168.71B
3 High Estimate 41.89B 44.57B 166.55B 192.27B
4 Year Ago Sales 35.02B 38.03B 143.01B 164.19B
5 Sales Growth (year/est) 17.20% 13.10% 14.80% 11.30%, 'Earnings History': Earnings History 3/30/2020 6/29/2020 9/29/2020 12/30/2020
0 EPS Est. 1.26 1.34 1.54 1.64
1 EPS Actual 1.4 1.46 1.82 2.03
2 Difference 0.14 0.12 0.28 0.39
3 Surprise % 11.10% 9.00% 18.20% 23.80%, 'EPS Trend': EPS Trend Current Qtr. (Mar 2021) Next Qtr. (Jun 2021) Current Year (2021) Next Year (2022)
0 Current Estimate 1.77 1.78 7.40 8.08
1 7 Days Ago 1.77 1.78 7.40 8.09
2 30 Days Ago 1.77 1.78 7.40 8.09
3 60 Days Ago 1.58 1.71 6.76 7.47
4 90 Days Ago 1.58 1.71 6.76 7.47, 'EPS Revisions': EPS Revisions Current Qtr. (Mar 2021) Next Qtr. (Jun 2021) Current Year (2021) Next Year (2022)
0 Up Last 7 Days NaN NaN 1.0 NaN
1 Up Last 30 Days NaN NaN 2.0 1.0
2 Down Last 7 Days NaN NaN NaN NaN
3 Down Last 30 Days NaN NaN NaN NaN, 'Growth Estimates': Growth Estimates MSFT Industry Sector(s) S&P 500
0 Current Qtr. 26.40% NaN NaN NaN
1 Next Qtr. 21.90% NaN NaN NaN
2 Current Year 28.50% NaN NaN NaN
3 Next Year 9.20% NaN NaN NaN
4 Next 5 Years (per annum) 16.70% NaN NaN NaN
5 Past 5 Years (per annum) 18.17% NaN NaN NaN}
get_holders()
{'Major Holders': 0.06% % of Shares Held by All Insider
0 71.84% % of Shares Held by Institutions
1 71.89% % of Float Held by Institutions
2 4849 Number of Institutions Holding Shares, 'Direct Holders (Forms 3 and 4)': Holder Shares Date Reported % Out Value
0 Vanguard Group, Inc. (The) 614100233 Dec 30, 2020 8.14% 136588173823
1 Blackrock Inc. 515509179 Dec 30, 2020 6.83% 114659551593
2 State Street Corporation 299126371 Dec 30, 2020 3.97% 66531687437
3 FMR, LLC 222257473 Dec 30, 2020 2.95% 49434507144
4 Price (T.Rowe) Associates Inc 177500157 Dec 30, 2020 2.35% 39479584919
5 Geode Capital Management, LLC 117798162 Dec 30, 2020 1.56% 26200667192
6 Capital World Investors 110441260 Dec 30, 2020 1.46% 24564345049
7 Capital Research Global Investors 95506129 Dec 30, 2020 1.27% 21242473212
8 Capital International Investors 91995988 Dec 30, 2020 1.22% 20461747650
9 Northern Trust Corporation 91215100 Dec 30, 2020 1.21% 20288062542, 'Top Institutional Holders': Holder Shares Date Reported % Out Value
0 Vanguard Total Stock Market Index Fund 213074576 Dec 30, 2020 2.83% 47392047193
1 Vanguard 500 Index Fund 151495446 Dec 30, 2020 2.01% 33695617099
2 SPDR S&P 500 ETF Trust 76510460 Jan 30, 2021 1.01% 17747366301
3 Fidelity 500 Index Fund 68511211 Jan 30, 2021 0.91% 15891860503
4 Vanguard Institutional Index Fund-Institutiona... 62176808 Dec 30, 2020 0.82% 13829365635
5 Invesco ETF Tr-Invesco QQQ Tr, Series 1 ETF 60727237 Jan 30, 2021 0.81% 14086289894
6 Vanguard Growth Index Fund 59959855 Dec 30, 2020 0.79% 13336270949
7 iShares Core S&P 500 ETF 56349109 Jan 30, 2021 0.75% 13070739323
8 Growth Fund Of America Inc 52798737 Dec 30, 2020 0.70% 11743495083
9 Washington Mutual Investors Fund 34200557 Dec 30, 2020 0.45% 7606887887}
[Module] option
get_calls get_expiration_dates get_options_chain get_puts |
[Module] news
get_yf_rss |
반응형
'Python > 라이브러리' 카테고리의 다른 글
파이썬 (python) 라이브러리 - Pandas 판다스 (0) | 2021.03.22 |
---|---|
파이썬 (python) 라이브러리 - finpie (1) | 2021.03.19 |
파이썬(python) 라이브러리 - numpy (0) | 2021.03.17 |
파이썬 (python) 라이브러리 - openpyxl, xlrd (excel 다루기) (0) | 2021.03.09 |
파이썬 (python) 라이브러리 - re (정규표현식) (1) | 2021.03.09 |