FinLab

raw JSON →
2.0.3 verified Fri May 01 auth: no python

FinLab is a Python library for Taiwanese stock analysis and backtesting. Current version: 2.0.3. The library provides tools for downloading stock data, technical analysis, and strategy backtesting. It has an active release cadence with breaking changes from v1 to v2.

pip install finlab
error ModuleNotFoundError: No module named 'finlab.data'
cause Using v1 import paths with v2 library.
fix
Change imports to 'from finlab import DataCenter', etc.
error KeyError: 'close'
cause Using English column names instead of Chinese.
fix
Use '收盤價' instead of 'close'.
error FileNotFoundError: [Errno 2] No such file or directory: 'config'
cause In v2, configuration file is no longer supported; need to pass token via login.
fix
Call login('your_token') explicitly.
breaking Version 2.0 completely changed the API. Old code using 'finlab.data' or 'finlab.backtest' will fail. No backward compatibility.
fix Migrate to v2 imports: 'from finlab import ...' instead of 'from finlab.data import ...'.
deprecated Automatic config file detection is deprecated. You must pass the token explicitly via login() or environment variable FINLAB_TOKEN.
fix Set FINLAB_TOKEN env var or call login('your_token').
gotcha DataCenter.get() expects the column name in Chinese (e.g., '收盤價'), not English. Using English names will raise KeyError.
fix Use Chinese column names like '收盤價', '成交量', etc.
gotcha The symbol parameter in DataCenter.get() expects a string without any prefix, e.g., '2330' not 'TW2330' or '2330.TW'.
fix Use plain stock numbers like '2330'.

Authenticate with your token and fetch closing prices for TSMC (2330).

import os
from finlab import DataCenter, login
login(os.environ.get('FINLAB_TOKEN', ''))
dc = DataCenter()
df = dc.get('收盤價', symbol='2330')
print(df.head())