Docs
Open Studio

Resources

Glossary

On this page5

Look up any term from the docs here: a one-line plain definition, how it is written in code and the page that covers it in detail.

Stock selection and backtesting

TermIn codeMeaning
backtestreport = sim(position, resample='M')Evaluate strategy performance using historical data. See Backtesting
positionposition = close > ma20The stocks currently held and their weights; True means hold that stock on that day. See Stock selection
entryentry_signal = close > ma20The point at which a strategy generates a buy signal. See Stock selection
exitexit_signal = close < ma20The point at which a strategy generates a sell signal. See Stock selection
hold until exitentry_signal.hold_until(exit_signal)Buy when the entry signal is True and hold until the exit signal is True. See Stock selection
stop lossstop_loss=0.1Automatically close a position when losses reach a certain percentage; 0.1 means exit at a 10% loss. See Risk management
take profittake_profit=0.2Automatically close a position when profits reach a certain percentage; 0.2 means exit at a 20% gain. See Risk management
rebalanceresample='M'Periodically adjust position weights to the target allocation; 'M' means monthly rebalancing. See Backtesting

Portfolios and orders

TermIn codeMeaning
portfolioPortfolio({'Strategy A': (report1, 0.5), ...})A collection of strategies, each with a weight. See Multi-strategy portfolio
PositionPosition.from_report(report, fund)The holdings an order is built from: symbols mapped to quantities (shares in a US account). See Orders
OrderExecutorOrderExecutor(position, account=account)Creates orders on a broker account to reach a target position; create_orders(view_only=True) previews without sending. See Orders
disposition stockexecutor.show_alerting_stocks()A Taiwan-market stock under disposition that requires cash or shares to be deposited at the broker before it can be traded; the method lists them among new orders. See Orders

Data

TermIn codeMeaning
DataFrameclose = data.get('price:adj_close') after data.set_market('us')The tabular data structure from pandas. In FinLab data, each row is a trading day and each column a stock. See Download data
FinlabDataFrameFinlabDataFrameA custom class extending pandas DataFrame: it aligns dates automatically in operations and adds methods such as technical indicators. See FinlabDataFrame
universewith data.us_universe(index='SP500'):Limits the data downloaded inside the block to the selected stocks. See Download data
lookahead biasA backtest using data that wasn't available yet. A FinLab dataset's dates are the days the data was published and available to you, and sim() trades on the next trading day after a signal, so write rules directly. See Backtesting

Performance metrics

TermIn codeMeaning
annual returnannual_returnAnnualized rate of return for the strategy: the average gain per year. In code it is report.metrics.annual_return(); in report.get_stats() the field is cagr. See Backtesting
Sharpe ratiodaily_sharpeRisk-adjusted return; higher is better. See Backtesting
maximum drawdownmax_drawdownLargest peak-to-trough decline in portfolio value. See Backtesting
win ratewin_ratioThe share of trades that made money. See Backtesting
MAE / MFEreport.display_mae_mfe_analysis()Each trade's maximum adverse (loss) and favorable (profit) movement while held, used to set stops. See Analysis modules
Edge ratiosim(..., mae_mfe_window=...)The MFE/MAE ratio at different holding periods; above 1 means gains outweigh losses. See Analysis modules
Standard terms in the docs

When writing docs, asking questions or searching, use the right-hand terms.

AvoidUse insteadReason
stop-profittake profitIndustry-standard term
dataframeDataFrameFirst letters should be capitalized (following pandas convention)
buy, sell (for signals)entry, exit"Entry/exit" are more precise
re-balance, roll overrebalanceUnified terminology
back testbacktestFollow industry standard

Writing guidelines:

  1. Use the terms above consistently in prose: stop loss, take profit, entry, exit, rebalance, backtest.
  2. Keep code parameters exactly as the API spells them: stop_loss=0.1, take_profit=0.2, resample='M'.
  3. Format code identifiers as code on every mention: sim(), FinlabDataFrame, position.

Next steps

↑↓ Move Enter Open Esc Close