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:
| Date | Fair Value Gap | Gap Top | Gap Bottom | Order Block Low |
|---|---|---|---|---|
| 2025-01-02 | -1 | 248.754 | 247.118 | 255.580 |
| 2025-01-03 | -1 | 247.445 | 242.237 | 255.580 |
| 2025-01-10 | -1 | 239.429 | 238.249 | 241.264 |
| 2025-01-13 | -1 | 238.140 | 232.802 | 238.140 |
| 2025-01-17 | -1 | 232.564 | 230.441 | 232.564 |
| 2025-01-21 | -1 | 226.215 | 222.634 | 232.564 |
| 2025-01-22 | -1 | 226.662 | 222.336 | 232.564 |
| 2025-01-28 | 1 | 228.973 | 223.834 | 219.648 |
| 2025-01-29 | 1 | 232.148 | 230.302 | 219.648 |
| 2025-02-03 | -1 | 235.322 | 229.985 | 232.148 |
| 2025-02-04 | -1 | 231.582 | 231.275 | 232.148 |
| 2025-02-12 | 1 | 229.096 | 229.006 | 225.640 |
| 2025-02-13 | 1 | 233.952 | 233.614 | 225.640 |
| 2025-02-14 | 1 | 239.335 | 235.333 | 225.640 |
| 2025-02-27 | -1 | 243.228 | 240.795 | 242.741 |
| 2025-03-11 | -1 | 233.148 | 224.289 | 233.148 |
| 2025-03-12 | -1 | 222.680 | 220.227 | 233.148 |
| 2025-03-13 | -1 | 215.957 | 215.351 | 233.148 |
| 2025-03-14 | -1 | 213.434 | 212.481 | 233.148 |
| 2025-03-24 | 1 | 217.079 | 215.996 | 210.037 |
| 2025-03-25 | 1 | 218.569 | 217.337 | 210.037 |
| 2025-04-03 | -1 | 217.397 | 206.065 | 217.397 |
| 2025-04-04 | -1 | 219.502 | 198.507 | 219.502 |
| 2025-04-07 | -1 | 199.868 | 192.817 | 219.502 |
| 2025-04-14 | 1 | 199.779 | 193.442 | 168.048 |
| 2025-04-15 | 1 | 198.428 | 198.170 | 168.048 |
| 2025-04-16 | -1 | 199.779 | 199.322 | 184.782 |
| 2025-04-17 | -1 | 198.428 | 197.464 | 198.428 |
| 2025-04-23 | 1 | 201.407 | 192.469 | 188.506 |
| 2025-04-24 | 1 | 201.546 | 200.206 | 188.506 |
| 2025-05-05 | -1 | 207.465 | 202.698 | 207.465 |
| 2025-05-06 | -1 | 200.772 | 199.272 | 207.465 |
| 2025-05-12 | 1 | 205.599 | 198.676 | 193.343 |
| 2025-05-13 | 1 | 207.837 | 199.163 | 196.183 |
| 2025-05-19 | -1 | 208.374 | 208.314 | 208.374 |
| 2025-05-20 | -1 | 208.602 | 207.310 | 208.374 |
| 2025-05-22 | -1 | 203.889 | 201.622 | 203.123 |
| 2025-05-23 | -1 | 199.593 | 196.600 | 203.123 |
| 2025-05-28 | 1 | 198.787 | 196.600 | 199.593 |
| 2025-06-12 | -1 | 199.454 | 198.569 | 199.454 |
| 2025-06-23 | 1 | 197.853 | 196.470 | 194.124 |
| 2025-07-01 | 1 | 204.993 | 202.089 | 198.887 |
| 2025-07-02 | 1 | 206.982 | 206.236 | 198.887 |
| 2025-07-03 | 1 | 210.631 | 209.020 | 198.887 |
| 2025-07-08 | -1 | 210.631 | 210.253 | 210.631 |
| 2025-07-22 | 1 | 211.049 | 210.611 | 208.423 |
| 2025-07-30 | -1 | 211.874 | 211.208 | 211.874 |
| 2025-07-31 | -1 | 209.647 | 208.672 | 211.874 |
| 2025-08-07 | 1 | 215.375 | 204.197 | 201.035 |
| 2025-08-08 | 1 | 218.030 | 214.181 | 201.035 |
| 2025-08-11 | 1 | 223.763 | 219.621 | 201.035 |
| 2025-08-13 | 1 | 229.408 | 228.542 | 223.763 |
| 2025-08-14 | 1 | 229.826 | 229.776 | 223.763 |
| 2025-08-21 | -1 | 228.332 | 225.515 | 229.408 |
| 2025-08-29 | 1 | 230.343 | 229.875 | 222.787 |
| 2025-09-03 | 1 | 233.320 | 232.345 | 230.343 |
| 2025-09-04 | 1 | 235.690 | 229.826 | 230.343 |
| 2025-09-10 | -1 | 235.291 | 231.389 | 235.690 |
| 2025-09-11 | -1 | 232.325 | 229.428 | 235.690 |
| 2025-09-15 | 1 | 233.987 | 229.428 | 224.947 |
| 2025-09-16 | 1 | 235.272 | 233.470 | 224.947 |
| 2025-09-19 | 1 | 239.144 | 239.035 | 233.987 |
| 2025-09-22 | 1 | 247.019 | 240.130 | 235.600 |
| 2025-09-23 | 1 | 252.455 | 245.207 | 235.600 |
| 2025-10-13 | -1 | 252.017 | 248.582 | 254.974 |
| 2025-10-20 | 1 | 254.496 | 247.935 | 244.042 |
| 2025-10-21 | 1 | 260.668 | 252.256 | 244.042 |
| 2025-10-23 | -1 | 260.668 | 259.464 | 260.668 |
| 2025-10-27 | 1 | 263.476 | 259.464 | 256.865 |
| 2025-10-28 | 1 | 266.960 | 262.958 | 256.865 |
| 2025-11-17 | -1 | 271.145 | 269.551 | 268.863 |
| 2025-11-25 | 1 | 274.294 | 272.381 | 264.997 |
| 2025-12-02 | 1 | 281.649 | 278.031 | 264.997 |
| 2025-12-05 | -1 | 282.317 | 280.164 | 281.649 |
| 2025-12-16 | -1 | 275.859 | 274.543 | 275.859 |
| 2025-12-26 | 1 | 271.913 | 271.554 | 269.571 |
76 rows
Parameters
get_fair_value_gaps accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The 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_column | str | The 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_window | int | The number of candles before the displacement candle searched for the order block. Defaults to 10. | 10 |
signals_only | bool | Whether to return only the periods in which at least one ticker has a gap. Defaults to False. | False |
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 |
show_columns | str | list[str] | None | The 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