File size: 6,287 Bytes
6ed0b9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
license: other
language:
  - en
pretty_name: Yahoo Equity Daily Bars (PIT)
tags:
  - point-in-time
  - pit
  - ziplime
  - backtesting
  - alternative-data
  - finance
  - us_equities
task_categories:
  - time-series-forecasting
size_categories:
  - n<1K
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/data_bundle/**/*.parquet
---

# 📈 Yahoo Equity Daily Bars (PIT)

Daily OHLCV bars for US equities, delivered as a point-in-time ziplime bundle.

Part of the **ziplime Point-in-Time (PIT) data layer** — append-only datasets with an
explicit split between when a fact *happened* (`event_date`) and when it became *known*
(`knowledge_date`). A simulation at time **T** can only ever observe rows with
`knowledge_date <= T`, so restatements, publication lag and hindsight can't leak into a
backtest. The identical code path runs live with **T = now**.

- **Data class:** Market data — daily equity OHLCV
- **Entity domain:** `us_equities` — US-listed equity, keyed by ticker (resolves via the `entity_map` dataset).
- **Origin:** Yahoo Finance (`yfinance`), auto-adjusted daily bars
- **License:** Yahoo Finance terms — research use only
- **Update cadence:** every US trading day, shortly after the 16:00 ET close (`0 22 * * 1-5`)
- **Format:** ziplime Delta Lake bundle (`data_type: PIT_DATA`)

## Why point-in-time?

Backtests on non-price data are systematically optimistic when the data layer has no notion
of *when a fact became known*. Three failure modes this dataset is built to avoid:

1. **Restatements** — a value reported one quarter and revised the next. Storing only the
   final value lets a backtest "know" the revision months early.
2. **Publication lag** — fundamentals keyed by fiscal-period-end, joined to prices at
   period end rather than the (weeks-later) filing date.
3. **Hindsight in derived signals** — a recent model scoring old text has already seen how
   the story ended.

All three are the same bug, and it is fixed in the data layer, not in strategy code.

## Schema

### System columns (every PIT dataset)

| Column | Type | Semantics |
|---|---|---|
| `entity_id` | Utf8 | Stable entity identifier (resolved via the `entity_map` PIT dataset) |
| `event_date` | Timestamp(UTC, µs) | The moment the fact refers to |
| `knowledge_date` | Timestamp(UTC, µs) | The moment it became publicly known — **the only column the as-of filter uses** |
| `knowledge_estimated` | Boolean | `true` if `knowledge_date` was reconstructed by a lag model rather than taken from the source |
| `ingested_at` | Timestamp(UTC, µs) | When our pipeline wrote the row (audit only; never used in as-of) |

### Value columns (this dataset)

| Column | Type | Description |
|---|---|---|
| `open` | Float64 | Session open (auto-adjusted) |
| `high` | Float64 | Session high |
| `low` | Float64 | Session low |
| `close` | Float64 | Session close (auto-adjusted) |
| `volume` | Float64 | Session volume |
| `price` | Float64 | Convenience alias of close |

The logical key of a fact is `(entity_id, event_date)`. A **revision** is a new row with the
same key and a later `knowledge_date`. Written rows are immutable; history is never rewritten.

## As-of access

Inside a ziplime strategy there is **no `T` parameter** — the knowledge moment always equals
the simulation clock (live: wall clock):

```python
async def initialize(context):
    context.ds = await context.pit("finance-yahoo-data")

async def handle_data(context, data):
    # only rows with knowledge_date <= current simulation time are visible
    latest = await context.ds.latest(
        assets=[context.asset], fields=['open', 'high']
    )
    history = await context.ds.as_of(
        assets=[context.asset], fields=['open'],
        event_range=("2022-01-01", None),
    )
```

### Reading it outside ziplime (plain Polars + delta-rs)

```python
import polars as pl

T = "2025-06-01T00:00:00Z"          # "what was known at T"
lf = pl.scan_delta("hf://datasets/ZipLime/finance-yahoo-data/data/data_bundle/yahoo_finance_daily_data/1784755946/data.delta")
as_of = (
    lf.filter(pl.col("knowledge_date") <= T)
      .sort("knowledge_date")
      .group_by(["entity_id", "event_date"], maintain_order=True)
      .last()
)
print(as_of.collect())
```

Delta time-travel (`AS OF <version>`) pins the table for reproducibility; the
`knowledge_date <= T` filter is what enforces point-in-time. They compose: a backtest records
`(dataset, delta_version)` and replays read the table at that version *and* apply the filter.

## Updates

`recipe.py` implements the collection contract `fetch(since: datetime) -> pl.DataFrame` in the
PIT schema above; `ingest.py` dedups and **appends** to the Delta bundle (never rewrites).
The scheduled job in `.github/workflows/update.yml` runs it every US trading day, shortly after the 16:00 ET close.

```python
# recipe.py (contract)
async def fetch(since: datetime) -> "pl.DataFrame": ...
```

## Knowledge-date convention

For quotes `knowledge_date ≈ event_date`: a daily bar is only complete once its session closes, so it is stamped visible from the close of that session. OHLCV is the one class the design doc keeps out of full PIT treatment — this dataset is the bootstrap bundle that seeds the format.

## What's in this repo

```
README.md                     # this card
manifest.json                 # PIT dataset manifest (schema, source, schedule)
recipe.py                     # fetch(since) -> PIT rows
ingest.py                     # dedup + append-only Delta writer
.github/workflows/update.yml  # scheduled ingestion
data/                         # ziplime Delta bundle + registry manifest
  bundle_registry/yahoo_finance_daily_data_1784755946.json
  data_bundle/yahoo_finance_daily_data/1784755946/data.delta/
```

The `data/` bundle is a ready-to-load ziplime Delta Lake market-data bundle (five US equity
tickers, daily bars) that seeds the pipeline and lets you exercise the loader end-to-end
today. Point `pl.scan_delta` (above) at it, or register it with ziplime's
`FileSystemBundleRegistry`.

---

<sub>Generated for the ziplime PIT data-layer prototype. Manifest and schema follow the
ziplime PIT spec; `source.*` fields declare origin and license per the dataset manifest.</sub>