資料視覺化
FinLab 提供一系列圖表工具,讓你更方便洞察市場數據!
In [1]:
Copied!
%%capture
!pip install finlab > log.txt
!pip install talib-binary > log.txt
%%capture
!pip install finlab > log.txt
!pip install talib-binary > log.txt
技術指標圖組¶
In [5]:
Copied!
from finlab.plot import plot_tw_stock_candles
from talib import abstract
from finlab.data import indicator
stock_id = '2330' # @param {type:"string"}
recent_days = 1000 # @param {type:"slider", min:200, max:6000, step:1}
adjust_price=False #@param ["False", "True"] {type:"raw"}
resample="D"#@param ["D", "W","M"] {allow-input: true}
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_candles
from talib import abstract
from finlab.data import indicator
stock_id = '2330' # @param {type:"string"}
recent_days = 1000 # @param {type:"slider", min:200, max:6000, step:1}
adjust_price=False #@param ["False", "True"] {type:"raw"}
resample="D"#@param ["D", "W","M"] {allow-input: true}
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)
漲跌幅與成交金額板塊圖¶
巢狀樹狀圖可以顯示多維度資料,並與圖表做互動,將依照產業分類的台股資料絢麗顯示。
In [ ]:
Copied!
from finlab.plot import plot_tw_stock_treemap
start= '2021-07-01' #@param {type:"date"}
end = '2021-07-02' #@param {type:"date"}
area_ind="turnover" #@param ["market_value","turnover"] {allow-input: true}
item="return_ratio" #@param ["return_ratio", "turnover_ratio"] {allow-input: true}
plot_tw_stock_treemap(start,end,area_ind,item)
from finlab.plot import plot_tw_stock_treemap
start= '2021-07-01' #@param {type:"date"}
end = '2021-07-02' #@param {type:"date"}
area_ind="turnover" #@param ["market_value","turnover"] {allow-input: true}
item="return_ratio" #@param ["return_ratio", "turnover_ratio"] {allow-input: true}
plot_tw_stock_treemap(start,end,area_ind,item)
輸入成功!
WARNING:finlab.data:price:收盤價 -- Daily data usage: 113.8 / 5000 MB WARNING:finlab.data:company_basic_info -- Daily data usage: 114.7 / 5000 MB WARNING:finlab.data:price:成交金額 -- Daily data usage: 149.3 / 5000 MB
本益比與市值板塊圖¶
In [ ]:
Copied!
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')
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')
輸入成功!
WARNING:finlab.data:price:收盤價 -- Daily data usage: 1092.5 / 5000 MB WARNING:finlab.data:company_basic_info -- Daily data usage: 1093.4 / 5000 MB WARNING:finlab.data:price:成交金額 -- Daily data usage: 1128.0 / 5000 MB WARNING:finlab.data:price_earning_ratio:本益比 -- Daily data usage: 1142.3 / 5000 MB
財務指標雷達圖¶
比較持股組合的指標分級特性。
In [ ]:
Copied!
from finlab.plot import plot_tw_stock_radar
portfolio = "1101,2330,8942,6263" #@param {type:"string"}
portfolio = portfolio.split(',')
mode = "bar_polar" #@param ['line_polar','bar_polar','scatter_polar'] {allow-input: true}
line_polar_fill='None' #@param ['toself','tonext','None'] {allow-input: true}
if line_polar_fill is "None":
line_polar_fill=None
plot_tw_stock_radar(portfolio=portfolio,mode=mode,line_polar_fill=line_polar_fill)
from finlab.plot import plot_tw_stock_radar
portfolio = "1101,2330,8942,6263" #@param {type:"string"}
portfolio = portfolio.split(',')
mode = "bar_polar" #@param ['line_polar','bar_polar','scatter_polar'] {allow-input: true}
line_polar_fill='None' #@param ['toself','tonext','None'] {allow-input: true}
if line_polar_fill is "None":
line_polar_fill=None
plot_tw_stock_radar(portfolio=portfolio,mode=mode,line_polar_fill=line_polar_fill)
In [ ]:
Copied!
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)
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 or PB 的最高與最低值繪製河流圖,判斷指標所處位階。
In [ ]:
Copied!
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 plot_tw_stock_river
plot_tw_stock_river(stock_id='2330', start='2015-1-1', end='2022-7-1', mode='pe', split_range=10)
策略部位旭日圖¶
監控多策略。
In [ ]:
Copied!
from finlab.plot import StrategySunburst
# 實例化物件
strategies = StrategySunburst()
strategies.plot().show()
from finlab.plot import StrategySunburst
# 實例化物件
strategies = StrategySunburst()
strategies.plot().show()