Skip to content

Getting Started

Installation

Supports Windows, macOS, Linux, and Colab; Docker also available.

Online AI Platform

Visit studio.finlab.tw to write strategies through AI conversation — no installation required.

Local AI Coding Assistant (Recommended)

Install the FinLab Skill in Claude Code, Cursor, Windsurf, or other AI coding tools. The AI learns the entire FinLab API and helps you write strategies, look up data fields, and debug backtests.

  1. Go to finlab.finance for the Skill installation link
  2. Follow the instructions to add the Skill to your AI coding tool
  3. Start a conversation, e.g.: "Write a revenue growth breakout strategy and backtest it"

What the Skill covers

Data access (data.get), backtesting (backtest.sim), factor analysis, machine learning (finlab.ml), live trading, and the full API. The AI assistant can write, run, and debug code for you.

# Run in a new Colab notebook
!pip install finlab
pip install finlab

Compatibility note

If you encounter dependency issues, try the Docker version instead.

docker pull finlab/jupyter-finlab
docker run -p 8888:8888 finlab/jupyter-finlab
# Open JupyterLab using the URL shown in the terminal

Download Data

Use the following code to download data. You can browse available datasets.

from finlab import data
close = data.get('price:收盤價')
close.tail()
from finlab import data
data.set_market('us')
close = data.get('price:adj_close')
close.tail()

Write a Strategy

Use simple Pandas syntax to write strategy logic. For example, a 300-day high breakout strategy:

from finlab import data

close = data.get('price:收盤價')

# Buy stocks making 300-day highs
position = close >= close.rolling(300).max()
position
from finlab import data

data.set_market('us')
close = data.get('price:adj_close')
close = close[close.index.dayofweek < 5]  # remove weekends

# Buy stocks making 300-day highs
position = close >= close.rolling(300).max()
position

Backtest

from finlab import backtest

report = backtest.sim(position, resample='M')
report.display()

image