Calculate the Fibonacci Retracement Levels for a given price series.

Fibonacci Retracement Levels are horizontal price levels, derived from ratios found in the Fibonacci sequence, that traders watch as potential support (during a pullback within an uptrend) or resistance (during a bounce within a downtrend) zones. For every date, the swing high and swing low are taken as the rolling maximum high and rolling minimum low over the specified window, and the retracement levels are derived from that high/low pair.

The formula is as follows:

\[\text{Uptrend (retracing down from the high):}\;\; \text{Level} = \text{High} - \text{Ratio} \cdot (\text{High} - \text{Low})\] \[\text{Downtrend (retracing up from the low):}\;\; \text{Level} = \text{Low} + \text{Ratio} \cdot (\text{High} - \text{Low})\]

Also known as: Fibonacci retracement, Fib levels, retracement levels.

Fibonacci Retracement Levels in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_fibonacci_retracement_levels as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["BTCUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_fibonacci_retracement_levels().xs("BTCUSD", level=1, axis="columns").tail(5)

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

What were the Fibonacci retracement levels of Bitcoin from 27 to 31 December 2025?

Which returns:

Date 0.0% 100.0% 23.6% 38.2% 50.0% 61.8% 78.6%
2025-12-27 90541.8 84400 89092.3 88195.6 87470.9 86746.2 85714.3
2025-12-28 90541.8 84400 89092.3 88195.6 87470.9 86746.2 85714.3
2025-12-29 90541.8 84400 89092.3 88195.6 87470.9 86746.2 85714.3
2025-12-30 90541.8 84400 89092.3 88195.6 87470.9 86746.2 85714.3
2025-12-31 90541.8 84400 89092.3 88195.6 87470.9 86746.2 85714.3

Parameters

get_fibonacci_retracement_levels accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”."Close"
windowintThe number of periods over which the rolling swing high (maximum) and swing low (minimum) are determined. Defaults to 14.20
levelslist[float] | NoneThe Fibonacci ratios to calculate levels for. Defaults to the standard [0.0, 0.236, 0.382, 0.5, 0.618, 0.786, 1.0].[0.236, 0.382, 0.5, 0.618]
trendstrWhether to compute retracement levels for an “uptrend” (levels measured down from the high — the conventional direction, used when a prior move was up and price is now pulling back) or a “downtrend” (levels measured up from the low, used when a prior move was down and price is now bouncing). Defaults to “uptrend”."downtrend"
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 retracement levels. 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