Alpha, in a general sense, represents the excess return an investment generates relative to a benchmark or a risk-adjusted return. It can be positive (indicating the investment outperformed the benchmark) or negative (indicating underperformance).

The formula is as follows:

\[\text{Alpha} = \text{Asset's Actual Return} - \text{Benchmark's Actual Return}\]

See definition: https://en.wikipedia.org/wiki/Alpha_(finance)

Also known as: excess return, outperformance, active return.

Alpha in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_alpha as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["COST", "WMT", "TGT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2020-01-01",
    end_date="2025-12-31",
)

toolkit.performance.get_alpha()

Or, after setting up the Finance Toolkit MCP, ask:

By how much did Costco, Walmart and Target beat or trail the S&P 500 in each year from 2021 to 2025?

Which returns:

Date COST WMT TGT
2021 0.2309 -0.2676 0.0418
2022 -0.0087 0.1772 -0.1606
2023 0.2282 -0.133 -0.2753
2024 0.1474 0.4911 -0.2715
2025 -0.2311 0.0677 -0.4221

Parameters

get_alpha accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”."quarterly"
show_full_resultsboolWhether to show the actual and benchmark returns next to the Alpha. Defaults to False.True
rollingintThe rolling window size to use for the calculation. If set, Alpha is calculated as the rolling mean excess return over this many periods across the full return history instead of per period. Defaults to None.4
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the ratios. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
Share