Look-Ahead Bias
Look-ahead bias arises when an analysis uses information that was not yet available at the date it is applied to. A backtest that buys a stock on 31 December because of its profit for that year uses figures that the company only published weeks later, so the strategy trades on knowledge the market did not have and its returns are too good to be true. Revised economic data, restated financial statements and today’s analyst estimates for past years carry the same problem.
Banz and Breen (1986) showed that results in finance research change when accounting data is matched to prices only once it was actually available, and Fama and French (1992) matched the figures of a fiscal year to returns from June of the following year onwards to make sure the statements had been published.
The Finance Toolkit applies the figures of a financial statement from the last day of the fiscal period they cover, never before: the daily ratios use a period’s figures from its period end and the price-based ratios take the close of that day. That avoids mixing in figures of a period that had not yet ended, but a company files its statements weeks later. With point in time switched on when creating the Toolkit, each period counts from the day its figures were filed with the SEC, as FinancialModelingPrep reports, the statements leave out the periods filed after the end date and the US economic series of FRED are taken as first published. Tickers without filing dates are then left out, and the figures are those reported today, so later restatements remain.
Example · AAPL, MSFT · 2023 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2023-01-01",
end_date="2025-12-31",
point_in_time=True,
)
toolkit.ratios.get_price_to_earnings_ratio(show_daily=True).loc["2025-10-27":"2025-11-04"]
Which returns:
| Item | AAPL | MSFT |
|---|---|---|
| 2025-10-27 | 44.1863 | 38.9641 |
| 2025-10-28 | 44.2176 | 39.7375 |
| 2025-10-29 | 44.3326 | 39.6994 |
| 2025-10-30 | 44.6121 | 38.5419 |
| 2025-10-31 | 36.2184 | 37.9591 |
| 2025-11-03 | 36.0415 | 37.9019 |
| 2025-11-04 | 36.1742 | 37.704 |
References
- Paper Banz, R.W. & Breen, W.J. (1986). “Sample-Dependent Results Using Accounting and Market Data: Some Evidence.” The Journal of Finance, 41(4), 779-793.
- Paper Fama, E.F. & French, K.R. (1992). “The Cross-Section of Expected Stock Returns.” The Journal of Finance, 47(2), 427-465.