Docs
Open Studio

API reference

API Reference Overview

On this page4

This page lists every module in the FinLab package and what each one does. Writing a strategy usually takes four of them, in this order:

from finlab import data, backtest

data.set_market('us')
close = data.get('price:adj_close')            # finlab.data: load data
position = close >= close.rolling(300).max()   # FinlabDataFrame: write the rule
report = backtest.sim(position, resample='M')  # finlab.backtest: backtest
report.display()                               # finlab.report: read the results

Look up the others when you need them. Each page opens with a "Which function to use" table, then documents every function with its call, parameters and defaults, return value and examples.

From data to backtest

ModulePurpose
finlabSign in to FinLab and manage your credentials.
finlab.dataLoad U.S. and other market data, search datasets, set the stock universe and cache, and compute technical indicators.
FinlabDataFrameAlign data of different frequencies, write selection rules, take the top names by rank, and set entry and exit signals.
finlab.backtestTurn a position signal into a historical backtest, with rebalancing, stops and trading costs.
finlab.reportRead the backtest report: metrics, equity curve, trade log, uploading and sharing.

Analyze and improve a strategy

ModulePurpose
finlab.analysisCheck liquidity, MAE/MFE, stability across periods, drawdowns and excess return.
finlab.optimizeBacktest every combination of several conditions and compare them.
finlab.toolsEvent studies and factor analysis.
finlab.mlBuild machine-learning features and labels and train prediction models.
finlab.plotPlot price candlesticks, treemaps, radar and river charts of financial data, and strategy performance.

Combine strategies and trade live

ModulePurpose
finlab.portfolioCombine strategies, allocate weights, and sync positions with the cloud.
finlab.onlineConnect broker accounts, compare holdings and place orders.
finlab.marketDefine a market's price data, benchmark and trading rules, or add a market of your own.

Next steps

↑↓ Move Enter Open Esc Close