11
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

yfinanceでYahoo!ファイナンスの情報を取得する。

Last updated at Posted at 2024-08-17

はじめに

株価や為替、主要な株式指などの情報を簡単に取得できる yfinance。スクリーニングに使えそうなので調べてみた。

目次

yfinanceでできること。

yfinanceは、Pythonで株価や為替、主要な株式指数などの情報を取得できるライブラリ。pip install yfinanceでライブラリをインストールする。株価を自分で指定した期間、間隔で取得できるのでグラフにしてチャートにすることもできる。また、企業の財務三表や配当金情報など、Yahoo! ファイナンスで取得できる情報はほぼ取得できるので、企業情報を調べたり、自分でスクリーニングカスタマイズしたりと、色々用途がありそう。ただ、注意点としては、個人使用のみを目的としているツールである点。

株情報

銘柄の情報を取得する。

yf.Tickerでシンボルを指定して情報を取得する。基本情報は.infoで取得できる。
シンボルはYahoo! ファイナスで確認することができる。例として、記事を書いたときの時価総額上位のシンボルを列挙する。東証のシンボルであれば。下記のように後ろに.Tつける。

銘柄 シンボル
トヨタ自動車(株) 7203.T
(株)三菱UFJフィナンシャル・グループ 8306.T
(株)日立製作所 6501.T
ソニーグループ(株) 6758.T
(株)キーエンス 6861.T
(株)リクルートホールディングス 6098.T
(株)ファーストリテイリング 9983.T
日本電信電話(株) 9432.T
東京エレクトロン(株) 8035.T
(株)三井住友フィナンシャルグループ 8316.T

米国株であれば。

銘柄 シンボル
アップル AAPL
マイクロソフト MSFT
エヌビディア NVDA
アマゾン・ドット・コム AMZN
メタ・プラットフォームズ META
アルファベット GOOGL
タイワン・セミコンダクター・マニュファクチャリング TSM
イーライ・リリー LLY
ブロードコム AVGO
テスラ TSLA
yf_example
import yfinance as yf

#Tikerで一つの銘柄の情報を取得 例は アップル。2024/8/17時点
STOCK = yf.Ticker("AAPL") 

# 情報取得(.info)
STOCK_info = STOCK.info

# シンボル
print(f"{STOCK_info['underlyingSymbol']=}")
# STOCK_info['underlyingSymbol']='AAPL'

# 会社名
print(f"{STOCK_info['shortName']=}")
# STOCK_info['shortName']='Apple Inc.'

print(f"{STOCK_info['longName']=}")
# STOCK_info['longName']='Apple Inc.'

# 現在値
print(f"{STOCK_info['currentPrice']=}ドル")
# STOCK_info['currentPrice']=226.05ドル

# 52週最高値
print(f"{STOCK_info['fiftyTwoWeekLow']=}ドル")
# STOCK_info['fiftyTwoWeekLow']=164.08ドル

# 52週最低値
print(f"{STOCK_info['fiftyTwoWeekHigh']=}ドル")
# STOCK_info['fiftyTwoWeekHigh']=237.23ドル

.infoではその他、企業の基本情報など様々な情報をとれる。

.infoでとれる情報はこちら!
# address1:One Apple Park Way
# city:Cupertino
# state:CA
# zip:95014
# country:United States
# phone:408 996 1010
# website:https://www.apple.com
# industry:Consumer Electronics
# industryKey:consumer-electronics
# industryDisp:Consumer Electronics
# sector:Technology
# sectorKey:technology
# sectorDisp:Technology
# longBusinessSummary:Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. The company offers iPhone, a line of smartphones; Mac, a line of personal computers; iPad, a line of multi-purpose tablets; and wearables, home, and accessories comprising AirPods, Apple TV, Apple Watch, Beats products, and HomePod. It also provides AppleCare support and cloud services; and operates various platforms, including the App Store that allow customers to discover and download applications and digital content, such as books, music, video, games, and podcasts. In addition, the company offers various services, such as Apple Arcade, a game subscription service; Apple Fitness+, a personalized fitness service; Apple Music, which offers users a curated listening experience with on-demand radio stations; Apple News+, a subscription news and magazine service; Apple TV+, which offers exclusive original content; Apple Card, a co-branded credit card; and Apple Pay, a cashless payment service, as well as licenses its intellectual property. The company serves consumers, and small and mid-sized businesses; and the education, enterprise, and government markets. It distributes third-party applications for its products through the App Store. The company also sells its products through its retail and online stores, and direct sales force; and third-party cellular network carriers, wholesalers, retailers, and resellers. Apple Inc. was founded in 1976 and is headquartered in Cupertino, California.
# fullTimeEmployees:161000
# companyOfficers:[{'maxAge': 1, 'name': 'Mr. Timothy D. Cook', 'age': 62, 'title': 'CEO & Director', 'yearBorn': 1961, 'fiscalYear': 2023, 'totalPay': 16239562, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Luca  Maestri', 'age': 60, 'title': 'CFO & Senior VP', 'yearBorn': 1963, 'fiscalYear': 2023, 'totalPay': 4612242, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Jeffrey E. Williams', 'age': 59, 'title': 'Chief Operating Officer', 'yearBorn': 1964, 'fiscalYear': 2023, 'totalPay': 4637585, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Ms. Katherine L. Adams', 'age': 59, 'title': 'Senior VP, General Counsel & Secretary', 'yearBorn': 1964, 'fiscalYear': 2023, 'totalPay': 4618064, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': "Ms. Deirdre  O'Brien", 'age': 56, 'title': 'Senior Vice President of Retail', 'yearBorn': 1967, 'fiscalYear': 2023, 'totalPay': 4613369, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Chris  Kondo', 'title': 'Senior Director of Corporate Accounting', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. James  Wilson', 'title': 'Chief Technology Officer', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Suhasini  Chandramouli', 'title': 'Director of Investor Relations', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Greg  Joswiak', 'title': 'Senior Vice President of Worldwide Marketing', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Adrian  Perica', 'age': 49, 'title': 'Head of Corporate Development', 'yearBorn': 1974, 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}]
# auditRisk:6
# boardRisk:1
# compensationRisk:2
# shareHolderRightsRisk:1
# overallRisk:1
# governanceEpochDate:1722470400
# compensationAsOfEpochDate:1703980800
# irWebsite:http://investor.apple.com/
# maxAge:86400
# priceHint:2
# previousClose:224.72
# open:223.92
# dayLow:223.6501
# dayHigh:226.8271
# regularMarketPreviousClose:224.72
# regularMarketOpen:223.92
# regularMarketDayLow:223.6501
# regularMarketDayHigh:226.8271
# dividendRate:1.0
# dividendYield:0.0045
# exDividendDate:1723420800
# payoutRatio:0.1476
# fiveYearAvgDividendYield:0.68
# beta:1.244
# trailingPE:34.458843
# forwardPE:30.220589
# volume:42366146
# regularMarketVolume:42366146
# averageVolume:65130295
# averageVolume10days:61813610
# averageDailyVolume10Day:61813610
# bid:225.98
# ask:226.1
# bidSize:200
# askSize:200
# marketCap:3436886884352
# fiftyTwoWeekLow:164.08
# fiftyTwoWeekHigh:237.23
# priceToSalesTrailing12Months:8.913019
# fiftyDayAverage:217.0224
# twoHundredDayAverage:191.4572
# trailingAnnualDividendRate:0.97
# trailingAnnualDividendYield:0.0043164827
# currency:USD
# enterpriseValue:3456176750592
# profitMargins:0.26441
# floatShares:15179658339
# sharesOutstanding:15204100096
# sharesShort:117696224
# sharesShortPriorMonth:132235437
# sharesShortPreviousMonthDate:1719532800
# dateShortInterest:1722384000
# sharesPercentSharesOut:0.0077
# heldPercentInsiders:0.02703
# heldPercentInstitutions:0.60719
# shortRatio:2.25
# shortPercentOfFloat:0.0077
# impliedSharesOutstanding:15410899968
# bookValue:4.382
# priceToBook:51.586037
# lastFiscalYearEnd:1696032000
# nextFiscalYearEnd:1727654400
# mostRecentQuarter:1719619200
# earningsQuarterlyGrowth:0.079
# netIncomeToCommon:101956001792
# trailingEps:6.56
# forwardEps:7.48
# pegRatio:3.02
# lastSplitFactor:4:1
# lastSplitDate:1598832000
# enterpriseToRevenue:8.963
# enterpriseToEbitda:26.227
# 52WeekChange:0.28786755
# SandP52WeekChange:0.26855552
# lastDividendValue:0.25
# lastDividendDate:1723420800
# exchange:NMS
# quoteType:EQUITY
# symbol:AAPL
# underlyingSymbol:AAPL
# shortName:Apple Inc.
# longName:Apple Inc.
# firstTradeDateEpochUtc:345479400
# timeZoneFullName:America/New_York
# timeZoneShortName:EDT
# uuid:8b10e4ae-9eeb-3684-921a-9ab27e4d87aa
# messageBoardId:finmb_24937
# gmtOffSetMilliseconds:-14400000
# currentPrice:226.05
# targetHighPrice:300.0
# targetLowPrice:183.86
# targetMeanPrice:236.23
# targetMedianPrice:240.5
# recommendationMean:2.0
# recommendationKey:buy
# numberOfAnalystOpinions:38
# totalCash:61801000960
# totalCashPerShare:4.065
# ebitda:131781001216
# totalDebt:101304000512
# quickRatio:0.798
# currentRatio:0.953
# totalRevenue:385603010560
# debtToEquity:151.862
# revenuePerShare:24.957
# returnOnAssets:0.22612
# returnOnEquity:1.60583
# freeCashflow:86158123008
# operatingCashflow:113040998400
# earningsGrowth:0.111
# revenueGrowth:0.049
# grossMargins:0.45962003
# ebitdaMargins:0.34175
# operatingMargins:0.29556
# financialCurrency:USD
# trailingPegRatio:2.1854

戻る

企業の財務三表を取得する。

企業の財務三表は、年毎と四半期毎の2種類を取得できる。

内容 パラメータ
損益計算書P/L .income_stmt:年毎
.quarterly_income_stmt:四半期毎
貸借対照表B/S .balance_sheet:年毎
.quarterly_balance_sheet:四半期毎
キャッシュフロー計算書C/F .cashflow:年毎
.quarterly_cashflow:四半期毎
yf_example
import yfinance as yf
import pandas

#TikerでAPLL指定。
STOCK = yf.Ticker("AAPL") 

# 損益計算書P/L (.income_stmt/.quarterly_income_stmt)------------------------
STOCK_income_stmt = STOCK.income_stmt
print(f'{type(STOCK_income_stmt)=}\n{STOCK_income_stmt}')

# 四半期ごとの場合は
STOCK_quarterly_income_stmt = STOCK.quarterly_income_stmt
print(f'{type(STOCK_quarterly_income_stmt)=}\n{STOCK_quarterly_income_stmt}')

# csvへ出力
STOCK_income_stmt.to_csv(STOCK_info['underlyingSymbol']+"_損益計算書.csv")


# 貸借対照表B/S (.balance_sheet/.quarterly_balance_sheet)--------------------
STOCK_balance_sheet = STOCK.balance_sheet
print(f'{type(STOCK_balance_sheet)=}\n{STOCK_balance_sheet}')

# 四半期ごとの場合は
STOCK_quarterly_balance_sheet = STOCK.quarterly_balance_sheet
print(f'{type(STOCK_quarterly_balance_sheet)=}\n{STOCK_quarterly_balance_sheet}')

# csvへ出力
STOCK_balance_sheet.to_csv(STOCK_info['underlyingSymbol']+"_貸借対照表.csv")


# キャッシュフロー計算書C/F (.cashflow /.quarterly_cashflow )----------------
STOCK_cashflow = STOCK.cashflow
print(f'{type(STOCK_cashflow)=}\n{STOCK_cashflow}')

# 四半期ごとの場合は
STOCK_quarterly_cashflow = STOCK.quarterly_cashflow
print(f'{type(STOCK_quarterly_cashflow)=}\n{STOCK_quarterly_cashflow}')

# csvへ出力
STOCK_cashflow.to_csv(STOCK_info['underlyingSymbol']+"_キャッシュフロー計算書.csv")

財務三表で取得できる情報はこちら!
type(STOCK_income_stmt)=<class 'pandas.core.frame.DataFrame'>
                                                        2023-09-30      2022-09-30      2021-09-30      2020-09-30
Tax Effect Of Unusual Items                                    0.0             0.0             0.0             0.0
Tax Rate For Calcs                                           0.147           0.162           0.133           0.144
Normalized EBITDA                                   129188000000.0  133138000000.0  123136000000.0   81020000000.0
Net Income From Continuing Operation Net Minori...   96995000000.0   99803000000.0   94680000000.0   57411000000.0
Reconciled Depreciation                              11519000000.0   11104000000.0   11284000000.0   11056000000.0
Reconciled Cost Of Revenue                          214137000000.0  223546000000.0  212981000000.0  169559000000.0
EBITDA                                              129188000000.0  133138000000.0  123136000000.0   81020000000.0
EBIT                                                117669000000.0  122034000000.0  111852000000.0   69964000000.0
Net Interest Income                                   -183000000.0    -106000000.0     198000000.0     890000000.0
Interest Expense                                      3933000000.0    2931000000.0    2645000000.0    2873000000.0
Interest Income                                       3750000000.0    2825000000.0    2843000000.0    3763000000.0
Normalized Income                                    96995000000.0   99803000000.0   94680000000.0   57411000000.0
Net Income From Continuing And Discontinued Ope...   96995000000.0   99803000000.0   94680000000.0   57411000000.0
Total Expenses                                      268984000000.0  274891000000.0  256868000000.0  208227000000.0
Total Operating Income As Reported                  114301000000.0  119437000000.0  108949000000.0   66288000000.0
Diluted Average Shares                               15812547000.0   16325819000.0   16864919000.0   17528214000.0
Basic Average Shares                                 15744231000.0   16215963000.0   16701272000.0   17352119000.0
Diluted EPS                                                   6.13            6.11            5.61            3.28
Basic EPS                                                     6.16            6.15            5.67            3.31
Diluted NI Availto Com Stockholders                  96995000000.0   99803000000.0   94680000000.0   57411000000.0
Net Income Common Stockholders                       96995000000.0   99803000000.0   94680000000.0   57411000000.0
Net Income                                           96995000000.0   99803000000.0   94680000000.0   57411000000.0
Net Income Including Noncontrolling Interests        96995000000.0   99803000000.0   94680000000.0   57411000000.0
Net Income Continuous Operations                     96995000000.0   99803000000.0   94680000000.0   57411000000.0
Tax Provision                                        16741000000.0   19300000000.0   14527000000.0    9680000000.0
Pretax Income                                       113736000000.0  119103000000.0  109207000000.0   67091000000.0
Other Income Expense                                  -382000000.0    -228000000.0      60000000.0     -87000000.0
Other Non Operating Income Expenses                   -382000000.0    -228000000.0      60000000.0     -87000000.0
Net Non Operating Interest Income Expense             -183000000.0    -106000000.0     198000000.0     890000000.0
Interest Expense Non Operating                        3933000000.0    2931000000.0    2645000000.0    2873000000.0
Interest Income Non Operating                         3750000000.0    2825000000.0    2843000000.0    3763000000.0
Operating Income                                    114301000000.0  119437000000.0  108949000000.0   66288000000.0
Operating Expense                                    54847000000.0   51345000000.0   43887000000.0   38668000000.0
Research And Development                             29915000000.0   26251000000.0   21914000000.0   18752000000.0
Selling General And Administration                   24932000000.0   25094000000.0   21973000000.0   19916000000.0
Gross Profit                                        169148000000.0  170782000000.0  152836000000.0  104956000000.0
Cost Of Revenue                                     214137000000.0  223546000000.0  212981000000.0  169559000000.0
Total Revenue                                       383285000000.0  394328000000.0  365817000000.0  274515000000.0
Operating Revenue                                   383285000000.0  394328000000.0  365817000000.0  274515000000.0
type(STOCK_quarterly_income_stmt)=<class 'pandas.core.frame.DataFrame'>
                                                       2024-06-30     2024-03-31  ...   2023-03-31    2022-12-31
Tax Effect Of Unusual Items                                   0.0            0.0  ...          NaN           NaN
Tax Rate For Calcs                                          0.159          0.158  ...          NaN           NaN
Normalized EBITDA                                   28202000000.0  30736000000.0  ...          NaN           NaN
Net Income From Continuing Operation Net Minori...  21448000000.0  23636000000.0  ...          NaN           NaN
Reconciled Depreciation                              2850000000.0   2836000000.0  ...          NaN           NaN
Reconciled Cost Of Revenue                          46099000000.0  48482000000.0  ...          NaN           NaN
EBITDA                                              28202000000.0  30736000000.0  ...          NaN           NaN
EBIT                                                25352000000.0  27900000000.0  ...          NaN           NaN
Net Interest Income                                           NaN            NaN  ...  -12000000.0  -135000000.0
Interest Expense                                              NaN            NaN  ...  930000000.0  1003000000.0
Interest Income                                               NaN            NaN  ...  918000000.0   868000000.0
Normalized Income                                   21448000000.0  23636000000.0  ...          NaN           NaN
Net Income From Continuing And Discontinued Ope...  21448000000.0  23636000000.0  ...          NaN           NaN
Total Expenses                                      60425000000.0  62853000000.0  ...          NaN           NaN
Total Operating Income As Reported                  25352000000.0  27900000000.0  ...          NaN           NaN
Diluted Average Shares                              15348175000.0  15464709000.0  ...          NaN           NaN
Basic Average Shares                                15287521000.0  15405856000.0  ...          NaN           NaN
Diluted EPS                                                   1.4           1.53  ...          NaN           NaN
Basic EPS                                                     1.4           1.53  ...          NaN           NaN
Diluted NI Availto Com Stockholders                 21448000000.0  23636000000.0  ...          NaN           NaN
Net Income Common Stockholders                      21448000000.0  23636000000.0  ...          NaN           NaN
Net Income                                          21448000000.0  23636000000.0  ...          NaN           NaN
Net Income Including Noncontrolling Interests       21448000000.0  23636000000.0  ...          NaN           NaN
Net Income Continuous Operations                    21448000000.0  23636000000.0  ...          NaN           NaN
Tax Provision                                        4046000000.0   4422000000.0  ...          NaN           NaN
Pretax Income                                       25494000000.0  28058000000.0  ...          NaN           NaN
Other Income Expense                                  142000000.0    158000000.0  ...          NaN           NaN
Other Non Operating Income Expenses                   142000000.0    158000000.0  ...          NaN           NaN
Net Non Operating Interest Income Expense                     NaN            NaN  ...  -12000000.0  -135000000.0
Interest Expense Non Operating                                NaN            NaN  ...  930000000.0  1003000000.0
Interest Income Non Operating                                 NaN            NaN  ...  918000000.0   868000000.0
Operating Income                                    25352000000.0  27900000000.0  ...          NaN           NaN
Operating Expense                                   14326000000.0  14371000000.0  ...          NaN           NaN
Research And Development                             8006000000.0   7903000000.0  ...          NaN           NaN
Selling General And Administration                   6320000000.0   6468000000.0  ...          NaN           NaN
Gross Profit                                        39678000000.0  42271000000.0  ...          NaN           NaN
Cost Of Revenue                                     46099000000.0  48482000000.0  ...          NaN           NaN
Total Revenue                                       85777000000.0  90753000000.0  ...          NaN           NaN
Operating Revenue                                   85777000000.0  90753000000.0  ...          NaN           NaN

[39 rows x 7 columns]
type(STOCK_balance_sheet)=<class 'pandas.core.frame.DataFrame'>
                                                      2023-09-30      2022-09-30  ...      2020-09-30 2019-09-30
Treasury Shares Number                                       0.0             NaN  ...             NaN        NaN
Ordinary Shares Number                             15550061000.0   15943425000.0  ...   16976763000.0        NaN
Share Issued                                       15550061000.0   15943425000.0  ...   16976763000.0        NaN
Net Debt                                           81123000000.0   96423000000.0  ...   74420000000.0        NaN
Total Debt                                        123930000000.0  132480000000.0  ...  122278000000.0        NaN
...                                                          ...             ...  ...             ...        ...
Cash Cash Equivalents And Short Term Investments   61555000000.0   48304000000.0  ...   90943000000.0        NaN
Other Short Term Investments                       31590000000.0   24658000000.0  ...   52927000000.0        NaN
Cash And Cash Equivalents                          29965000000.0   23646000000.0  ...   38016000000.0        NaN
Cash Equivalents                                    1606000000.0    5100000000.0  ...   20243000000.0        NaN
Cash Financial                                     28359000000.0   18546000000.0  ...   17773000000.0        NaN

[68 rows x 5 columns]
type(STOCK_quarterly_balance_sheet)=<class 'pandas.core.frame.DataFrame'>
                                                      2024-06-30      2024-03-31  ... 2023-03-31 2022-12-31
Treasury Shares Number                                       NaN             NaN  ...        NaN        NaN
Ordinary Shares Number                             15222259000.0   15337686000.0  ...        NaN        NaN
Share Issued                                       15222259000.0   15337686000.0  ...        NaN        NaN
Net Debt                                           75739000000.0   71895000000.0  ...        NaN        NaN
Total Debt                                        101304000000.0  104590000000.0  ...        NaN        NaN
...                                                          ...             ...  ...        ...        ...
Cash Cash Equivalents And Short Term Investments   61801000000.0   67150000000.0  ...        NaN        NaN
Other Short Term Investments                       36236000000.0   34455000000.0  ...        NaN        NaN
Cash And Cash Equivalents                          25565000000.0   32695000000.0  ...        NaN        NaN
Cash Equivalents                                    2699000000.0    4468000000.0  ...        NaN        NaN
Cash Financial                                     22866000000.0   28227000000.0  ...        NaN        NaN

[70 rows x 7 columns]
type(STOCK_cashflow)=<class 'pandas.core.frame.DataFrame'>
                                                    2023-09-30      2022-09-30  ...      2020-09-30   2019-09-30
Free Cash Flow                                   99584000000.0  111443000000.0  ...   73365000000.0          NaN
Repurchase Of Capital Stock                     -77550000000.0  -89402000000.0  ...  -72358000000.0          NaN
Repayment Of Debt                               -11151000000.0   -9543000000.0  ...  -12629000000.0          NaN
Issuance Of Debt                                  5228000000.0    5465000000.0  ...   16091000000.0          NaN
Issuance Of Capital Stock                                  NaN             NaN  ...     880000000.0  781000000.0
Capital Expenditure                             -10959000000.0  -10708000000.0  ...   -7309000000.0          NaN
Interest Paid Supplemental Data                   3803000000.0    2865000000.0  ...    3002000000.0          NaN
Income Tax Paid Supplemental Data                18679000000.0   19573000000.0  ...    9501000000.0          NaN
End Cash Position                                30737000000.0   24977000000.0  ...   39789000000.0          NaN
Beginning Cash Position                          24977000000.0   35929000000.0  ...   50224000000.0          NaN
Changes In Cash                                   5760000000.0  -10952000000.0  ...  -10435000000.0          NaN
Financing Cash Flow                            -108488000000.0 -110749000000.0  ...  -86820000000.0          NaN
Cash Flow From Continuing Financing Activities -108488000000.0 -110749000000.0  ...  -86820000000.0          NaN
Net Other Financing Charges                      -6012000000.0   -6383000000.0  ...   -2880000000.0          NaN
Cash Dividends Paid                             -15025000000.0  -14841000000.0  ...  -14081000000.0          NaN
Common Stock Dividend Paid                      -15025000000.0  -14841000000.0  ...  -14081000000.0          NaN
Net Common Stock Issuance                       -77550000000.0  -89402000000.0  ...  -72358000000.0          NaN
Common Stock Payments                           -77550000000.0  -89402000000.0  ...  -72358000000.0          NaN
Common Stock Issuance                                      NaN             NaN  ...     880000000.0  781000000.0
Net Issuance Payments Of Debt                    -9901000000.0    -123000000.0  ...    2499000000.0          NaN
Net Short Term Debt Issuance                     -3978000000.0    3955000000.0  ...    -963000000.0          NaN
Net Long Term Debt Issuance                      -5923000000.0   -4078000000.0  ...    3462000000.0          NaN
Long Term Debt Payments                         -11151000000.0   -9543000000.0  ...  -12629000000.0          NaN
Long Term Debt Issuance                           5228000000.0    5465000000.0  ...   16091000000.0          NaN
Investing Cash Flow                               3705000000.0  -22354000000.0  ...   -4289000000.0          NaN
Cash Flow From Continuing Investing Activities    3705000000.0  -22354000000.0  ...   -4289000000.0          NaN
Net Other Investing Changes                      -1337000000.0   -2086000000.0  ...    -909000000.0          NaN
Net Investment Purchase And Sale                 16001000000.0   -9560000000.0  ...    5453000000.0          NaN
Sale Of Investment                               45514000000.0   67363000000.0  ...  120391000000.0          NaN
Purchase Of Investment                          -29513000000.0  -76923000000.0  ... -114938000000.0          NaN
Net Business Purchase And Sale                             NaN    -306000000.0  ...   -1524000000.0 -624000000.0
Purchase Of Business                                       NaN    -306000000.0  ...   -1524000000.0 -624000000.0
Net PPE Purchase And Sale                       -10959000000.0  -10708000000.0  ...   -7309000000.0          NaN
Purchase Of PPE                                 -10959000000.0  -10708000000.0  ...   -7309000000.0          NaN
Operating Cash Flow                             110543000000.0  122151000000.0  ...   80674000000.0          NaN
Cash Flow From Continuing Operating Activities  110543000000.0  122151000000.0  ...   80674000000.0          NaN
Change In Working Capital                        -6577000000.0    1200000000.0  ...    5690000000.0          NaN
Change In Other Working Capital                            NaN     478000000.0  ...    2081000000.0 -625000000.0
Change In Other Current Liabilities               3031000000.0    6110000000.0  ...    8916000000.0          NaN
Change In Other Current Assets                   -5684000000.0   -6499000000.0  ...   -9588000000.0          NaN
Change In Payables And Accrued Expense           -1889000000.0    9448000000.0  ...   -4062000000.0          NaN
Change In Payable                                -1889000000.0    9448000000.0  ...   -4062000000.0          NaN
Change In Account Payable                        -1889000000.0    9448000000.0  ...   -4062000000.0          NaN
Change In Inventory                              -1618000000.0    1484000000.0  ...    -127000000.0          NaN
Change In Receivables                             -417000000.0   -9343000000.0  ...    8470000000.0          NaN
Changes In Account Receivables                   -1688000000.0   -1823000000.0  ...    6917000000.0          NaN
Other Non Cash Items                             -2227000000.0    1006000000.0  ...     -97000000.0          NaN
Stock Based Compensation                         10833000000.0    9038000000.0  ...    6829000000.0          NaN
Deferred Tax                                               NaN     895000000.0  ...    -215000000.0 -340000000.0
Deferred Income Tax                                        NaN     895000000.0  ...    -215000000.0 -340000000.0
Depreciation Amortization Depletion              11519000000.0   11104000000.0  ...   11056000000.0          NaN
Depreciation And Amortization                    11519000000.0   11104000000.0  ...   11056000000.0          NaN
Net Income From Continuing Operations            96995000000.0   99803000000.0  ...   57411000000.0          NaN

[53 rows x 5 columns]
type(STOCK_quarterly_cashflow)=<class 'pandas.core.frame.DataFrame'>
                                                   2024-06-30     2024-03-31  ...    2023-03-31   2022-12-31
Free Cash Flow                                  26707000000.0  20694000000.0  ...           NaN          NaN
Repurchase Of Capital Stock                    -26522000000.0 -23205000000.0  ...           NaN          NaN
Repayment Of Debt                               -3253000000.0  -3148000000.0  ...           NaN          NaN
Issuance Of Debt                                          NaN            NaN  ...           NaN          NaN
Capital Expenditure                             -2151000000.0  -1996000000.0  ...           NaN          NaN
Interest Paid Supplemental Data                           NaN            NaN  ...  1170000000.0  703000000.0
Income Tax Paid Supplemental Data                4699000000.0   7276000000.0  ...           NaN          NaN
End Cash Position                               26635000000.0  33921000000.0  ...           NaN          NaN
Beginning Cash Position                         33921000000.0  41974000000.0  ...           NaN          NaN
Changes In Cash                                 -7286000000.0  -8053000000.0  ...           NaN          NaN
Financing Cash Flow                            -36017000000.0 -30433000000.0  ...           NaN          NaN
Cash Flow From Continuing Financing Activities -36017000000.0 -30433000000.0  ...           NaN          NaN
Net Other Financing Charges                     -2347000000.0   -370000000.0  ...           NaN          NaN
Cash Dividends Paid                             -3895000000.0  -3710000000.0  ...           NaN          NaN
Common Stock Dividend Paid                      -3895000000.0  -3710000000.0  ...           NaN          NaN
Net Common Stock Issuance                      -26522000000.0 -23205000000.0  ...           NaN          NaN
Common Stock Payments                          -26522000000.0 -23205000000.0  ...           NaN          NaN
Net Issuance Payments Of Debt                   -3253000000.0  -3148000000.0  ...           NaN          NaN
Net Short Term Debt Issuance                      997000000.0      2000000.0  ...           NaN          NaN
Short Term Debt Payments                          997000000.0      2000000.0  ...   254000000.0          NaN
Net Long Term Debt Issuance                     -4250000000.0  -3150000000.0  ...           NaN          NaN
Long Term Debt Payments                         -4250000000.0  -3150000000.0  ...           NaN          NaN
Long Term Debt Issuance                                   NaN            NaN  ...           NaN          NaN
Investing Cash Flow                              -127000000.0   -310000000.0  ...           NaN          NaN
Cash Flow From Continuing Investing Activities   -127000000.0   -310000000.0  ...           NaN          NaN
Net Other Investing Changes                      -388000000.0   -445000000.0  ...           NaN          NaN
Net Investment Purchase And Sale                 2412000000.0   2131000000.0  ...           NaN          NaN
Sale Of Investment                              15444000000.0  17393000000.0  ...           NaN          NaN
Purchase Of Investment                         -13032000000.0 -15262000000.0  ...           NaN          NaN
Net PPE Purchase And Sale                       -2151000000.0  -1996000000.0  ...           NaN          NaN
Purchase Of PPE                                 -2151000000.0  -1996000000.0  ...           NaN          NaN
Operating Cash Flow                             28858000000.0  22690000000.0  ...           NaN          NaN
Cash Flow From Continuing Operating Activities  28858000000.0  22690000000.0  ...           NaN          NaN
Change In Working Capital                        1684000000.0  -5764000000.0  ...           NaN          NaN
Change In Other Working Capital                           NaN            NaN  ...           NaN  131000000.0
Change In Other Current Liabilities              3439000000.0    428000000.0  ...           NaN          NaN
Change In Other Current Assets                  -1188000000.0  -2981000000.0  ...           NaN          NaN
Change In Payables And Accrued Expense           1539000000.0 -12168000000.0  ...           NaN          NaN
Change In Payable                                1539000000.0 -12168000000.0  ...           NaN          NaN
Change In Account Payable                        1539000000.0 -12168000000.0  ...           NaN          NaN
Change In Inventory                               -12000000.0    190000000.0  ...           NaN          NaN
Change In Receivables                           -2094000000.0   8767000000.0  ...           NaN          NaN
Changes In Account Receivables                  -1030000000.0   1172000000.0  ...           NaN          NaN
Other Non Cash Items                                7000000.0   -982000000.0  ...           NaN          NaN
Stock Based Compensation                         2869000000.0   2964000000.0  ...           NaN          NaN
Depreciation Amortization Depletion              2850000000.0   2836000000.0  ...           NaN          NaN
Depreciation And Amortization                    2850000000.0   2836000000.0  ...           NaN          NaN
Net Income From Continuing Operations           21448000000.0  23636000000.0  ...           NaN          NaN

戻る

配当金の情報を取得する。

配当金の情報は.dividendsで取得できる。

yf_example
import yfinance as yf
import pandas

#TikerでAPLL指定。
STOCK = yf.Ticker("AAPL") 

# 配当(.dividends)==========================
STOCK_dividends = STOCK.dividends
print(f'{type(STOCK_dividends)=}\n{STOCK_dividends}')

# type(STOCK_dividends)=<class 'pandas.core.series.Series'>
# Date
# 1987-05-11 00:00:00-04:00    0.000536
# 1987-08-10 00:00:00-04:00    0.000536
# 1987-11-17 00:00:00-05:00    0.000714
# 1988-02-12 00:00:00-05:00    0.000714
# 1988-05-16 00:00:00-04:00    0.000714
#                                ...
# 2023-08-11 00:00:00-04:00    0.240000
# 2023-11-10 00:00:00-05:00    0.240000
# 2024-02-09 00:00:00-05:00    0.240000
# 2024-05-10 00:00:00-04:00    0.250000
# 2024-08-12 00:00:00-04:00    0.250000
# Name: Dividends, Length: 84, dtype: float64

# csvへ出力
STOCK_dividends.to_csv(STOCK_info['underlyingSymbol']+"_配当.csv")

戻る

株価を取得する。

株価は、yf.downloadで取得できる。各パラメータは下記の通り。

内容 パラメータ 指定する値
銘柄 tickers 銘柄のシンボルを指定。
取得期間 period 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
取得間隔 interval 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
開始時期 start YYYY-MM-DD
終了時期 end YYYY-MM-DD
yf_example
import yfinance as yf

# 最大期間取得
STOCK_download = yf.download(tickers="AAPL", period="max")
print(STOCK_download)

#                   Open        High         Low       Close   Adj Close     Volume
# Date
# 1980-12-12    0.128348    0.128906    0.128348    0.128348    0.098943  469033600
# 1980-12-15    0.122210    0.122210    0.121652    0.121652    0.093781  175884800
# 1980-12-16    0.113281    0.113281    0.112723    0.112723    0.086898  105728000
# 1980-12-17    0.115513    0.116071    0.115513    0.115513    0.089049   86441600
# 1980-12-18    0.118862    0.119420    0.118862    0.118862    0.091630   73449600
# ...                ...         ...         ...         ...         ...        ...
# 2024-08-12  216.070007  219.509995  215.600006  217.529999  217.529999   38028100
# 2024-08-13  219.009995  221.889999  219.009995  221.270004  221.270004   44155300
# 2024-08-14  220.570007  223.029999  219.699997  221.720001  221.720001   41960600
# 2024-08-15  224.600006  225.350006  222.759995  224.720001  224.720001   46414000
# 2024-08-16  223.919998  226.830002  223.649994  226.050003  226.050003   44289900


# 1分足
STOCK_download = yf.download(tickers="AAPL", period="1d",interval="1m")
print(STOCK_download)

#                                  Open        High         Low       Close   Adj Close   Volume
# Datetime
# 2024-08-16 09:30:00-04:00  223.919998  224.500000  223.701996  223.701996  223.701996  4780458
# 2024-08-16 09:31:00-04:00  223.699997  224.339996  223.650101  224.189896  224.189896   191182
# 2024-08-16 09:32:00-04:00  224.119995  224.119995  223.790100  223.969894  223.969894    96866
# 2024-08-16 09:33:00-04:00  223.940002  224.000000  223.660294  223.964996  223.964996   103738
# 2024-08-16 09:34:00-04:00  223.929993  224.000000  223.789993  223.880005  223.880005   100297
# ...                               ...         ...         ...         ...         ...      ...
# 2024-08-16 15:55:00-04:00  225.830002  226.139999  225.809998  226.110001  226.110001   203415
# 2024-08-16 15:56:00-04:00  226.110001  226.139999  225.899994  226.059998  226.059998   156953
# 2024-08-16 15:57:00-04:00  226.070007  226.086899  225.979996  226.009995  226.009995   156152
# 2024-08-16 15:58:00-04:00  226.009995  226.020004  225.809998  225.850006  225.850006   226269
# 2024-08-16 15:59:00-04:00  225.860001  226.100006  225.790497  226.100006  226.100006   411741

# 日付指定
STOCK_download = yf.download(tickers="AAPL", start="2020-08-01", end="2024-08-01")
print(STOCK_download)

#                   Open        High         Low       Close   Adj Close     Volume
# Date
# 2020-08-03  108.199997  111.637497  107.892502  108.937500  106.267006  308151200
# 2020-08-04  109.132500  110.790001  108.387497  109.665001  106.976677  173071600
# 2020-08-05  109.377502  110.392502  108.897499  110.062500  107.364433  121776800
# 2020-08-06  110.404999  114.412498  109.797501  113.902496  111.110313  202428800
# 2020-08-07  113.205002  113.675003  110.292503  111.112503  108.584114  198045600
# ...                ...         ...         ...         ...         ...        ...
# 2024-07-25  218.929993  220.850006  214.619995  217.490005  217.238556   51391200
# 2024-07-26  218.699997  219.490005  216.009995  217.960007  217.708008   41601300
# 2024-07-29  216.960007  219.300003  215.750000  218.240005  217.987686   36311800
# 2024-07-30  219.190002  220.330002  216.119995  218.800003  218.547043   41643800
# 2024-07-31  221.440002  223.820007  220.630005  222.080002  221.823242   50036300


株価はyf.Tickerでシンボルを指定して.historyで取得することもできる。パラメータは、yf.downloadと同じものを使える(シンボルは指定済みなのでtickersは除く)。

yf_example
import yfinance as yf

# APPLの株価データ(history)
STOCK = yf.Ticker("AAPL") 
STOCK_history = STOCK.history(period="max", interval="3mo")
print(STOCK_history)

                                 Open        High         Low       Close       Volume  Dividends  Stock Splits
# Date
# 1984-12-01 00:00:00-05:00    0.100234    0.107117    0.085177    0.085177  11099804800       0.00           0.0
# 1985-03-01 00:00:00-05:00    0.085177    0.089479    0.058076    0.059796  12122745600       0.00           0.0
# 1985-06-01 00:00:00-04:00    0.058506    0.063668    0.049902    0.051622  10230729600       0.00           0.0
# 1985-09-01 00:00:00-04:00    0.051622    0.071411    0.050762    0.069261   8467782400       0.00           0.0
# 1985-12-01 00:00:00-05:00    0.069261    0.092061    0.066249    0.086038  13283872000       0.00           0.0
# ...                               ...         ...         ...         ...          ...        ...           ...
# 2023-09-01 00:00:00-04:00  188.525291  191.947765  164.826554  188.982941   3609892300       0.24           0.0
# 2023-12-01 00:00:00-05:00  189.610498  198.865372  178.572382  180.066711   3411621100       0.24           0.0
# 2024-03-01 00:00:00-05:00  179.099493  192.515742  163.668307  191.767624   4015037500       0.25           0.0
# 2024-06-01 00:00:00-04:00  192.676971  236.955721  191.927839  224.460190   3557721400       0.25           0.0
# 2024-08-16 00:00:00-04:00  223.919998  226.827103  223.650101  226.050003     42366146       0.00           0.0

戻る

為替情報

通貨を指定すれば、為替情報も取得できる。株価と同じくyf.downloadで取得する。
為替のシンボルは Yahoo! ファイナスで確認できる。

通貨 シンボル
米(ドル) / 日本(円) USDJPY=X
欧州(ユーロ) / 日本(円) EURJPY=X
中国(元) / 日本(円) CNYJPY=X
欧州(ユーロ) / 米(ドル) EURUSD=X
yf_example
import yfinance as yf

# 米(ドル) / 日本(円)
STOCK_download = yf.download(tickers="USDJPY=X", period="max", interval="1mo")
print(STOCK_download)

#                   Open        High         Low       Close   Adj Close  Volume
# Date
# 1996-10-30  114.370003  114.480003  113.610001  114.180000  114.180000       0
# 1996-11-01  113.500000  113.500000  113.500000  113.500000  113.500000       0
# 1996-11-04  113.279999  113.980003  112.949997  113.879997  113.879997       0
# 1996-11-05  113.709999  114.330002  113.449997  114.250000  114.250000       0
# 1996-11-06  114.230003  114.680000  113.650002  113.949997  113.949997       0
# ...                ...         ...         ...         ...         ...     ...
# 2024-08-13  146.981995  147.929993  146.910995  146.981995  146.981995       0
# 2024-08-14  146.970993  147.552002  146.080994  146.970993  146.970993       0
# 2024-08-15  147.253006  149.263000  147.063004  147.253006  147.253006       0
# 2024-08-16  149.222000  149.229996  147.639008  149.222000  149.222000       0
# 2024-08-17  149.296997  149.319000  147.561005  147.578995  147.578995       0

株価と同じくyf.Tickerでシンボルを指定して取得することもできる。例えば、現在の買気配、売気配を取得したい場合は

yf_example
import yfinance as yf

# 欧州(ユーロ) / 日本(円)
STOCK = yf.Ticker("EURJPY=X") 
# .info取得
STOCK_info = STOCK.info

# シンボル
print(f"{STOCK_info['underlyingSymbol']=}")
# ask/bid
print(f"買気配{STOCK_info['bid']=}円 売気配{STOCK_info['ask']=}")

# STOCK_info['underlyingSymbol']='EURJPY=X'
# 買気配STOCK_info['bid']=162.776円 売気配STOCK_info['ask']=162.781円

戻る

各種指標情報

株価と同じくyf.downloadで取得できる。

指標 シンボル
日経225 ^N225
Dow 30 ^DJI
S&P 500 ^GSPC
NASDAQ ^IXIC
yf_example
import yfinance as yf

# 日経225
STOCK_download = yf.download(tickers="^N225", period="max", interval="1mo")
print(STOCK_download)

#                     Open          High           Low         Close     Adj Close      Volume
# Date
# 1985-01-01  11543.000000  11992.309570  11543.000000  11992.309570  11992.309570           0
# 1985-02-01  11946.959961  12321.919922  11823.429688  12321.919922  12321.919922           0
# 1985-03-01  12412.139648  12604.019531  12263.849609  12580.759766  12580.759766           0
# 1985-04-01  12677.150391  12683.259766  12052.820312  12426.290039  12426.290039           0
# 1985-05-01  12456.650391  12790.269531  12358.030273  12758.459961  12758.459961           0
# ...                  ...           ...           ...           ...           ...         ...
# 2024-04-01  40646.699219  40697.218750  36733.058594  38405.660156  38405.660156  2522300000
# 2024-05-01  38107.378906  39437.160156  37617.000000  38487.898438  38487.898438  2632400000
# 2024-06-01  38734.949219  39788.628906  37950.199219  39583.078125  39583.078125  2209000000
# 2024-07-01  39839.820312  42426.769531  37611.191406  39101.820312  39101.820312  2570500000
# 2024-08-01  38781.558594  38781.558594  31156.119141  38062.671875  38062.671875  2030400000

戻る

11
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?