在上一篇測試中使用 yfinance 套件的 download() 函式從 Yahoo Finance API 下載股票的歷史價量資料, 本篇則是要用 Ticker 物件來下載更多金融資訊, 此物件除了能像 download() 那樣取得歷史價量資料外, 還可以取得公司基本資訊, 大戶與機構持股比例, 損益表, 資產負債表, 現金流量表等財報資料, 功能比 download() 還多.
本系列前一篇文章參考 :
本測試參考了下面幾篇的文章 :
6. 用 Ticker 物件取得更多金融資訊 :
Ticker 是 yfinance 套件中的一個類別, 呼叫其建構子 Ticker() 並傳入商品代號 (例如 'TSLA') 即可建立該商品之 Ticker 物件, 再用其屬性與方法取得歷史交易價量與財報資訊. 注意, 如果是查詢台股標的, 須在台股代號後面添加 ".TW", 例如 :
>>> import yfinance as yf
>>> type(yf.Ticker)
<class 'type'>
>>> tsla=yf.Ticker('TSLA') # 美股 Tesla
>>> type(tsla)
<class 'yfinance.ticker.Ticker'>
>>> tw2330=yf.Ticker("2330.TW") # 台積電
>>> type(tw2330)
<class 'yfinance.ticker.Ticker'>
可見 Ticker() 會建立並傳回一個 Ticker 物件, 以下使用一個自訂模組 members 來檢視 Ticker 物件的內容, 其 list_members() 函式會列出模組或套件中的公開成員 (即屬性與方法), 參考 :
# Python 學習筆記 : 檢視物件成員與取得變數名稱字串的方法
例如 :
>>> import members
>>> tw2330=yf.Ticker("2330.tw") # 台積電
>>> members.list_members(tw2330)
actions <class 'pandas.core.frame.DataFrame'>
analysis <class 'NoneType'>
balance_sheet <class 'pandas.core.frame.DataFrame'>
balancesheet <class 'pandas.core.frame.DataFrame'>
calendar <class 'NoneType'>
cashflow <class 'pandas.core.frame.DataFrame'>
dividends <class 'pandas.core.series.Series'>
earnings <class 'pandas.core.frame.DataFrame'>
earnings_dates <class 'pandas.core.frame.DataFrame'>
earnings_history <class 'NoneType'>
financials <class 'pandas.core.frame.DataFrame'>
get_actions <class 'method'>
get_analysis <class 'method'>
get_balance_sheet <class 'method'>
get_balancesheet <class 'method'>
get_calendar <class 'method'>
get_cashflow <class 'method'>
get_dividends <class 'method'>
get_earnings <class 'method'>
get_earnings_dates <class 'method'>
get_earnings_history <class 'method'>
get_financials <class 'method'>
get_info <class 'method'>
get_institutional_holders <class 'method'>
get_isin <class 'method'>
get_major_holders <class 'method'>
get_mutualfund_holders <class 'method'>
get_news <class 'method'>
get_recommendations <class 'method'>
get_shares <class 'method'>
get_splits <class 'method'>
get_sustainability <class 'method'>
history <class 'method'>
info <class 'dict'>
institutional_holders <class 'pandas.core.frame.DataFrame'>
isin <class 'str'>
major_holders <class 'pandas.core.frame.DataFrame'>
mutualfund_holders <class 'NoneType'>
news <class 'list'>
option_chain <class 'method'>
options <class 'tuple'>
quarterly_balance_sheet <class 'pandas.core.frame.DataFrame'>
quarterly_balancesheet <class 'pandas.core.frame.DataFrame'>
quarterly_cashflow <class 'pandas.core.frame.DataFrame'>
quarterly_earnings <class 'pandas.core.frame.DataFrame'>
quarterly_financials <class 'pandas.core.frame.DataFrame'>
recommendations <class 'NoneType'>
session <class 'NoneType'>
shares <class 'NoneType'>
splits <class 'pandas.core.series.Series'>
stats <class 'method'>
sustainability <class 'NoneType'>
ticker <class 'str'>
常用屬性如下表 :
Ticker 物件常用屬性 | 說明 |
info | 商品之綜合資訊 (字典) |
major_holders | 大戶持股比例 |
institutional_holders | 機構法人持股比例 |
financials | 近四年損益表 (DataFrame) |
balance_sheet | 近四年資產負債表 (DataFrame) |
cashflow | 近四年現金流量表 (DataFrame) |
quarterly_financials | 近四季損益表 (DataFrame) |
quarterly_balancesheet | 近四季資產負債表 (DataFrame) |
quarterly_cashflow | 近四季現金流量表 (DataFrame) |
quarterly_earnings | 近四年營收與獲利 (DataFrame) |
recommendations | 投資建議 (DataFrame) |
dividends | 歷年股息 (DataFrame) |
earnings | 歷年獲利 (DataFrame) |
actions | 歷年股息與股利 (DataFrame) |
常用方法如下表 :
Ticker 物件常用方法 | 說明 |
history() | 傳回歷史價量資料 |
get_info() | 傳回商品之綜合資訊 (字典) |
get_financials() | 傳回近四年損益表 (DataFrame) |
get_balance_sheet() | 傳回近四年資產負債表 (DataFrame) |
get_cashflow() | 傳回近四年現金流量表 (DataFrame) |
get_shares() | 傳回近四年流通股數 (DataFrame) |
get_dividends() | 傳回歷年股利 (DataFrame) |
get_earnings() | 傳回歷年獲利 (DataFrame) |
get_major_holders() | 傳回大戶持股比例 (DataFrame) |
get_institutional_holders() | 傳回機構法人持股比例 (DataFrame) |
get_actions() | 傳回歷年股息與股利 (DataFrame) |
其中最重要的是用來取得歷史價量資料的 history() 方法. 財報資料例如損益表 (financials), 資產負債表 (balance_sheet), 現金流量表 (cashflow), 流通股數 (shares), 股利 (dividends), 獲利 (earnings) 等可用屬性取得, 也可以呼叫方法取得. 以下會交替使用屬性與方法呼叫來取得這些資料.
(1). 呼叫 history() 方法取得歷史價量資料 :
history() 方法的功能與 download() 函式類似, 都是用來取得商品的價量資料, 同樣會傳回一個 Pandas 的 DataFrame, 語法如下 :
df=ticker.history([start, end] [, period, interval])
參數說明如下表 :
history() 參數 | 說明 |
start | 起始日期 YYYY-MM-DD (字串), 例如 '2022-08-22' |
end | 結束日期 YYYY-MM-DD (字串), 例如 '2022-09-06', 注意, 不包含此日資料 |
period | 期間, 可用 d (日), mo(月), y(年), ytd, max(全部), 例如 5d (5 天), 3mo(三個月) |
interval | 頻率, 可用 m(分), h(小時), d(日), wk(周), mo(月), 例如 1m(一分線) |
actions | 是否下載配息與配股事件 (布林值, 預設 True) |
auto_adjust | 是否自動調整所有 OHLC 值 (布林值, 預設 True) |
prepost | 是否包含 Pre 與 Post 之市場資料 (布林值, 預設 False) |
常用的參數為前四個 (後三個都是有預設值的布林值), 用法與 download() 函式一樣, 同樣分成 Start-end, Period-interval, 以及 Start-end-interval 三種模式, 如果沒有傳入任何參數, 預設傳回近一個月的歷史資料, 例如 :
>>> tw2330.history()
Open High Low Close Volume Dividends Stock Splits
Date
2022-08-08 510.0 515.0 509.0 512.0 19333128 0 0
2022-08-09 507.0 511.0 504.0 510.0 21164373 0 0
2022-08-10 500.0 503.0 499.5 500.0 20861380 0 0
2022-08-11 513.0 514.0 510.0 514.0 23740033 0 0
2022-08-12 515.0 518.0 514.0 517.0 19535923 0 0
2022-08-15 520.0 524.0 519.0 523.0 21273166 0 0
2022-08-16 526.0 526.0 523.0 525.0 20720414 0 0
2022-08-17 524.0 527.0 521.0 527.0 27143102 0 0
2022-08-18 520.0 521.0 519.0 520.0 17831084 0 0
2022-08-19 519.0 523.0 517.0 519.0 14022812 0 0
2022-08-22 511.0 514.0 510.0 512.0 11494000 0 0
2022-08-23 503.0 506.0 502.0 504.0 19191108 0 0
2022-08-24 504.0 508.0 503.0 503.0 14363212 0 0
2022-08-25 505.0 510.0 504.0 508.0 9357138 0 0
2022-08-26 513.0 515.0 511.0 512.0 12914846 0 0
2022-08-29 497.0 502.0 496.0 498.5 26590824 0 0
2022-08-30 497.5 500.0 496.0 496.0 24214535 0 0
2022-08-31 492.0 505.0 492.0 505.0 39357089 0 0
2022-09-01 495.0 495.5 490.0 490.5 39168672 0 0
2022-09-02 488.0 489.5 485.0 485.0 29982959 0 0
2022-09-05 485.0 488.0 484.0 486.0 15903415 0 0
2022-09-06 488.5 491.5 486.5 489.0 16700285 0 0
2022-09-07 477.0 478.0 472.0 472.5 34678562 0 0
2022-09-08 473.0 475.0 472.0 475.0 27931552 0 0
可見 history() 方法與 download() 函式取得的資料類似, 都有 OHLCV (但缺了調整收盤價), 而且多出 Dividends 與 Stock Splits 欄位 (因為 actions 參數預設為 True, 如果傳入 actions=False 就不會出現這兩欄了). 可惜台股似乎只是聊備一格沒資料, 但美股就有, 例如 :
>>> tsla.history()
Open High Low Close Volume Dividends Stock Splits
Date
2022-08-10 297.066681 297.510010 283.369995 294.356659 94918800 0 0.0
2022-08-11 296.513336 298.236664 285.833344 286.630005 70155000 0 0.0
2022-08-12 289.416656 300.160004 285.033325 300.029999 79657200 0 0.0
2022-08-15 301.786682 313.133331 301.230011 309.320007 89359200 0 0.0
2022-08-16 311.666656 314.666656 302.883331 306.563324 88136400 0 0.0
2022-08-17 303.396667 309.656677 300.033325 303.996674 68766000 0 0.0
2022-08-18 306.000000 306.500000 301.853333 302.869995 47500500 0 0.0
2022-08-19 299.000000 300.359985 292.500000 296.666656 61395300 0 0.0
2022-08-22 291.913330 292.399994 286.296661 289.913330 55843200 0 0.0
2022-08-23 291.453339 298.826660 287.923340 296.453339 63984900 0 0.0
2022-08-24 297.563324 303.646667 296.500000 297.096680 57259800 0 0.0
2022-08-25 302.359985 302.959991 291.600006 296.070007 53230000 0 3.0
2022-08-26 297.429993 302.000000 287.470001 288.089996 57163900 0 0.0
2022-08-29 282.829987 287.739990 280.700012 284.820007 41864700 0 0.0
2022-08-30 287.869995 288.480011 272.649994 277.700012 50541800 0 0.0
2022-08-31 280.619995 281.250000 271.809998 275.609985 52107300 0 0.0
2022-09-01 272.579987 277.579987 266.149994 277.160004 54287000 0 0.0
2022-09-02 281.070007 282.350006 269.079987 270.209991 50752200 0 0.0
2022-09-06 272.679993 275.989990 265.739990 274.420013 55860000 0 0.0
2022-09-07 273.100006 283.839996 272.269989 283.700012 50028900 0 0.0
2022-09-08 281.299988 289.500000 279.760010 289.260010 53713100 0 0.0
2022-09-09 291.670013 299.850006 291.250000 299.679993 54338100 0 0.0
特斯拉的 Dividends 都是 0, 這不是沒資料, 而是該公司從未配息.
Start-end 模式是傳入起迄日期內的歷史資料 (不含 end 那一天), 例如 :
>>> tw2330.history(start='2022-08-24', end='2022-09-07')
Open High Low Close Volume Dividends Stock Splits
Date
2022-08-24 504.0 508.0 503.0 503.0 14363212 0 0
2022-08-25 505.0 510.0 504.0 508.0 9357138 0 0
2022-08-26 513.0 515.0 511.0 512.0 12914846 0 0
2022-08-29 497.0 502.0 496.0 498.5 26590824 0 0
2022-08-30 497.5 500.0 496.0 496.0 24214535 0 0
2022-08-31 492.0 505.0 492.0 505.0 39357089 0 0
2022-09-01 495.0 495.5 490.0 490.5 39168672 0 0
2022-09-02 488.0 489.5 485.0 485.0 29982959 0 0
2022-09-05 485.0 488.0 484.0 486.0 15903415 0 0
2022-09-06 488.5 491.5 486.5 489.0 16700285 0 0
Period-Interval 模式會傳回最近一段期間特定頻率的價量資料 :
>>> tw2330.history(period='10d', interval='1d')
Open High Low Close Volume Dividends Stock Splits
Date
2022-08-26 513.0 515.0 511.0 512.0 12914846 0 0
2022-08-29 497.0 502.0 496.0 498.5 26590824 0 0
2022-08-30 497.5 500.0 496.0 496.0 24214535 0 0
2022-08-31 492.0 505.0 492.0 505.0 39357089 0 0
2022-09-01 495.0 495.5 490.0 490.5 39168672 0 0
2022-09-02 488.0 489.5 485.0 485.0 29982959 0 0
2022-09-05 485.0 488.0 484.0 486.0 15903415 0 0
2022-09-06 488.5 491.5 486.5 489.0 16700285 0 0
2022-09-07 477.0 478.0 472.0 472.5 34678562 0 0
2022-09-08 473.0 475.0 472.0 475.0 27931552 0 0
傳入 period='max' 會下載股票上市以來的全部價量資料, 例如 Tesla :
>>> df=tsla.history(period='max')
>>> df
Open High ... Dividends Stock Splits
Date ...
2010-06-29 1.266667 1.666667 ... 0 0.0
2010-06-30 1.719333 2.028000 ... 0 0.0
2010-07-01 1.666667 1.728000 ... 0 0.0
2010-07-02 1.533333 1.540000 ... 0 0.0
2010-07-06 1.333333 1.333333 ... 0 0.0
... ... ... ... ... ...
2022-09-01 272.579987 277.579987 ... 0 0.0
2022-09-02 281.070007 282.350006 ... 0 0.0
2022-09-06 272.679993 275.989990 ... 0 0.0
2022-09-07 273.100006 283.839996 ... 0 0.0
2022-09-08 281.299988 289.500000 ... 0 0.0
[3071 rows x 7 columns]
此處將傳回的 DataFrame 儲存在 df 變數中, 可用 Matplotlib 來繪製全部歷史收盤價圖形 :
>>> import matplotlib.pyplot as plt
>>> df['Close'].plot(figsize=(16, 9))
<matplotlib.axes._subplots.AxesSubplot object at 0x00000188333272B0>
>>> plt.show()
結果如下 :
如果要畫得漂亮些可用 Seaborn, 用法參考 :
例如 :
>>> import seaborn as sns
>>> sns.set(rc={'figure.figsize':(16, 9)})
>>> sns.lineplot(x='Date', y="Close", data=df)
<matplotlib.axes._subplots.AxesSubplot object at 0x000001884337A828>
>>> plt.show()
結果如下 :
哇, 如果在 2020 年買進特斯拉就賺爆了.
用 Period-interval 模式下載月收盤資料 :
>>> tw2330.history(period='ytd', interval='1mo')
Open High Low Close Volume Dividends Stock Splits
Date
2022-02-01 637.363946 643.302119 593.817341 597.776123 554354568.0 0.00 0
2022-03-01 592.827658 603.714309 549.281052 590.848267 976978169.0 0.00 0
2022-03-16 NaN NaN NaN NaN NaN 2.75 0
2022-04-01 581.839394 585.817783 520.174364 535.093323 613866812.0 0.00 0
2022-05-01 535.093347 556.974487 502.271636 556.974487 597891764.0 0.00 0
2022-06-01 547.028479 552.001465 473.428284 473.428284 619492801.0 0.00 0
2022-06-16 NaN NaN NaN NaN NaN 2.75 0
2022-07-01 471.500000 510.000000 433.000000 509.000000 718989084.0 0.00 0
2022-08-01 506.000000 527.000000 488.500000 505.000000 513479662.0 0.00 0
2022-09-01 495.000000 495.500000 472.000000 475.000000 164365445.0 0.00 0
2022-09-08 473.000000 475.000000 472.000000 475.000000 28881358.0 0.00 0
不知何故會出現 2022-03-16 與 2022-06-16 的 NaN 資料, 這是與 download() 不同之處.
高頻交易數據 (例如 1 分 K) 同樣只能下載近 7 天資料 :
>>> tw2330.history(period='7d', interval='1m')
Open High Low Close Volume Dividends Stock Splits
Datetime
2022-08-31 09:00:00+08:00 492.0 493.0 492.0 492.5 0 0 0
2022-08-31 09:01:00+08:00 492.5 493.0 492.0 492.5 392000 0 0
2022-08-31 09:02:00+08:00 492.5 493.0 492.0 492.5 233000 0 0
2022-08-31 09:03:00+08:00 492.5 493.5 492.5 493.0 254000 0 0
2022-08-31 09:04:00+08:00 493.5 493.5 493.0 493.5 243000 0 0
... ... ... ... ... ... ... ...
2022-09-08 13:21:00+08:00 474.5 474.5 474.0 474.0 103000 0 0
2022-09-08 13:22:00+08:00 474.0 474.5 474.0 474.0 168093 0 0
2022-09-08 13:23:00+08:00 474.0 474.5 473.5 474.0 243000 0 0
2022-09-08 13:24:00+08:00 474.5 474.5 474.0 474.0 120643 0 0
2022-09-08 13:30:00+08:00 475.0 475.0 475.0 475.0 0 0 0
[1845 rows x 7 columns]
>>> tw2330.history(period='8d', interval='1m')
- 2330.TW: 1m data not available for startTime=1662085882 and endTime=1662777082. Only 7 days worth of 1m granularity data are allowed to be fetched per request.
Empty DataFrame
Columns: [Open, High, Low, Close, Adj Close, Volume]
Index: []
Start-end-interval 模式是 Start-end 模式加上 interval 參數指定期間內的資料頻率, 例如下載 2022-09-06 與 2022-09-07 這兩天的五分 K 資料 (interval='5m')
>>> tw2330.history(start='2022-09-06', end='2022-09-08', interval='5m')
Open High Low Close Volume Dividends Stock Splits
Datetime
2022-09-06 09:00:00+08:00 488.5 491.0 488.0 491.0 0 0 0
2022-09-06 09:05:00+08:00 491.0 491.5 489.5 489.5 477000 0 0
2022-09-06 09:10:00+08:00 489.5 490.5 489.5 490.0 543911 0 0
2022-09-06 09:15:00+08:00 490.0 490.5 489.0 489.0 711856 0 0
2022-09-06 09:20:00+08:00 489.0 489.5 488.0 489.0 396767 0 0
... ... ... ... ... ... ... ...
2022-09-07 13:05:00+08:00 473.5 474.0 473.0 473.0 1531608 0 0
2022-09-07 13:10:00+08:00 473.0 473.5 472.5 472.5 869565 0 0
2022-09-07 13:15:00+08:00 472.5 474.5 472.0 473.0 1845877 0 0
2022-09-07 13:20:00+08:00 473.0 475.0 473.0 473.0 1243638 0 0
2022-09-07 13:25:00+08:00 473.0 473.0 473.0 473.0 81857 0 0
[107 rows x 7 columns]
下載周收盤資料 (繪製周 K 線用) :
>>> tw2330.history(start='2022-07-04', end='2022-09-09', interval='1wk')
Open High Low Close Volume Dividends Stock Splits
Date
2022-07-04 443.0 470.5 433.0 467.0 229129023 0 0
2022-07-11 468.0 494.0 449.5 492.5 172796995 0 0
2022-07-18 495.5 505.0 486.5 503.0 141993085 0 0
2022-07-25 500.0 510.0 491.0 509.0 113325604 0 0
2022-08-01 506.0 516.0 488.5 516.0 150371495 0 0
2022-08-08 510.0 518.0 499.5 517.0 104634837 0 0
2022-08-15 520.0 527.0 517.0 519.0 100990578 0 0
2022-08-22 511.0 515.0 502.0 512.0 67320304 0 0
2022-08-29 497.0 505.0 485.0 485.0 159314079 0 0
2022-09-05 485.0 491.5 472.0 475.0 95213814 0 0
2022-09-08 473.0 475.0 472.0 475.0 28881358 0 0
下載月收盤資料 (繪製月 K 線用) :
>>> tw2330.history(start='2022-01-01', end='2022-09-01', interval='1mo')
Open High Low Close Volume Dividends Stock Splits
Date
2022-01-01 612.621586 680.910583 611.631890 629.446411 922313952.0 0.00 0
2022-02-01 637.363946 643.302119 593.817341 597.776123 554354568.0 0.00 0
2022-03-01 592.827658 603.714309 549.281052 590.848267 976978169.0 0.00 0
2022-03-16 NaN NaN NaN NaN NaN 2.75 0
2022-04-01 581.839394 585.817783 520.174364 535.093323 613866812.0 0.00 0
2022-05-01 535.093347 556.974487 502.271636 556.974487 597891764.0 0.00 0
2022-06-01 547.028479 552.001465 473.428284 473.428284 619492801.0 0.00 0
2022-06-16 NaN NaN NaN NaN NaN 2.75 0
2022-07-01 471.500000 510.000000 433.000000 509.000000 718989084.0 0.00 0
2022-08-01 506.000000 527.000000 488.500000 505.000000 513479662.0 0.00 0
2022-09-01 495.000000 495.500000 472.000000 475.000000 164365445.0 0.00 0
除了上面常用的三種參數組合模式外, start/end 也可以與 period 合用, 例如 Start-period 模式可指定開始日期至今頻率為 period 的價量資料; 或 End-period 模式可指定自上市起至 end 日期頻率為 period 的價量資料.
(2). 商品綜合資訊 info :
Ticker 物件的 info 屬性以字典型態儲存商品之綜合資訊, 呼叫方法 get_info() 也會傳回相同的資料, 此字典的項目非常多, 如果直接 print 不會顯示全部內容, 必須用 for 迴圈走訪 items() 傳回的字典鍵與值.
>>> for k, v in tw2330.info.items(): # 也可以用 tw2330.get_info().items()
print(f'{k}:\t{v}')
zip: 300096
sector: Technology
fullTimeEmployees: 54193
longBusinessSummary: Taiwan Semiconductor Manufacturing Company Limited manufactures, packages, tests, and sells integrated circuits and other semiconductor devices in Taiwan, China, Europe, the Middle East, Africa, Japan, the United States, and internationally. It provides complementary metal oxide silicon wafer fabrication processes to manufacture logic, mixed-signal, radio frequency, and embedded memory semiconductors. The company also offers customer support, account management, and engineering services, as well as manufactures masks. Its products are used in mobile devices, high performance computing, automotive electronics, and internet of things markets. The company was incorporated in 1987 and is headquartered in Hsinchu City, Taiwan.
city: Hsinchu City
phone: 886 3 563 6688
country: Taiwan
companyOfficers: []
website: https://www.tsmc.com
maxAge: 1
address1: Hsinchu Science Park
fax: 886 3 563 7000
industry: Semiconductors
address2: No. 8, Li-Hsin Road 6
ebitdaMargins: 0.67949
profitMargins: 0.40587002
grossMargins: 0.54959
operatingCashflow: 1407924699136
revenueGrowth: 0.435
operatingMargins: 0.44752
ebitda: 1276140847104
targetLowPrice: 500
recommendationKey: buy
grossProfits: 819537266000
freeCashflow: 143859351552
targetMedianPrice: 650
currentPrice: 475
earningsGrowth: 0.764
currentRatio: 2.255
returnOnAssets: 0.14123
numberOfAnalystOpinions: 29
targetMeanPrice: 675.37
debtToEquity: 36.432
returnOnEquity: 0.33964002
targetHighPrice: 860
totalCash: 1450175234048
totalDebt: 914603245568
totalRevenue: 1878076424192
totalCashPerShare: 55.926
financialCurrency: TWD
revenuePerShare: 72.429
quickRatio: 1.981
recommendationMean: 1.8
exchange: TAI
shortName: TAIWAN SEMICONDUCTOR MANUFACTUR
longName: Taiwan Semiconductor Manufacturing Company Limited
exchangeTimezoneName: Asia/Taipei
exchangeTimezoneShortName: CST
isEsgPopulated: False
gmtOffSetMilliseconds: 28800000
quoteType: EQUITY
symbol: 2330.TW
messageBoardId: finmb_380075
market: tw_market
annualHoldingsTurnover: None
enterpriseToRevenue: 6.419
beta3Year: None
enterpriseToEbitda: 9.446
52WeekChange: -0.23667204
morningStarRiskRating: None
forwardEps: 37.85
revenueQuarterlyGrowth: None
sharesOutstanding: 25930399744
fundInceptionDate: None
annualReportExpenseRatio: None
totalAssets: None
bookValue: 96.271
sharesShort: None
sharesPercentSharesOut: None
fundFamily: None
lastFiscalYearEnd: 1640908800
heldPercentInstitutions: 0.42201
netIncomeToCommon: 762250854400
trailingEps: 29.23
lastDividendValue: 2.75
SandP52WeekChange: -0.13021445
priceToBook: 4.933988
heldPercentInsiders: 0
nextFiscalYearEnd: 1703980800
yield: None
mostRecentQuarter: 1656547200
shortRatio: None
sharesShortPreviousMonthDate: None
floatShares: 24181894477
beta: 1.117948
enterpriseValue: 12054771531776
priceHint: 2
threeYearAverageReturn: None
lastSplitDate: 1247616000
lastSplitFactor: 1:1
legalType: None
lastDividendDate: 1671062400
morningStarOverallRating: None
earningsQuarterlyGrowth: 0.764
priceToSalesTrailing12Months: 6.6326323
dateShortInterest: None
pegRatio: 0.58
ytdReturn: None
forwardPE: 12.549539
lastCapGain: None
shortPercentOfFloat: None
sharesShortPriorMonth: None
impliedSharesOutstanding: 0
category: None
fiveYearAverageReturn: None
previousClose: 472.5
regularMarketOpen: 473
twoHundredDayAverage: 559.825
trailingAnnualDividendYield: 0.023280423
payoutRatio: 0.3763
volume24Hr: None
regularMarketDayHigh: 475
navPrice: None
averageDailyVolume10Day: 24886832 (近 10 日均量)
regularMarketPreviousClose: 472.5
fiftyDayAverage: 493.17
trailingAnnualDividendRate: 11
open: 473
toCurrency: None
averageVolume10days: 24886832
expireDate: None
algorithm: None
dividendRate: 11
exDividendDate: 1663200000
circulatingSupply: None
startDate: None
regularMarketDayLow: 472
currency: TWD
trailingPE: 16.250427
regularMarketVolume: 28881358
lastMarket: None
maxSupply: None
openInterest: None
marketCap: 12456590049280
volumeAllCurrencies: None
strikePrice: None
averageVolume: 28951866
dayLow: 472
ask: 475.5
askSize: 0
volume: 28881358
fiftyTwoWeekHigh: 688 (近 52 周最高價)
fromCurrency: None
fiveYearAvgDividendYield: 2.78 (近 5 年平均現金股息)
fiftyTwoWeekLow: 433 (近 52 周最低價)
bid: 475
tradeable: False
dividendYield: 0.0227
bidSize: 0
dayHigh: 475
coinMarketCapLink: None
regularMarketPrice: 475
preMarketPrice: None
logo_url: https://logo.clearbit.com/tsmc.com
trailingPegRatio: 0.788
如果用 Colab 就可以直接 print, 不須用迴圈走訪 items() :
此資料也可以用 get_info() 方法取得.
(3). 內部人士與大戶持股比例 major_holders :
Ticker 物件的 major_holders 屬性以 DataFrame 型態儲存商品之大戶持股比例 :
>>> tw2330.major_holders
0 1
0 0.00% % of Shares Held by All Insider
1 42.20% % of Shares Held by Institutions
2 42.20% % of Float Held by Institutions
3 641 Number of Institutions Holding Shares
此資料也可以呼叫 get_major_holders() 取得, 例如 :
>>> tsla.get_major_holders()
0 1
0 16.43% % of Shares Held by All Insider
1 44.43% % of Shares Held by Institutions
2 53.17% % of Float Held by Institutions
3 3304 Number of Institutions Holding Shares
(4). 機構法人持股比例 major_holders :
不知為何, 這個資料對台股來說不論用屬性或方法都傳回 None :
>>> print(tw2330.institutional_holders)
None
>>> print(tw2330.get_institutional_holders())
None
但美股則有資料, 例如特斯拉 :
(5). 損益表 financials :
financials 屬性儲存商品過去四年的損益表 (即營收與獲利虧損情形) :
>>> tw2330.financials
此資料也可以用 get_financials() 方法取得, 例如 :
(6). 資產負債表 financials :
balance_sheet 屬性儲存商品過去四年的資產負債表 :
>>> tw2330.balance_sheet
此資料也可以用 get_balance_sheet() 方法取得, 例如 :
>>> tsla.get_balance_sheet()
(7). 現金流量表 cashflow :
cashflow 屬性儲存商品過去四年的現金流量表 :
>>> tw2330.cashflow
此資料也可以用 get_cashflow() 方法取得, 例如 :
以上程式碼均可在 Colab 測試, 參考 :
沒有留言 :
張貼留言