매직명령어(!)를 사용하여 코랩리서치에 필요한 패키지를 설치한다
!pip install yahoo_fin
!pip install requests_html
Collecting yahoo_fin Downloading https://files.pythonhosted.org/packages/d3/5c/6bf0c0147cc94d643e2a2413d0a9b27967e964ee99f88f26db93a0b963b8/yahoo_fin-0.8.6-py3-none-any.whl Installing collected packages: yahoo-fin Successfully installed yahoo-fin-0.8.6 Collecting requests_html Downloading https://files.pythonhosted.org/packages/24/bc/a4380f09bab3a776182578ce6b2771e57259d0d4dbce178205779abdc347/requests_html-0.10.0-py3-none-any.whl Collecting fake-useragent Downloading https://files.pythonhosted.org/packages/d1/79/af647635d6968e2deb57a208d309f6069d31cb138066d7e821e575112a80/fake-useragent-0.1.11.tar.gz Collecting parse Downloading https://files.pythonhosted.org/packages/b8/49/85f19d9ff908817b864deebf7f68211f9a6fc0b48746d372d970f60d01f5/parse-1.18.0.tar.gz Collecting pyppeteer>=0.0.14 Downloading https://files.pythonhosted.org/packages/5d/4b/3c2aabdd1b91fa52aa9de6cde33b488b0592b4d48efb0ad9efbf71c49f5b/pyppeteer-0.2.2-py3-none-any.whl (145kB) |████████████████████████████████| 153kB 6.5MB/s Collecting w3lib Downloading https://files.pythonhosted.org/packages/a3/59/b6b14521090e7f42669cafdb84b0ab89301a42f1f1a82fcf5856661ea3a7/w3lib-1.22.0-py2.py3-none-any.whl Requirement already satisfied: bs4 in /usr/local/lib/python3.6/dist-packages (from requests_html) (0.0.1) Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from requests_html) (2.23.0) Collecting pyquery Downloading https://files.pythonhosted.org/packages/78/43/95d42e386c61cb639d1a0b94f0c0b9f0b7d6b981ad3c043a836c8b5bc68b/pyquery-1.4.1-py2.py3-none-any.whl Collecting tqdm<5.0.0,>=4.42.1 Downloading https://files.pythonhosted.org/packages/93/3a/96b3dc293aa72443cf9627444c3c221a7ba34bb622e4d8bf1b5d4f2d9d08/tqdm-4.51.0-py2.py3-none-any.whl (70kB) |████████████████████████████████| 71kB 6.1MB/s Collecting urllib3<2.0.0,>=1.25.8 Downloading https://files.pythonhosted.org/packages/f5/71/45d36a8df68f3ebb098d6861b2c017f3d094538c0fb98fa61d4dc43e69b9/urllib3-1.26.2-py2.py3-none-any.whl (136kB) |████████████████████████████████| 143kB 7.7MB/s Collecting websockets<9.0,>=8.1 Downloading https://files.pythonhosted.org/packages/bb/d9/856af84843912e2853b1b6e898ac8b802989fcf9ecf8e8445a1da263bf3b/websockets-8.1-cp36-cp36m-manylinux2010_x86_64.whl (78kB) |████████████████████████████████| 81kB 5.8MB/s Collecting pyee<8.0.0,>=7.0.1 Downloading https://files.pythonhosted.org/packages/64/f3/90db6276dbc6cb1defa558251acc73c8e436ca8e1e2b38ec75786278de7c/pyee-7.0.4-py2.py3-none-any.whl Collecting appdirs<2.0.0,>=1.4.3 Downloading https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python3.6/dist-packages (from w3lib->requests_html) (1.15.0) Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.6/dist-packages (from bs4->requests_html) (4.6.3) Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->requests_html) (3.0.4) Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->requests_html) (2.10) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->requests_html) (2020.6.20) Collecting cssselect>0.7.9 Downloading https://files.pythonhosted.org/packages/3b/d4/3b5c17f00cce85b9a1e6f91096e1cc8e8ede2e1be8e96b87ce1ed09e92c5/cssselect-1.1.0-py2.py3-none-any.whl Requirement already satisfied: lxml>=2.1 in /usr/local/lib/python3.6/dist-packages (from pyquery->requests_html) (4.2.6) Building wheels for collected packages: fake-useragent, parse Building wheel for fake-useragent (setup.py) ... done Created wheel for fake-useragent: filename=fake_useragent-0.1.11-cp36-none-any.whl size=13485 sha256=f8e6e6237abbdb838fc9b40210a04865a678f4b1ae9bbd029ca3c025c7a383b2 Stored in directory: /root/.cache/pip/wheels/5e/63/09/d1dc15179f175357d3f5c00cbffbac37f9e8690d80545143ff Building wheel for parse (setup.py) ... done Created wheel for parse: filename=parse-1.18.0-cp36-none-any.whl size=24133 sha256=0e08a5f05bee79d1f87dfdd971dfcda580cc32ea4ef3a9172d674a3545f41572 Stored in directory: /root/.cache/pip/wheels/2a/53/09/869ca5781ede342254ffac09ca99461b008c3e5f8dd079b0c0 Successfully built fake-useragent parse ERROR: requests 2.23.0 has requirement urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1, but you'll have urllib3 1.26.2 which is incompatible. ERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible. Installing collected packages: fake-useragent, parse, tqdm, urllib3, websockets, pyee, appdirs, pyppeteer, w3lib, cssselect, pyquery, requests-html Found existing installation: tqdm 4.41.1 Uninstalling tqdm-4.41.1: Successfully uninstalled tqdm-4.41.1 Found existing installation: urllib3 1.24.3 Uninstalling urllib3-1.24.3: Successfully uninstalled urllib3-1.24.3 Successfully installed appdirs-1.4.4 cssselect-1.1.0 fake-useragent-0.1.11 parse-1.18.0 pyee-7.0.4 pyppeteer-0.2.2 pyquery-1.4.1 requests-html-0.10.0 tqdm-4.51.0 urllib3-1.26.2 w3lib-1.22.0 websockets-8.1
가장 먼저 할 일은 yahoo_fin에서 stock_info모듈을 임포트하는 것이다. 이 모듈과 함께 같이 필요한 것이 pandas패키지이다.
import yahoo_fin.stock_info as si
import pandas as pd
/usr/local/lib/python3.6/dist-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.26.2) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning)
종목 통계정보
si.get_analysts_info('nflx')
{'EPS Revisions': EPS Revisions ... Next Year (2021) 0 Up Last 7 Days ... 1.0 1 Up Last 30 Days ... 28.0 2 Down Last 7 Days ... NaN 3 Down Last 30 Days ... NaN [4 rows x 5 columns], 'EPS Trend': EPS Trend ... Next Year (2021) 0 Current Estimate ... 9.02 1 7 Days Ago ... 9.01 2 30 Days Ago ... 8.80 3 60 Days Ago ... 8.79 4 90 Days Ago ... 8.80 [5 rows x 5 columns], 'Earnings Estimate': Earnings Estimate ... Next Year (2021) 0 No. of Analysts ... 40.00 1 Avg. Estimate ... 9.02 2 Low Estimate ... 8.22 3 High Estimate ... 10.63 4 Year Ago EPS ... 6.27 [5 rows x 5 columns], 'Earnings History': Earnings History 12/30/2019 3/30/2020 6/29/2020 9/29/2020 0 EPS Est. 0.53 1.65 1.81 2.14 1 EPS Actual 1.3 1.57 1.59 1.74 2 Difference 0.77 -0.08 -0.22 -0.4 3 Surprise % 145.30% -4.80% -12.20% -18.70%, 'Growth Estimates': Growth Estimates NFLX Industry Sector(s) S&P 500 0 Current Qtr. 6.20% NaN NaN NaN 1 Next Qtr. 32.50% NaN NaN NaN 2 Current Year 51.80% NaN NaN NaN 3 Next Year 43.90% NaN NaN NaN 4 Next 5 Years (per annum) 40.95% NaN NaN NaN 5 Past 5 Years (per annum) 76.94% NaN NaN NaN, 'Revenue Estimate': Revenue Estimate ... Next Year (2021) 0 No. of Analysts ... 39 1 Avg. Estimate ... 29.44B 2 Low Estimate ... 27.88B 3 High Estimate ... 30.71B 4 Year Ago Sales ... 24.95B 5 Sales Growth (year/est) ... 18.00% [6 rows x 5 columns]}
si.get_balance_sheet('nflx')
endDate | 2019-12-31 | 2018-12-31 | 2017-12-31 | 2016-12-31 |
---|---|---|---|---|
Breakdown | ||||
intangibleAssets | 1.470335e+10 | 1.495114e+10 | 1.037106e+10 | 7.274501e+09 |
totalLiab | 2.639356e+10 | 2.073564e+10 | 1.543079e+10 | 1.090681e+10 |
totalStockholderEquity | 7.582157e+09 | 5.238765e+09 | 3.581956e+09 | 2.679800e+09 |
otherCurrentLiab | 5.338306e+09 | 5.442461e+09 | 4.791663e+09 | 4.076183e+09 |
totalAssets | 3.397571e+10 | 2.597440e+10 | 1.901274e+10 | 1.358661e+10 |
commonStock | 2.793929e+09 | 2.315988e+09 | 1.871396e+09 | 1.599762e+09 |
retainedEarnings | 4.811749e+09 | 2.942359e+09 | 1.731117e+09 | 1.128603e+09 |
otherLiab | 3.355987e+09 | 3.888257e+09 | 3.465042e+09 | 2.955842e+09 |
treasuryStock | -2.352100e+07 | -1.958200e+07 | -2.055700e+07 | -4.856500e+07 |
otherAssets | 1.099664e+10 | 9.108430e+08 | 6.523090e+08 | 3.399060e+08 |
cash | 5.018437e+09 | 3.794483e+09 | 2.822795e+09 | 1.467576e+09 |
totalCurrentLiabilities | 6.855696e+09 | 6.487320e+09 | 5.466312e+09 | 4.586657e+09 |
deferredLongTermAssetCharges | 6.582060e+08 | 5.644250e+08 | 4.782660e+08 | 2.272480e+08 |
otherStockholderEquity | -2.352100e+07 | -1.958200e+07 | -2.055700e+07 | -4.856500e+07 |
propertyPlantEquipment | 2.097221e+09 | 4.182810e+08 | 3.194040e+08 | 2.503950e+08 |
totalCurrentAssets | 6.178504e+09 | 9.694135e+09 | 7.669974e+09 | 5.720291e+09 |
netTangibleAssets | -7.121195e+09 | -9.712376e+09 | -6.789099e+09 | -4.594701e+09 |
netReceivables | 9.790680e+08 | 5.696330e+08 | NaN | NaN |
longTermDebt | 1.475926e+10 | 1.036006e+10 | 6.499432e+09 | 3.364311e+09 |
accountsPayable | 6.743470e+08 | 5.629850e+08 | 3.595550e+08 | 3.128420e+08 |
otherCurrentAssets | NaN | 5.151186e+09 | 4.847179e+09 | 3.986509e+09 |
longTermInvestments | NaN | NaN | NaN | 1.517000e+06 |
shortTermInvestments | NaN | NaN | NaN | 2.662060e+08 |
si.get_cash_flow('nflx')
endDate | 2019-12-31 | 2018-12-31 | 2017-12-31 | 2016-12-31 |
---|---|---|---|---|
Breakdown | ||||
changeToLiabilities | 2.599090e+08 | 3.414750e+08 | 2.525330e+08 | 1.289980e+08 |
totalCashflowsFromInvestingActivities | -3.870640e+08 | -3.391200e+08 | 3.432900e+07 | 4.976500e+07 |
netBorrowings | 4.469306e+09 | 3.961852e+09 | 3.020510e+09 | 1.000000e+09 |
totalCashFromFinancingActivities | 4.505662e+09 | 4.048527e+09 | 3.076990e+09 | 1.091630e+09 |
changeToOperatingActivities | -2.168660e+08 | -4.770800e+07 | -1.935560e+08 | 6.338200e+07 |
issuanceOfStock | 7.249000e+07 | 1.245020e+08 | 8.837800e+07 | 3.697900e+07 |
netIncome | 1.866916e+09 | 1.211242e+09 | 5.589290e+08 | 1.866780e+08 |
changeInCash | 1.231745e+09 | 9.892460e+08 | 1.355219e+09 | -3.417540e+08 |
effectOfExchangeRate | 4.690000e+05 | -3.968200e+07 | 2.984800e+07 | -9.165000e+06 |
totalCashFromOperatingActivities | -2.887322e+09 | -2.680479e+09 | -1.785948e+09 | -1.473984e+09 |
depreciation | 1.035790e+08 | 8.315700e+07 | 7.191100e+07 | 5.752800e+07 |
otherCashflowsFromInvestingActivities | -1.340290e+08 | -1.651740e+08 | -6.040900e+07 | -9.410000e+05 |
otherCashflowsFromFinancingActivities | -3.613400e+07 | -3.782700e+07 | -3.189800e+07 | 5.465100e+07 |
changeToNetincome | -1.411711e+10 | -1.180073e+10 | -8.673582e+09 | -6.778020e+09 |
capitalExpenditures | -2.530350e+08 | -1.739460e+08 | -1.733020e+08 | -1.076530e+08 |
investments | NaN | NaN | 2.680400e+08 | 2.355360e+08 |
종목의 과거 주가 데이터
msft_data = si.get_data('msft')
msft_data.head()
open | high | low | close | adjclose | volume | ticker | |
---|---|---|---|---|---|---|---|
1986-03-13 | 0.088542 | 0.101562 | 0.088542 | 0.097222 | 0.062055 | 1031788800 | MSFT |
1986-03-14 | 0.097222 | 0.102431 | 0.097222 | 0.100694 | 0.064271 | 308160000 | MSFT |
1986-03-17 | 0.100694 | 0.103299 | 0.100694 | 0.102431 | 0.065379 | 133171200 | MSFT |
1986-03-18 | 0.102431 | 0.103299 | 0.098958 | 0.099826 | 0.063717 | 67766400 | MSFT |
1986-03-19 | 0.099826 | 0.100694 | 0.097222 | 0.098090 | 0.062609 | 47894400 | MSFT |
si.get_data("amzn", start_date = "04/01/2020", end_date = "04/30/2020")
open | high | low | close | adjclose | volume | ticker | |
---|---|---|---|---|---|---|---|
2020-04-01 | 1932.969971 | 1944.959961 | 1893.000000 | 1907.699951 | 1907.699951 | 4121900 | AMZN |
2020-04-02 | 1901.640015 | 1927.530029 | 1890.000000 | 1918.829956 | 1918.829956 | 4336000 | AMZN |
2020-04-03 | 1911.150024 | 1926.329956 | 1889.150024 | 1906.589966 | 1906.589966 | 3609900 | AMZN |
2020-04-06 | 1936.000000 | 1998.520020 | 1930.020020 | 1997.589966 | 1997.589966 | 5773200 | AMZN |
2020-04-07 | 2017.109985 | 2035.719971 | 1997.619995 | 2011.599976 | 2011.599976 | 5114000 | AMZN |
2020-04-08 | 2021.000000 | 2044.000000 | 2011.150024 | 2043.000000 | 2043.000000 | 3977300 | AMZN |
2020-04-09 | 2044.300049 | 2053.000000 | 2017.660034 | 2042.760010 | 2042.760010 | 4655600 | AMZN |
2020-04-13 | 2040.000000 | 2180.000000 | 2038.000000 | 2168.870117 | 2168.870117 | 6716700 | AMZN |
2020-04-14 | 2200.469971 | 2292.000000 | 2186.209961 | 2283.320068 | 2283.320068 | 8087200 | AMZN |
2020-04-15 | 2257.679932 | 2333.370117 | 2245.000000 | 2307.679932 | 2307.679932 | 6866600 | AMZN |
2020-04-16 | 2346.000000 | 2461.000000 | 2335.000000 | 2408.189941 | 2408.189941 | 12038200 | AMZN |
2020-04-17 | 2372.330078 | 2400.000000 | 2316.020020 | 2375.000000 | 2375.000000 | 7930000 | AMZN |
2020-04-20 | 2389.949951 | 2444.979980 | 2386.050049 | 2393.610107 | 2393.610107 | 5770700 | AMZN |
2020-04-21 | 2416.610107 | 2428.310059 | 2279.659912 | 2328.120117 | 2328.120117 | 7476700 | AMZN |
2020-04-22 | 2369.000000 | 2394.000000 | 2351.000000 | 2363.489990 | 2363.489990 | 4218300 | AMZN |
2020-04-23 | 2399.979980 | 2424.219971 | 2382.080078 | 2399.449951 | 2399.449951 | 5066600 | AMZN |
2020-04-24 | 2417.000000 | 2420.429932 | 2382.000000 | 2410.219971 | 2410.219971 | 3831800 | AMZN |
2020-04-27 | 2443.199951 | 2444.879883 | 2363.000000 | 2376.000000 | 2376.000000 | 5645600 | AMZN |
2020-04-28 | 2372.100098 | 2373.500000 | 2306.000000 | 2314.080078 | 2314.080078 | 5269400 | AMZN |
2020-04-29 | 2330.010010 | 2391.889893 | 2310.000000 | 2372.709961 | 2372.709961 | 4591600 | AMZN |
# get list of 'amzn', 'ba', 'msft', 'aapl', 'goog' tickers
sp = ['amzn', 'ba', 'msft', 'aapl', 'goog']#si.tickers_sp500()
# pull data for each stock
price_data = {ticker : si.get_data(ticker, start_date = "04/01/2020", end_date = "04/30/2020") for ticker in sp}
from functools import reduce
combined = reduce(lambda x,y: x.append(y), price_data.values())
combined.head()
open | high | low | close | adjclose | volume | ticker | |
---|---|---|---|---|---|---|---|
2020-04-01 | 1932.969971 | 1944.959961 | 1893.000000 | 1907.699951 | 1907.699951 | 4121900 | AMZN |
2020-04-02 | 1901.640015 | 1927.530029 | 1890.000000 | 1918.829956 | 1918.829956 | 4336000 | AMZN |
2020-04-03 | 1911.150024 | 1926.329956 | 1889.150024 | 1906.589966 | 1906.589966 | 3609900 | AMZN |
2020-04-06 | 1936.000000 | 1998.520020 | 1930.020020 | 1997.589966 | 1997.589966 | 5773200 | AMZN |
2020-04-07 | 2017.109985 | 2035.719971 | 1997.619995 | 2011.599976 | 2011.599976 | 5114000 | AMZN |
combined.tail()
open | high | low | close | adjclose | volume | ticker | |
---|---|---|---|---|---|---|---|
2020-04-23 | 1271.550049 | 1293.310059 | 1265.670044 | 1276.310059 | 1276.310059 | 1566200 | GOOG |
2020-04-24 | 1261.170044 | 1280.400024 | 1249.449951 | 1279.310059 | 1279.310059 | 1640400 | GOOG |
2020-04-27 | 1296.000000 | 1296.150024 | 1269.000000 | 1275.880005 | 1275.880005 | 1600600 | GOOG |
2020-04-28 | 1287.930054 | 1288.050049 | 1232.199951 | 1233.670044 | 1233.670044 | 2951300 | GOOG |
2020-04-29 | 1341.459961 | 1359.989990 | 1325.339966 | 1341.479980 | 1341.479980 | 3793600 | GOOG |
매매일 현재 상승 상위100개종목
si.get_day_gainers()
매매일 현재 하락 상위100개종목
si.get_day_losers()
거래량 상위정보
si.get_day_most_active()
종목의 보유정보
si.get_holders('nflx')
종목의 현재가격
si.get_live_price('nflx')
486.7699890136719
종목의 호가정보
si.get_quote_table('aapl')
{'1y Target Est': 123.11, '52 Week Range': '53.15 - 137.98', 'Ask': '119.00 x 800', 'Avg. Volume': 160946870.0, 'Beta (5Y Monthly)': 1.35, 'Bid': '118.95 x 900', "Day's Range": '118.57 - 120.53', 'EPS (TTM)': 3.28, 'Earnings Date': 'Jan 26, 2021 - Feb 01, 2021', 'Ex-Dividend Date': 'Nov 06, 2020', 'Forward Dividend & Yield': '0.82 (0.69%)', 'Market Cap': '2.027T', 'Open': 119.62, 'PE Ratio (TTM)': 36.34, 'Previous Close': 119.49, 'Quote Price': 119.20999908447266, 'Volume': 103350674.0}
종목의 통계정보
si.get_stats('nflx')
Attribute | Value | |
---|---|---|
0 | Beta (5Y Monthly) | 1.02 |
1 | 52-Week Change 3 | 69.45% |
2 | S&P500 52-Week Change 3 | 15.37% |
3 | 52 Week High 3 | 575.37 |
4 | 52 Week Low 3 | 283.22 |
5 | 50-Day Moving Average 3 | 505.06 |
6 | 200-Day Moving Average 3 | 479.32 |
7 | Avg Vol (3 month) 3 | 6.14M |
8 | Avg Vol (10 day) 3 | 5.88M |
9 | Shares Outstanding 5 | 441.8M |
10 | Float | 435.48M |
11 | % Held by Insiders 1 | 1.64% |
12 | % Held by Institutions 1 | 82.90% |
13 | Shares Short (Oct 29, 2020) 4 | 10.42M |
14 | Short Ratio (Oct 29, 2020) 4 | 1.51 |
15 | Short % of Float (Oct 29, 2020) 4 | 2.41% |
16 | Short % of Shares Outstanding (Oct 29, 2020) 4 | 2.36% |
17 | Shares Short (prior month Sep 29, 2020) 4 | 9.44M |
18 | Forward Annual Dividend Rate 4 | NaN |
19 | Forward Annual Dividend Yield 4 | NaN |
20 | Trailing Annual Dividend Rate 3 | NaN |
21 | Trailing Annual Dividend Yield 3 | NaN |
22 | 5 Year Average Dividend Yield 4 | NaN |
23 | Payout Ratio 4 | 0.00% |
24 | Dividend Date 3 | NaN |
25 | Ex-Dividend Date 4 | NaN |
26 | Last Split Factor 2 | 7:1 |
27 | Last Split Date 3 | Jul 14, 2015 |
28 | Fiscal Year Ends | Dec 30, 2019 |
29 | Most Recent Quarter (mrq) | Sep 29, 2020 |
30 | Profit Margin | 11.78% |
31 | Operating Margin (ttm) | 17.17% |
32 | Return on Assets (ttm) | 7.35% |
33 | Return on Equity (ttm) | 32.64% |
34 | Revenue (ttm) | 23.82B |
35 | Revenue Per Share (ttm) | 54.13 |
36 | Quarterly Revenue Growth (yoy) | 22.70% |
37 | Gross Profit (ttm) | 7.72B |
38 | EBITDA | 4.2B |
39 | Net Income Avi to Common (ttm) | 2.81B |
40 | Diluted EPS (ttm) | 6.19 |
41 | Quarterly Earnings Growth (yoy) | 18.70% |
42 | Total Cash (mrq) | 8.39B |
43 | Total Cash Per Share (mrq) | 19 |
44 | Total Debt (mrq) | 18.14B |
45 | Total Debt/Equity (mrq) | 175.52 |
46 | Current Ratio (mrq) | 1.24 |
47 | Book Value Per Share (mrq) | 23.39 |
48 | Operating Cash Flow (ttm) | 1.1B |
49 | Levered Free Cash Flow (ttm) | 12.12B |
si.get_stats_valuation('nflx')
Unnamed: 0 | As of Date: 11/11/2020Current | 9/30/2020 | 6/30/2020 | 3/31/2020 | 12/31/2019 | 9/30/2019 | |
---|---|---|---|---|---|---|---|
0 | Market Cap (intraday) 5 | 212.17B | 220.91B | 200.68B | 165.14B | 141.98B | 117.28B |
1 | Enterprise Value 3 | 219.82B | 229.55B | 210.20B | 174.88B | 149.98B | 124.87B |
2 | Trailing P/E | 77.58 | 84.46 | 92.11 | 90.92 | 103.71 | 105.36 |
3 | Forward P/E 1 | 55.25 | 57.47 | 71.94 | 62.50 | 61.73 | 48.78 |
4 | PEG Ratio (5 yr expected) 1 | 2.07 | 2.18 | 3.02 | 2.75 | 2.23 | 1.76 |
5 | Price/Sales (ttm) | 9.14 | 10.00 | 9.61 | 8.42 | 7.74 | 6.86 |
6 | Price/Book (mrq) | 20.53 | 23.67 | 23.86 | 21.78 | 20.69 | 19.21 |
7 | Enterprise Value/Revenue 3 | 9.23 | 35.67 | 34.19 | 30.32 | 27.43 | 23.81 |
8 | Enterprise Value/EBITDA 6 | 15.19 | 56.30 | 52.66 | 50.08 | 51.51 | 35.82 |
다우존스지수 종목의 티커
si.tickers_dow()
['AAPL', 'AMGN', 'AXP', 'BA', 'CAT', 'CRM', 'CSCO', 'CVX', 'DIS', 'DOW', 'GS', 'HD', 'HON', 'IBM', 'INTC', 'JNJ', 'JPM', 'KO', 'MCD', 'MMM', 'MRK', 'MSFT', 'NKE', 'PG', 'TRV', 'UNH', 'V', 'VZ', 'WBA', 'WMT']
나스닥종목의 티커
si.tickers_nasdaq()
기타 종목의 티커
si.tickers_other()
S&P 500 구성종목을 돌려준다( https://en.wikipedia.org/wiki/List_of_S%26P_500_companies )
si.tickers_sp500()
암호화 화폐 거래정보
si.get_top_crypto()
개별종목의 호가정보는 get_quote_table를 사용하여 구한다
quote = si.get_quote_table("aapl")
get_quote_table 메서드는 다음과 같이 여러 정보가 담긴 딕셔너리를 돌려준다.
quote
다음과 같이 키 값(여기선 "PE Ratio (TTM)")을 사용하여 값을 얻을 수 있다.
quote["PE Ratio (TTM)"] # 22.71
36.34
PER을 구하는 또 다른 방법은 get_stats_valuation 메서드를 이용하는 것이다.
이것은 야후파이낸스의 종목 통계섹션의 내용이다.
val = si.get_stats_valuation("aapl")
val
Unnamed: 0 | As of Date: 11/8/2020Current | 9/30/2020 | 6/30/2020 | 3/31/2020 | 12/31/2019 | 9/30/2019 | |
---|---|---|---|---|---|---|---|
0 | Market Cap (intraday) 5 | 2.02T | 1.97T | 1.56T | 1.10T | 1.29T | 995.15B |
1 | Enterprise Value 3 | 2.04T | 1.99T | 1.58T | 1.10T | 1.30T | 1.01T |
2 | Trailing P/E | 36.19 | 35.12 | 28.52 | 20.02 | 24.70 | 19.01 |
3 | Forward P/E 1 | 29.94 | 30.12 | 24.33 | 19.65 | 22.17 | 17.27 |
4 | PEG Ratio (5 yr expected) 1 | 2.98 | 2.86 | 2.02 | 1.58 | 2.03 | 2.04 |
5 | Price/Sales (ttm) | 7.58 | 7.50 | 6.12 | 4.34 | 5.25 | 4.09 |
6 | Price/Book (mrq) | 30.88 | 27.20 | 19.93 | 12.28 | 14.23 | 10.32 |
7 | Enterprise Value/Revenue 3 | 7.43 | 30.69 | 26.44 | 18.88 | 14.11 | 15.76 |
8 | Enterprise Value/EBITDA 6 | 25.17 | 108.89 | 95.15 | 66.00 | 43.87 | 50.16 |
val = val.iloc[:,:2]
val.columns = ["Attribute", "Recent"]
val
Attribute | Recent | |
---|---|---|
0 | Market Cap (intraday) 5 | 2.02T |
1 | Enterprise Value 3 | 2.04T |
2 | Trailing P/E | 36.19 |
3 | Forward P/E 1 | 29.94 |
4 | PEG Ratio (5 yr expected) 1 | 2.98 |
5 | Price/Sales (ttm) | 7.58 |
6 | Price/Book (mrq) | 30.88 |
7 | Enterprise Value/Revenue 3 | 7.43 |
8 | Enterprise Value/EBITDA 6 | 25.17 |
P/E 비율을 추출하면 다음과 같다
float(val[val.Attribute.str.contains("Trailing P/E")].iloc[0,1])
36.19
주가매출액(Price-to-Sales) 비율
float(val[val.Attribute.str.contains("Price/Sales")].iloc[0,1])
7.58
다우지수내 각 종목의 Price-to-Earnings 와 Price-to-Sales 비율을 구해보도록 하자.
tickers_dow메서드는 지수를 구성하는 종목의 티커를 돌려준다.
# 각 종목 밸류에이션을 가져온다
# get_stats_valuation()는 데이터프레임을 돌려주는 데,
# 첫 두개의 컬럼만 가져온다
dow_stats = {}
for ticker in ['amzn', 'ba', 'msft', 'aapl', 'goog']:
temp = si.get_stats_valuation(ticker)
temp = temp.iloc[:,:2]
temp.columns = ["Attribute", "Recent"]
dow_stats[ticker] = temp
# 가져온 각 종목 데이터를 하나로 합친다
combined_stats = pd.concat(dow_stats)
combined_stats = combined_stats.reset_index()
del combined_stats["level_1"]
# 컬럼이름 변경
combined_stats.columns = ["Ticker", "Attribute", "Recent"]
combined_stats
주가수익률(P/E) 비율
# get P/E ratio for each stock
combined_stats[combined_stats.Attribute.str.contains("Trailing P/E")]
Ticker | Attribute | Recent | |
---|---|---|---|
2 | amzn | Trailing P/E | 96.82 |
11 | ba | Trailing P/E | NaN |
20 | msft | Trailing P/E | 34.93 |
29 | aapl | Trailing P/E | 36.19 |
38 | goog | Trailing P/E | 33.37 |
주가매출액비율(Price-to-Sales) 비율
# get P/S ratio for each stock
combined_stats[combined_stats.Attribute.str.contains("Price/Sales")]
Ticker | Attribute | Recent | |
---|---|---|---|
5 | amzn | Price/Sales (ttm) | 4.84 |
14 | ba | Price/Sales (ttm) | 1.47 |
23 | msft | Price/Sales (ttm) | 11.28 |
32 | aapl | Price/Sales (ttm) | 7.58 |
41 | goog | Price/Sales (ttm) | 6.33 |
주가순자산(Price / Book) 비율
# get Price-to-Book ratio for each stock
combined_stats[combined_stats.Attribute.str.contains("Price/Book")]
Ticker | Attribute | Recent | |
---|---|---|---|
6 | amzn | Price/Book (mrq) | 20.07 |
15 | ba | Price/Book (mrq) | NaN |
24 | msft | Price/Book (mrq) | 13.27 |
33 | aapl | Price/Book (mrq) | 30.88 |
42 | goog | Price/Book (mrq) | 4.98 |
주가이익성장배율(Price / Earnings-to-Growth) 비율
# get PEG ratio for each stock
combined_stats[combined_stats.Attribute.str.contains("PEG")]
Ticker | Attribute | Recent | |
---|---|---|---|
4 | amzn | PEG Ratio (5 yr expected) 1 | 1.28 |
13 | ba | PEG Ratio (5 yr expected) 1 | 6.53 |
22 | msft | PEG Ratio (5 yr expected) 1 | 2.53 |
31 | aapl | PEG Ratio (5 yr expected) 1 | 2.98 |
40 | goog | PEG Ratio (5 yr expected) 1 | 1.45 |
Forward P/E 비율
# get forward P/E ratio for each stock
combined_stats[combined_stats.Attribute.str.contains("Forward P/E")]
Ticker | Attribute | Recent | |
---|---|---|---|
3 | amzn | Forward P/E 1 | 62.50 |
12 | ba | Forward P/E 1 | 44.05 |
21 | msft | Forward P/E 1 | 32.47 |
30 | aapl | Forward P/E 1 | 29.94 |
39 | goog | Forward P/E 1 | 27.25 |
combined_stats
Ticker | Attribute | Recent | |
---|---|---|---|
0 | amzn | Market Cap (intraday) 5 | 1.66T |
1 | amzn | Enterprise Value 3 | 1.67T |
2 | amzn | Trailing P/E | 96.82 |
3 | amzn | Forward P/E 1 | 62.50 |
4 | amzn | PEG Ratio (5 yr expected) 1 | 1.28 |
5 | amzn | Price/Sales (ttm) | 4.84 |
6 | amzn | Price/Book (mrq) | 20.07 |
7 | amzn | Enterprise Value/Revenue 3 | 4.81 |
8 | amzn | Enterprise Value/EBITDA 6 | 36.44 |
9 | ba | Market Cap (intraday) 5 | 89.05B |
10 | ba | Enterprise Value 3 | 122.89B |
11 | ba | Trailing P/E | NaN |
12 | ba | Forward P/E 1 | 44.05 |
13 | ba | PEG Ratio (5 yr expected) 1 | 6.53 |
14 | ba | Price/Sales (ttm) | 1.47 |
15 | ba | Price/Book (mrq) | NaN |
16 | ba | Enterprise Value/Revenue 3 | 2.02 |
17 | ba | Enterprise Value/EBITDA 6 | -29.28 |
18 | msft | Market Cap (intraday) 5 | 1.64T |
19 | msft | Enterprise Value 3 | 1.57T |
20 | msft | Trailing P/E | 34.93 |
21 | msft | Forward P/E 1 | 32.47 |
22 | msft | PEG Ratio (5 yr expected) 1 | 2.53 |
23 | msft | Price/Sales (ttm) | 11.28 |
24 | msft | Price/Book (mrq) | 13.27 |
25 | msft | Enterprise Value/Revenue 3 | 10.68 |
26 | msft | Enterprise Value/EBITDA 6 | 21.97 |
27 | aapl | Market Cap (intraday) 5 | 2.02T |
28 | aapl | Enterprise Value 3 | 2.04T |
29 | aapl | Trailing P/E | 36.19 |
30 | aapl | Forward P/E 1 | 29.94 |
31 | aapl | PEG Ratio (5 yr expected) 1 | 2.98 |
32 | aapl | Price/Sales (ttm) | 7.58 |
33 | aapl | Price/Book (mrq) | 30.88 |
34 | aapl | Enterprise Value/Revenue 3 | 7.43 |
35 | aapl | Enterprise Value/EBITDA 6 | 25.17 |
36 | goog | Market Cap (intraday) 5 | 1.03T |
37 | goog | Enterprise Value 3 | 924.60B |
38 | goog | Trailing P/E | 33.37 |
39 | goog | Forward P/E 1 | 27.25 |
40 | goog | PEG Ratio (5 yr expected) 1 | 1.45 |
41 | goog | Price/Sales (ttm) | 6.33 |
42 | goog | Price/Book (mrq) | 4.98 |
43 | goog | Enterprise Value/Revenue 3 | 5.57 |
44 | goog | Enterprise Value/EBITDA 6 | 19.16 |
야후파이낸스 종목 통계섹션에는“Valuation Measures” 테이블이 있는데
get_stats method를 통해 기타 통계 정보(Return on Equity (ROE),
Return on Assets, profit margin)를 구할 수 있다.
dow_extra_stats = {}
for ticker in ['amzn', 'ba', 'msft', 'aapl', 'goog']:
dow_extra_stats[ticker] = si.get_stats(ticker)
combined_extra_stats = pd.concat(dow_extra_stats)
combined_extra_stats = combined_extra_stats.reset_index()
del combined_extra_stats["level_1"]
combined_extra_stats.columns = ["ticker", "Attribute", "Value"]
combined_extra_stats
ticker | Attribute | Value | |
---|---|---|---|
0 | amzn | Beta (5Y Monthly) | 1.30 |
1 | amzn | 52-Week Change 3 | 78.81% |
2 | amzn | S&P500 52-Week Change 3 | 15.37% |
3 | amzn | 52 Week High 3 | 3552.25 |
4 | amzn | 52 Week Low 3 | 1626.03 |
... | ... | ... | ... |
245 | goog | Total Debt/Equity (mrq) | 12.94 |
246 | goog | Current Ratio (mrq) | 3.41 |
247 | goog | Book Value Per Share (mrq) | 314.17 |
248 | goog | Operating Cash Flow (ttm) | 56.87B |
249 | goog | Levered Free Cash Flow (ttm) | 28.15B |
250 rows × 3 columns
자기자본이익률(ROE)
combined_extra_stats[combined_extra_stats.Attribute.str.contains("Return on Equity")]
ticker | Attribute | Value | |
---|---|---|---|
33 | amzn | Return on Equity (ttm) | 24.95% |
83 | ba | Return on Equity (ttm) | NaN |
133 | msft | Return on Equity (ttm) | 41.40% |
183 | aapl | Return on Equity (ttm) | 73.69% |
233 | goog | Return on Equity (ttm) | 17.51% |
총자산이익률(ROA)
combined_extra_stats[combined_extra_stats.Attribute.str.contains("Return on Assets")]
ticker | Attribute | Value | |
---|---|---|---|
32 | amzn | Return on Assets (ttm) | 5.17% |
82 | ba | Return on Assets (ttm) | -2.92% |
132 | msft | Return on Assets (ttm) | 12.10% |
182 | aapl | Return on Assets (ttm) | 12.51% |
232 | goog | Return on Assets (ttm) | 7.74% |
이익률(profit margin)
combined_extra_stats[combined_extra_stats.Attribute.str.contains("Profit Margin")]
ticker | Attribute | Value | |
---|---|---|---|
30 | amzn | Profit Margin | 4.99% |
80 | ba | Profit Margin | -7.34% |
130 | msft | Profit Margin | 32.28% |
180 | aapl | Profit Margin | 20.91% |
230 | goog | Profit Margin | 20.80% |
get_balance_sheet 메서드를 사용하여 재무상태표를 구할 수 있는 데, 유동현금, 자산, 부채등을 알 수 있다.
sheet = si.get_balance_sheet("aapl")
sheet
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
totalLiab | 258549000000 | 248028000000 | 258578000000 | 241272000000 |
totalStockholderEquity | 65339000000 | 90488000000 | 107147000000 | 134047000000 |
otherCurrentLiab | 47867000000 | 43242000000 | 39293000000 | 38099000000 |
totalAssets | 323888000000 | 338516000000 | 365725000000 | 375319000000 |
commonStock | 50779000000 | 45174000000 | 40201000000 | 35867000000 |
otherCurrentAssets | 11264000000 | 12352000000 | 12087000000 | 13936000000 |
retainedEarnings | 14966000000 | 45898000000 | 70400000000 | 98330000000 |
otherLiab | 46108000000 | 50503000000 | 48914000000 | 43251000000 |
treasuryStock | -406000000 | -584000000 | -3454000000 | -150000000 |
otherAssets | 33952000000 | 32978000000 | 22283000000 | 18177000000 |
cash | 38016000000 | 48844000000 | 25913000000 | 20289000000 |
totalCurrentLiabilities | 105392000000 | 105718000000 | 115929000000 | 100814000000 |
shortLongTermDebt | 8773000000 | 10260000000 | 8784000000 | 6496000000 |
otherStockholderEquity | -406000000 | -584000000 | -3454000000 | -150000000 |
propertyPlantEquipment | 45336000000 | 37378000000 | 41304000000 | 33783000000 |
totalCurrentAssets | 143713000000 | 162819000000 | 131339000000 | 128645000000 |
longTermInvestments | 100887000000 | 105341000000 | 170799000000 | 194714000000 |
netTangibleAssets | 65339000000 | 90488000000 | 107147000000 | 134047000000 |
shortTermInvestments | 52927000000 | 51713000000 | 40388000000 | 53892000000 |
netReceivables | 37445000000 | 45804000000 | 48995000000 | 35673000000 |
longTermDebt | 98667000000 | 91807000000 | 93735000000 | 97207000000 |
inventory | 4061000000 | 4106000000 | 3956000000 | 4855000000 |
accountsPayable | 42296000000 | 46236000000 | 55888000000 | 44242000000 |
총현금(Total cash on hand)
sheet[sheet.index == "cash"]
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
cash | 38016000000 | 48844000000 | 25913000000 | 20289000000 |
자본(Stockholders’ equity)
sheet[sheet.index == "totalStockholderEquity"]
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
totalStockholderEquity | 65339000000 | 90488000000 | 107147000000 | 134047000000 |
총자산(Total Assets)
sheet[sheet.index == "totalAssets"]
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
totalAssets | 323888000000 | 338516000000 | 365725000000 | 375319000000 |
다우지수 구성종목들의 재무상태표를 다음과 같이 얻을 수 있다.
balance_sheets = {}
for ticker in ['amzn', 'ba', 'msft', 'aapl', 'goog']:
balance_sheets[ticker] = si.get_balance_sheet(ticker)
balance_sheets['aapl']
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
totalLiab | 258549000000 | 248028000000 | 258578000000 | 241272000000 |
totalStockholderEquity | 65339000000 | 90488000000 | 107147000000 | 134047000000 |
otherCurrentLiab | 47867000000 | 43242000000 | 39293000000 | 38099000000 |
totalAssets | 323888000000 | 338516000000 | 365725000000 | 375319000000 |
commonStock | 50779000000 | 45174000000 | 40201000000 | 35867000000 |
otherCurrentAssets | 11264000000 | 12352000000 | 12087000000 | 13936000000 |
retainedEarnings | 14966000000 | 45898000000 | 70400000000 | 98330000000 |
otherLiab | 46108000000 | 50503000000 | 48914000000 | 43251000000 |
treasuryStock | -406000000 | -584000000 | -3454000000 | -150000000 |
otherAssets | 33952000000 | 32978000000 | 22283000000 | 18177000000 |
cash | 38016000000 | 48844000000 | 25913000000 | 20289000000 |
totalCurrentLiabilities | 105392000000 | 105718000000 | 115929000000 | 100814000000 |
shortLongTermDebt | 8773000000 | 10260000000 | 8784000000 | 6496000000 |
otherStockholderEquity | -406000000 | -584000000 | -3454000000 | -150000000 |
propertyPlantEquipment | 45336000000 | 37378000000 | 41304000000 | 33783000000 |
totalCurrentAssets | 143713000000 | 162819000000 | 131339000000 | 128645000000 |
longTermInvestments | 100887000000 | 105341000000 | 170799000000 | 194714000000 |
netTangibleAssets | 65339000000 | 90488000000 | 107147000000 | 134047000000 |
shortTermInvestments | 52927000000 | 51713000000 | 40388000000 | 53892000000 |
netReceivables | 37445000000 | 45804000000 | 48995000000 | 35673000000 |
longTermDebt | 98667000000 | 91807000000 | 93735000000 | 97207000000 |
inventory | 4061000000 | 4106000000 | 3956000000 | 4855000000 |
accountsPayable | 42296000000 | 46236000000 | 55888000000 | 44242000000 |
각 종목의 재무상태표를 묶어서 최근 데이터를 보여준다.
recent_sheets = {ticker : sheet.iloc[:,:2] for ticker, sheet in balance_sheets.items()}
recent_sheets
{'aapl': endDate 2020-09-26 2019-09-28 Breakdown totalLiab 258549000000 248028000000 totalStockholderEquity 65339000000 90488000000 otherCurrentLiab 47867000000 43242000000 totalAssets 323888000000 338516000000 commonStock 50779000000 45174000000 otherCurrentAssets 11264000000 12352000000 retainedEarnings 14966000000 45898000000 otherLiab 46108000000 50503000000 treasuryStock -406000000 -584000000 otherAssets 33952000000 32978000000 cash 38016000000 48844000000 totalCurrentLiabilities 105392000000 105718000000 shortLongTermDebt 8773000000 10260000000 otherStockholderEquity -406000000 -584000000 propertyPlantEquipment 45336000000 37378000000 totalCurrentAssets 143713000000 162819000000 longTermInvestments 100887000000 105341000000 netTangibleAssets 65339000000 90488000000 shortTermInvestments 52927000000 51713000000 netReceivables 37445000000 45804000000 longTermDebt 98667000000 91807000000 inventory 4061000000 4106000000 accountsPayable 42296000000 46236000000, 'amzn': endDate 2019-12-31 2018-12-31 Breakdown intangibleAssets 4.049000e+09 4.110000e+09 capitalSurplus 3.365800e+10 2.679100e+10 totalLiab 1.631880e+11 1.190990e+11 totalStockholderEquity 6.206000e+10 4.354900e+10 otherCurrentLiab 1.220200e+10 9.959000e+09 totalAssets 2.252480e+11 1.626480e+11 commonStock 5.000000e+06 5.000000e+06 otherCurrentAssets 2.760000e+08 4.180000e+08 retainedEarnings 3.122000e+10 1.962500e+10 otherLiab 1.217100e+10 1.756300e+10 goodWill 1.475400e+10 1.454800e+10 treasuryStock -2.823000e+09 -2.872000e+09 otherAssets 1.009600e+10 6.370000e+09 cash 3.609200e+10 3.175000e+10 totalCurrentLiabilities 8.781200e+10 6.839100e+10 shortLongTermDebt 1.307000e+09 1.371000e+09 otherStockholderEquity -9.860000e+08 -1.035000e+09 propertyPlantEquipment 9.784600e+10 6.179700e+10 totalCurrentAssets 9.633400e+10 7.510100e+10 longTermInvestments 2.169000e+09 7.220000e+08 netTangibleAssets 4.325700e+10 2.489100e+10 shortTermInvestments 1.892900e+10 9.500000e+09 netReceivables 2.054000e+10 1.625900e+10 longTermDebt 2.341400e+10 2.349500e+10 inventory 2.049700e+10 1.717400e+10 accountsPayable 4.718300e+10 3.819200e+10, 'ba': endDate 2019-12-31 2018-12-31 Breakdown intangibleAssets 3.338000e+09 3.429000e+09 capitalSurplus 6.745000e+09 6.768000e+09 totalLiab 1.419250e+11 1.169490e+11 totalStockholderEquity -8.617000e+09 3.390000e+08 minorityInterest 3.170000e+08 7.100000e+07 otherCurrentLiab 6.371700e+10 5.493600e+10 totalAssets 1.336250e+11 1.173590e+11 commonStock 5.061000e+09 5.061000e+09 otherCurrentAssets 3.106000e+09 2.335000e+09 retainedEarnings 5.064400e+10 5.594100e+10 otherLiab 2.367300e+10 2.470200e+10 goodWill 8.060000e+09 7.840000e+09 treasuryStock -7.106700e+10 -6.743100e+10 otherAssets 3.086000e+09 2.110000e+09 cash 9.485000e+09 7.637000e+09 totalCurrentLiabilities 9.731200e+10 8.159000e+10 deferredLongTermAssetCharges 6.830000e+08 2.840000e+08 shortLongTermDebt 6.840000e+09 2.690000e+09 otherStockholderEquity -1.615300e+10 -1.508300e+10 propertyPlantEquipment 1.368400e+10 1.264500e+10 totalCurrentAssets 1.022290e+11 8.783000e+10 longTermInvestments 1.092000e+09 1.087000e+09 netTangibleAssets -2.001500e+10 -1.093000e+10 shortTermInvestments 5.450000e+08 9.270000e+08 netReceivables 1.230900e+10 1.390400e+10 longTermDebt 1.823300e+10 8.501000e+09 inventory 7.662200e+10 6.256700e+10 accountsPayable 1.555300e+10 1.291600e+10, 'goog': endDate 2019-12-31 2018-12-31 Breakdown intangibleAssets 1979000000 2220000000 totalLiab 74467000000 55164000000 totalStockholderEquity 201442000000 177628000000 otherCurrentLiab 22159000000 17612000000 totalAssets 275909000000 232792000000 commonStock 50552000000 45049000000 otherCurrentAssets 4412000000 4236000000 retainedEarnings 152122000000 134885000000 otherLiab 14478000000 16532000000 goodWill 20624000000 17888000000 treasuryStock -1232000000 -2306000000 otherAssets 3063000000 3430000000 cash 18498000000 16701000000 totalCurrentLiabilities 45221000000 34620000000 deferredLongTermAssetCharges 721000000 737000000 otherStockholderEquity -1232000000 -2306000000 propertyPlantEquipment 84587000000 59719000000 totalCurrentAssets 152578000000 135676000000 longTermInvestments 13078000000 13859000000 netTangibleAssets 178839000000 157520000000 shortTermInvestments 101177000000 92439000000 netReceivables 27492000000 21193000000 longTermDebt 3958000000 3950000000 inventory 999000000 1107000000 accountsPayable 5561000000 4378000000, 'msft': endDate 2020-06-30 2019-06-30 Breakdown intangibleAssets 7038000000 7750000000 totalLiab 183007000000 184226000000 totalStockholderEquity 118304000000 102330000000 otherCurrentLiab 46001000000 45860000000 totalAssets 301311000000 286556000000 commonStock 80552000000 78520000000 otherCurrentAssets 11517000000 10133000000 retainedEarnings 34566000000 24150000000 otherLiab 34492000000 35699000000 goodWill 43351000000 42026000000 treasuryStock 3186000000 -340000000 otherAssets 13138000000 14723000000 cash 13576000000 11356000000 totalCurrentLiabilities 72310000000 69420000000 deferredLongTermAssetCharges 6405000000 7536000000 shortLongTermDebt 3749000000 5516000000 otherStockholderEquity 3186000000 -340000000 propertyPlantEquipment 52904000000 43856000000 totalCurrentAssets 181915000000 175552000000 longTermInvestments 2965000000 2649000000 netTangibleAssets 67915000000 52554000000 shortTermInvestments 122916000000 122476000000 netReceivables 32011000000 29524000000 longTermDebt 59578000000 66662000000 inventory 1895000000 2063000000 accountsPayable 12530000000 9382000000}
recent_sheets['aapl'][recent_sheets['aapl'].index=='cash']
endDate | 2020-09-26 | 2019-09-28 |
---|---|---|
Breakdown | ||
cash | 38016000000 | 48844000000 |
손익계산서는 get_income_statement 메서드를 사용하여 얻을 수 있다
income=si.get_income_statement("aapl")
income
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
researchDevelopment | 18752000000 | 16217000000 | 14236000000 | 11581000000 |
effectOfAccountingCharges | None | None | None | None |
incomeBeforeTax | 67091000000 | 65737000000 | 72903000000 | 64089000000 |
minorityInterest | None | None | None | None |
netIncome | 57411000000 | 55256000000 | 59531000000 | 48351000000 |
sellingGeneralAdministrative | 19916000000 | 18245000000 | 16705000000 | 15261000000 |
grossProfit | 104956000000 | 98392000000 | 101839000000 | 88186000000 |
ebit | 66288000000 | 63930000000 | 70898000000 | 61344000000 |
operatingIncome | 66288000000 | 63930000000 | 70898000000 | 61344000000 |
otherOperatingExpenses | None | None | None | None |
interestExpense | -2873000000 | -3576000000 | -3240000000 | -2323000000 |
extraordinaryItems | None | None | None | None |
nonRecurring | None | None | None | None |
otherItems | None | None | None | None |
incomeTaxExpense | 9680000000 | 10481000000 | 13372000000 | 15738000000 |
totalRevenue | 274515000000 | 260174000000 | 265595000000 | 229234000000 |
totalOperatingExpenses | 208227000000 | 196244000000 | 194697000000 | 167890000000 |
costOfRevenue | 169559000000 | 161782000000 | 163756000000 | 141048000000 |
totalOtherIncomeExpenseNet | 803000000 | 1807000000 | 2005000000 | 2745000000 |
discontinuedOperations | None | None | None | None |
netIncomeFromContinuingOps | 57411000000 | 55256000000 | 59531000000 | 48351000000 |
netIncomeApplicableToCommonShares | 57411000000 | 55256000000 | 59531000000 | 48351000000 |
매출액(total revenue)
income[income.index == "totalRevenue"]
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
totalRevenue | 274515000000 | 260174000000 | 265595000000 | 229234000000 |
매출총이익(gross profit)
income[income.index == "grossProfit"]
endDate | 2020-09-26 | 2019-09-28 | 2018-09-29 | 2017-09-30 |
---|---|---|---|---|
Breakdown | ||||
grossProfit | 104956000000 | 98392000000 | 101839000000 | 88186000000 |
여러 종목의 손익계산서 구하기
income_statements = {}
for ticker in ['amzn', 'ba', 'msft', 'aapl', 'goog'] :
income_statements[ticker] = si.get_income_statement(ticker)
income_statements
recent_income_statements = {ticker : sheet.iloc[:,:2] for ticker,sheet in income_statements.items()}
recent_income_statements
{'aapl': endDate 2020-09-26 2019-09-28 Breakdown researchDevelopment 18752000000 16217000000 effectOfAccountingCharges None None incomeBeforeTax 67091000000 65737000000 minorityInterest None None netIncome 57411000000 55256000000 sellingGeneralAdministrative 19916000000 18245000000 grossProfit 104956000000 98392000000 ebit 66288000000 63930000000 operatingIncome 66288000000 63930000000 otherOperatingExpenses None None interestExpense -2873000000 -3576000000 extraordinaryItems None None nonRecurring None None otherItems None None incomeTaxExpense 9680000000 10481000000 totalRevenue 274515000000 260174000000 totalOperatingExpenses 208227000000 196244000000 costOfRevenue 169559000000 161782000000 totalOtherIncomeExpenseNet 803000000 1807000000 discontinuedOperations None None netIncomeFromContinuingOps 57411000000 55256000000 netIncomeApplicableToCommonShares 57411000000 55256000000, 'amzn': endDate 2019-12-31 2018-12-31 Breakdown researchDevelopment 35931000000 28837000000 effectOfAccountingCharges None None incomeBeforeTax 13962000000 11270000000 minorityInterest None None netIncome 11588000000 10073000000 sellingGeneralAdministrative 64313000000 52177000000 grossProfit 114986000000 93731000000 ebit 14404000000 12421000000 operatingIncome 14404000000 12421000000 otherOperatingExpenses 338000000 296000000 interestExpense -1600000000 -1417000000 extraordinaryItems None None nonRecurring None None otherItems None None incomeTaxExpense 2374000000 1197000000 totalRevenue 280522000000 232887000000 totalOperatingExpenses 266118000000 220466000000 costOfRevenue 165536000000 139156000000 totalOtherIncomeExpenseNet -442000000 -1151000000 discontinuedOperations None None netIncomeFromContinuingOps 11588000000 10073000000 netIncomeApplicableToCommonShares 11588000000 10073000000, 'ba': endDate 2019-12-31 2018-12-31 Breakdown researchDevelopment 3219000000 3269000000 effectOfAccountingCharges None None incomeBeforeTax -2259000000 11604000000 minorityInterest 317000000 71000000 netIncome -636000000 10460000000 sellingGeneralAdministrative 3642000000 4525000000 grossProfit 4759000000 19637000000 ebit -2102000000 11843000000 operatingIncome -2102000000 11843000000 otherOperatingExpenses None None interestExpense -722000000 -475000000 extraordinaryItems None None nonRecurring None None otherItems None None incomeTaxExpense -1623000000 1144000000 totalRevenue 76559000000 101127000000 totalOperatingExpenses 78661000000 89284000000 costOfRevenue 71800000000 81490000000 totalOtherIncomeExpenseNet -157000000 -239000000 discontinuedOperations None None netIncomeFromContinuingOps -636000000 10460000000 netIncomeApplicableToCommonShares -636000000 10460000000, 'goog': endDate 2019-12-31 2018-12-31 Breakdown researchDevelopment 26018000000 21419000000 effectOfAccountingCharges None None incomeBeforeTax 39625000000 34913000000 minorityInterest None None netIncome 34343000000 30736000000 sellingGeneralAdministrative 27461000000 23256000000 grossProfit 89961000000 77270000000 ebit 36482000000 32595000000 operatingIncome 36482000000 32595000000 otherOperatingExpenses None None interestExpense -100000000 -114000000 extraordinaryItems None None nonRecurring None None otherItems None None incomeTaxExpense 5282000000 4177000000 totalRevenue 161857000000 136819000000 totalOperatingExpenses 125375000000 104224000000 costOfRevenue 71896000000 59549000000 totalOtherIncomeExpenseNet 3143000000 2318000000 discontinuedOperations None None netIncomeFromContinuingOps 34343000000 30736000000 netIncomeApplicableToCommonShares 34343000000 30736000000, 'msft': endDate 2020-06-30 2019-06-30 Breakdown researchDevelopment 19269000000 16876000000 effectOfAccountingCharges None None incomeBeforeTax 53036000000 43688000000 minorityInterest None None netIncome 44281000000 39240000000 sellingGeneralAdministrative 24709000000 23098000000 grossProfit 96937000000 82933000000 ebit 52959000000 42959000000 operatingIncome 52959000000 42959000000 otherOperatingExpenses None None interestExpense -2591000000 -2686000000 extraordinaryItems None None nonRecurring None None otherItems None None incomeTaxExpense 8755000000 4448000000 totalRevenue 143015000000 125843000000 totalOperatingExpenses 90056000000 82884000000 costOfRevenue 46078000000 42910000000 totalOtherIncomeExpenseNet 77000000 729000000 discontinuedOperations None None netIncomeFromContinuingOps 44281000000 39240000000 netIncomeApplicableToCommonShares 44281000000 39240000000}
recent_income_statements['aapl'][recent_income_statements['aapl'].index=='netIncome']
endDate | 2020-09-26 | 2019-09-28 |
---|---|---|
Breakdown | ||
netIncome | 57411000000 | 55256000000 |
현금흐름표(cash flow statements)는 get_cash_flow 메서드를 사용하여 구한다
flow = si.get_cash_flow("aapl")
flow.items
<bound method DataFrame.items of endDate 2020-09-26 ... 2017-09-30 Breakdown ... investments 5335000000 ... -33542000000 changeToLiabilities -1981000000 ... 8373000000 totalCashflowsFromInvestingActivities -4289000000 ... -46446000000 netBorrowings 2499000000 ... 29014000000 totalCashFromFinancingActivities -86820000000 ... -17974000000 changeToOperatingActivities 881000000 ... -8480000000 issuanceOfStock 880000000 ... 555000000 netIncome 57411000000 ... 48351000000 changeInCash -10435000000 ... -195000000 repurchaseOfStock -75992000000 ... -34774000000 totalCashFromOperatingActivities 80674000000 ... 64225000000 depreciation 11056000000 ... 10157000000 otherCashflowsFromInvestingActivities -791000000 ... -124000000 dividendsPaid -14081000000 ... -12769000000 changeToInventory -127000000 ... -2723000000 changeToAccountReceivables 6917000000 ... -2093000000 otherCashflowsFromFinancingActivities -126000000 ... -105000000 changeToNetincome 6517000000 ... 10640000000 capitalExpenditures -7309000000 ... -12451000000 [19 rows x 4 columns]>
여러 종목의 현금흐름표 다운로드
cash_flows = {}
for ticker in ['amzn', 'ba', 'msft', 'aapl', 'goog']:
cash_flows[ticker] = si.get_cash_flow(ticker)
다운받은 현금흐름표 묶기
recent_cash_flows = {ticker : flow.iloc[:,:2] for ticker,flow in cash_flows.items()}
recent_cash_flows['amzn'][recent_cash_flows['amzn'].index=='depreciation']
endDate | 2019-12-31 | 2018-12-31 |
---|---|---|
Breakdown | ||
depreciation | 2.178900e+10 | 1.534100e+10 |