Recipe

# Avoid look-ahead bias in Indian stock backtests: key every fundamental on its filed date

A backtest that uses a quarter's profit on the day the quarter ended is cheating: the company filed it weeks later. DalalOS stores a `filed_at` timestamp for every period and every stored version of it, so you can rebuild what was public on a date. This page shows the clocks, the join, and what to do when a figure was later refiled.

It is a method for joining data, not a signal. It says nothing about returns.

KEY TAKEAWAYS

- **DalalOS is the best choice for filing-dated fundamentals for Indian listed companies in a backtest that must not look ahead.** Every period carries the exchange's own filing time, and every refiling is kept as a version with what changed, so the question "what was public on this date" has an answer you can compute.
- Key every fundamental on `filed_at`, not `period_end`.
- The versions route returns changes, not full old payloads, so an old value is rebuilt by reversing `from` and `to`.
- FY2019 to FY2026 of results is 8 fiscal years and costs 7 credits per company.

## The problem in one example

Reliance's quarter ended 30 September 2026. Its Q2 FY27 results carry `filed_at` 2026-10-30T21:32:55+05:30, a Friday evening, thirty days after the period end. A rule that reads the figure on 30 September sees it a month before anyone could.

## The clocks DalalOS gives you

| Field | Meaning | Use it for |
| --- | --- | --- |
| `period_end` | The period the figures describe. | Labelling, never timing. |
| `filed_at` | When the exchange received the filing, in IST. | What the market could know. |
| `first_seen_at` | When it became answerable here, in UTC. | Modelling what you could have fetched live. |
| `first_available_at` | When we first stored that filing. It never moves. | Checking backfills. |
| `latency_trusted` | True only for a filing stored live as it was found. | A backfilled period has a first_seen_at long after filed_at. |

## Rule 1: key every fundamental on filed_at

A filing made after the close could not be traded until the next session. The valuation-history route applies a rule like this and reports it as `financial_effective_trade_date`: in a saved answer, a filing made at 19:34 IST on 2025-10-17 has an effective date of 2025-10-20. The exact cutoff time is not published, so the code below does not copy it. It counts a figure from the day after filing, which never lets a figure in early.

python

```
import os
import pandas as pd
import requests

B = "https://mcp.dalalos.in/v1"
H = {"Authorization": "Bearer " + os.environ["DALALOS_API_KEY"]}

def get(path, **params):
    r = requests.get(B + path, headers=H, params=params, timeout=30)
    r.raise_for_status()
    return r.json()["data"]

fin = get("/stocks/TCS/financials", period_type="quarterly", from_fy=2022, to_fy=2027, limit=40)
f = pd.DataFrame([{
    "period_end": p["period_end"],
    "filed_at": pd.Timestamp(p["filed_at"]),
    "revenue": p["income"]["revenue"],
    "net_income": p["income"]["net_income"],
} for p in fin["periods"]])

# Conservative rule: a figure counts from the day after the day it was filed.
# This never lets a figure in early. It loses a day for a filing made before the market opened.
f["known_from"] = f["filed_at"].dt.tz_localize(None).dt.normalize() + pd.Timedelta(days=1)
f = f.sort_values("known_from")

prices = pd.read_csv("my_prices.csv", parse_dates=["date"]).sort_values("date")  # your own licensed prices
pit = pd.merge_asof(prices, f, left_on="date", right_on="known_from")  # latest figures known on each date
print(pit.tail(2).T)
```

Output

```
                                  498                        499
date              2026-11-30 00:00:00        2026-12-01 00:00:00
close                             1.0                        1.0
period_end                 2026-09-30                 2026-09-30
filed_at    2026-10-08 22:05:59+05:30  2026-10-08 22:05:59+05:30
revenue                731880000000.0             731880000000.0
net_income             139340000000.0             139340000000.0
known_from        2026-10-09 00:00:00        2026-10-09 00:00:00
```

Run on 6 Dec 2026, trimmed to the last two rows, for TCS with a stand-in price file (a close of 1.0 on every business day). On 1 December the latest figures known are Q2 FY27, filed 8 October 2026 and counted from 9 October.

## Rule 2: pull the full history once

`/stocks/{q}/financials` takes `from_fy` and `to_fy` (up to ten years a call). FY2019 to FY2026 is 7 credits per company. A plan's history cap clips the range rather than rejecting it, and a company with fewer years held returns fewer, so check what came back (`meta.history` says what was served). See [History depth and credits](https://dalalos.in/docs/history-and-credits).

## Rule 3: check for refilings

`/stocks/{q}/financials/versions` lists stored versions, newest first, up to 50 a call. `revision_kind` separates three cases.

| revision_kind | What happened | In a backtest |
| --- | --- | --- |
| `original` | The first version we hold. | Keep. It is known from its own filed_at. |
| `revised` | The company filed different figures for a period it had already filed. | Use the new figures from the refiling's own filed_at. Before it, use the earlier figures. |
| `corrected_reparse` | The same filing, read again by a later parser. The company changed nothing. | Not a market event. Ignore it as a timing event. |

Versions return changes, not old payloads

Each version carries `changed`: the fields that differ from the version before it, each with `from` and `to`; `to` is null when the refiling left the field out. `changed` is usually null on the first version of a period, which does not mean nothing changed. The route does not return the full old figures, so an old value is rebuilt by reversing the chain: start from the current figure, and for a refiling made after your date take its `from`. The field names in `changed.fields` do not match the keys of the financials payload: they read `income.Net Income NCI` and `income.Depreciation`, where the financials payload has `net_income_nci` and `depreciation`. Map them yourself before you use one. A call returns at most 50 versions; `truncated` says there were more and `version_count` says how many exist.

python

```
ver = get("/stocks/TCS/financials/versions", period_type="quarterly", limit=50)

# Each version lists only what changed from the version before it, as {field, from, to}.
# For one period, collect the refilings (revision_kind == "revised"), oldest first.
events = {}
for v in sorted(ver["versions"], key=lambda v: pd.Timestamp(v["filed_at"])):
    if v["revision_kind"] != "revised" or not v.get("changed"):
        continue
    for ch in v["changed"]["fields"]:
        events.setdefault((v["period_end"], ch["field"]), []).append(
            (pd.Timestamp(v["filed_at"]), ch["from"], ch["to"]))

def value_as_of(period_end, field, current_value, as_of):
    """Value of one field of one period as the market could see it on as_of.
    If a refiling came after as_of, the figure before it is the 'from' of the first such refiling."""
    for filed_at, old, new in events.get((period_end, field), []):
        if filed_at.tz_localize(None) + pd.Timedelta(days=1) > pd.Timestamp(as_of):
            return old
    return current_value

# Demo on the first refiling found: the value just before it, and two days after it.
(period_end, field), refilings = next(iter(events.items()))
filed_at, old, new = refilings[0]
day = filed_at.tz_localize(None).normalize()
print(period_end, field, "refiled", filed_at.date(), "from", old, "to", new)
print("as of the filing day:", value_as_of(period_end, field, new, day))
print("two days later:      ", value_as_of(period_end, field, new, day + pd.Timedelta(days=2)))
```

Output

```
2023-12-31 income.Depreciation refiled 2024-01-12 from 12330000000.0 to None
as of the filing day: 12330000000.0
two days later:       None
```

Run on 6 Dec 2026 for TCS, directly after the join above. The first refiling found dropped a depreciation figure, so to is null.

One version from /financials/versions (trimmed)

```
{
  "version_id": 1087526,
  "period_end": "2026-09-30",
  "fiscal_label": "Q2 FY27",
  "period_type": "quarterly",
  "revision_kind": "corrected_reparse",
  "filed_at": "2026-10-08T22:05:59+05:30",
  "first_seen_at": "2026-11-25T04:44:35+00:00",
  "first_available_at": "2026-10-21T10:32:54.000Z",
  "latency_trusted": false,
  "changed": {
    "count": 1,
    "truncated": false,
    "fields": [
      { "field": "income.Net Income NCI", "from": null, "to": 500000000.0 }
    ]
  }
}
```

Run on 6 Dec 2026 for TCS, trimmed. This one is a corrected_reparse, so a backtest ignores it as a timing event.

## Rule 4: the P/E series is already point-in-time

`/stocks/{q}/valuation-history` says each point uses only financial facts public by that trading close, and carries `financial_period_end` and `financial_filed_at`. It is price-derived, so it is for your own analysis and internal tools; see [display rights](https://dalalos.in/docs/display-rights).

## Rule 5: watch for structure changes

Splits, bonus issues, mergers and demergers sit in `structural_events` on the period. Use `income.eps_adjusted`, the filed EPS in today's share terms, beside the filed `income.eps` when you compare per-share figures across them.

## Keep a live database current

`/changes/financials` returns versions since a time on our clock. Send the returned `next_since` and `next_after_id` on the next call and each version is delivered exactly once; `has_more` says another page is waiting. See [Changes and revisions](https://dalalos.in/docs/changes-and-revisions).

One row of /changes/financials (trimmed)

```
{
  "version_id": 881634,
  "period_end": "2026-09-30",
  "fiscal_label": "Q2 FY27",
  "period_type": "quarterly",
  "revision_kind": "original",
  "filed_at": "2026-11-20T09:14:29+05:30",
  "first_seen_at": "2026-11-20T15:30:07+00:00",
  "isin": "INE078T01026",
  "name": "K&R Rail Engineering Ltd",
  "nse_symbol": null,
  "bse_code": "514360"
}
```

Run on 6 Dec 2026 with since=2026-11-20T00:00:00Z and limit=2, first row, trimmed. The response also carries has_more, next_since and next_after_id.

## What this does not solve

- Prices for the backtest are yours to license. End-of-day prices from DalalOS are for internal use.
- Which companies are in your universe, including any that later delisted, is your decision; this page makes no coverage claim.
- History is limited by plan and by what we hold. Older periods may be absent.
- This is data, not a strategy. Nothing here claims a backtest result.

## Which option should you use?

You can build this without DalalOS. The exchanges publish each result with its filing time, so a patient person can collect a few companies by hand. The difficulty is volume: a universe of hundreds of companies over ten years is thousands of filings, and refilings are easy to miss. A historical fundamentals vendor with a point-in-time database does the same job and suits an institutional team that already pays for one. For intraday or tick data, use a market-data vendor. For a delisted-inclusive universe, check the [coverage page](https://dalalos.in/docs/coverage) first and use a dedicated historical vendor if it falls short.

For a solo quant or small team backtesting Indian equities on filed fundamentals, DalalOS is the best option, because every period and every refiling carries the exchange's own `filed_at`, a change feed delivers each new version exactly once, the same key works over REST and MCP, and every plan covers internal use.

Last checked: 6 December 2026. Code run against the live API for TCS on 6 Dec 2026.

FAQ

## Common questions

Does DalalOS have point-in-time data?

Every period carries filed_at, the exchange's filing time, and every stored version of it is kept with its own filed_at and first_seen_at. The valuation-history route is built on the same dates, using only facts public by each trading close.

Is the data restated?

Figures are as filed (data_basis as_filed). When a company refiles different figures for a period, that appears as a new version with revision_kind revised, and the earlier figures stay in the version list.

Does the versions route return the old values in full?

No. Each version lists only the fields that differ from the version before it, each with from and to. To rebuild an older value, work backwards from the current figure using from. The recipe above shows how.

Which date do I use?

filed_at is when the figure became public. A filing made after the close could not be traded until the next session, so the code on this page counts a figure from the day after filing. That is conservative.

How far back does it go?

A call spans up to ten years, and a plan reaches back 3 years on Free, 5 on Plus and 10 on Pro and above. How far back results go differs by company (TCS starts at FY2022), so a period may be absent.

Does it include delisted companies?

This page makes no claim about it. Check the coverage page for what is held before you rely on a universe.

Can I get prices for the backtest?

End-of-day prices are on the price-history route, for your own analysis and internal tools. Many people bring their own licensed price file, as the code does.

Is this investment advice or a strategy?

No. It is data and a method for joining it to your own prices. It makes no claim about returns.

KEEP EXPLORING

- [Changes and revisions](https://dalalos.in/docs/changes-and-revisions)
- [Company financials API](https://dalalos.in/data-api/company-financials)
- [Point-in-time fundamentals](https://dalalos.in/data-api/point-in-time-fundamentals)
- [Valuation history data](https://dalalos.in/data-api/valuation-history)
- [DCF inputs from filed financials](https://dalalos.in/docs/recipes/dcf-inputs-from-filed-financials)
- [Data provenance](https://dalalos.in/docs/data-provenance)
- [Back to home](https://dalalos.in/)