Skip to content

Data Visualization

FinLab provides a suite of charting tools to help you gain deeper insight into market data. Every function returns a plotly figure; see the finlab.plot reference for all parameters.

Technical Indicator Charts

Use plot_candles to draw candlestick charts from any price series, with support for overlaying multiple EMA lines and technical indicator subplots such as STOCH and RSI.

from finlab import data
from finlab.data import indicator
from finlab.plot import plot_candles

data.set_market('us')
symbol = 'AAPL'

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_candles(
    symbol,
    close=data.get('price:close')[symbol],
    open_=data.get('price:open')[symbol],
    high=data.get('price:high')[symbol],
    low=data.get('price:low')[symbol],
    volume=data.get('price:volume')[symbol],
    recent_days=1000,
    resample='D',
    overlay_func=overlay_func,
    technical_func=technical_func,
)

data.indicator() uses unadjusted prices by default, so the candles above use the unadjusted price:* series too.

Financial Indicator Radar Chart

Compare the indicator rankings of a portfolio's holdings. Supports bar_polar, line_polar, and scatter_polar modes. Each metric is ranked across all stocks and cut into levels, so metrics with different units are comparable.

bar_polar Mode

from finlab import data
from finlab.plot import plot_tw_stock_radar

data.set_market('us')

feats = [
    'us_ratios:gross_profit_margin',
    'us_ratios:operating_profit_margin',
    'us_ratios:net_profit_margin',
    'us_key_metrics:return_on_equity',
]

plot_tw_stock_radar(
    portfolio=['AAPL', 'MSFT', 'NVDA', 'AMZN'], feats=feats, mode='bar_polar'
)

line_polar Mode (Custom Financial Indicators)

You can specify particular financial indicators for comparison and adjust the number of bins.

from finlab import data
from finlab.plot import plot_tw_stock_radar

data.set_market('us')

feats = [
    'us_ratios:gross_profit_margin',
    'us_ratios:operating_profit_margin',
    'us_ratios:net_profit_margin',
    'us_ratios:current_ratio',
    'us_ratios:debt_to_assets_ratio',
]

plot_tw_stock_radar(portfolio=['NVDA'], feats=feats, mode='line_polar', cut_bins=8)

us_ratios:* and us_key_metrics:* hold recent daily snapshots, which suits a latest-value comparison like this one.

Strategy Return Comparison

Compare the returns of your uploaded strategies with the S&P 500 over a period.

from finlab import data
from finlab.plot import StrategyReturnStats

sp500 = data.get('world_index:adj_close')['^GSPC']

stats = StrategyReturnStats('2025-01-01', '2025-12-31', benchmark_return=sp500)
stats.plot_strategy_last_return().show()
stats.plot_strategy_creturn().show()

Strategy Position Sunburst Chart

StrategySunburst draws the holdings of your FinLab cloud strategies as a sunburst grouped by Taiwan industry. It is for Taiwan strategies only; see finlab.plot.

Taiwan Market Charts

These helpers read Taiwan datasets and are for the Taiwan market only:

  • plot_tw_stock_candles(): candlestick chart that loads a Taiwan stock's prices for you.
  • plot_tw_stock_treemap(): nested treemap of Taiwan stocks grouped by market and industry, sized by market value or trading value and colored by return or another dataset.
  • plot_tw_stock_river(): P/E or P/B river chart that shows where a Taiwan stock's valuation sits within its historical range.
from finlab.plot import plot_tw_stock_treemap

# Taiwan market: block area is trading value, color is the return over the period
plot_tw_stock_treemap(
    start='2024-01-02', end='2024-01-31', area_ind='turnover', item='return_ratio'
)