跳轉到

資料視覺化

FinLab 提供一系列圖表工具,讓你更方便洞察市場數據!

技術指標圖組

使用 plot_tw_stock_candles 繪製 K 線圖,可疊加多條 EMA 均線以及 STOCH、RSI 等技術指標子圖。

from finlab.plot import plot_tw_stock_candles
from talib import abstract
from finlab.data import indicator

stock_id = '2330'
recent_days = 1000
adjust_price = False
resample = "D"

overlay_func = {
    'ema_5': indicator('EMA', timeperiod=5),
    'ema_10': indicator('EMA', timeperiod=10),
    'ema_20': indicator('EMA', timeperiod=20),
    'ema_60': indicator('EMA', timeperiod=60),
}

k, d = indicator('STOCH')
rsi = indicator('RSI')
technical_func = [{'K': k, 'D': d}, {'RSI': rsi}]

plot_tw_stock_candles(
    stock_id, recent_days, adjust_price, resample,
    overlay_func=overlay_func,
    technical_func=technical_func
)

漲跌幅與成交金額板塊圖

巢狀樹狀圖可以顯示多維度資料,並與圖表做互動,將依照產業分類的台股資料絢麗顯示。

from finlab.plot import plot_tw_stock_treemap

plot_tw_stock_treemap(
    start='2021-07-01',
    end='2021-07-02',
    area_ind="turnover",
    item="return_ratio"
)

本益比與市值板塊圖

也可以用市值作為面積指標,並以本益比作為顏色指標,搭配 clipcolor_continuous_scale 參數自訂視覺效果。

from finlab.plot import plot_tw_stock_treemap

plot_tw_stock_treemap(
    start='2021-07-01',
    end='2021-07-02',
    area_ind="market_value",
    item="price_earning_ratio:本益比",
    clip=(0, 50),
    color_continuous_scale='RdBu_r'
)

財務指標雷達圖

比較持股組合的指標分級特性,支援 bar_polarline_polarscatter_polar 等模式。

bar_polar 模式

from finlab.plot import plot_tw_stock_radar

portfolio = ['1101', '2330', '8942', '6263']

plot_tw_stock_radar(
    portfolio=portfolio,
    mode="bar_polar"
)

line_polar 模式(自訂財務指標)

可以指定特定的財務指標進行比較,並調整分級數量。

from finlab.plot import plot_tw_stock_radar

feats = [
    'fundamental_features:營業毛利率',
    'fundamental_features:營業利益率',
    'fundamental_features:稅後淨利率',
    'fundamental_features:現金流量比率',
    'fundamental_features:負債比率'
]

plot_tw_stock_radar(
    portfolio=["9939"],
    feats=feats,
    mode="line_polar",
    cut_bins=8
)

本益比河流圖

使用 PE 或 PB 的最高與最低值繪製河流圖,判斷指標所處位階。

from finlab.plot import plot_tw_stock_river

plot_tw_stock_river(
    stock_id='2330',
    start='2015-1-1',
    end='2022-7-1',
    mode='pe',
    split_range=10
)

策略部位旭日圖

監控多策略的部位配置,以旭日圖呈現。

from finlab.plot import StrategySunburst

strategies = StrategySunburst()
strategies.plot().show()