finlab
Analyzing stock has never been easier.
What it is and what it does
Finlab is a backtesting framework designed for Taiwan stock market analysis. It provides one-line access to historical price and fundamental data for 2000 stocks, integrates seamlessly with pandas for strategy definition, and executes multi-stock backtests with detailed performance reports. Strategies are written using familiar pandas syntax—boolean conditions on rolling windows, resampling logic, and position signals—making it accessible to traders without deep programming expertise.
The package combines data retrieval, strategy expression, and backtesting into a unified workflow. It handles multi-frequency data alignment automatically and uses Cython-optimized computation to run backtests on large stock universes in seconds. It also supports machine-learning strategy development via qlib integration. The 10 runtime dependencies (requests, numpy, pandas, pyarrow, lz4, tqdm, jinja2, ipython, scipy, cryptography) provide data fetching, numerical computation, and reporting capabilities.
Use it for:
- Test a mean-reversion strategy on 2000 Taiwan stocks over a decade of historical data in minutes.
- Develop and iterate on technical-indicator-based trading rules using pandas rolling-window operations.
- Generate detailed backtest reports with performance metrics to compare strategy variants.
- Prototype machine-learning trading strategies using qlib within the finlab framework.
- Analyze historical stock performance and identify patterns across Taiwan's equity market.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Backtest trading strategies on Taiwan stock market data by writing simple pandas-based logic, with historical data for 2000 stocks and detailed performance analysis.
Yes, with conditions. Install if you are backtesting Taiwan stock strategies and accept GPL-3.0-or-later licensing. The package is actively maintained, supports modern Python versions, and has no known vulnerabilities. Medium install friction from 10 dependencies is typical for data-science workflows. Not suitable if you require proprietary or closed-source derivative work.
Install
finlab on PyPI
pip
pip install finlabuv
uv add finlabpoetry
poetry add finlabInstalling finlab
Before you install
Medium install friction due to 10 runtime dependencies including numpy, pandas, scipy, and cryptography. Package is actively maintained with recent release history and supports modern Python versions (3.9–3.14) across multiple platforms via precompiled wheels.
License in practice
Licensed under GPL-3.0-or-later (copyleft). Any derivative work or distribution must also be open-source under a compatible GPL license; proprietary use or closed-source modifications are not permitted.
Quickstart
from finlab import data, backtest
close = data.get('price:收盤價')
position = close >= close.rolling(300).max()
report = backtest.sim(position, resample='M')
report.display()
Requires Python 3.9 or later; data retrieval depends on finlab's remote database access.
Verify before relying
- Whether the 2000 stocks dataset covers all Taiwan-listed companies or a specific subset.
- Exact historical data depth and date range available beyond 'past ten years' mentioned in description.
- Performance characteristics and typical runtime for backtesting 2000 stocks as claimed.
- Whether qlib machine-learning integration is built-in or requires separate installation.
Package facts
| License | GPL-3.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 10 — requests, numpy, pandas, pyarrow, lz4, tqdm, jinja2, ipython, scipy, cryptography |
| Maintenance | actively maintained — 12 days since the last release |
| First released | |
| Downloads | 77,351/month — #14,533 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: finlab-2.0.17-cp310-cp310-macosx_10_15_universal2.whl; finlab-2.0.17-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; finlab-2.0.17-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; finlab-2.0.17-cp310-cp310-win_amd64.whl; finlab-2.0.17-cp311-cp311-macosx_10_15_universal2.whl; finlab-2.0.17-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; finlab-2.0.17-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; finlab-2.0.17-cp311-cp311-win_amd64.whl; finlab-2.0.17-cp312-cp312-macosx_10_15_universal2.whl; finlab-2.0.17-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; finlab-2.0.17-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; finlab-2.0.17-cp312-cp312-win_amd64.whl; finlab-2.0.17-cp313-cp313-macosx_10_15_universal2.whl; finlab-2.0.17-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; finlab-2.0.17-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; finlab-2.0.17-cp313-cp313-win_amd64.whl; finlab-2.0.17-cp314-cp314-macosx_10_15_universal2.whl; finlab-2.0.17-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; finlab-2.0.17-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; finlab-2.0.17-cp314-cp314-win_amd64.whl
Tags
More Information Analysis packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyarrowpyarrow provides Python bindings to Apache…
permissive · top 100 on PyPI
networkxNetworkX provides data structures and…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
snowflake-snowpark-pythonSnowpark Python provides APIs to query and…
permissive · top 1,000 on PyPI
backtestingBacktesting.py lets you define and test trading…
agpl · top 15,000 on PyPI
vectorbtVectorized backtesting engine that packs…
unclear · top 15,000 on PyPI
tushareFetches historical and real-time Chinese stock…
permissive · top 15,000 on PyPI
efinanceFetches historical and real-time stock, fund,…
permissive · top 15,000 on PyPI
lumibotLumibot is a Python framework for building,…
permissive · top 15,000 on PyPI
pandas_market_calendarsProvides market and exchange trading calendars…
permissive · top 5,000 on PyPI
baostockBaoStock retrieves historical China stock…
permissive · top 15,000 on PyPI
finance-datareaderFetches historical and current financial…
permissive · top 15,000 on PyPI
stockstatsAdds technical analysis indicators and…
permissive · top 15,000 on PyPI
stockfishWraps the Stockfish chess engine to let Python…
permissive · top 5,000 on PyPI