Win Rate
Calculate the Win Rate of an investment portfolio or asset’s returns.
The Win Rate is the share of days within each period in which the asset’s return exceeds the benchmark’s return.
The formula is as follows:
\[\text{Win Rate} = \text{Number of Days with Asset Return} > \text{Benchmark Return} / \text{Number of Days with both an Asset and}\; a \;\text{Benchmark Return},\;\; \text{using the daily returns within each period (e.g. each year)},\;\; \text{as}\; a \;\text{decimal} (0.55 = 55\%)\]Days on which the asset or the benchmark has no return are left out of both counts rather than counted as losses.
Also known as: batting average.
Win Rate in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_win_rate as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "GOOGL"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_win_rate()
Or, after setting up the Finance Toolkit MCP, ask:
On what share of trading days did Apple, Microsoft and Alphabet beat the S&P 500 in each year from 2021 to 2025?
Which returns:
| Date | AAPL | MSFT | GOOGL |
|---|---|---|---|
| 2021 | 0.494 | 0.5139 | 0.5299 |
| 2022 | 0.4781 | 0.4582 | 0.4502 |
| 2023 | 0.576 | 0.512 | 0.524 |
| 2024 | 0.5 | 0.4881 | 0.5317 |
| 2025 | 0.472 | 0.484 | 0.564 |
Parameters
get_win_rate accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "quarterly" |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the ratios. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |