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
| Term | In code | Meaning |
|---|---|---|
| backtest | report = sim(position, resample='M') | Evaluate strategy performance using historical data. See Backtesting |
| position | position = close > ma20 | The stocks currently held and their weights; True means hold that stock on that day. See Stock selection |
| entry | entry_signal = close > ma20 | The point at which a strategy generates a buy signal. See Stock selection |
| exit | exit_signal = close < ma20 | The point at which a strategy generates a sell signal. See Stock selection |
| hold until exit | entry_signal.hold_until(exit_signal) | Buy when the entry signal is True and hold until the exit signal is True. See Stock selection |
| stop loss | stop_loss=0.1 | Automatically close a position when losses reach a certain percentage; 0.1 means exit at a 10% loss. See Risk management |
| take profit | take_profit=0.2 | Automatically close a position when profits reach a certain percentage; 0.2 means exit at a 20% gain. See Risk management |
| rebalance | resample='M' | Periodically adjust position weights to the target allocation; 'M' means monthly rebalancing. See Backtesting |
Portfolios and orders
| Term | In code | Meaning |
|---|---|---|
| portfolio | Portfolio({'Strategy A': (report1, 0.5), ...}) | A collection of strategies, each with a weight. See Multi-strategy portfolio |
| Position | Position.from_report(report, fund) | The holdings an order is built from: symbols mapped to quantities (shares in a US account). See Orders |
| OrderExecutor | OrderExecutor(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 stock | executor.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
| Term | In code | Meaning |
|---|---|---|
| DataFrame | close = 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 |
| FinlabDataFrame | FinlabDataFrame | A custom class extending pandas DataFrame: it aligns dates automatically in operations and adds methods such as technical indicators. See FinlabDataFrame |
| universe | with data.us_universe(index='SP500'): | Limits the data downloaded inside the block to the selected stocks. See Download data |
| lookahead bias | A 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
| Term | In code | Meaning |
|---|---|---|
| annual return | annual_return | Annualized 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 ratio | daily_sharpe | Risk-adjusted return; higher is better. See Backtesting |
| maximum drawdown | max_drawdown | Largest peak-to-trough decline in portfolio value. See Backtesting |
| win rate | win_ratio | The share of trades that made money. See Backtesting |
| MAE / MFE | report.display_mae_mfe_analysis() | Each trade's maximum adverse (loss) and favorable (profit) movement while held, used to set stops. See Analysis modules |
| Edge ratio | sim(..., 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.
| Avoid | Use instead | Reason |
|---|---|---|
| stop-profit | take profit | Industry-standard term |
| dataframe | DataFrame | First letters should be capitalized (following pandas convention) |
| buy, sell (for signals) | entry, exit | "Entry/exit" are more precise |
| re-balance, roll over | rebalance | Unified terminology |
| back test | backtest | Follow industry standard |
Writing guidelines:
- Use the terms above consistently in prose: stop loss, take profit, entry, exit, rebalance, backtest.
- Keep code parameters exactly as the API spells them:
stop_loss=0.1,take_profit=0.2,resample='M'. - Format code identifiers as code on every mention:
sim(),FinlabDataFrame,position.
Next steps
- Risk management Stop loss and take profit in detail.
- Download data Using DataFrames and finding dataset names.
- Multi-strategy portfolio Combine several strategies into a portfolio.
- Backtesting Backtest settings and performance metrics.
Was this page helpful?