Fair Value Gaps

Mark the fair value gaps and their order blocks in every ticker’s candles: three-candle price imbalances that a fast move leaves behind and the last opposite candle before that move, levels that prices often return to.

A fair value gap is the part of the middle candle of three that the first and the third candle do not overlap: in a bullish gap the low of the third candle lies above the high of the first, so the price range in between traded only once, in one direction. A bearish gap is the mirror image. Traders expect prices to come back to fill the gap, and read the gap as support (bullish) or resistance (bearish) when they do. The order block is the last candle against the move before the middle (displacement) candle: the last down candle before a bullish gap, the last up candle before a bearish one, where the large orders behind the move are taken to rest.

A Bullish Gap (1) has Low > High(t-2) and a Bearish Gap (-1) High < Low(t-2). The Order Block is the High and Low of the last candle with Close < Open (bullish gap) or Close > Open (bearish gap) among the order_block_window candles before t-1.

The formula is as follows:

\[\text{Gap Top} = \text{Low} \quad \text{if } \text{Low} > \text{High}_{t-2}\] \[\text{Gap Bottom} = \text{High}_{t-2} \quad \text{if } \text{Low} > \text{High}_{t-2}\] \[\text{Gap Top} = \text{Low}_{t-2} \quad \text{if } \text{High} < \text{Low}_{t-2}\] \[\text{Gap Bottom} = \text{High} \quad \text{if } \text{High} < \text{Low}_{t-2}\] \[\text{Gap Size} = \text{Gap Top} - \text{Gap Bottom}\]

Fair value gaps and order blocks come from the ICT (Inner Circle Trader) and Smart Money Concepts community, without a primary publication; the three-candle definition is the one these sources share.

Also known as: fair value gap, FVG, imbalance, price imbalance, order block, smart money concepts, SMC, ICT.

Example · AAPL, MSFT · 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_fair_value_gaps:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2025-01-01",
    end_date="2025-12-31",
)

gaps = toolkit.technicals.get_fair_value_gaps().xs("AAPL", level=1, axis="columns")

gaps.loc[gaps["Fair Value Gap"] != 0, ["Fair Value Gap", "Gap Top", "Gap Bottom", "Order Block Low"]]

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

Which fair value gaps did Apple's share price leave from 25 November to the end of 2025, with the top and bottom of each gap and the low of its order block, on data from the start of 2025?

Which returns:

DateFair Value GapGap TopGap BottomOrder Block Low
2025-01-02-1248.754247.118255.580
2025-01-03-1247.445242.237255.580
2025-01-10-1239.429238.249241.264
2025-01-13-1238.140232.802238.140
2025-01-17-1232.564230.441232.564
2025-01-21-1226.215222.634232.564
2025-01-22-1226.662222.336232.564
2025-01-281228.973223.834219.648
2025-01-291232.148230.302219.648
2025-02-03-1235.322229.985232.148
2025-02-04-1231.582231.275232.148
2025-02-121229.096229.006225.640
2025-02-131233.952233.614225.640
2025-02-141239.335235.333225.640
2025-02-27-1243.228240.795242.741
2025-03-11-1233.148224.289233.148
2025-03-12-1222.680220.227233.148
2025-03-13-1215.957215.351233.148
2025-03-14-1213.434212.481233.148
2025-03-241217.079215.996210.037
2025-03-251218.569217.337210.037
2025-04-03-1217.397206.065217.397
2025-04-04-1219.502198.507219.502
2025-04-07-1199.868192.817219.502
2025-04-141199.779193.442168.048
2025-04-151198.428198.170168.048
2025-04-16-1199.779199.322184.782
2025-04-17-1198.428197.464198.428
2025-04-231201.407192.469188.506
2025-04-241201.546200.206188.506
2025-05-05-1207.465202.698207.465
2025-05-06-1200.772199.272207.465
2025-05-121205.599198.676193.343
2025-05-131207.837199.163196.183
2025-05-19-1208.374208.314208.374
2025-05-20-1208.602207.310208.374
2025-05-22-1203.889201.622203.123
2025-05-23-1199.593196.600203.123
2025-05-281198.787196.600199.593
2025-06-12-1199.454198.569199.454
2025-06-231197.853196.470194.124
2025-07-011204.993202.089198.887
2025-07-021206.982206.236198.887
2025-07-031210.631209.020198.887
2025-07-08-1210.631210.253210.631
2025-07-221211.049210.611208.423
2025-07-30-1211.874211.208211.874
2025-07-31-1209.647208.672211.874
2025-08-071215.375204.197201.035
2025-08-081218.030214.181201.035
2025-08-111223.763219.621201.035
2025-08-131229.408228.542223.763
2025-08-141229.826229.776223.763
2025-08-21-1228.332225.515229.408
2025-08-291230.343229.875222.787
2025-09-031233.320232.345230.343
2025-09-041235.690229.826230.343
2025-09-10-1235.291231.389235.690
2025-09-11-1232.325229.428235.690
2025-09-151233.987229.428224.947
2025-09-161235.272233.470224.947
2025-09-191239.144239.035233.987
2025-09-221247.019240.130235.600
2025-09-231252.455245.207235.600
2025-10-13-1252.017248.582254.974
2025-10-201254.496247.935244.042
2025-10-211260.668252.256244.042
2025-10-23-1260.668259.464260.668
2025-10-271263.476259.464256.865
2025-10-281266.960262.958256.865
2025-11-17-1271.145269.551268.863
2025-11-251274.294272.381264.997
2025-12-021281.649278.031264.997
2025-12-05-1282.317280.164281.649
2025-12-16-1275.859274.543275.859
2025-12-261271.913271.554269.571

76 rows

Parameters

get_fair_value_gaps accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”, in which case the open, high and low prices are adjusted for dividends in the same way. “Close” uses the candles as traded (split-adjusted)."Close"
order_block_windowintThe number of candles before the displacement candle searched for the order block. Defaults to 10.10
signals_onlyboolWhether to return only the periods in which at least one ticker has a gap. Defaults to False.False
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
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Library Shares similar logic as pandas-ta’s smc
Share