From a5184bb4171e99cc657313fd4e310401f3d46363 Mon Sep 17 00:00:00 2001 From: Boki Date: Sun, 6 Dec 2026 11:25:07 -0500 Subject: [PATCH] chore(m2): execute host/quant verification, fix live blockers, and record M2 closure evidence (T-215) --- CLAUDE.md | 2 +- .../export-curate-inputs-benchmark.ts | 4 +- design/DATA-CONTRACTS.md | 4 +- design/MILESTONES.md | 20 +- design/README.md | 1 + design/data-pipeline/m2-macro-series-map.tsv | 7 + .../data-pipeline/m2-source-field-shapes.md | 696 ++++++++++++++++++ design/m2-close-evidence.md | 152 ++++ .../postgres/src/research-copilot-executor.ts | 15 +- .../test/research-copilot-executor.test.ts | 52 ++ libs/research/src/mcp/protocol.ts | 5 +- libs/research/test/mcp-protocol.test.ts | 31 + scripts/test/verify-m2-quant.test.ts | 44 ++ scripts/verify-m2-quant.ts | 155 +++- tools/curate-etl/src/cli.rs | 70 +- tools/curate-etl/src/lib.rs | 2 +- tools/curate-etl/src/run_curate_bars_1m.rs | 30 +- .../src/run_curate_bars_1m_tests.rs | 57 ++ tools/curate-etl/src/run_mongo.rs | 78 +- tools/curate-etl/src/run_mongo_tests.rs | 8 +- tools/curate-etl/tests/curate_bars_1m.rs | 11 +- 21 files changed, 1370 insertions(+), 74 deletions(-) create mode 100644 design/data-pipeline/m2-macro-series-map.tsv create mode 100644 design/data-pipeline/m2-source-field-shapes.md create mode 100644 design/m2-close-evidence.md diff --git a/CLAUDE.md b/CLAUDE.md index ba04bdbb..d91b0780 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,7 +16,7 @@ Read [AGENTS.md](./AGENTS.md) first for mandatory environment and database safet 3. **Identity & Point-in-Time (`PIT`):** - Key market, fundamental, and feature records by `listing_id` (`instrument_listings`), never bare ticker strings. - Enforce `known_at <= as_of` on every non-price join; never filter universes on current `is_active` or `delisted_at IS NULL`. - - Respect empirical provider adjustment semantics (`eodPrices` has raw OHLC + **split-adjusted volume**; `eodIntraday1M` has **split-adjusted OHLC**; `qmPrices` has raw OHLC + raw `sharevolume`). + - Respect empirical provider adjustment semantics (`eodPrices` has raw OHLC + **split-adjusted volume**; `eodIntraday1M` has **raw OHLCV** across audited US splits with partial ticker coverage, so `qmIntraday` takes precedence on overlap and Canadian/missing tickers; `qmPrices` has raw OHLC + raw `sharevolume`; `qmFinancials` has an Apple-duplication ingestion defect on non-Apple tickers, so `qmFinancials-old` supplies issuer-specific history). 4. **Storage Split (`D1`):** - **DuckDB + Hive Parquet** owns `1d` bars, corporate actions, PIT fundamentals/earnings/shorts/macro, `1d` FX (`CAD.FOREX`), and versioned feature matrices. - **QuestDB `10.2.0`** owns `1m`/`5m`/`1h` intraday and hot streaming bars (`listing_id SYMBOL CAPACITY 65536 NOCACHE`). diff --git a/apps/stock/data-pipeline/benchmarks/export-curate-inputs-benchmark.ts b/apps/stock/data-pipeline/benchmarks/export-curate-inputs-benchmark.ts index 9178e0c2..4f394563 100644 --- a/apps/stock/data-pipeline/benchmarks/export-curate-inputs-benchmark.ts +++ b/apps/stock/data-pipeline/benchmarks/export-curate-inputs-benchmark.ts @@ -84,8 +84,8 @@ function buildSyntheticTables(): { const currency = id % 5 === 0 ? 'CAD' : 'USD'; const mic = currency === 'CAD' - ? cadMics[Math.floor(id / 5) % cadMics.length]! - : usdMics[i % usdMics.length]!; + ? (cadMics[Math.floor(id / 5) % cadMics.length] ?? 'XTSE') + : (usdMics[i % usdMics.length] ?? 'XNYS'); if (id <= OTC_CONTINUITY_COUNT) { listings[i] = { listing_id: id, diff --git a/design/DATA-CONTRACTS.md b/design/DATA-CONTRACTS.md index 837da47a..7a918e69 100644 --- a/design/DATA-CONTRACTS.md +++ b/design/DATA-CONTRACTS.md @@ -12,13 +12,13 @@ Authoritative specification for `data-pipeline`, PostgreSQL reference schemas, D | --- | --- | --- | | `eodPrices` (`845.7M`) | `open/high/low/close` are **raw**, **but `volume` is retroactively split-adjusted** (`NVDA` pre-10:1 split `2024-06-07` has `close=1208.88`, `volume=412.39M` = $10\times$ raw; `X.TO` pre-5:1 split has $5\times$ raw volume). Indexes: `{date:1, eodSearchCode:1}` and `{eodSearchCode:1}` (no `{eodSearchCode:1, date:1}`). | Divide historical `volume` by cumulative post-bar split factor so `close * raw_volume` equals true dollar volume; cross-check against `qmPrices.sharevolume`. Query cross-sectional slices by `date` first when scanning MongoDB. | | `qmPrices` (`51.5M`) | `unadjustedopen..unadjustedclose` and `sharevolume` are **genuinely raw** (both price and share count). Index: `{qmSearchCode:1, date:1}`. | Use as primary raw-volume truth and cross-check partner for `eodPrices`. | -| `eodIntraday1M` (`3.40B`) | **OHLCV is ALREADY retroactively split-adjusted** (`NEXM.V` pre-1:20 reverse split on `2025-06-18` reports `close=24.29` instead of raw `~1.21`). Covers US deeply back to Dec 2003; sparse/empty on many TSX tickers (`SHOP.TO` has `0` rows). | Un-adjust pre-split OHLCV using cumulative split factors before writing raw `bars_1m` (or never re-apply `adj_factors` on top without un-adjusting first!). Verify `1m` session close vs raw `bars_1d.close`. | +| `eodIntraday1M` (`3.40B`) | **OHLCV is ALREADY RAW (unadjusted)** across live US forward & reverse splits (`AAPL.US` 7:1 2014 & 4:1 2020, `GE.US` 1:8 2021, `AMZN.US` 20:1 2022, `GOOGL.US` 20:1 2022, `CMG.US` 50:1 2024, `AVGO.US` 10:1 2024; 24/25 audited 2018–2025 splits raw). Coverage is deep for US tickers back to Dec 2003, but partial on later-alphabet tickers (`NVDA.US`, `MSFT.US`, `TSLA.US`, `WMT.US` have `0` rows) and sparse/corrupt on TSX/TSXV (`SHOP.TO` `0` rows; `NEXM.V` has 33 corrupt `~$24.25` rows unrelated to NexMetals Mining `$0.405→$8.40`). | Preserve raw OHLCV by default (`curate-bars-1m --split-mode raw`; `--split-mode unadjust` opt-in for legacy adjusted dumps), rely on `qmIntraday` (`bars_1m_qm`) for TSX/TSXV and missing US tickers (`NVDA`, `NEXM:CA`), and cross-check `1m` RTH session closes against raw `bars_1d.close`. | | `qmIntraday` (`173.3M`) | Stores **both** raw (`open..close`, `sharevolume`) and adjusted (`adjustedopen..adjustedclose`, `avolume`). Covers TSX/CA (`SHOP:CA`, `X:CA`) from ~May 2024 onward. | Primary `1m` intraday source for Canadian listings where `eodIntraday1M` is empty, and split-calibration truth for overlapping symbols. | | `eodSymbols` (`317.8k`) | `103.8k` rows have composite `eodExchange="US"`, of which **`44,970` (`43.3%`) have `Exchange="NMFQS"` (mutual funds)**, `18,114` `PINK`, `15,858` `NASDAQ`, `9,879` `NYSE`. `52,745` US + `3,136` CA rows have `delisted=true`. EOD retroactively renames changed tickers (`META.US` holds 2012–2022 Facebook; `FB.US` is now a 2025 ProShares ETF) and overwrote pre-bankruptcy `GM.US` (`starts 2010-11-18`) and `HTZ.US` (`starts 2021-07-01`). | Resolve US MIC from `eodSymbols.Exchange` (not `eodExchange="US"`); exclude `NMFQS` from equity universes; never assume `Code.US` is a single historical company without checking bar spans and `qmFilings`. | | `ibSymbols` (`18,402`) | Fields use **`exchangeId`** and **`description`** (which legacy `provider-symbol.ts` ignored). `100%` ISIN/CUSIP/`conid`, **but `exchangeId` is an execution/ATS venue, NOT primary listing MIC**: CA has `AEQLIT=2,506` (`65%`) vs `TSE=514`; US has `OTCLNKECN=6,627`, `ARCAEDGE=1,067`, `BEX=777`, `DRCTEDGE=682`, `IEX=509` vs **`NYSE=370` (`2.5%`) and `NASDAQ=241` (`1.7%`)**! Contains placeholder/checksum-bad ISINs (`CATSETEST001`, `CA00149WBAD4`, `CA8131391062` for `SCU.UN`). | **Never block `ibSymbols` on MIC.** Validate ISIN Luhn check digit (derive `US`/`CA` + CUSIP + check digit when ISIN checksum fails on a valid 9-char CUSIP), match globally to `instrument`, and attach `conid` to `listing` by `(instrument_id, currency)`. | | `qmSymbols` (`47,243`) | `0%` ISIN/CUSIP; `15,790` US + `3,626` CA rows have `active=false`. Contains duplicate `(symbol, exchange)` pairs on CSE (`VOY:CNX` active + `VOY:CC` inactive). | Disambiguate via `active` flag, `qmSearchCode`, and observed `[first_bar_date, last_bar_date]` overlap. | | `ceoSymbols` (`12,589`), `ceoPosts` (`14.78M`), `ceoShorts` (`692.9k`) | 100% Canadian (`CNQ=4,583`, `TSX=4,127`, `CDX=3,292`, `AQL=587`). `ceoSymbols.symbol` embeds `.TO`/`.V` suffixes. `ceoPosts` has `1.8%` edited posts (`edited != null` mutates `spiel`) and `bot="1"` (`@thenewswire`). `ceoShorts.timestamp` is the 15th / month-end **report period date**, NOT CIRO dissemination date. | Map `TSX→XTSE`, `CDX→XTSX`, `CNQ→XCNQ`, `AQL→NEOE`; strip embedded `.TO`/`.V`; separate `bot="1"` posts and set text `known_at = COALESCE(edited, timestamp)`; set `ceoShorts` `known_at = timestamp + 4 Canadian business days (17:00 ET)`. | -| `qmFinancials` (`1.86M`), `qmFinancials-old` (`908k`) | Standardized `BalanceSheet`, `CashFlow`, `IncomeStatement`, `periodEndDate`, `reportDate` — **`0%` `filingDate` and `0` restatement versions** (overwritten in place). | Derive `known_at` by joining `(listing_id, periodEndDate)` to `qmFilings.timefiled`; where unlinked, add statutory deadline lag (`+45d Q / +90d FY` US & TSX; `+60d Q / +120d FY` TSXV/CSE) with `known_at_source = 'statutory_lag_estimate'`. | +| `qmFinancials` (`1.86M`), `qmFinancials-old` (`908k`) | Standardized `BalanceSheet`, `CashFlow`, `IncomeStatement`, `periodEndDate`, `reportDate` — **`0%` `filingDate` and `0` restatement versions** (overwritten in place). **Live QA MongoDB caveat (verified 2026-12-06):** `qmFinancials` contains Apple (`AAPL`) financial figures (`2011-12-31` rev `$46.333B` / NI `$13.064B`, `2025-03-29` rev `$95.359B`, `currency="USD"`) duplicated across unrelated symbols (`BMO:CA`, `RY:CA`, `SHOP:CA`, `CNQ:CA`, `X:CA`), whereas `qmFinancials-old` (`balancesheet`, `cashflow`, `income`, `reportDate`, `reportType`, `symbol`) carries distinct issuer-specific figures (`BMO` rev `$4.458B`, `RY` rev `$12.539B`, `SHOP` rev `$1.714B`, `CNQ` rev `$11.762B`). | **Quarantine `qmFinancials` until re-ingested with verified per-issuer payloads**; use `qmFinancials-old` (or validated re-ingested financials) joined to `qmFilings.timefiled`, falling back to statutory deadline lags (`+45d Q / +90d FY` US & TSX; `+60d Q / +120d FY` TSXV/CSE) with `known_at_source = 'statutory_lag_estimate'`. | | `eodFinancialsOLD` (`2.98M`), `eodFundamentalsOLD` (`106.6k`) | `eodFinancialsOLD` sets `filingDate == reportDate` on **`99.26%`** of rows. `eodFundamentalsOLD` has `filing_date: null`, unversioned current valuation ratios, and mislabels USD figures as `"CAD"` on NEO CDRs (`AAPL` CDR `$335B` assets). | **Quarantine `eodFundamentalsOLD` `Highlights`/`Valuation` from all backtests.** Use `eodFinancialsOLD` only for pre-QM historical backfill with mandatory statutory lag (ignoring its `filingDate`). | | `qmFilings` (`30.52M`) | Has exact second-level `timefiled` (`"2025-01-31T06:01:27 EST"`) for both US EDGAR (`10-Q`, `10-K`, `8-K`, `4`, `144`) and **Canadian SEDAR+** (`Interim financial statements/report`, `Annual financial statements`, `MD&A`, `52-109`, `NI 43-101`, `45-106F1`). Metadata + external download URLs only (no parsed Form 4 share counts). | Primary `known_at` clock for `qmFinancials` and `qmEarnings`, plus standalone filing-arrival/form-type event stream. Convert `EST`/`EDT` strings cleanly using `America/New_York` rules. | | `qmEarnings` (`444.9k`) | `66.94%` (`297,779`) have `announceTime="N/A"` (`80,481` `AMC`, `66,605` `BTO`); `consensusEps` is overwritten post-hoc. | Link to same-day `qmFilings` `8-K` / `News release` `timefiled`; if still unknown, set `known_at = reportDate 16:05 ET` (tradable `T+1` open). | diff --git a/design/MILESTONES.md b/design/MILESTONES.md index 36a4289c..d807e60a 100644 --- a/design/MILESTONES.md +++ b/design/MILESTONES.md @@ -80,27 +80,27 @@ Actionable build tracker for turning Stock Bot into the AI algo research & IB li --- -## M2 — MCP Copilot, Intraday QuestDB `10.2.0` & PIT Fundamentals *(Weeks 4–5)* +## M2 — MCP Copilot, Intraday QuestDB `10.2.0` & PIT Fundamentals *(Weeks 4–5 — **CLOSED**, see [m2-close-evidence.md](m2-close-evidence.md))* -**Goal:** Connect desktop Claude Code via MCP, curate 2D point-in-time fundamentals (`qmFinancials × qmFilings`) and split-unadjusted `1m` intraday bars (`QuestDB 10.2.0`), and launch the versioned batch Feature Library. +**Goal:** Connect desktop Claude Code via MCP, curate 2D point-in-time fundamentals (`qmFinancials × qmFilings`) and raw/unadjusted `1m` intraday bars (`QuestDB 10.2.0`), and launch the versioned batch Feature Library. ### Checklist -- [ ] **MCP Server (`web-api` / standalone stdio+SSE wrapper):** +- [x] **MCP Server (`web-api` / standalone stdio+SSE wrapper):** - Expose `search_symbols`, `query_data` (vault-fenced), `analyze_signal`, `event_study`, `file_finding`, `read_knowledge` (serving `~/repos/studio/catalog/quant/library/library.yml` + Postgres `findings`/`provider_caveats`). -- [ ] **PIT Fundamentals & CEO Posts (`Parquet + DuckDB`):** +- [x] **PIT Fundamentals & CEO Posts (`Parquet + DuckDB`):** - Join `qmFinancials` (+ `qmFinancials-old`) to `qmFilings.timefiled` (`10-Q`, `10-K`, `40-F`, SEDAR `Interim/Annual financial statements`), applying `+45d/+90d` (US/TSX) and `+60d/+120d` (TSXV/CSE) statutory lags where unlinked (`known_at_source = 'statutory_lag_estimate'`). - Materialize 2D `(period_end, known_at)` deduplicated wide snapshots + TTM features (`fundamentals_pit`). - Curate `ceoPosts` (`14.8M`) separating `bot == "1"` newswires from retail posts and guarding `edited != null` text timestamps; curate lagged `teData` regime series. -- [ ] **Intraday Curation (`QuestDB 10.2.0`):** +- [x] **Intraday Curation (`QuestDB 10.2.0`):** - Replace legacy `libs/data/questdb` (`LATEST BY` → `LATEST ON`, parameterized PGWire queries, ILP v2 batch writer); verify `vm.max_map_count >= 1048576` and `ulimits.nofile = 1048576` on `quant` before bulk load. - - Extend `tools/curate-etl` with sharded multi-socket ILP v2 writers to stream split-unadjusted `eodIntraday1M` (`3.40B` rows, US 2003–2025), raw `qmIntraday` (CA/US 2024–2025), and `CAD.FOREX` `1m` (`5.2M` bars) into **`PARTITION BY MONTH`** `bars_1m` (`270` partitions across 22.5y) and `fx_1m` (`listing_id SYMBOL CAPACITY 65536 NOCACHE`, `DEDUP UPSERT KEYS(ts, listing_id)`). -- [ ] **Versioned Feature Library (`D04` reopened):** + - Extend `tools/curate-etl` with sharded multi-socket ILP v2 writers to stream raw `eodIntraday1M` (`3.40B` rows, US 2003–2025; `--split-mode raw` default after live corpus audit, optional `--split-mode unadjust`), raw `qmIntraday` (CA/US 2024–2025), and `CAD.FOREX` `1m` (`5.2M` bars) into **`PARTITION BY MONTH`** `bars_1m` (`270` partitions across 22.5y) and `fx_1m` (`listing_id SYMBOL CAPACITY 65536 NOCACHE`, `DEDUP UPSERT KEYS(ts, listing_id)`). +- [x] **Versioned Feature Library (`D04` reopened):** - Build declarative SQL/Polars batch runner writing versioned `(listing_id, ts, known_at, value)` columns + `register_signal(...)` SDK entrypoint. ### Exit Criteria -1. Desktop Claude Code via MCP executes a fundamental + alt-data signal study and event study end-to-end, exports a `marimo check`-clean static HTML snapshot, and files a finding. -2. Restatement fixture test proves a restated Q1 (`known_at > Q2`) never overwrites Q2 in `fundamentalsAsOf`. -3. Split-boundary test on `NEXM.V` (`1:20`) and `NVDA.US` (`10:1`) confirms `bars_1m` session closes match raw `bars_1d` closes within `0.5%`, and 1y of `1m` bars for one listing loads in **`< 250 ms` warm / `< 1 s` cold**. +1. [x] Desktop Claude Code via MCP executes a fundamental + alt-data signal study and event study end-to-end, exports a `marimo check`-clean static HTML snapshot, and files a finding. *(Verified `2026-12-06`; see [m2-close-evidence.md](m2-close-evidence.md).)* +2. [x] Restatement fixture test proves a restated Q1 (`known_at > Q2`) never overwrites Q2 in `fundamentalsAsOf`. *(Verified in Rust `curate-etl`, DuckDB `MarketDataStore`, and Python `stockbot` tests.)* +3. [x] Split-boundary test on `NEXM.V` (`1:20`) and `NVDA.US` (`10:1`) confirms `bars_1m` session closes match raw `bars_1d` closes within `0.5%`, and 1y of `1m` bars for one listing loads in **`< 250 ms` warm / `< 1 s` cold**. *(Verified on `quant` QuestDB `10.2.0`: `NVDA.US` `0.0965%`, `NEXM.V` `0.0000%`, `AVGO.US` `0.0408%`; 1y `CMG.US` `137,382` bars `291.65 ms` cold / `128.74 ms` warm median Pass 1, `207.88 ms` cold / `127.94 ms` warm median Pass 2.)* --- diff --git a/design/README.md b/design/README.md index c7dfa150..67035e8a 100644 --- a/design/README.md +++ b/design/README.md @@ -16,6 +16,7 @@ Start here. Every document below has a single responsibility; historical sprint | **[data-pipeline/rust-migration-evaluation.md](data-pipeline/rust-migration-evaluation.md)** | Evidence-based evaluation of keeping `apps/stock/data-pipeline` in TypeScript vs. moving bulk MongoDB streaming or the full pipeline into Rust (`tools/curate-etl`) | Before `M2` adds PIT fundamentals, `ceoPosts`, or `bars_1m` QuestDB ingestion | | **[m2-completion-audit.md](m2-completion-audit.md)** | Historical read-only Milestone `M2` completion audit prior to `T-205`–`T-207` (`T-204`; superseded by `m2-master-audit.md`) | Historical reference for pre-`T-205` M2 state | | **[m2-master-audit.md](m2-master-audit.md)** | Current read-only Milestone `M2` audit against `master` (post-`T-205`/`T-206`/`T-207`), Done/Partial/Missing matrix, director trade-offs, and 7-task M2 closure backlog (`T-208`) | Before closing `M2`, queuing remaining `M2` tasks, or starting `M3` | +| **[m2-close-evidence.md](m2-close-evidence.md)** | Milestone `M2` closure evidence (`T-215`): host check gates, read-only QA MongoDB probe, `quant` QuestDB `10.2.0` verification & split-boundary/latency receipts, and desktop Claude Code EC-1 sign-off | Reference for closed `M2` verification receipts and live-data caveats before starting `M3` | --- diff --git a/design/data-pipeline/m2-macro-series-map.tsv b/design/data-pipeline/m2-macro-series-map.tsv new file mode 100644 index 00000000..5275568b --- /dev/null +++ b/design/data-pipeline/m2-macro-series-map.tsv @@ -0,0 +1,7 @@ +te_symbol country category country_iso indicator lag_class +CPI YOY United States Inflation Rate US cpi_yoy monthly_release +USURTOT United States Unemployment Rate US unemployment_rate monthly_release +GDP CQOQ United States GDP Growth Rate US gdp_qoq gdp65 +CACPIYOY Canada Inflation Rate CA cpi_yoy monthly_release +CANLXEMR Canada Unemployment Rate CA unemployment_rate monthly_release +CGE9QOQ Canada GDP Growth Rate CA gdp_qoq gdp65 diff --git a/design/data-pipeline/m2-source-field-shapes.md b/design/data-pipeline/m2-source-field-shapes.md new file mode 100644 index 00000000..53c0e724 --- /dev/null +++ b/design/data-pipeline/m2-source-field-shapes.md @@ -0,0 +1,696 @@ +# Source Field Shapes Report + +- **Scope:** bounded sample, not a full scan (head sample via `find().limit()`, no aggregation or `$sample`) +- **Sample limit per collection:** 1000 +- **Collections probed:** 6 +- **Total documents sampled:** 6000 + +## `ceoPosts` (1000 docs sampled) + +| Field | Presence | Types | String Patterns | Examples | +| --- | --- | --- | --- | --- | +| `_id` | 100.0% (1000/1000) | objectId: 1000 | — | — | +| `bot` | 100.0% (1000/1000) | string: 631, null: 369 | numeric: 16, other: 615 (len 1..12) | `1`, `accesswire`, `businesswire` | +| `ceoId` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 1..8) | `A`, `AA`, `AAA-P` | +| `color` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 4..10) | `#000`, `#00bfa3`, `#023252` | +| `created_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-06-22T18:38:14.364Z`, `2025-06-22T18:38:15.795Z`, `2025-06-22T18:38:17.014Z` | +| `editable` | 100.0% (1000/1000) | int: 1000 | — | `0` | +| `edited` | 100.0% (1000/1000) | bool: 4, null: 996 | — | `true` | +| `fake` | 100.0% (1000/1000) | int: 1000 | — | `0` | +| `featured` | 100.0% (1000/1000) | bool: 1000 | — | `false` | +| `flagged` | 100.0% (1000/1000) | bool: 1000 | — | `false` | +| `name` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 2..28) | `@2old2broke`, `@AAGresearch`, `@Ailla` | +| `ownSpiel` | 100.0% (1000/1000) | bool: 1000 | — | `false` | +| `parentChannel` | 100.0% (1000/1000) | string: 687, null: 313 | other: 687 (len 2..68) | `@featured/stock-picking-contest-update-3-mont...`, `@joshy/the-battle-for-glory-ceoca-2024-stock-...`, `@stateside` | +| `parentId` | 100.0% (1000/1000) | string: 687, null: 313 | numeric: 5, other: 682 (len 12..12) | `0018bc1edd14`, `00342cecc114`, `00434432d587` | +| `parentTimestamp` | 100.0% (1000/1000) | double: 687, null: 313 | — | `1488577058073`, `1490183712035`, `1490183892054` | +| `poll` | 100.0% (1000/1000) | null: 1000 | — | — | +| `publicId` | 100.0% (1000/1000) | string: 274, null: 726 | numeric: 1, other: 273 (len 6..12) | `00c160ce40`, `01dc78f726`, `0c4820f140` | +| `savedId` | 100.0% (1000/1000) | null: 1000 | — | — | +| `savedTimestamp` | 100.0% (1000/1000) | null: 1000 | — | — | +| `score` | 100.0% (1000/1000) | int: 296, null: 704 | — | `-2`, `0`, `1` | +| `spiel` | 100.0% (1000/1000) | string: 1000 | emptyOrWhitespace: 1, other: 999 (len 0..9185) | , ` year high event 2018 $0.42 $...`, ` @0691lapero yes we certainly do and deserve ...` | +| `spielId` | 100.0% (1000/1000) | string: 1000 | numeric: 13, other: 987 (len 12..12) | `0015fee4c5c1`, `0057e9747169`, `0064a504097d` | +| `spielReplyTo` | 100.0% (1000/1000) | null: 1000 | — | — | +| `spielReplyToEdited` | 100.0% (1000/1000) | null: 1000 | — | — | +| `spielReplyToId` | 100.0% (1000/1000) | string: 95, null: 905 | emptyOrWhitespace: 95 (len 0..0) | | +| `spielReplyToName` | 100.0% (1000/1000) | null: 1000 | — | — | +| `timestamp` | 100.0% (1000/1000) | double: 1000 | — | `1488577058374`, `1490183712067`, `1490183892125` | +| `updated_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-06-22T18:40:19.335Z`, `2025-06-23T18:26:38.743Z`, `2025-06-24T22:34:01.407Z` | +| `userId` | 100.0% (1000/1000) | null: 1000 | — | — | +| `verified` | 100.0% (1000/1000) | bool: 1000 | — | `false` | +| `voted` | 100.0% (1000/1000) | bool: 1000 | — | `false` | +| `votedInPoll` | 100.0% (1000/1000) | null: 1000 | — | — | +| `votes` | 100.0% (1000/1000) | int: 1000 | — | `0`, `1`, `12` | + +## `eodIntraday1M` (1000 docs sampled) + +| Field | Presence | Types | String Patterns | Examples | +| --- | --- | --- | --- | --- | +| `_id` | 100.0% (1000/1000) | objectId: 1000 | — | — | +| `close` | 100.0% (1000/1000) | int: 13, double: 987 | — | `208.61`, `208.74`, `208.79` | +| `created_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-07-11T02:11:33.617Z` | +| `datetime` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 19..19) | `2025-03-13 08:00:00`, `2025-03-13 08:01:00`, `2025-03-13 08:02:00` | +| `eodSearchCode` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 7..7) | `AAPL.US` | +| `exchange` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 2..2) | `US` | +| `gmtoffset` | 100.0% (1000/1000) | int: 1000 | — | `0` | +| `high` | 100.0% (1000/1000) | int: 13, double: 987 | — | `208.8`, `208.9794`, `209.03` | +| `low` | 100.0% (1000/1000) | int: 19, double: 981 | — | `202.0051`, `208.42`, `208.52` | +| `open` | 100.0% (1000/1000) | int: 10, double: 990 | — | `208.61`, `208.72`, `208.79` | +| `source` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..3) | `eod` | +| `symbol` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 4..4) | `AAPL` | +| `timestamp` | 100.0% (1000/1000) | int: 1000 | — | `1741852800`, `1741852860`, `1741852920` | +| `updated_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-07-14T00:53:24.427Z`, `2025-07-14T00:53:24.428Z` | +| `volume` | 100.0% (1000/1000) | int: 1000 | — | `1`, `10`, `100` | + +## `qmFinancials` (1000 docs sampled) + +| Field | Presence | Types | String Patterns | Examples | +| --- | --- | --- | --- | --- | +| `BalanceSheet` | 100.0% (1000/1000) | object: 1000 | — | — | +| `BalanceSheet.AccountsPayable` | 100.0% (1000/1000) | double: 1000 | — | `14912000000`, `15516000000`, `16808000000` | +| `BalanceSheet.AccountsReceivable` | 100.0% (1000/1000) | double: 1000 | — | `10370000000`, `10788000000`, `10905000000` | +| `BalanceSheet.AccumulatedDepreciation` | 98.5% (985/1000) | double: 985 | — | `-10562000000`, `-11922000000`, `-13800000000` | +| `BalanceSheet.CapitalStock` | 100.0% (1000/1000) | double: 1000 | — | `13961000000`, `14850000000`, `15573000000` | +| `BalanceSheet.Cash` | 98.5% (985/1000) | double: 985 | — | `10121000000`, `10746000000`, `11248000000` | +| `BalanceSheet.CashAndCashEquivalents` | 100.0% (1000/1000) | double: 1000 | — | `10121000000`, `10310000000`, `10746000000` | +| `BalanceSheet.CashCashEquivalentsAndShortTermInvestments` | 100.0% (1000/1000) | double: 1000 | — | `100557000000`, `107162000000`, `25077000000` | +| `BalanceSheet.CashEquivalents` | 31.0% (310/1000) | double: 310 | — | `10310000000`, `10746000000`, `13844000000` | +| `BalanceSheet.CommercialPaper` | 79.2% (792/1000) | int: 90, double: 702 | — | `10000000000`, `10493000000`, `10982000000` | +| `BalanceSheet.CommonStock` | 100.0% (1000/1000) | double: 1000 | — | `13961000000`, `14850000000`, `15573000000` | +| `BalanceSheet.CommonStockEquity` | 100.0% (1000/1000) | double: 1000 | — | `102498000000`, `105860000000`, `107147000000` | +| `BalanceSheet.CurrentAccruedExpenses` | 49.0% (490/1000) | double: 490 | — | `10430000000`, `11414000000`, `11500000000` | +| `BalanceSheet.CurrentAssets` | 100.0% (1000/1000) | double: 1000 | — | `101990000000`, `103332000000`, `106869000000` | +| `BalanceSheet.CurrentCapitalLeaseObligation` | 34.3% (343/1000) | int: 343 | — | `1082000000`, `1084000000`, `1087000000` | +| `BalanceSheet.CurrentDebt` | 82.2% (822/1000) | int: 15, double: 807 | — | `10498000000`, `11000000000`, `11209000000` | +| `BalanceSheet.CurrentDebtAndCapitalLeaseObligation` | 82.2% (822/1000) | int: 15, double: 807 | — | `10498000000`, `11000000000`, `11209000000` | +| `BalanceSheet.CurrentDeferredAssets` | 22.2% (222/1000) | int: 15, double: 207 | — | `1937000000`, `2253000000`, `2309000000` | +| `BalanceSheet.CurrentDeferredLiabilities` | 100.0% (1000/1000) | double: 1000 | — | `12809000000`, `14033000000`, `14085000000` | +| `BalanceSheet.CurrentDeferredRevenue` | 100.0% (1000/1000) | double: 1000 | — | `4886000000`, `5247000000`, `5434000000` | +| `BalanceSheet.CurrentDeferredTaxesAssets` | 52.0% (520/1000) | int: 15, double: 505 | — | `10015000000`, `10911000000`, `18295000000` | +| `BalanceSheet.CurrentDeferredTaxesLiabilities` | 43.0% (430/1000) | double: 430 | — | `10138000000`, `11595000000`, `13073000000` | +| `BalanceSheet.CurrentLiabilities` | 100.0% (1000/1000) | double: 1000 | — | `100814000000`, `102171000000`, `105392000000` | +| `BalanceSheet.FinishedGoods` | 28.2% (282/1000) | int: 192, double: 90 | — | `1081000000`, `1279000000`, `1385000000` | +| `BalanceSheet.GainsLossesNotAffectingRetainedEarnings` | 31.0% (310/1000) | int: 280, double: 30 | — | `-150000000`, `-345000000`, `-3454000000` | +| `BalanceSheet.Goodwill` | 46.0% (460/1000) | int: 178, double: 282 | — | `1132000000`, `1135000000`, `1141000000` | +| `BalanceSheet.GoodwillAndOtherIntangibleAssets` | 46.0% (460/1000) | double: 460 | — | `4368000000`, `4745000000`, `5359000000` | +| `BalanceSheet.GrossPPE` | 98.5% (985/1000) | double: 985 | — | `100917000000`, `103526000000`, `105493000000` | +| `BalanceSheet.IncomeTaxPayable` | 35.7% (357/1000) | int: 237, double: 120 | — | `1200000000`, `1209000000`, `1290000000` | +| `BalanceSheet.InterestPayable` | 77.6% (776/1000) | int: 506, double: 270 | — | `-1003000000`, `-1006000000`, `-1055000000` | +| `BalanceSheet.Inventory` | 100.0% (1000/1000) | int: 281, double: 719 | — | `1102000000`, `1122000000`, `1236000000` | +| `BalanceSheet.InvestmentsAndAdvances` | 100.0% (1000/1000) | double: 1000 | — | `100544000000`, `100592000000`, `100887000000` | +| `BalanceSheet.LandAndImprovements` | 1.5% (15/1000) | double: 15 | — | `2742000000` | +| `BalanceSheet.Leases` | 21.0% (210/1000) | int: 150, double: 60 | — | `1015000000`, `1069000000`, `2930000000` | +| `BalanceSheet.LongTermCapitalLeaseObligation` | 19.5% (195/1000) | double: 195 | — | `10408000000`, `13518000000`, `7745000000` | +| `BalanceSheet.LongTermDebt` | 89.6% (896/1000) | double: 896 | — | `101362000000`, `103323000000`, `103922000000` | +| `BalanceSheet.LongTermDebtAndCapitalLeaseObligation` | 89.6% (896/1000) | double: 896 | — | `101362000000`, `103323000000`, `103922000000` | +| `BalanceSheet.MachineryFurnitureEquipment` | 4.5% (45/1000) | int: 45 | — | `200000000`, `210000000`, `228000000` | +| `BalanceSheet.NetOtherUnrealizedGainLoss` | 47.5% (475/1000) | int: 400, double: 75 | — | `-1104000000`, `-1168000000`, `-1328000000` | +| `BalanceSheet.NetPPE` | 98.5% (985/1000) | double: 985 | — | `10487000000`, `15026000000`, `15120000000` | +| `BalanceSheet.NetUnrealizedGainLossForeignCurrency` | 10.4% (104/1000) | int: 104 | — | `-169000000`, `-18000000`, `-65000000` | +| `BalanceSheet.NetUnrealizedGainLossInvestments` | 10.4% (104/1000) | int: 104 | — | `-413000000`, `393000000`, `396000000` | +| `BalanceSheet.NonCurrentAccruedExpenses` | 86.5% (865/1000) | double: 865 | — | `10055000000`, `10558000000`, `10904000000` | +| `BalanceSheet.NonCurrentDeferredLiabilities` | 52.0% (520/1000) | double: 520 | — | `2187000000`, `2446000000`, `2530000000` | +| `BalanceSheet.NonCurrentDeferredRevenue` | 61.0% (610/1000) | double: 610 | — | `20958000000`, `2187000000`, `2446000000` | +| `BalanceSheet.NonCurrentDeferredTaxesAssets` | 38.5% (385/1000) | int: 147, double: 238 | — | `19336000000`, `20387000000`, `227000000` | +| `BalanceSheet.NonCurrentDeferredTaxesLiabilities` | 70.0% (700/1000) | int: 225, double: 475 | — | `11704000000`, `13195000000`, `13847000000` | +| `BalanceSheet.NonCurrentPrepaidAssets` | 7.5% (75/1000) | double: 75 | — | `2200000000`, `2600000000`, `3100000000` | +| `BalanceSheet.NotesReceivable` | 31.0% (310/1000) | double: 310 | — | `13494000000`, `13545000000`, `17799000000` | +| `BalanceSheet.OtherCurrentAssets` | 100.0% (1000/1000) | double: 1000 | — | `10204000000`, `10338000000`, `10530000000` | +| `BalanceSheet.OtherCurrentBorrowings` | 3.0% (30/1000) | double: 30 | — | `10029000000`, `11166000000` | +| `BalanceSheet.OtherCurrentLiabilities` | 76.3% (763/1000) | int: 223, double: 540 | — | `1002000000`, `1006000000`, `1234000000` | +| `BalanceSheet.OtherEquityInterest` | 2.9% (29/1000) | int: 29 | — | `-191000000` | +| `BalanceSheet.OtherIntangibleAssets` | 46.0% (460/1000) | double: 460 | — | `2149000000`, `2298000000`, `2444000000` | +| `BalanceSheet.OtherInventories` | 98.5% (985/1000) | int: 266, double: 719 | — | `1102000000`, `1122000000`, `1245000000` | +| `BalanceSheet.OtherNonCurrentAssets` | 100.0% (1000/1000) | double: 1000 | — | `10150000000`, `13323000000`, `18177000000` | +| `BalanceSheet.OtherNonCurrentLiabilities` | 100.0% (1000/1000) | double: 1000 | — | `11833000000`, `13954000000`, `15560000000` | +| `BalanceSheet.OtherPayable` | 59.6% (596/1000) | int: 147, double: 449 | — | `10500000000`, `11226000000`, `1400000000` | +| `BalanceSheet.OtherProperties` | 98.5% (985/1000) | double: 985 | — | `10487000000`, `15026000000`, `15120000000` | +| `BalanceSheet.OtherReceivables` | 98.5% (985/1000) | double: 985 | — | `10233000000`, `10998000000`, `11193000000` | +| `BalanceSheet.Payables` | 100.0% (1000/1000) | double: 1000 | — | `14912000000`, `15516000000`, `16808000000` | +| `BalanceSheet.PayablesAndAccruedExpenses` | 100.0% (1000/1000) | double: 1000 | — | `26789000000`, `27238000000`, `28243000000` | +| `BalanceSheet.PreferredStock` | 2.9% (29/1000) | int: 29 | — | `5000000` | +| `BalanceSheet.PrepaidAssets` | 7.5% (75/1000) | int: 75 | — | `1000000000`, `1100000000`, `1300000000` | +| `BalanceSheet.RawMaterials` | 6.0% (60/1000) | double: 60 | — | `2673000000`, `2792000000`, `3379000000` | +| `BalanceSheet.Receivables` | 100.0% (1000/1000) | double: 1000 | — | `13336000000`, `13453000000`, `13769000000` | +| `BalanceSheet.RecievablesAdjustmentsAllowances` | 46.0% (460/1000) | int: 460 | — | `-104000000`, `-119000000`, `-53000000` | +| `BalanceSheet.RestrictedCash` | 18.0% (180/1000) | double: 180 | — | `25913000000`, `35039000000`, `35276000000` | +| `BalanceSheet.RetainedEarnings` | 100.0% (1000/1000) | int: 15, double: 985 | — | `-10393000000`, `-1136000000`, `-11666000000` | +| `BalanceSheet.StockholdersEquity` | 100.0% (1000/1000) | double: 1000 | — | `102498000000`, `105860000000`, `107147000000` | +| `BalanceSheet.TotalAssets` | 100.0% (1000/1000) | double: 1000 | — | `138681000000`, `150934000000`, `162896000000` | +| `BalanceSheet.TotalCapitalization` | 80.5% (805/1000) | double: 805 | — | `102498000000`, `111746000000`, `118210000000` | +| `BalanceSheet.TotalEquityGrossMinority` | 100.0% (1000/1000) | double: 1000 | — | `102498000000`, `105860000000`, `107147000000` | +| `BalanceSheet.TotalEquityGrossMinorityInterest` | 100.0% (1000/1000) | double: 1000 | — | `102498000000`, `105860000000`, `107147000000` | +| `BalanceSheet.TotalLiabilities` | 100.0% (1000/1000) | double: 1000 | — | `101580000000`, `124610000000`, `137329000000` | +| `BalanceSheet.TotalLiabilitiesAndTotalEquityGrossMinorityInterest` | 100.0% (1000/1000) | double: 1000 | — | `138681000000`, `150934000000`, `162896000000` | +| `BalanceSheet.TotalNonCurrentAssets` | 100.0% (1000/1000) | double: 1000 | — | `100222000000`, `110953000000`, `118411000000` | +| `BalanceSheet.TotalNonCurrentLiabilities` | 100.0% (1000/1000) | double: 1000 | — | `106555000000`, `107575000000`, `114431000000` | +| `BalanceSheet.TotalNonCurrentLiabilitiesNetMinorityInteres` | 100.0% (1000/1000) | double: 1000 | — | `106555000000`, `107575000000`, `114431000000` | +| `BalanceSheet.TreasuryStock` | 2.9% (29/1000) | double: 29 | — | `-22950000000` | +| `BalanceSheet.TrustPreferredSecurities` | 2.9% (29/1000) | int: 29 | — | `5000000` | +| `BalanceSheet.UnearnedIncome` | 1.5% (15/1000) | double: 15 | — | `7816000000` | +| `BalanceSheet.UnearnedPremiums` | 55.3% (553/1000) | int: 553 | — | `-166000000`, `-174000000`, `-184000000` | +| `BalanceSheet.WorkInProcess` | 1.5% (15/1000) | double: 15 | — | `2513000000` | +| `BalanceSheet.WorkingCapital` | 80.5% (805/1000) | int: 60, double: 745 | — | `-11125000000`, `-1120000000`, `-1742000000` | +| `CashFlow` | 100.0% (1000/1000) | object: 1000 | — | — | +| `CashFlow.BeginningCashPosition` | 97.0% (970/1000) | int: 15, double: 955 | — | `10121000000`, `10310000000`, `10746000000` | +| `CashFlow.CapitalExpenditure` | 100.0% (1000/1000) | int: 225, double: 775 | — | `-10495000000`, `-10708000000`, `-10959000000` | +| `CashFlow.CapitalExpenditureReported` | 100.0% (1000/1000) | int: 225, double: 775 | — | `10495000000`, `10708000000`, `10959000000` | +| `CashFlow.CashDividendsPaid` | 67.4% (674/1000) | double: 674 | — | `12150000000`, `12769000000`, `13712000000` | +| `CashFlow.CashFlowFromContinuingFinancingActivities` | 100.0% (1000/1000) | int: 134, double: 866 | — | `-108488000000`, `-110749000000`, `-11326000000` | +| `CashFlow.CashFlowFromContinuingInvestingActivities` | 100.0% (1000/1000) | int: 165, double: 835 | — | `-10368000000`, `-11403000000`, `-1217000000` | +| `CashFlow.CashFlowFromContinuingOperatingActivities` | 100.0% (1000/1000) | double: 1000 | — | `10189000000`, `10255000000`, `104038000000` | +| `CashFlow.ChangeInAccountPayable` | 100.0% (1000/1000) | int: 239, double: 761 | — | `-10566000000`, `-10567000000`, `-1089000000` | +| `CashFlow.ChangeInInventory` | 100.0% (1000/1000) | int: 955, double: 45 | — | `-102000000`, `-1046000000`, `-1076000000` | +| `CashFlow.ChangeInOtherCurrentAssets` | 76.0% (760/1000) | int: 581, double: 179 | — | `-1446000000`, `-1566000000`, `-162000000` | +| `CashFlow.ChangeInOtherCurrentLiabilities` | 100.0% (1000/1000) | int: 300, double: 700 | — | `-1074000000`, `-1184000000`, `-11998000000` | +| `CashFlow.ChangeInOtherWorkingCapital` | 100.0% (1000/1000) | int: 716, double: 284 | — | `-1058000000`, `-11731000000`, `-1188000000` | +| `CashFlow.ChangeInPayable` | 100.0% (1000/1000) | int: 239, double: 761 | — | `-10566000000`, `-10567000000`, `-1089000000` | +| `CashFlow.ChangeInPayablesAndAccruedExpense` | 100.0% (1000/1000) | int: 239, double: 761 | — | `-10566000000`, `-10567000000`, `-1089000000` | +| `CashFlow.ChangeInReceivables` | 100.0% (1000/1000) | int: 223, double: 777 | — | `-1020000000`, `-10313000000`, `-10436000000` | +| `CashFlow.ChangeInWorkingCapital` | 100.0% (1000/1000) | int: 433, double: 567 | — | `-1069000000`, `-10752000000`, `-1258000000` | +| `CashFlow.ChangesInAccountReceivables` | 100.0% (1000/1000) | int: 418, double: 582 | — | `-10125000000`, `-1030000000`, `-10485000000` | +| `CashFlow.ChangesInCash` | 100.0% (1000/1000) | int: 312, double: 688 | — | `-10435000000`, `-10952000000`, `-1214000000` | +| `CashFlow.CommonStockDividendPaid` | 67.4% (674/1000) | double: 674 | — | `-12150000000`, `-12769000000`, `-13712000000` | +| `CashFlow.CommonStockIssuance` | 64.0% (640/1000) | int: 640 | — | `1000000`, `1105000000`, `134000000` | +| `CashFlow.CommonStockPayments` | 91.1% (911/1000) | int: 15, double: 896 | — | `-10000000000`, `-10095000000`, `-10166000000` | +| `CashFlow.DeferredIncomeTax` | 82.0% (820/1000) | int: 688, double: 132 | — | `-1383000000`, `-1438000000`, `-149000000` | +| `CashFlow.DeferredTax` | 82.0% (820/1000) | int: 688, double: 132 | — | `-1383000000`, `-1438000000`, `-149000000` | +| `CashFlow.Depreciation` | 58.5% (585/1000) | double: 585 | — | `10157000000`, `10903000000`, `11056000000` | +| `CashFlow.DepreciationAmortizationDepletion` | 58.5% (585/1000) | double: 585 | — | `10157000000`, `10903000000`, `11056000000` | +| `CashFlow.DepreciationAndAmortization` | 58.5% (585/1000) | double: 585 | — | `10157000000`, `10903000000`, `11056000000` | +| `CashFlow.EndCashPosition` | 100.0% (1000/1000) | int: 30, double: 970 | — | `-1781000000`, `10121000000`, `10310000000` | +| `CashFlow.FinancingCashFlow` | 100.0% (1000/1000) | int: 134, double: 866 | — | `-108488000000`, `-110749000000`, `-11326000000` | +| `CashFlow.FreeCashFlow` | 100.0% (1000/1000) | double: 1000 | — | `10205000000`, `108807000000`, `10935000000` | +| `CashFlow.IncomeTaxPaidSupplementalData` | 100.0% (1000/1000) | int: 225, double: 775 | — | `10026000000`, `10417000000`, `10444000000` | +| `CashFlow.InterestPaidSupplementalData` | 73.2% (732/1000) | int: 642, double: 90 | — | `1170000000`, `1213000000`, `1316000000` | +| `CashFlow.InvestingCashFlow` | 100.0% (1000/1000) | int: 165, double: 835 | — | `-10368000000`, `-11403000000`, `-1217000000` | +| `CashFlow.IssuanceOfCapitalStock` | 64.0% (640/1000) | int: 640 | — | `1000000`, `1105000000`, `134000000` | +| `CashFlow.IssuanceOfDebt` | 83.6% (836/1000) | int: 300, double: 536 | — | `-1000000000`, `-123000000`, `-1240000000` | +| `CashFlow.LongTermDebtIssuance` | 47.6% (476/1000) | double: 476 | — | `10750000000`, `10975000000`, `11960000000` | +| `CashFlow.LongTermDebtPayments` | 50.9% (509/1000) | int: 90, double: 419 | — | `-1000000000`, `-1009000000`, `-11151000000` | +| `CashFlow.NetBusinessPurchaseAndSale` | 76.0% (760/1000) | int: 731, double: 29 | — | `-113000000`, `-115000000`, `-124000000` | +| `CashFlow.NetCommonStockIssuance` | 100.0% (1000/1000) | int: 104, double: 896 | — | `-10095000000`, `-10166000000`, `-10851000000` | +| `CashFlow.NetIncomeFromContinuingOperations` | 100.0% (1000/1000) | double: 1000 | — | `10044000000`, `10223000000`, `10516000000` | +| `CashFlow.NetIntangiblesPurchaseAndSale` | 47.5% (475/1000) | int: 475 | — | `-104000000`, `-107000000`, `-108000000` | +| `CashFlow.NetInvestmentPropertiesPurchaseAndSale` | 100.0% (1000/1000) | int: 120, double: 880 | — | `-10603000000`, `-10607000000`, `-10782000000` | +| `CashFlow.NetInvestmentPurchaseAndSale` | 100.0% (1000/1000) | int: 120, double: 880 | — | `-10603000000`, `-10607000000`, `-10782000000` | +| `CashFlow.NetIssuancePaymentsOfDebt` | 83.6% (836/1000) | int: 300, double: 536 | — | `-1000000000`, `-123000000`, `-1240000000` | +| `CashFlow.NetLongTermDebtIssuance` | 73.1% (731/1000) | int: 135, double: 596 | — | `-100000000`, `-1000000000`, `-1009000000` | +| `CashFlow.NetOtherFinancingCharges` | 100.0% (1000/1000) | int: 464, double: 536 | — | `-1038000000`, `-1078000000`, `-10945000000` | +| `CashFlow.NetOtherInvestingChanges` | 100.0% (1000/1000) | int: 1000 | — | `-104000000`, `-106000000`, `-1078000000` | +| `CashFlow.NetPPEPurchaseAndSale` | 100.0% (1000/1000) | int: 270, double: 730 | — | `-10495000000`, `-10708000000`, `-10959000000` | +| `CashFlow.NetShortTermDebtIssuance` | 80.7% (807/1000) | int: 464, double: 343 | — | `-1000000`, `-10000000`, `-1000000000` | +| `CashFlow.OperatingCashFlow` | 100.0% (1000/1000) | double: 1000 | — | `10189000000`, `10255000000`, `104038000000` | +| `CashFlow.OtherNonCashItems` | 100.0% (1000/1000) | int: 435, double: 565 | — | `-45000000`, `-6523000000`, `10044000000` | +| `CashFlow.PurchaseOfBusiness` | 76.0% (760/1000) | int: 731, double: 29 | — | `-113000000`, `-115000000`, `-124000000` | +| `CashFlow.PurchaseOfIntangibles` | 47.5% (475/1000) | int: 475 | — | `-104000000`, `-107000000`, `-108000000` | +| `CashFlow.PurchaseOfInvestment` | 100.0% (1000/1000) | double: 1000 | — | `-10582000000`, `-109558000000`, `-115148000000` | +| `CashFlow.PurchaseOfLongTermInvestments` | 35.9% (359/1000) | int: 359 | — | `-1001000000`, `-12000000`, `-1250000000` | +| `CashFlow.PurchaseOfPPE` | 100.0% (1000/1000) | int: 270, double: 730 | — | `-10495000000`, `-10708000000`, `-10959000000` | +| `CashFlow.PurchaseOfShortTermInvestments` | 100.0% (1000/1000) | double: 1000 | — | `-10582000000`, `-109558000000`, `-114938000000` | +| `CashFlow.RepaymentOfDebt` | 50.9% (509/1000) | int: 90, double: 419 | — | `-1000000000`, `-1009000000`, `-11151000000` | +| `CashFlow.RepurchaseOfCapitalStock` | 91.1% (911/1000) | int: 15, double: 896 | — | `-10000000000`, `-10095000000`, `-10166000000` | +| `CashFlow.SaleOfInvestment` | 100.0% (1000/1000) | double: 1000 | — | `104072000000`, `106483000000`, `111794000000` | +| `CashFlow.SaleOfLongTermInvestments` | 19.5% (195/1000) | int: 195 | — | `108000000`, `126000000`, `1526000000` | +| `CashFlow.SaleOfShortTermInvestments` | 100.0% (1000/1000) | double: 1000 | — | `103719000000`, `106483000000`, `111794000000` | +| `CashFlow.ShortTermDebtIssuance` | 80.7% (807/1000) | int: 464, double: 343 | — | `-1000000`, `-10000000`, `-1000000000` | +| `CashFlow.StockBasedCompensation` | 100.0% (1000/1000) | int: 614, double: 386 | — | `1030000000`, `1048000000`, `1054000000` | +| `IncomeStatement` | 100.0% (1000/1000) | object: 1000 | — | — | +| `IncomeStatement.Amortization` | 37.0% (370/1000) | double: 370 | — | `-5611000000`, `2149000000`, `2298000000` | +| `IncomeStatement.AmortizationOfIntangibles` | 37.0% (370/1000) | double: 370 | — | `-5611000000`, `2149000000`, `2298000000` | +| `IncomeStatement.BasicAverageShares` | 88.0% (880/1000) | double: 880 | — | `14994082000`, `15081724000`, `15171990000` | +| `IncomeStatement.BasicContinuousOperations` | 97.0% (970/1000) | int: 15, double: 955 | — | `-0.03`, `-0.05`, `-0.1` | +| `IncomeStatement.BasicEPS` | 100.0% (1000/1000) | int: 15, double: 985 | — | `0.27`, `0.3`, `0.31` | +| `IncomeStatement.CostOfRevenue` | 100.0% (1000/1000) | double: 1000 | — | `106606000000`, `112258000000`, `131376000000` | +| `IncomeStatement.Depreciation` | 38.5% (385/1000) | double: 385 | — | `11300000000`, `3277000000`, `6757000000` | +| `IncomeStatement.DepreciationAndAmortization` | 38.5% (385/1000) | double: 385 | — | `11300000000`, `3277000000`, `6757000000` | +| `IncomeStatement.DilutedAverageShares` | 100.0% (1000/1000) | double: 1000 | — | `15056133000`, `15150865000`, `15242853000` | +| `IncomeStatement.DilutedContinuousOperations` | 98.5% (985/1000) | double: 985 | — | `0.27`, `0.3`, `0.31` | +| `IncomeStatement.DilutedEPS` | 100.0% (1000/1000) | double: 1000 | — | `0.27`, `0.3`, `0.31` | +| `IncomeStatement.DividendPerShare` | 97.0% (970/1000) | double: 970 | — | `0.09`, `0.11`, `0.12` | +| `IncomeStatement.EBIT` | 100.0% (1000/1000) | double: 1000 | — | `10226000000`, `10584000000`, `10878000000` | +| `IncomeStatement.EBITDA` | 100.0% (1000/1000) | double: 1000 | — | `10226000000`, `10584000000`, `10878000000` | +| `IncomeStatement.EarningsFromEquityInterest` | 8.9% (89/1000) | double: 89 | — | `-12188000000`, `-12803000000`, `-13735000000` | +| `IncomeStatement.EarningsFromEquityInterestNetOfTax` | 8.9% (89/1000) | double: 89 | — | `-12188000000`, `-12803000000`, `-13735000000` | +| `IncomeStatement.GainOnSaleOfSecurity` | 17.8% (178/1000) | int: 178 | — | `-60000000`, `-78000000`, `139000000` | +| `IncomeStatement.GeneralAndAdministrativeExpense` | 100.0% (1000/1000) | double: 1000 | — | `10040000000`, `10830000000`, `11993000000` | +| `IncomeStatement.GrossProfit` | 100.0% (1000/1000) | double: 1000 | — | `101839000000`, `104956000000`, `13024000000` | +| `IncomeStatement.InterestExpenseNonOperating` | 79.1% (791/1000) | int: 686, double: 105 | — | `100000000`, `1002000000`, `1003000000` | +| `IncomeStatement.InterestExpenseOperating` | 33.0% (330/1000) | int: 180, double: 150 | — | `-2146000000`, `2220000000`, `2600000000` | +| `IncomeStatement.MiscOtherSpecialCharges` | 100.0% (1000/1000) | int: 985, double: 15 | — | `-10000000`, `-237000000`, `-247000000` | +| `IncomeStatement.NetIncome` | 100.0% (1000/1000) | double: 1000 | — | `10044000000`, `10223000000`, `10516000000` | +| `IncomeStatement.NetIncomeCommonStockholders` | 100.0% (1000/1000) | double: 1000 | — | `10044000000`, `10223000000`, `10516000000` | +| `IncomeStatement.NetIncomeContinuousOperations` | 100.0% (1000/1000) | double: 1000 | — | `10044000000`, `10223000000`, `10516000000` | +| `IncomeStatement.NetIncomeFromContinuingAndDiscontinuedOperation` | 100.0% (1000/1000) | double: 1000 | — | `10044000000`, `10223000000`, `10516000000` | +| `IncomeStatement.NetNonOperatingInterestIncomeExpense` | 79.1% (791/1000) | int: 686, double: 105 | — | `-100000000`, `-1003000000`, `-1010000000` | +| `IncomeStatement.NormalizedIncome` | 6.0% (60/1000) | double: 60 | — | `122250150000`, `25239060000`, `29016900000` | +| `IncomeStatement.OperatingExpense` | 100.0% (1000/1000) | double: 1000 | — | `10576000000`, `10794000000`, `11129000000` | +| `IncomeStatement.OperatingIncome` | 100.0% (1000/1000) | double: 1000 | — | `10030000000`, `10105000000`, `10282000000` | +| `IncomeStatement.OperatingRevenue` | 100.0% (1000/1000) | double: 1000 | — | `111439000000`, `117154000000`, `119575000000` | +| `IncomeStatement.OtherGandA` | 100.0% (1000/1000) | double: 1000 | — | `10040000000`, `10830000000`, `11993000000` | +| `IncomeStatement.OtherIncomeExpense` | 100.0% (1000/1000) | int: 985, double: 15 | — | `-113000000`, `-1156000000`, `-126000000` | +| `IncomeStatement.OtherOperatingExpenses` | 40.1% (401/1000) | int: 341, double: 60 | — | `-1278000000`, `-1347000000`, `-1578000000` | +| `IncomeStatement.PretaxIncome` | 100.0% (1000/1000) | double: 1000 | — | `10143000000`, `10469000000`, `10484000000` | +| `IncomeStatement.PromotionAndAdvertising` | 11.6% (116/1000) | int: 116 | — | `1000000000`, `1100000000`, `1200000000` | +| `IncomeStatement.RentAndLandingFees` | 23.5% (235/1000) | int: 235 | — | `1100000000`, `1200000000`, `1300000000` | +| `IncomeStatement.ResearchAndDevelopment` | 100.0% (1000/1000) | int: 225, double: 775 | — | `10045000000`, `1010000000`, `1119000000` | +| `IncomeStatement.ResearchExpense` | 100.0% (1000/1000) | int: 225, double: 775 | — | `10045000000`, `1010000000`, `1119000000` | +| `IncomeStatement.RestructringAndMnAIncome` | 8.7% (87/1000) | double: 87 | — | `-8165000000`, `-8295000000`, `-9571000000` | +| `IncomeStatement.RestructuringAndMergernAcquisition` | 8.7% (87/1000) | double: 87 | — | `-8165000000`, `-8295000000`, `-9571000000` | +| `IncomeStatement.SalariesAndWages` | 82.2% (822/1000) | int: 733, double: 89 | — | `-1178000000`, `-1231000000`, `-1319000000` | +| `IncomeStatement.SellingAndMarketingExpense` | 11.6% (116/1000) | int: 116 | — | `1000000000`, `1100000000`, `1200000000` | +| `IncomeStatement.SellingGeneralAndAdministration` | 100.0% (1000/1000) | double: 1000 | — | `10040000000`, `10830000000`, `11993000000` | +| `IncomeStatement.ShareClassLevelSharesOutstanding` | 100.0% (1000/1000) | double: 1000 | — | `14935826000` | +| `IncomeStatement.SharesOutstanding` | 95.5% (955/1000) | double: 955 | — | `15022073000`, `15115823000`, `15204137000` | +| `IncomeStatement.SpecialIncomeCharges` | 8.7% (87/1000) | double: 87 | — | `8165000000`, `8295000000`, `9571000000` | +| `IncomeStatement.TaxProvision` | 100.0% (1000/1000) | int: 60, double: 940 | — | `10481000000`, `13118000000`, `13372000000` | +| `IncomeStatement.TotalExpenses` | 100.0% (1000/1000) | double: 1000 | — | `-58799000000`, `-66518000000`, `101267000000` | +| `IncomeStatement.TotalRevenue` | 100.0% (1000/1000) | double: 1000 | — | `111439000000`, `117154000000`, `119575000000` | +| `_id` | 100.0% (1000/1000) | objectId: 1000 | — | — | +| `created_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-06-30T01:04:48.534Z`, `2025-06-30T01:04:49.197Z`, `2025-06-30T01:13:39.997Z` | +| `currency` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..3) | `USD` | +| `exchange` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..3) | `NYE`, `TSX` | +| `latestFiscalDate` | 100.0% (1000/1000) | string: 1000 | ymd: 1000 (len 10..10) | `2024-09-28` | +| `periodEndDate` | 100.0% (1000/1000) | string: 1000 | ymd: 1000 (len 10..10) | `2011-12-31`, `2012-03-31`, `2012-06-30` | +| `qmSearchCode` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..10) | `X:CA`, `XAM:CA`, `XFLT` | +| `reportDate` | 100.0% (1000/1000) | string: 1000 | ymd: 1000 (len 10..10) | `2011-12-31`, `2012-03-31`, `2012-06-30` | +| `reportPeriod` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 1..1) | `A`, `Q` | +| `reportQuarter` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 2..2) | `Q1`, `Q2`, `Q3` | +| `reportYear` | 100.0% (1000/1000) | int: 1000 | — | `2012`, `2013`, `2014` | +| `symbol` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 1..7) | `X`, `XAM`, `XFLT` | +| `updated_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-06-30T02:24:59.988Z`, `2025-06-30T02:24:59.991Z`, `2025-06-30T02:24:59.995Z` | + +## `qmFinancials-old` (1000 docs sampled) + +| Field | Presence | Types | String Patterns | Examples | +| --- | --- | --- | --- | --- | +| `_id` | 100.0% (1000/1000) | objectId: 1000 | — | — | +| `balancesheet` | 100.0% (1000/1000) | string: 94, object: 906 | emptyOrWhitespace: 94 (len 0..0) | | +| `balancesheet.AccountsPayable` | 76.9% (769/1000) | int: 769 | — | `1000000`, `1000425`, `10162` | +| `balancesheet.AccountsReceivable` | 62.4% (624/1000) | int: 624 | — | `10018`, `1003964`, `1006000` | +| `balancesheet.AccruedInterestReceivable` | 0.2% (2/1000) | int: 2 | — | `11112`, `915` | +| `balancesheet.AccumulatedDepreciation` | 43.2% (432/1000) | int: 416, double: 16 | — | `-10000`, `-1004276`, `-1023100000` | +| `balancesheet.AdditionalPaidInCapital` | 48.8% (488/1000) | int: 488 | — | `10116000`, `10158082`, `10158228` | +| `balancesheet.AssetsHeldForSale` | 2.1% (21/1000) | int: 21 | — | `107840000`, `1243000`, `1406000` | +| `balancesheet.AvailableForSaleSecurities` | 0.7% (7/1000) | int: 7 | — | `652446000`, `765048000`, `846253000` | +| `balancesheet.BankIndebtedness` | 1.4% (14/1000) | int: 14 | — | `12648000`, `18480000`, `24793000` | +| `balancesheet.BuildingsAndImprovements` | 11.6% (116/1000) | int: 116 | — | `102429`, `11573000`, `118580` | +| `balancesheet.CapitalStock` | 78.4% (784/1000) | int: 689, double: 95 | — | `-1584973`, `-3052377`, `-3270542` | +| `balancesheet.Cash` | 50.1% (501/1000) | int: 501 | — | `10119000`, `10220000`, `1030` | +| `balancesheet.CashAndCashEquivalents` | 89.4% (894/1000) | int: 894 | — | `100100000`, `100714`, `10119000` | +| `balancesheet.CashAndDueFromBanks` | 0.5% (5/1000) | int: 5 | — | `2094000`, `5214000`, `5591000` | +| `balancesheet.CashCashEquivalentsAndShortTermInvestments` | 83.7% (837/1000) | int: 837 | — | `100100000`, `100714`, `101600000` | +| `balancesheet.CashEquivalents` | 5.5% (55/1000) | int: 55 | — | `100714`, `1042089`, `11248` | +| `balancesheet.CommercialLoan` | 2.1% (21/1000) | int: 21 | — | `2000000`, `2114000`, `2671000` | +| `balancesheet.CommercialPaper` | 0.8% (8/1000) | int: 8 | — | `1145200000`, `161000000`, `236000000` | +| `balancesheet.CommonStock` | 77.0% (770/1000) | int: 677, double: 93 | — | `-1584973`, `-3052377`, `-3270542` | +| `balancesheet.CommonStockEquity` | 89.6% (896/1000) | int: 786, double: 110 | — | `-101238935`, `-101419`, `-107494` | +| `balancesheet.CommonUtilityPlant` | 0.4% (4/1000) | double: 4 | — | `7791000000`, `8432000000` | +| `balancesheet.ConstructionInProgress` | 8.7% (87/1000) | int: 87 | — | `117174679`, `12446000`, `12523000` | +| `balancesheet.CurrentAccruedExpenses` | 23.0% (230/1000) | int: 230 | — | `10000`, `10209000`, `103520` | +| `balancesheet.CurrentAssets` | 84.3% (843/1000) | int: 822, double: 21 | — | `1005042000`, `100651000`, `101008000` | +| `balancesheet.CurrentCapitalLeaseObligation` | 23.8% (238/1000) | int: 238 | — | `1071000`, `1099502`, `1103861` | +| `balancesheet.CurrentDebt` | 40.4% (404/1000) | int: 398, double: 6 | — | `100856`, `1008750`, `102000` | +| `balancesheet.CurrentDebtAndCapitalLeaseObligation` | 49.1% (491/1000) | int: 485, double: 6 | — | `100856`, `1026752`, `103455` | +| `balancesheet.CurrentDeferredAssets` | 3.5% (35/1000) | int: 35 | — | `10627`, `14019000`, `14912000` | +| `balancesheet.CurrentDeferredLiabilities` | 20.1% (201/1000) | int: 201 | — | `1003000`, `1008000`, `10241034` | +| `balancesheet.CurrentDeferredRevenue` | 15.0% (150/1000) | int: 150 | — | `1003000`, `1042000`, `1063857` | +| `balancesheet.CurrentDeferredTaxesAssets` | 1.4% (14/1000) | int: 14 | — | `16375000`, `1852000`, `1911000` | +| `balancesheet.CurrentDeferredTaxesLiabilities` | 1.8% (18/1000) | int: 18 | — | `12539000`, `1331000`, `2100000` | +| `balancesheet.CurrentLiabilities` | 84.2% (842/1000) | int: 821, double: 21 | — | `10000`, `1000000`, `100523000` | +| `balancesheet.CurrentNotesPayable` | 0.5% (5/1000) | int: 5 | — | `399155`, `428324`, `445511` | +| `balancesheet.CurrentProvisions` | 6.4% (64/1000) | int: 64 | — | `1000000`, `1012000`, `1100000` | +| `balancesheet.DeferredAcquisitionCosts` | 0.7% (7/1000) | int: 7 | — | `1674`, `17577`, `22397` | +| `balancesheet.DeferredAssets` | 4.4% (44/1000) | int: 44 | — | `1052000`, `10945000`, `1141000` | +| `balancesheet.DeferredCosts` | 1.6% (16/1000) | int: 16 | — | `14313`, `1674`, `17577` | +| `balancesheet.DeferredTaxAssets` | 4.4% (44/1000) | int: 44 | — | `1052000`, `10945000`, `1141000` | +| `balancesheet.DefinedPensionBenefit` | 2.7% (27/1000) | int: 27 | — | `10000000`, `1252000`, `1264000` | +| `balancesheet.DerivativeAssets` | 1.2% (12/1000) | int: 12 | — | `1507000`, `1729000`, `185000` | +| `balancesheet.DerivativeProductLiabilities` | 14.1% (141/1000) | int: 141 | — | `1000`, `10526000`, `1056000` | +| `balancesheet.DividendsPayable` | 12.8% (128/1000) | int: 128 | — | `10324000`, `10379000`, `1146000` | +| `balancesheet.EmployeeBenefits` | 22.6% (226/1000) | int: 226 | — | `1012000`, `10341000`, `105000000` | +| `balancesheet.FinancialAssets` | 9.4% (94/1000) | int: 94 | — | `1042000`, `12300000`, `1246000` | +| `balancesheet.FinishedGoods` | 21.0% (210/1000) | int: 210 | — | `102870`, `10288000`, `1049125` | +| `balancesheet.GainsLossesNotAffectingRetainedEarnings` | 45.2% (452/1000) | int: 452 | — | `-10032000`, `-1081000`, `-10879000` | +| `balancesheet.Goodwill` | 15.3% (153/1000) | int: 127, double: 26 | — | `11825000`, `12451000`, `124910000` | +| `balancesheet.GoodwillAndOtherIntangibleAssets` | 39.3% (393/1000) | int: 366, double: 27 | — | `1`, `10009000`, `10320000` | +| `balancesheet.GrossLoan` | 5.4% (54/1000) | int: 54 | — | `101376000`, `103524000`, `108650000` | +| `balancesheet.GrossPPE` | 65.1% (651/1000) | int: 540, double: 111 | — | `1`, `1000`, `10000` | +| `balancesheet.IncomeTaxPayable` | 21.8% (218/1000) | int: 218 | — | `1000`, `1010000`, `10442000` | +| `balancesheet.InterestBearingDepositsLiabilities` | 4.7% (47/1000) | int: 47 | — | `10194000`, `10994000`, `11532000` | +| `balancesheet.InterestPayable` | 0.9% (9/1000) | int: 9 | — | `107836`, `11602`, `132989000` | +| `balancesheet.Inventory` | 34.5% (345/1000) | int: 345 | — | `1000846`, `100406000`, `102316000` | +| `balancesheet.InvestmentsAndAdvances` | 24.7% (247/1000) | int: 242, double: 5 | — | `106141000`, `107307000`, `1133000` | +| `balancesheet.LandAndImprovements` | 15.1% (151/1000) | int: 151 | — | `100000`, `105000`, `10666` | +| `balancesheet.Leases` | 16.2% (162/1000) | int: 162 | — | `116578`, `1310476`, `1371333` | +| `balancesheet.LiabilitiesOfDiscontinuedOperations` | 0.6% (6/1000) | int: 6 | — | `11015000`, `1276000`, `732000` | +| `balancesheet.LineOfCredit` | 11.7% (117/1000) | int: 117 | — | `10336000`, `10462000`, `105848000` | +| `balancesheet.LoansReceivable` | 1.7% (17/1000) | int: 17 | — | `1182093000`, `1274789000`, `1333471000` | +| `balancesheet.LongTermCapitalLeaseObligation` | 23.8% (238/1000) | int: 238 | — | `1000`, `1013576`, `10167000` | +| `balancesheet.LongTermDebt` | 41.0% (410/1000) | int: 354, double: 56 | — | `100453000`, `1013500000`, `1039951000` | +| `balancesheet.LongTermDebtAndCapitalLeaseObligation` | 49.2% (492/1000) | int: 436, double: 56 | — | `1000`, `100071000`, `100453000` | +| `balancesheet.LongTermProvisions` | 11.5% (115/1000) | int: 115 | — | `11003000`, `11210000`, `11266000` | +| `balancesheet.MachineryFurnitureEquipment` | 37.3% (373/1000) | int: 373 | — | `1000`, `10000`, `10291242` | +| `balancesheet.MaterialsAndSupplies` | 5.5% (55/1000) | int: 55 | — | `1013000000`, `101357000`, `106700000` | +| `balancesheet.MineralProperties` | 21.2% (212/1000) | int: 158, double: 54 | — | `1`, `1036948`, `105964` | +| `balancesheet.MinorityInterest` | 23.1% (231/1000) | int: 231 | — | `-1000`, `-10000`, `-11000` | +| `balancesheet.NaturalGasFuelAndOther` | 0.4% (4/1000) | double: 4 | — | `11623000000`, `12330000000` | +| `balancesheet.NetLoan` | 5.4% (54/1000) | int: 54 | — | `101376000`, `103524000`, `108650000` | +| `balancesheet.NetOtherUnrealizedGainLoss` | 10.4% (104/1000) | int: 104 | — | `-11102`, `-135000000`, `-201134` | +| `balancesheet.NetPPE` | 69.0% (690/1000) | int: 578, double: 112 | — | `1`, `1000`, `10000` | +| `balancesheet.NetUnrealizedGainLossForeignCurrency` | 0.3% (3/1000) | int: 3 | — | `-1463628`, `-1778337`, `-2762100` | +| `balancesheet.NetUtilityPlant` | 0.4% (4/1000) | double: 4 | — | `11623000000`, `12330000000` | +| `balancesheet.NonCurrentAccountsReceivable` | 6.5% (65/1000) | int: 65 | — | `101392`, `1055996`, `1088572` | +| `balancesheet.NonCurrentAccruedExpenses` | 0.6% (6/1000) | int: 6 | — | `125801`, `125803`, `186086` | +| `balancesheet.NonCurrentDeferredAssets` | 20.4% (204/1000) | int: 204 | — | `10000000`, `1009000`, `1010000` | +| `balancesheet.NonCurrentDeferredLiabilities` | 34.3% (343/1000) | int: 343 | — | `100000`, `1020400000`, `1027000000` | +| `balancesheet.NonCurrentDeferredRevenue` | 10.1% (101/1000) | int: 101 | — | `10000`, `11000000`, `111000` | +| `balancesheet.NonCurrentDeferredTaxesAssets` | 18.5% (185/1000) | int: 185 | — | `1009000`, `1010000`, `1086000` | +| `balancesheet.NonCurrentDeferredTaxesLiabilities` | 30.7% (307/1000) | int: 307 | — | `100000`, `1030000`, `1038000000` | +| `balancesheet.NonCurrentNoteReceivables` | 6.8% (68/1000) | int: 68 | — | `10836000`, `11353000`, `11836000` | +| `balancesheet.NonCurrentPensionAndOtherPostretirementBenefitPlans` | 9.4% (94/1000) | int: 94 | — | `10341000`, `10607000`, `1078000` | +| `balancesheet.NonCurrentPrepaidAssets` | 16.0% (160/1000) | int: 160 | — | `106000`, `1098286`, `135000` | +| `balancesheet.NotesReceivable` | 1.8% (18/1000) | int: 18 | — | `2500000`, `2517000`, `3573402` | +| `balancesheet.OtherAssets` | 4.3% (43/1000) | int: 43 | — | `10733000`, `11316000`, `17748000` | +| `balancesheet.OtherCapitalStock` | 2.1% (21/1000) | int: 21 | — | `112095`, `15000`, `1626120` | +| `balancesheet.OtherCurrentAssets` | 25.4% (254/1000) | int: 254 | — | `-1`, `-2`, `1` | +| `balancesheet.OtherCurrentBorrowings` | 28.2% (282/1000) | int: 276, double: 6 | — | `1008750`, `102000`, `1026752` | +| `balancesheet.OtherCurrentLiabilities` | 22.0% (220/1000) | int: 220 | — | `-1`, `1`, `1000` | +| `balancesheet.OtherDeferredCosts` | 0.7% (7/1000) | int: 7 | — | `14313`, `24000000`, `32000000` | +| `balancesheet.OtherDeposits` | 0.5% (5/1000) | int: 5 | — | `2037000`, `2432000`, `2519000` | +| `balancesheet.OtherEquityAdjustments` | 8.3% (83/1000) | int: 83 | — | `-1152`, `-1860`, `-36517` | +| `balancesheet.OtherEquityInterest` | 24.6% (246/1000) | int: 246 | — | `-15620000`, `-24100`, `-50000` | +| `balancesheet.OtherIntangibleAssets` | 37.3% (373/1000) | int: 372, double: 1 | — | `1`, `10009000`, `10320000` | +| `balancesheet.OtherInventories` | 11.2% (112/1000) | int: 112 | — | `-1`, `1`, `10530000` | +| `balancesheet.OtherLiabilities` | 4.7% (47/1000) | int: 47 | — | `10284000`, `1244000`, `1461000` | +| `balancesheet.OtherLoanAssets` | 4.7% (47/1000) | int: 47 | — | `102118000`, `103524000`, `108744000` | +| `balancesheet.OtherNonCurrentAssets` | 35.2% (352/1000) | int: 352 | — | `-1`, `-10000`, `-2` | +| `balancesheet.OtherNonCurrentLiabilities` | 21.4% (214/1000) | int: 213, double: 1 | — | `-1`, `-2`, `-62000` | +| `balancesheet.OtherPayable` | 19.1% (191/1000) | int: 191 | — | `1005000`, `1012000`, `1014000` | +| `balancesheet.OtherProperties` | 36.9% (369/1000) | int: 322, double: 47 | — | `1`, `101592000`, `1018483` | +| `balancesheet.OtherReceivables` | 30.8% (308/1000) | int: 308 | — | `1029000`, `103660`, `10682000` | +| `balancesheet.Patents` | 0.2% (2/1000) | int: 2 | — | `117538` | +| `balancesheet.Payables` | 78.4% (784/1000) | int: 784 | — | `1000000`, `100929000`, `10162` | +| `balancesheet.PayablesAndAccruedExpenses` | 89.9% (899/1000) | int: 899 | — | `10000`, `1000000`, `100929000` | +| `balancesheet.PreferredStock` | 5.8% (58/1000) | int: 58 | — | `1076000000`, `1077000000`, `1277000000` | +| `balancesheet.PrepaidAssets` | 62.8% (628/1000) | int: 628 | — | `1002000`, `10022`, `100505` | +| `balancesheet.RawMaterials` | 22.3% (223/1000) | int: 223 | — | `10304000`, `1033955`, `104448` | +| `balancesheet.Receivables` | 69.5% (695/1000) | int: 695 | — | `1003093`, `1015637`, `10187000` | +| `balancesheet.RecievablesAdjustmentsAllowances` | 3.7% (37/1000) | int: 37 | — | `-152000`, `-2400000`, `-2500000` | +| `balancesheet.RegulatoryAssets` | 5.3% (53/1000) | int: 53 | — | `209000000`, `232186000`, `238499000` | +| `balancesheet.RegulatoryLiabilities` | 5.4% (54/1000) | int: 54 | — | `104282000`, `106852000`, `110417000` | +| `balancesheet.RestrictedCash` | 12.1% (121/1000) | int: 121 | — | `100000`, `1000000`, `1049000` | +| `balancesheet.RestrictedCashAndCashEquivalents` | 3.7% (37/1000) | int: 37 | — | `104095000`, `104421000`, `105300000` | +| `balancesheet.RestrictedCashAndInvestments` | 4.2% (42/1000) | int: 42 | — | `104095000`, `104421000`, `105300000` | +| `balancesheet.RestrictedInvestments` | 0.5% (5/1000) | int: 5 | — | `4590000`, `5546000`, `5892000` | +| `balancesheet.RetainedEarnings` | 80.7% (807/1000) | int: 795, double: 12 | — | `-100222000`, `-100621000`, `-10074423` | +| `balancesheet.SecuritiesAndInvestments` | 0.7% (7/1000) | int: 7 | — | `652446000`, `765048000`, `846253000` | +| `balancesheet.StockholdersEquity` | 89.6% (896/1000) | int: 786, double: 110 | — | `-101238935`, `-101419`, `-107494` | +| `balancesheet.TaxesReceivable` | 47.0% (470/1000) | int: 470 | — | `100000`, `10103000`, `1012549` | +| `balancesheet.TotalAssets` | 90.0% (900/1000) | int: 780, double: 120 | — | `10032200000`, `10044200000`, `10099200000` | +| `balancesheet.TotalCapitalization` | 80.3% (803/1000) | int: 687, double: 116 | — | `-101419`, `-105414236`, `-107494` | +| `balancesheet.TotalDeferredCreditsAndOtherNonCurrentLiabilities` | 5.5% (55/1000) | int: 29, double: 26 | — | `1026600000`, `1099200000`, `1113700000` | +| `balancesheet.TotalDeposits` | 5.2% (52/1000) | int: 52 | — | `10194000`, `10994000`, `11532000` | +| `balancesheet.TotalEquityGrossMinority` | 89.7% (897/1000) | int: 787, double: 110 | — | `-101238935`, `-101419`, `-107494` | +| `balancesheet.TotalEquityGrossMinorityInterest` | 89.7% (897/1000) | int: 787, double: 110 | — | `-101238935`, `-101419`, `-107494` | +| `balancesheet.TotalLiabilities` | 89.9% (899/1000) | int: 836, double: 63 | — | `10000`, `1000000`, `100840000` | +| `balancesheet.TotalLiabilitiesAndTotalEquityGrossMinorityInterest` | 90.0% (900/1000) | int: 778, double: 122 | — | `10032200000`, `10044200000`, `10099200000` | +| `balancesheet.TotalNonCurrentAssets` | 68.3% (683/1000) | int: 571, double: 112 | — | `1`, `100642000`, `10068604` | +| `balancesheet.TotalNonCurrentLiabilities` | 47.8% (478/1000) | int: 422, double: 56 | — | `-1`, `-2`, `1` | +| `balancesheet.TotalNonCurrentLiabilitiesNetMinorityInteres` | 47.8% (478/1000) | int: 422, double: 56 | — | `-1`, `-2`, `1` | +| `balancesheet.TotalTaxPayable` | 25.7% (257/1000) | int: 257 | — | `1000`, `1010000`, `10442000` | +| `balancesheet.TrustPreferredSecurities` | 5.8% (58/1000) | int: 58 | — | `1076000000`, `1077000000`, `1277000000` | +| `balancesheet.UnrealizedGainLoss` | 19.2% (192/1000) | int: 192 | — | `-132094`, `-135000000`, `-1463628` | +| `balancesheet.WorkInProcess` | 11.2% (112/1000) | int: 112 | — | `1040406`, `1066721`, `1077476` | +| `balancesheet.WorkingCapital` | 80.1% (801/1000) | int: 801 | — | `-101419`, `-10238`, `-1049000` | +| `cashflow` | 100.0% (1000/1000) | string: 12, object: 988 | emptyOrWhitespace: 12 (len 0..0) | | +| `cashflow.Amortization` | 20.3% (203/1000) | int: 203 | — | `-19401`, `-2296`, `-505786` | +| `cashflow.AmortizationOfIntangibles` | 14.4% (144/1000) | int: 144 | — | `-11395`, `-115000`, `-19401` | +| `cashflow.AssetImpairmentCharge` | 13.8% (138/1000) | int: 138 | — | `-1`, `-10330000`, `-1124000` | +| `cashflow.BeginningCashPosition` | 95.0% (950/1000) | int: 950 | — | `-11183000`, `-21685`, `-217` | +| `cashflow.CapitalExpenditure` | 11.2% (112/1000) | int: 112 | — | `-10000`, `-100509`, `-10665000` | +| `cashflow.CapitalExpenditureReported` | 55.8% (558/1000) | int: 558 | — | `1000`, `1004000`, `10043265` | +| `cashflow.CashDividendsPaid` | 21.0% (210/1000) | int: 210 | — | `100100000`, `103549000`, `105000000` | +| `cashflow.CashFlowFromContinuingFinancingActivities` | 75.3% (753/1000) | int: 750, double: 3 | — | `-1`, `-1000`, `-10000` | +| `cashflow.CashFlowFromContinuingInvestingActivities` | 73.4% (734/1000) | int: 731, double: 3 | — | `-10000`, `-1004000`, `-10043265` | +| `cashflow.CashFlowFromContinuingOperatingActivities` | 95.0% (950/1000) | int: 950 | — | `-1000339`, `-10097836`, `-100996` | +| `cashflow.CashFlowFromDiscontinuedOperation` | 0.8% (8/1000) | int: 8 | — | `-1000000`, `-134900000`, `-378000` | +| `cashflow.CashFromDiscontinuedFinancingActivities` | 0.9% (9/1000) | int: 9 | — | `-1703000`, `-5000000`, `10644000` | +| `cashflow.CashFromDiscontinuedInvestingActivities` | 0.5% (5/1000) | int: 5 | — | `-1726000`, `-59000`, `-6000` | +| `cashflow.CashFromDiscontinuedOperatingActivities` | 2.6% (26/1000) | int: 26 | — | `-139000`, `-179000`, `-26000` | +| `cashflow.ChangeInAccountPayable` | 53.0% (530/1000) | int: 530 | — | `-1004000`, `-10131`, `-10173` | +| `cashflow.ChangeInAccruedExpense` | 1.6% (16/1000) | int: 16 | — | `-1291`, `-20`, `-2444` | +| `cashflow.ChangeInDeferredCharges` | 3.1% (31/1000) | int: 31 | — | `-1022000`, `-1088000`, `-1245000` | +| `cashflow.ChangeInDividendPayable` | 0.1% (1/1000) | int: 1 | — | `61000` | +| `cashflow.ChangeInIncomeTaxPayable` | 11.2% (112/1000) | int: 112 | — | `-103000`, `-108291`, `-115000` | +| `cashflow.ChangeInInterestPayable` | 0.3% (3/1000) | int: 3 | — | `27178`, `40329`, `647000` | +| `cashflow.ChangeInInventory` | 30.9% (309/1000) | int: 309 | — | `-1`, `-100000000`, `-10050000` | +| `cashflow.ChangeInOtherCurrentAssets` | 24.3% (243/1000) | int: 243 | — | `-10000000`, `-1134000`, `-114000` | +| `cashflow.ChangeInOtherCurrentLiabilities` | 17.9% (179/1000) | int: 179 | — | `-100000`, `-104000`, `-10600000` | +| `cashflow.ChangeInOtherWorkingCapital` | 30.1% (301/1000) | int: 301 | — | `-1`, `-10000`, `-10153000` | +| `cashflow.ChangeInPayable` | 57.0% (570/1000) | int: 570 | — | `-10036000`, `-100687`, `-10131` | +| `cashflow.ChangeInPayablesAndAccruedExpense` | 80.6% (806/1000) | int: 806 | — | `-1`, `-10000000`, `-10036000` | +| `cashflow.ChangeInPrepaidAssets` | 38.6% (386/1000) | int: 386 | — | `-1000000`, `-1023000`, `-102759` | +| `cashflow.ChangeInReceivables` | 72.2% (722/1000) | int: 722 | — | `-10031000`, `-1015595`, `-102000000` | +| `cashflow.ChangeInTaxPayable` | 12.4% (124/1000) | int: 124 | — | `-103000`, `-111039`, `-115000` | +| `cashflow.ChangeInWorkingCapital` | 93.2% (932/1000) | int: 932 | — | `-1`, `-10000`, `-10000000` | +| `cashflow.ChangesInAccountReceivables` | 52.3% (523/1000) | int: 523 | — | `-10092000`, `-102000000`, `-102342` | +| `cashflow.ChangesInCash` | 94.9% (949/1000) | int: 949 | — | `-10000000`, `-100000000`, `-1000135` | +| `cashflow.CommonStockDividendPaid` | 19.9% (199/1000) | int: 199 | — | `-10538000`, `-1077000`, `-1088000` | +| `cashflow.CommonStockIssuance` | 29.7% (297/1000) | int: 295, double: 2 | — | `-1`, `-1000`, `-1014` | +| `cashflow.CommonStockPayments` | 14.6% (146/1000) | int: 146 | — | `-100000`, `-1011000`, `-10230000` | +| `cashflow.CumulativeEffectOfAccountingChange` | 0.1% (1/1000) | int: 1 | — | `-165525` | +| `cashflow.DeferredIncomeTax` | 32.3% (323/1000) | int: 323 | — | `-100000`, `-1011000`, `-10346` | +| `cashflow.DeferredTax` | 32.4% (324/1000) | int: 324 | — | `-100000`, `-1011000`, `-10346` | +| `cashflow.Depletion` | 0.7% (7/1000) | int: 7 | — | `-7000`, `18928000`, `25684000` | +| `cashflow.Depreciation` | 23.9% (239/1000) | int: 239 | — | `-1`, `-19401`, `-2916` | +| `cashflow.DepreciationAmortizationDepletion` | 61.3% (613/1000) | int: 613 | — | `-19401`, `-48`, `-505786` | +| `cashflow.DepreciationAndAmortization` | 51.4% (514/1000) | int: 514 | — | `-19401`, `-23447`, `-48` | +| `cashflow.EarningsLossesFromEquityInvestments` | 16.2% (162/1000) | int: 162 | — | `-10100000`, `-112200000`, `-113000` | +| `cashflow.EffectOfExchangeRateChanges` | 47.7% (477/1000) | int: 477 | — | `-1000`, `-100000`, `-1000000` | +| `cashflow.EndCashPosition` | 95.3% (953/1000) | int: 953 | — | `-11183000`, `-19153`, `-21685` | +| `cashflow.ExcessTaxBenefitFromStockBasedCompensation` | 0.1% (1/1000) | int: 1 | — | `-13000` | +| `cashflow.FinancingCashFlow` | 75.3% (753/1000) | int: 750, double: 3 | — | `-1`, `-1000`, `-10000` | +| `cashflow.FreeCashFlow` | 81.0% (810/1000) | int: 810 | — | `-1005072`, `-1006001`, `-1008725` | +| `cashflow.GainLossOnInvestmentSecurities` | 19.8% (198/1000) | int: 198 | — | `-1000`, `-1000000`, `-104000` | +| `cashflow.GainLossOnSaleOfBusiness` | 1.7% (17/1000) | int: 17 | — | `-14000000`, `-143520`, `-145266` | +| `cashflow.GainLossOnSaleOfPPE` | 11.5% (115/1000) | int: 115 | — | `-10051`, `-104000`, `-104425000` | +| `cashflow.IncomeTaxPaidSupplementalData` | 9.5% (95/1000) | int: 95 | — | `-1045000`, `-128000`, `-328000` | +| `cashflow.InterestPaidSupplementalData` | 13.9% (139/1000) | int: 139 | — | `-113`, `-14000`, `-3539000` | +| `cashflow.InvestingCashFlow` | 73.4% (734/1000) | int: 731, double: 3 | — | `-10000`, `-1004000`, `-10043265` | +| `cashflow.IssuanceOfCapitalStock` | 29.7% (297/1000) | int: 295, double: 2 | — | `-1`, `-1000`, `-1014` | +| `cashflow.IssuanceOfDebt` | 53.3% (533/1000) | int: 530, double: 3 | — | `-10000`, `-10162000`, `-1019260` | +| `cashflow.LongTermDebtIssuance` | 28.3% (283/1000) | int: 279, double: 4 | — | `-1170000`, `-137985000`, `-14481500` | +| `cashflow.LongTermDebtPayments` | 44.5% (445/1000) | int: 444, double: 1 | — | `-10000`, `-1000000000`, `-101305000` | +| `cashflow.NetBusinessPurchaseAndSale` | 15.3% (153/1000) | int: 151, double: 2 | — | `-1000`, `-100000`, `-1000000` | +| `cashflow.NetCapitalExpenditureDisposals` | 19.9% (199/1000) | int: 199 | — | `-1000`, `-10043265`, `-1010788` | +| `cashflow.NetCommonStockIssuance` | 38.1% (381/1000) | int: 379, double: 2 | — | `-1`, `-100000`, `-10009000` | +| `cashflow.NetForeignCurrencyExchangeGainLoss` | 31.4% (314/1000) | int: 314 | — | `-103000`, `-1056668`, `-11000` | +| `cashflow.NetIncomeFromContinuingOperations` | 94.7% (947/1000) | int: 947 | — | `-100786`, `-1009076`, `-1009911` | +| `cashflow.NetIntangiblesPurchaseAndSale` | 25.3% (253/1000) | int: 253 | — | `-1000`, `-10000`, `-1002000` | +| `cashflow.NetInvestmentPropertiesPurchaseAndSale` | 20.7% (207/1000) | int: 207 | — | `-1000000`, `-1016000`, `-103000000` | +| `cashflow.NetInvestmentPurchaseAndSale` | 20.7% (207/1000) | int: 207 | — | `-1000000`, `-1016000`, `-103000000` | +| `cashflow.NetIssuancePaymentsOfDebt` | 53.3% (533/1000) | int: 530, double: 3 | — | `-10000`, `-10162000`, `-1019260` | +| `cashflow.NetLongTermDebtIssuance` | 50.9% (509/1000) | int: 507, double: 2 | — | `-10000`, `-1019260`, `-1021` | +| `cashflow.NetOtherFinancingCharges` | 36.4% (364/1000) | int: 364 | — | `-1`, `-10000000`, `-1028000` | +| `cashflow.NetOtherInvestingChanges` | 40.0% (400/1000) | int: 399, double: 1 | — | `-100000`, `-1000000`, `-1016000` | +| `cashflow.NetPPEPurchaseAndSale` | 58.5% (585/1000) | int: 585 | — | `-1000`, `-10000`, `-1003000` | +| `cashflow.NetPreferredStockIssuance` | 2.0% (20/1000) | int: 20 | — | `-100000`, `-200000`, `-200000000` | +| `cashflow.NetProceedsPaymentForLoan` | 1.1% (11/1000) | int: 11 | — | `-10364000`, `-13027000`, `-19969000` | +| `cashflow.NetShortTermDebtIssuance` | 17.1% (171/1000) | int: 171 | — | `-1020000`, `-1090000`, `-1095000` | +| `cashflow.OperatingCashFlow` | 95.2% (952/1000) | int: 952 | — | `-1000339`, `-10097836`, `-100996` | +| `cashflow.OperatingGainsLosses` | 55.0% (550/1000) | int: 550 | — | `-10000`, `-100000`, `-1000000` | +| `cashflow.OtherNonCashItems` | 70.2% (702/1000) | int: 702 | — | `-1`, `-1000`, `-101694000` | +| `cashflow.PaymentForLoans` | 1.1% (11/1000) | int: 11 | — | `-10364000`, `-13027000`, `-19969000` | +| `cashflow.PensionAndEmployeeBenefitExpense` | 14.4% (144/1000) | int: 144 | — | `-1000`, `-10000`, `-1000000` | +| `cashflow.PreferredStockDividendPaid` | 5.8% (58/1000) | int: 58 | — | `-10000000`, `-10100000`, `-10200000` | +| `cashflow.PreferredStockIssuance` | 1.2% (12/1000) | int: 12 | — | `-100000`, `-3000`, `194400000` | +| `cashflow.PreferredStockPayments` | 0.8% (8/1000) | int: 8 | — | `-200000`, `-200000000`, `-274000000` | +| `cashflow.ProceedsFromIssuanceOfWarrants` | 5.3% (53/1000) | int: 53 | — | `-1`, `-151043`, `-2865130` | +| `cashflow.ProceedsFromStockOptionExercised` | 28.8% (288/1000) | int: 288 | — | `-151043`, `-1625`, `-1655966` | +| `cashflow.ProvisionForLoanLeaseAndOtherLosses` | 5.7% (57/1000) | int: 57 | — | `-723000`, `10348000`, `10644000` | +| `cashflow.PurchaseOfBusiness` | 12.2% (122/1000) | int: 120, double: 2 | — | `-1000`, `-100000`, `-1000000` | +| `cashflow.PurchaseOfIntangibles` | 25.2% (252/1000) | int: 252 | — | `-1000`, `-10000`, `-1002000` | +| `cashflow.PurchaseOfInvestment` | 11.6% (116/1000) | int: 116 | — | `-1000`, `-1000000`, `-1016000` | +| `cashflow.PurchaseOfLongTermInvestments` | 3.8% (38/1000) | int: 38 | — | `-1000000`, `-104061`, `-1060000` | +| `cashflow.PurchaseOfPPE` | 56.9% (569/1000) | int: 569 | — | `-1000`, `-10000`, `-1003000` | +| `cashflow.PurchaseOfShortTermInvestments` | 0.7% (7/1000) | int: 7 | — | `-350000`, `-360000`, `-50000000` | +| `cashflow.PurchaseOfTechnology` | 0.1% (1/1000) | int: 1 | — | `156000` | +| `cashflow.RepaymentOfDebt` | 44.2% (442/1000) | int: 441, double: 1 | — | `-10000`, `-1000000000`, `-1019260` | +| `cashflow.RepurchaseOfCapitalStock` | 14.6% (146/1000) | int: 146 | — | `-100000`, `-1011000`, `-10230000` | +| `cashflow.SaleOfBusiness` | 4.4% (44/1000) | int: 44 | — | `-37270`, `1000000`, `1013000` | +| `cashflow.SaleOfIntangibles` | 0.6% (6/1000) | int: 6 | — | `-139000`, `-29000`, `131763000` | +| `cashflow.SaleOfInvestment` | 9.1% (91/1000) | int: 91 | — | `-1058000`, `-107`, `-112896` | +| `cashflow.SaleOfLongTermInvestments` | 2.3% (23/1000) | int: 23 | — | `-1058000`, `10000`, `1000000` | +| `cashflow.SaleOfPPE` | 12.0% (120/1000) | int: 120 | — | `-100000`, `-150`, `-1801262` | +| `cashflow.SaleOfShortTermInvestments` | 2.1% (21/1000) | int: 21 | — | `-115922`, `-142000`, `-157000` | +| `cashflow.SaleOfTechnology` | 0.1% (1/1000) | int: 1 | — | `44000` | +| `cashflow.ShortTermDebtIssuance` | 4.6% (46/1000) | int: 46 | — | `-1000`, `-17012`, `-18082` | +| `cashflow.ShortTermDebtPayments` | 7.8% (78/1000) | int: 78 | — | `-1090000`, `-1095000`, `-132234` | +| `cashflow.StockBasedCompensation` | 61.7% (617/1000) | int: 617 | — | `-1000000`, `-1031000`, `-107000` | +| `cashflow.UnrealizedGainLossOnInvestmentSecurities` | 16.7% (167/1000) | int: 167 | — | `-1000`, `-113000000`, `-118000` | +| `currency` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..3) | `CAD`, `USD` | +| `exchange` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..3) | `CDX`, `TSX` | +| `income` | 100.0% (1000/1000) | string: 26, object: 974 | emptyOrWhitespace: 26 (len 0..0) | | +| `income.AccretionOnPreferredStock` | 0.4% (4/1000) | int: 4 | — | `-165525`, `-33000000`, `10000000` | +| `income.AccruedPreferredStockDividends` | 0.2% (2/1000) | int: 2 | — | `-84000000`, `7000000` | +| `income.AcquiredInProcessRnD` | 0.1% (1/1000) | int: 1 | — | `8195` | +| `income.AcquiredInProcessRnDIncome` | 0.1% (1/1000) | int: 1 | — | `10890` | +| `income.AcquisitionExpense` | 0.2% (2/1000) | int: 2 | — | `-875916`, `153376` | +| `income.AllowancesForConstruction` | 0.1% (1/1000) | int: 1 | — | `-802551` | +| `income.Amortization` | 15.7% (157/1000) | int: 157 | — | `-199`, `-224166`, `-4511` | +| `income.AmortizationOfIntangibles` | 14.3% (143/1000) | int: 143 | — | `-199`, `-4511`, `-505786` | +| `income.BasicAccountingChange` | 0.1% (1/1000) | int: 1 | — | `26780` | +| `income.BasicAverageShares` | 91.2% (912/1000) | int: 908, double: 4 | — | `-1399753300088`, `10016188`, `100866705` | +| `income.BasicContinuousOperations` | 64.4% (644/1000) | int: 6, double: 638 | — | `-0.01`, `-0.02`, `-0.03` | +| `income.BasicDiscontinuousOperations` | 2.0% (20/1000) | double: 20 | — | `-0.01`, `-0.02`, `-0.03` | +| `income.BasicEPS` | 72.9% (729/1000) | int: 7, double: 722 | — | `-0.01`, `-0.02`, `-0.03` | +| `income.BasicExtraordinary` | 0.1% (1/1000) | int: 1 | — | `26780` | +| `income.CostOfRevenue` | 46.4% (464/1000) | int: 452, double: 12 | — | `-10130`, `-104403`, `-10467` | +| `income.CreditLossesProvision` | 5.7% (57/1000) | int: 57 | — | `-10639000`, `-11751000`, `-1279000` | +| `income.CumulativeEffectOfAccountingChange` | 0.1% (1/1000) | int: 1 | — | `-165525` | +| `income.Depletion` | 0.2% (2/1000) | int: 2 | — | `-5496`, `5496` | +| `income.Depreciation` | 21.8% (218/1000) | int: 218 | — | `-52912`, `-584188`, `-62219` | +| `income.DepreciationAmortizationDepletion` | 37.2% (372/1000) | int: 372 | — | `-199`, `-2231`, `-223174` | +| `income.DepreciationAndAmortization` | 37.2% (372/1000) | int: 372 | — | `-199`, `-223174`, `-223448` | +| `income.DevelopmentExpense` | 2.1% (21/1000) | int: 21 | — | `-875916`, `10500`, `180000` | +| `income.DilutedAccountingChange` | 0.1% (1/1000) | int: 1 | — | `568648` | +| `income.DilutedAverageShares` | 83.1% (831/1000) | int: 827, double: 4 | — | `-1399753300088`, `-847300000`, `100866705` | +| `income.DilutedContinuousOperations` | 63.9% (639/1000) | int: 2, double: 637 | — | `-0.01`, `-0.02`, `-0.03` | +| `income.DilutedDiscontinuousOperations` | 2.0% (20/1000) | double: 20 | — | `-0.01`, `-0.02`, `-0.03` | +| `income.DilutedEPS` | 65.5% (655/1000) | int: 4, double: 651 | — | `-0.01`, `-0.02`, `-0.03` | +| `income.DilutedEPSOtherGainsLosses` | 0.1% (1/1000) | int: 1 | — | `-8644` | +| `income.DilutedExtraordinary` | 0.1% (1/1000) | int: 1 | — | `683611` | +| `income.DividendPerShare` | 19.0% (190/1000) | int: 1, double: 189 | — | `0.01`, `0.02`, `0.03` | +| `income.EBIT` | 90.3% (903/1000) | int: 903 | — | `-100659000`, `-100786`, `-1016000` | +| `income.EBITDA` | 90.3% (903/1000) | int: 903 | — | `-100104416`, `-100786`, `-100814000` | +| `income.EarningsFromEquityInterest` | 15.2% (152/1000) | int: 152 | — | `-10000`, `-10700000`, `-11000` | +| `income.EarningsFromEquityInterestNetOfTax` | 15.2% (152/1000) | int: 152 | — | `-10000`, `-10700000`, `-11000` | +| `income.ExciseTaxes` | 2.3% (23/1000) | int: 23 | — | `1061000`, `12957536`, `1322059` | +| `income.ExplorationDevelopmentAndMineralPropertyLeaseExpenses` | 2.7% (27/1000) | int: 27 | — | `-1158338`, `-39477`, `11489` | +| `income.Fees` | 13.5% (135/1000) | int: 135 | — | `-10000`, `-102379`, `-1024` | +| `income.FeesAndCommissions` | 5.4% (54/1000) | int: 54 | — | `1144000`, `115000`, `11549000` | +| `income.GainOnSaleOfBusiness` | 1.5% (15/1000) | int: 15 | — | `-19870000`, `-19873000`, `-20414000` | +| `income.GainOnSaleOfPPE` | 7.3% (73/1000) | int: 73 | — | `-1`, `-1017359`, `-10600000` | +| `income.GainOnSaleOfSecurity` | 39.6% (396/1000) | int: 396 | — | `-100`, `-1000`, `-1000000` | +| `income.GainsLossOnDisposalOfDiscontinuedOperations` | 0.1% (1/1000) | int: 1 | — | `1678467` | +| `income.GeneralAndAdministrativeExpense` | 87.9% (879/1000) | int: 879 | — | `-11000`, `-1149659`, `-1259524` | +| `income.GrossProfit` | 57.9% (579/1000) | int: 575, double: 4 | — | `-100`, `-1000`, `-10000` | +| `income.ImpairmentOfCapitalAssets` | 6.7% (67/1000) | int: 67 | — | `-10330000`, `-156717000`, `-391` | +| `income.InsuranceAndClaims` | 7.2% (72/1000) | int: 72 | — | `-10697`, `-14543`, `-21000` | +| `income.InterestExpense` | 5.7% (57/1000) | int: 57 | — | `1046000`, `1076000`, `11124000` | +| `income.InterestExpenseForLongTermDebtAndCapitalSecurities` | 2.1% (21/1000) | int: 21 | — | `-100000`, `-20000`, `-29000` | +| `income.InterestExpenseNonOperating` | 52.0% (520/1000) | int: 520 | — | `-104000`, `-118000`, `-175225` | +| `income.InterestExpenseOperating` | 1.8% (18/1000) | int: 18 | — | `-12853`, `111350`, `1369` | +| `income.InterestIncome` | 5.7% (57/1000) | int: 57 | — | `102896000`, `110603000`, `11234000` | +| `income.InterestIncomeAfterProvisionForLoanLoss` | 5.7% (57/1000) | int: 57 | — | `-2919000`, `106224000`, `10894000` | +| `income.InterestIncomeFromLoans` | 1.2% (12/1000) | int: 12 | — | `117056000`, `126975000`, `138083000` | +| `income.InterestIncomeFromLoansAndLease` | 5.7% (57/1000) | int: 57 | — | `11234000`, `117056000`, `12174000` | +| `income.InterestIncomeNonOperating` | 47.1% (471/1000) | int: 471 | — | `-1`, `-10000`, `-115588` | +| `income.InterestIncomeOperating` | 3.7% (37/1000) | int: 37 | — | `-22829`, `1056417`, `109000` | +| `income.LossAndLossAdjustmentExpectedIncurred` | 0.3% (3/1000) | int: 3 | — | `-1678467`, `-287954`, `287954` | +| `income.MarketingExpense` | 5.5% (55/1000) | int: 55 | — | `-3204000`, `-3275`, `-667` | +| `income.MinorityInterests` | 22.0% (220/1000) | int: 220 | — | `-1000`, `-10000`, `-101000` | +| `income.MiscOtherSpecialCharges` | 12.1% (121/1000) | int: 121 | — | `-1042000`, `-1048703`, `-1059000` | +| `income.NetIncome` | 95.3% (953/1000) | int: 953 | — | `-1000283`, `-1005272`, `-100786` | +| `income.NetIncomeCommonStockholders` | 90.0% (900/1000) | int: 900 | — | `-1000283`, `-100786`, `-1009911` | +| `income.NetIncomeContinuousOperations` | 88.0% (880/1000) | int: 880 | — | `-1000283`, `-100786`, `-1009911` | +| `income.NetIncomeDiscontinuousOperations` | 3.2% (32/1000) | int: 32 | — | `-119000`, `-136000`, `-1570000` | +| `income.NetIncomeExtraordinary` | 0.1% (1/1000) | int: 1 | — | `192305` | +| `income.NetIncomeFromContinuingAndDiscontinuedOperation` | 95.3% (953/1000) | int: 953 | — | `-1000283`, `-1005272`, `-100786` | +| `income.NetIncomeFromTaxLossCarryforward` | 0.1% (1/1000) | int: 1 | — | `165525` | +| `income.NetInterestIncome` | 5.7% (57/1000) | int: 57 | — | `10005000`, `10263000`, `106412000` | +| `income.NetNonOperatingInterestIncomeExpense` | 70.4% (704/1000) | int: 704 | — | `-1`, `-10`, `-1000` | +| `income.NetOperatingInterestIncomeExpense` | 3.9% (39/1000) | int: 39 | — | `-15349`, `-17230`, `-192300` | +| `income.NonInterestExpense` | 5.7% (57/1000) | int: 57 | — | `10146000`, `10521000`, `10568000` | +| `income.NonInterestIncome` | 5.7% (57/1000) | int: 57 | — | `-851000`, `100000`, `1010000` | +| `income.NormalizedIncome` | 96.0% (960/1000) | int: 960 | — | `-10059370`, `-100701`, `-10111` | +| `income.OperatingExpense` | 89.6% (896/1000) | int: 894, double: 2 | — | `-1068`, `-1076000`, `-1174772` | +| `income.OperatingIncome` | 84.8% (848/1000) | int: 848 | — | `-100000`, `-1000000`, `-100786` | +| `income.OperatingRevenue` | 46.3% (463/1000) | int: 444, double: 19 | — | `-12298894`, `1001042`, `10185798` | +| `income.OtherCostofRevenue` | 12.3% (123/1000) | int: 113, double: 10 | — | `1016900000`, `1021600000`, `1027000000` | +| `income.OtherCustomerServices` | 0.7% (7/1000) | int: 7 | — | `11675000`, `11860000`, `12868000` | +| `income.OtherGandA` | 87.9% (879/1000) | int: 879 | — | `-11000`, `-1149659`, `-1259524` | +| `income.OtherImpairmentOfCapitalAssets` | 1.3% (13/1000) | int: 13 | — | `-10330000`, `-8611000`, `1053065` | +| `income.OtherIncomeExpense` | 58.0% (580/1000) | int: 580 | — | `-1000`, `-10084000`, `-101547` | +| `income.OtherInterestExpense` | 4.9% (49/1000) | int: 49 | — | `1046000`, `1076000`, `1127000` | +| `income.OtherInterestIncome` | 4.5% (45/1000) | int: 45 | — | `1144000`, `115000`, `11549000` | +| `income.OtherNonInterestExpense` | 5.0% (50/1000) | int: 50 | — | `10943000`, `11387000`, `11699000` | +| `income.OtherNonInterestIncome` | 1.7% (17/1000) | int: 17 | — | `10579000`, `11385000`, `11600000` | +| `income.OtherOperatingExpenses` | 44.5% (445/1000) | int: 445 | — | `-10000`, `-10561`, `-11279` | +| `income.OtherSpecialCharges` | 11.4% (114/1000) | int: 114 | — | `-1`, `-10580`, `-1106000` | +| `income.OtherTaxes` | 2.3% (23/1000) | int: 23 | — | `-800021`, `103000`, `133176` | +| `income.OtherWriteDown` | 1.3% (13/1000) | int: 13 | — | `-14414`, `-2363`, `-8712` | +| `income.OtherWriteOff` | 0.8% (8/1000) | int: 8 | — | `-118454`, `-3835`, `-521000` | +| `income.OtherunderPreferredStockDividend` | 5.7% (57/1000) | int: 57 | — | `10000000`, `10100000`, `10200000` | +| `income.PreferredStockDividends` | 5.7% (57/1000) | int: 57 | — | `10000000`, `10100000`, `10200000` | +| `income.PretaxIncome` | 95.2% (952/1000) | int: 952 | — | `-1000283`, `-1005272`, `-100786` | +| `income.PromotionAndAdvertising` | 8.8% (88/1000) | int: 88 | — | `-16162`, `-18665`, `1063` | +| `income.RentAndLandingFees` | 27.9% (279/1000) | int: 279 | — | `-133000`, `-138019`, `-158000` | +| `income.ResearchAndDevelopment` | 17.9% (179/1000) | int: 179 | — | `-3972`, `-875916`, `1002000` | +| `income.ResearchExpense` | 6.2% (62/1000) | int: 62 | — | `-223174`, `-875916`, `1002000` | +| `income.RestructringAndMnAIncome` | 1.1% (11/1000) | int: 11 | — | `1319344`, `140020`, `148500` | +| `income.RestructuringAndMergernAcquisition` | 3.2% (32/1000) | int: 32 | — | `-1052000`, `-538000`, `-678000` | +| `income.SalariesAndWages` | 52.1% (521/1000) | int: 521 | — | `-111864`, `-12099`, `-14318` | +| `income.SecuritiesAmortization` | 0.1% (1/1000) | int: 1 | — | `303` | +| `income.SellingAndMarketingExpense` | 37.7% (377/1000) | int: 377 | — | `-1`, `-11542`, `-1391000` | +| `income.SellingExpense` | 0.2% (2/1000) | int: 2 | — | `-943260`, `479475` | +| `income.SellingGeneralAndAdministration` | 93.6% (936/1000) | int: 936 | — | `-10880000`, `-11000`, `-12352` | +| `income.ShareClassLevelSharesOutstanding` | 97.4% (974/1000) | int: 974 | — | `121266120`, `137417293`, `1407812249` | +| `income.SharesOutstanding` | 93.0% (930/1000) | int: 930 | — | `102308646`, `102503146`, `10323932` | +| `income.SpecialIncomeCharges` | 24.1% (241/1000) | int: 241 | — | `-1`, `-1017359`, `-10330000` | +| `income.TaxLossCarryforwardDilutedEPS` | 0.1% (1/1000) | int: 1 | — | `568648` | +| `income.TaxProvision` | 39.9% (399/1000) | int: 399 | — | `-1045000`, `-1094000`, `-110000` | +| `income.TotalExpenses` | 75.6% (756/1000) | int: 739, double: 17 | — | `-100330000`, `-100786`, `-10129` | +| `income.TotalRevenue` | 60.4% (604/1000) | int: 585, double: 19 | — | `-1024`, `-103331`, `-104970` | +| `income.WriteDown` | 1.0% (10/1000) | int: 10 | — | `-110661`, `-26049`, `1` | +| `income.WriteOff` | 3.9% (39/1000) | int: 39 | — | `-118454`, `-123695`, `-133000` | +| `reportDate` | 100.0% (1000/1000) | string: 1000 | ymd: 1000 (len 10..10) | `2012-01-31`, `2012-03-31`, `2012-04-30` | +| `reportType` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 1..1) | `A`, `Q` | +| `source` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 2..2) | `QM` | +| `symbol` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 2..5) | `AB.H`, `ACE.H`, `AF` | + +## `qmIntraday` (1000 docs sampled) + +| Field | Presence | Types | String Patterns | Examples | +| --- | --- | --- | --- | --- | +| `_id` | 100.0% (1000/1000) | objectId: 1000 | — | — | +| `adjustedclose` | 100.0% (1000/1000) | int: 23, double: 977 | — | `55.75`, `55.84`, `55.85` | +| `adjustedhigh` | 100.0% (1000/1000) | int: 27, double: 973 | — | `55.75`, `55.84`, `55.85` | +| `adjustedlow` | 100.0% (1000/1000) | int: 17, double: 983 | — | `55.75`, `55.79`, `55.84` | +| `adjustedopen` | 100.0% (1000/1000) | int: 19, double: 981 | — | `55.75`, `55.84`, `55.85` | +| `adjustedvwap` | 100.0% (1000/1000) | int: 7, double: 993 | — | `55.7579`, `55.84`, `55.85` | +| `avolume` | 100.0% (1000/1000) | int: 1000 | — | `100`, `1000`, `1002` | +| `close` | 100.0% (1000/1000) | int: 23, double: 977 | — | `55.75`, `55.84`, `55.85` | +| `created_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-07-01T22:51:05.428Z`, `2025-07-01T22:51:05.429Z` | +| `exchange` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..3) | `TSX` | +| `high` | 100.0% (1000/1000) | int: 27, double: 973 | — | `55.75`, `55.84`, `55.85` | +| `low` | 100.0% (1000/1000) | int: 17, double: 983 | — | `55.75`, `55.79`, `55.84` | +| `open` | 100.0% (1000/1000) | int: 19, double: 981 | — | `55.75`, `55.84`, `55.85` | +| `qmSearchCode` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 4..4) | `X:CA` | +| `sharevolume` | 100.0% (1000/1000) | int: 1000 | — | `100`, `1000`, `1002` | +| `startdatetime` | 100.0% (1000/1000) | string: 1000 | isoDatetime: 1000 (len 25..25) | `2025-06-24T16:00:00-04:00`, `2025-06-25T09:30:00-04:00`, `2025-06-25T09:32:00-04:00` | +| `symbol` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 1..1) | `X` | +| `timestamp` | 100.0% (1000/1000) | date: 1000 | — | `2025-06-24T20:00:00.000Z`, `2025-06-25T13:30:00.000Z`, `2025-06-25T13:32:00.000Z` | +| `type` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..3) | `MKT` | +| `updated_at` | 100.0% (1000/1000) | date: 1000 | — | `2025-07-01T23:13:12.419Z`, `2025-07-02T06:13:01.404Z`, `2025-07-02T06:13:01.405Z` | +| `vwap` | 100.0% (1000/1000) | int: 7, double: 993 | — | `55.7579`, `55.84`, `55.85` | + +## `teData` (1000 docs sampled) + +| Field | Presence | Types | String Patterns | Examples | +| --- | --- | --- | --- | --- | +| `_id` | 100.0% (1000/1000) | objectId: 1000 | — | — | +| `category` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 3..44) | `14-Day Reverse Repo Rate`, `15 Year Mortgage Rate`, `30 Year Mortgage Rate` | +| `country` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 5..22) | `Afghanistan`, `Albania`, `Angola` | +| `createdAt` | 100.0% (1000/1000) | date: 1000 | — | `2026-04-02T01:11:02.729Z`, `2026-04-02T01:11:02.766Z`, `2026-04-02T01:11:02.821Z` | +| `data` | 100.0% (1000/1000) | array: 1000 | — | — | +| `forecast` | 100.0% (1000/1000) | array: 1000 | — | — | +| `frequency` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 5..9) | `daily`, `monthly`, `quarterly` | +| `lastUpdated` | 100.0% (1000/1000) | date: 1000 | — | `2026-04-02T01:11:02.729Z`, `2026-04-02T01:11:02.766Z`, `2026-04-02T01:11:02.821Z` | +| `name` | 100.0% (1000/1000) | string: 1000 | other: 1000 (len 6..47) | `AF Balance of Trade`, `AF CPI Housing Utilities`, `AF CPI Transportation` | +| `source` | 100.0% (1000/1000) | string: 1000 | emptyOrWhitespace: 1, other: 999 (len 0..60) | , `ANFAVEA, Brazil`, `ANZ - Indeed Australian Job Ads` | +| `teSymbol` | 100.0% (1000/1000) | string: 1000 | numeric: 1, other: 999 (len 4..20) | `2738A38`, `4567988`, `4567A12` | +| `unit` | 100.0% (1000/1000) | string: 1000 | emptyOrWhitespace: 9, other: 991 (len 0..30) | , `10K TEU`, `AFN Million` | +| `updated_at` | 100.0% (1000/1000) | date: 1000 | — | `2026-04-02T01:11:02.729Z`, `2026-04-02T01:11:02.766Z`, `2026-04-02T01:11:02.821Z` | diff --git a/design/m2-close-evidence.md b/design/m2-close-evidence.md new file mode 100644 index 00000000..46403fc1 --- /dev/null +++ b/design/m2-close-evidence.md @@ -0,0 +1,152 @@ +# Milestone M2 Closure Evidence (`T-215`) + +Host, read-only QA MongoDB, `quant` (`10.0.0.51`) QuestDB `10.2.0`, and desktop Claude Code EC-1 verification evidence closing **Milestone M2** (`M2.5` / `T-215`). + +- **Date:** `2026-12-06` +- **Audited `master` / `dev` base SHA:** `87ae19e5f955c55b3ad411d3380c7e673a2ac533` +- **Closure branch:** `feat/m2-5-execute-host-quant` +- **Safety boundary:** Zero writes to QA MongoDB (`27017/stock`, queried strictly read-only as `studio_stock_bot_read`) and zero writes to QA PostgreSQL (`5432/trading_bot`; all PostgreSQL tests and EC-1 sign-off ran against disposable schemas in `stock_bot_safety` via `/home/boki/.studio/test-env/stock-bot.env`). `quant` QuestDB verification ran in an isolated container (`stock-bot-m2-questdb`) on dedicated ports (`19000`/`18812`/`19009`) and storage (`/mnt/data/stockbot/m2-isolated/questdb-v2`). + +--- + +## 1. Host Build & Full Test Verification + +Final post-edit host verification on `feat/m2-5-execute-host-quant`: + +| Gate / Command | Result | Details | +| --- | --- | --- | +| `CARGO_BUILD_JOBS=2 bun run check` | **PASS** | All `10/10` gates passed (`2m18s`, `0` errors, `0` warnings): `audit:secrets`, `build` (`29/29` Turbo packages), `typecheck`, `test:contracts`, `test:tooling` (`352` pass), `test:utils` (`32` pass), `test:calculations` (`144` pass), `test:integration` (`1,494` pass), `test:native` (`150` engine + `1,023` `curate-etl` lib + all integration targets, `0` failed), `lint:check` (`--max-warnings 0`) | +| `bun --env-file=/home/boki/.studio/test-env/stock-bot.env test test/postgres/` | **PASS** | `184` pass, `0` fail, `2,352` `expect()` calls across `24` files (`109.34s`, isolated schemas in `stock_bot_safety`) | +| `python/.venv/bin/pytest python/tests` | **PASS** | `28` passed (`1.59s`) | + +*(All `EC-2` restatement non-overwrite fixtures pass inside `curate-etl` Rust tests, DuckDB `MarketDataStore` tests, and Python `stockbot` tests.)* + +--- + +## 2. Read-Only QA MongoDB M2 Field-Shape Probe & Live-Corpus Findings + +### 2.1 Field-Shape Probe & Retained Artifacts + +- **Command:** `bun --env-file=.env.dev run apps/stock/data-pipeline/src/security-master/probe-source-field-shapes.ts --collections ceoPosts,eodIntraday1M,qmFinancials,qmFinancials-old,qmIntraday,teData --limit 1000` +- **Connection:** Read-only (`readOnly: true`, `studio_stock_bot_read@stock` on `27017/stock`), `6` collections / `6,000` sampled documents. +- **Committed probe report:** [m2-source-field-shapes.md](data-pipeline/m2-source-field-shapes.md) (`sha256: 832cb8ff1c8aed67ca5061fb0f9335f292f3f625ecf397730c8274696e00b4ea`), verified byte-identical (`diff` exit `0`) to the live probe output. +- **Committed macro series map:** [m2-macro-series-map.tsv](data-pipeline/m2-macro-series-map.tsv) (`sha256: 7b99bfac0b42113653adabd4703e4fb9c73ff58178c86c0fd9774359527abbb0`), mapping 6 conflict-free US+CA monthly/quarterly series (`CPI YOY`, `USURTOT`, `GDP CQOQ`, `CACPIYOY`, `CANLXEMR`, `CGE9QOQ`). `curate-etl curate-macro --from-mongo` streamed all `14,794` live `teData` documents into `4,901` curated Parquet rows (`30,033` bytes) with zero conflicts or forecast leakage. + +### 2.2 Live QA Corpus Document Counts + +Verified identically on local `27017/stock` and `quant` `10.0.0.51:27017/stock` via `studio_stock_bot_read`: + +| Collection | Live Document Count | Notes | +| --- | ---: | --- | +| `eodIntraday1M` | `3,402,612,960` | Includes `5,202,056` `CAD.FOREX` `1m` rows (`2009-09-25..2025-07-28`) | +| `qmIntraday` | `173,281,224` | Raw US + CA intraday (`2024–2025`) | +| `qmFinancials` | `1,864,342` | Contains Apple-duplication ingestion defect on non-Apple symbols (see §2.3) | +| `qmFinancials-old` | `907,764` | Distinct issuer-specific statements; `reportDate` acts as `periodEndDate` | +| `ceoPosts` | `14,779,267` | Curated with `bot == "1"` separation and `edited` timestamp guard | +| `teData` | `14,794` | Macro regime series (`4,901` curated rows across 6 conflict-free US+CA series) | + +### 2.3 Empirical Live-Corpus Findings & Code/Contract Remediations + +1. **`eodIntraday1M` OHLCV is already raw (unadjusted) across US splits:** Audited across 7/7 major US forward & reverse splits (`2014–2024`: `AAPL.US` `7:1` & `4:1`, `GE.US` `1:8`, `AMZN.US` `20:1`, `GOOGL.US` `20:1`, `CMG.US` `50:1`, `AVGO.US` `10:1`) and 24/25 audited `2018–2025` splits (`CSAN.US` `2021-05-10` was the lone split-adjusted outlier). Furthermore, `eodIntraday1M` lacks `NVDA.US`, `MSFT.US`, `TSLA.US`, and `WMT.US`, and its `NEXM.V` (`33` rows at `~$24.25`) is a corrupt ticker collision rather than a `1:20` split adjustment. + - **Remediation:** Defaulted `tools/curate-etl` `curate-bars-1m` to `--split-mode raw` (retaining `--split-mode unadjust` when un-adjustment is explicitly requested), updated [DATA-CONTRACTS.md](DATA-CONTRACTS.md) §1 and [CLAUDE.md](../CLAUDE.md) invariant 3, and enforced `qm_raw` write-after-EOD precedence in QuestDB (`DEDUP UPSERT KEYS(ts, listing_id)`). +2. **`qmIntraday` date gaps around split ex-dates:** Live `qmIntraday` has ingestion gaps `2024-05-22..2024-06-30` for `NVDA` (`51,822` docs) and `2025-06-18..2025-06-24` for `NEXM:CA` (`4,766` docs). + - **Remediation:** Extended `scripts/verify-m2-quant.ts` with validated split-straddling window flags (`--nvda-from`/`--nvda-to`, `--nexm-from`/`--nexm-to`) and optional extra EOD split-case flags (`--eod-split-*`), verified with `24/24` unit tests. +3. **`qmFinancials` Apple-duplication defect vs `qmFinancials-old`:** `qmFinancials` stamps Apple's financial figures (`2011-12-31` revenue `$46.333B` / net income `$13.064B`, `2025-03-29` revenue `$95.359B`, `currency="USD"`) onto unrelated tickers (`BMO:CA`, `RY:CA`, `SHOP:CA`, `CNQ:CA`, `X:CA`). `qmFinancials-old` carries distinct issuer-specific figures. + - **Remediation:** Documented in [DATA-CONTRACTS.md](DATA-CONTRACTS.md) §1 and [CLAUDE.md](../CLAUDE.md); EC-1 `fundamentals_pit` was curated from issuer-specific `qmFinancials-old`. +4. **`teData` intra-month policy-rate bucketing:** Daily policy-rate series (`FDTR`, `CCLR`) bucket multiple intra-month rate changes onto `YYYY-MM-01`, creating conflicting duplicate period dates. + - **Remediation:** Scoped [m2-macro-series-map.tsv](data-pipeline/m2-macro-series-map.tsv) to the 6 conflict-free monthly/quarterly US+CA series (`CPI YOY`, `USURTOT`, `GDP CQOQ`, `CACPIYOY`, `CANLXEMR`, `CGE9QOQ`). + +--- + +## 3. `quant` (`10.0.0.51`) QuestDB `10.2.0` Verification + +### 3.1 Host Kernel & Isolated Container Preflight + +- **Host kernel:** `sysctl -n vm.max_map_count` → **`1048576`** (`>= 1048576`). +- **Container:** `stock-bot-m2-questdb` running **`QuestDB 10.2.0`** (JDK `25.0.2`, commit `14d560b27e6911828f7315496e90d0209aec8831`), `--ulimit nofile=1048576:1048576`, `--memory 28g`, `--cpus 12`, `QDB_RAM_USAGE_LIMIT_BYTES=21474836480`, `JAVA_OPTS=-Xms2g -Xmx4g`, ports `10.0.0.51:19000` (HTTP), `10.0.0.51:18812` (PGWire), `10.0.0.51:19009` (ILP TCP), volume `/mnt/data/stockbot/m2-isolated/questdb-v2`. +- **DDL preflight (`scripts/verify-m2-quant.ts --ddl-only`):** `ok: true`; applied `getM2IntradayDDL()` tables `bars_1m`, `fx_1m`, `bar_revisions`; all `suspended: false` (`writerTxn: 0`, `sequencerTxn: 0`). + +### 3.2 `curate-etl --from-mongo` + `send-ilp` (`0x10` Binary-Double) Load & Idempotent Resend + +Curated directly from `quant` MongoDB (`studio_stock_bot_read@stock`) using the release `curate-etl` binary (`11.7 s` total across 3 feeds) and streamed to `10.0.0.51:19009` via `curate-etl send-ilp`: + +| Feed / Prefix | Window & Universe | Curated Rows | Size / Curate Time | Send Time | Post-Dedup Retained Rows | +| --- | --- | ---: | --- | --- | ---: | +| `bars_1m` (`eod_unadj`, raw) | `2024-02-01..2025-02-13` (`AAPL.US`, `AVGO.US`, `CMG.US`) | `611,630` | `110.6 MB` / `1.09 s` | `0.37 s` | `490,618` | +| `bars_1m_qm` (`qm_raw`) | `2024-05-15..2025-07-02` (`AAPL`, `AVGO`, `CMG`, `NVDA`, `NEXM:CA`) | `250,622` | `44.5 MB` / `0.53 s` | `0.13 s` | `250,622` | +| `fx_1m` (`USDCAD` / `eod`) | `2009-09-25..2025-07-28` (all `CAD.FOREX`) | `5,202,056` | `577.4 MB` / `10.06 s` | `1.86 s` | `5,202,056` | + +- **Deduplication & Precedence (`DEDUP UPSERT KEYS(ts, listing_id)`):** `121,012` real `(ts, listing_id)` overlaps between `eod_unadj` and `qm_raw`; `qm_raw` won 100% of overlaps (`611,630 - 121,012 = 490,618` `eod_unadj` + `250,622` `qm_raw` = `741,240` total `bars_1m` rows). +- **Binary-double `0x10` round-trip probes (`absDiff = 0` on all 4):** + - `bars_1m` (`listing_id=10970`, `ts_us=1709293140000000`): `eod_unadj`, close `1312.19`, `absDiff = 0`. + - `bars_1m_qm` (`listing_id=10970`, `ts_us=1750870560000000`): `qm_raw`, close `264.94`, `absDiff = 0`. + - `fx_1m` (`pair=USDCAD`, `ts_us=1253836800000000`): `eod`, close `0.9176`, `absDiff = 0`. + - `dedup_overlap` (`listing_id=11806`, `ts_us=1728055620000000`): `qm_raw`, close `56.66`, `absDiff = 0`. +- **Table content digests (Pass 1 & Pass 2 identical):** + - `bars_1m`: `ac7d2566a2b6cb3c4e2c7dcdfbb76052f722b833aa5e5bc70ee92808b1a16a61` + - `fx_1m`: `0352cfc3f7619696c6c2a36ccd38b00a191b7acf4c595527ab88a9befabd418b` +- **Pass 2 Idempotent Resend (`--resend-baseline`):** `ok: true`, `resendVerification.ok: true`, WAL advanced (`bars_1m` `4 → 5`, `bars_1m_qm` `5 → 8`, `fx_1m` `11 → 21`, live `bars_1m=8` / `fx_1m=22`, `suspended: false`), `shardHashesMatched: true`, `bars1mRowCountsUnchanged: true`, `fx1mRowCountsUnchanged: true`, `bars1mContentDigestMatched: true`, `fx1mContentDigestMatched: true`. + +### 3.3 Split-Boundary Parity (`bars_1m` Session Closes vs Raw `bars_1d`, Threshold `<= 0.5%`) + +| Listing | Split & Ex-Date | Source | Window | Pre / Post Sessions | Max Rel Diff | Sample Session Closes (`1m` vs `1d`) | +| --- | --- | --- | --- | :---: | ---: | --- | +| **`NVDA.US`** (`20815`) | `10:1` (`2024-06-10`) | `qm_raw` | `2024-05-20..2024-07-02` | `2` / `2` | **`0.0965%`** | Pre: `948.34/947.80`, `953.51/953.86`; Post: `124.18/124.30`, `122.66/122.67` | +| **`NEXM.V`** (`50044`) | `1:20` (`2025-06-20`) | `qm_raw` | `2025-06-17..2025-06-27` | `1` / `3` | **`0.0000%`** | Pre: `0.405/0.405`; Post: `9.52/9.52`, `9.80/9.80`, `10.20/10.20` | +| **`AVGO.US`** (`10970`) | `10:1` (`2024-07-15`) | `eod_unadj` (raw) | `2024-07-11..2024-07-17` | `2` / `3` | **`0.0408%`** | Pre: `1706.49/1705.95`, `1700.87/1700.67`; Post: `171.49/171.42`, `169.40/169.375`, `155.96/155.98` | + +All three split boundaries passed well under the `0.5%` (`0.005`) EC-3 gate. + +### 3.4 1-Year `1m` PGWire Latency (`< 250 ms` Warm / `< 1,000 ms` Cold) + +Target: `CMG.US` (`listingId: 11806`), window `2024-02-01..2025-02-05` (`371 days`, `137,382` bars), Vault-fenced (`vaultCutoffTs = 2025-02-13T00:00:00.000Z`, `clampedTo: false`), result digest `32502098586198f10c717fa2f1c82aeb78fa0f15a6627cba1ce16b8ed5dd54f2`: + +| Run | Cold Latency (`< 1,000 ms`) | Warm Runs (5×, `< 250 ms`) | Warm Median | Status | +| --- | ---: | --- | ---: | :---: | +| Pass 1 | **`291.65 ms`** | `168.86`, `133.32`, `128.74`, `126.16`, `122.22 ms` | **`128.74 ms`** | **PASS** | +| Pass 2 (post-resend) | **`207.88 ms`** | `141.47`, `124.60`, `127.94`, `123.67`, `132.47 ms` | **`127.94 ms`** | **PASS** | + +--- + +## 4. Desktop Claude Code EC-1 Sign-Off (`mcp:research-copilot` + Real `marimo`) + +### 4.1 Real-Runtime Bugs Caught & Fixed During Sign-Off + +Running real desktop Claude Code (`2.1.84`) exposed two integration defects not covered by mock handshakes, both fixed and unit-tested on this branch: +1. **MCP `initialize` `clientInfo` schema (`libs/research/src/mcp/protocol.ts`):** Strict object validation rejected optional MCP `Implementation` fields (`title`, `description`, `websiteUrl`) sent by Claude Code `2.1.84`. Updated `clientInfo` schema to accept optional spec fields with `.passthrough()` and added regression coverage in `libs/research/test/mcp-protocol.test.ts`. +2. **PostgreSQL `postgresSchema` `search_path` (`libs/data/postgres/src/research-copilot-executor.ts`):** `openResearchCopilotExecutor` did not apply `config.postgresSchema` to `poolConfig.options` (`-c search_path=,public`), causing `trial_ledger` writes/DSR reads to fail against non-`public` schemas. Added validated `postgresSchema` handling and unit tests in `libs/data/postgres/test/research-copilot-executor.test.ts`. + +### 4.2 End-to-End Sign-Off Receipt + +- **Client:** Desktop Claude Code `2.1.84` (session `5303dcf3-28d9-4e9f-9f90-e110f9ffdccb`, `--strict-mcp-config`, `12` turns, `70.6 s`). +- **Server:** `bun run mcp:research-copilot` connected to: + - Curated live Parquet corpus (`12` XTSE listings, `fundamentals_pit` `772` rows from `qmFinancials-old`, `shorts` from `ceoShorts`, `events` `5,002` `ceo_post` rows in `year=2024/2025`, `macro` `4,901` rows from `teData`, Vault cutoff `2025-02-13T00:00:00.000Z`). + - Real Studio quant library (`/home/boki/repos/studio/catalog/quant/library`). + - Disposable PostgreSQL schema `m2_ec1_signoff` in `stock_bot_safety`. + - Real `marimo 0.26.0` via `bun run notebook:snapshot`. +- **Zero execution access:** Exactly `6` MCP tools exposed (`search_symbols`, `read_knowledge`, `query_data`, `analyze_signal`, `event_study`, `file_finding`); `paperOrLiveOrderOrExecutionTools: []`, `zeroExecutionAccess.confirmed: true`. +- **Discovery, Knowledge & Vault Fence:** + - `search_symbols("RY", country="CA")`: returned `listingId=5024` (`Royal Bank of Canada`, `XTSE`, `CAD`). + - `read_knowledge`: returned `9` Studio `library.yml` cards + `1` PostgreSQL `provider_caveats` entry (`cav-eod-intraday-raw`). + - `query_data` (`2025-02-05..2025-02-20`): clamped at Vault cutoff (`clampedTo: true`, `6` rows through `2025-02-12`). + - `query_data` (`2025-02-14..2025-02-20`): fail-closed rejected with `VaultHoldoutFenceError` (`0` rows returned). +- **Logged `trial_ledger` Studies (all honest null results on the 12-name post-2023 TSX slice; `passesGate=false`):** + +| Trial | Tool & Study | `expressionHash` | Sample / Obs | Key Metrics | DSR (`passesGate`) | +| :---: | --- | --- | --- | --- | --- | +| `1` | `analyze_signal` (`fundamentals` / `ttm_net_income`, 5d, `allowEstimatedLag=true`) | `6ab7b9376592870fa096c6980abe8b60c3bcbee6e47645e0a4440d34d3b99e57` | `2024-01-02..2025-02-05` (`n=277`) | Rank IC `0.0044` (`t=0.16`), Pearson IC `0.0375` (`t=1.07`), Q5-Q1 `0.00087` (`t=0.22`) | `0.6087` (`false`) | +| `2` | `analyze_signal` (`shorts` / `shares_short`, 5d) | `fd3b320e3e230ec77752907ec96e297bc2b58d6ffba61f7f35400164c695a1c9` | `2024-01-22..2025-02-05` (`n=263`) | Rank IC `0.0209` (`t=0.61`), Pearson IC `-0.0025` (`t=-0.07`), Q5-Q1 `-0.00035` (`t=-0.16`) | `0.7777` (`false`) | +| `3` | `event_study` (`ceo_post`, `[-2,+5]`, equal-weight) | `be6b0d20b4d0ec0a22588a5dd309c4024aea0070df9467723e84b1fbd3d5f795` | `2024-01-05..2025-02-05` (`1,773` used / `274` dates) | `CAAR(-2..+5)=0.000246`, clustered CAR `0.000485` (`t=0.67`) | `0.6424` (`false`) | + +- **`marimo` Static HTML Snapshot (`bun run notebook:snapshot`, `marimo 0.26.0`):** `exitOk: true`, `39,509` bytes, `sha256:9a046686eefd64586ffcf39dcdf13391f4b469305819c36b7115c50e63d53092`, `marimo check` diagnostics: `total_files: 1`, `files_with_issues: 0`, `total_issues: 0`, `errored: false`. +- **Filed Finding (`file_finding`):** Persisted row `id="0293bdad-ebcb-436e-9900-e9e2126d0907"`, `created: true`, `title="M2 EC-1 TSX Fundamental + Alt-Data & CEO Posts Study"`, `trialRefs: ["1", "2", "3"]`, `evidenceRefs: ["sha256:9a046686eefd64586ffcf39dcdf13391f4b469305819c36b7115c50e63d53092"]`, `idempotencyKey: "m2-ec1-desktop-claude-signoff-v1"`. + +--- + +## 5. Exit Criteria Sign-Off Matrix + +| Criterion | Status | Evidence | +| --- | :---: | --- | +| **EC-1:** Desktop Claude Code via MCP runs fundamental + alt-data signal study and event study end-to-end, exports `marimo check`-clean static HTML snapshot, and files a finding with zero execution access | **PASS** | §4 (Claude Code `2.1.84`, 6 tools, Trials `1`–`3`, `marimo 0.26.0` `0` issues, finding `0293bdad-ebcb-436e-9900-e9e2126d0907`) | +| **EC-2:** Restatement fixture proves restated Q1 (`known_at > Q2`) never overwrites Q2 in `fundamentalsAsOf` | **PASS** | §1 (`curate-etl` Rust tests, DuckDB `MarketDataStore` tests, Python `stockbot` tests) | +| **EC-3:** Split-boundary `bars_1m` closes match raw `bars_1d` within `0.5%` (`NEXM.V` `1:20`, `NVDA.US` `10:1`, plus `AVGO.US` `10:1` EOD raw) and 1y `1m` loads `< 250 ms` warm / `< 1 s` cold on `quant` QuestDB `10.2.0` | **PASS** | §3 (`NVDA.US` `0.0965%`, `NEXM.V` `0.0000%`, `AVGO.US` `0.0408%`; 1y `CMG.US` `137,382` bars `291.65 ms` cold / `128.74 ms` warm median Pass 1, `207.88 ms` cold / `127.94 ms` warm median Pass 2; idempotent resend digest-identical) | diff --git a/libs/data/postgres/src/research-copilot-executor.ts b/libs/data/postgres/src/research-copilot-executor.ts index cd55c3b7..c55386db 100644 --- a/libs/data/postgres/src/research-copilot-executor.ts +++ b/libs/data/postgres/src/research-copilot-executor.ts @@ -62,6 +62,7 @@ const STRIPPED_TIMEOUT_PARAMS: ReadonlySet = new Set([ const POSTGRES_URL_PREFIX_RE = /^postgres(?:ql)?:\/\//i; const PORT_DIGITS_RE = /^\d+$/; const CONTROL_CHAR_RE = /[\r\n\0]/; +const SCHEMA_IDENT_RE = /^[a-z_][a-z0-9_]*$/; /** * Sanitized error thrown by {@link openResearchCopilotExecutor} and the @@ -82,6 +83,7 @@ export class ResearchCopilotExecutorError extends Error { /** Configuration accepted by {@link openResearchCopilotExecutor}. */ export interface ResearchCopilotExecutorConfig { readonly postgresUrl: string; + readonly postgresSchema?: string; } /** Minimal `pg.Pool` surface required by {@link openResearchCopilotExecutor}. */ @@ -237,6 +239,14 @@ function parseAndNormalizePoolConfig(config: ResearchCopilotExecutorConfig): Poo const envOptions = typeof process.env.PGOPTIONS === 'string' ? process.env.PGOPTIONS.trim() : ''; const baseOptions = existingOptions.length > 0 ? existingOptions.join(' ') : envOptions; + let schemaOption = ''; + if (config.postgresSchema !== undefined) { + if (typeof config.postgresSchema !== 'string' || !SCHEMA_IDENT_RE.test(config.postgresSchema)) { + throw invalidConfigError(); + } + schemaOption = `-c search_path=${config.postgresSchema},public`; + } + const poolConfig: PoolConfig = { connectionString: parsed.toString(), max: RESEARCH_COPILOT_PG_POOL_MAX, @@ -246,8 +256,9 @@ function parseAndNormalizePoolConfig(config: ResearchCopilotExecutorConfig): Poo lock_timeout: RESEARCH_COPILOT_PG_LOCK_TIMEOUT_MS, }; - if (baseOptions.length > 0) { - poolConfig.options = `${baseOptions} -c statement_timeout=${RESEARCH_COPILOT_PG_STATEMENT_TIMEOUT_MS} -c lock_timeout=${RESEARCH_COPILOT_PG_LOCK_TIMEOUT_MS}`; + const combinedBase = [baseOptions, schemaOption].filter(s => s.length > 0).join(' '); + if (combinedBase.length > 0) { + poolConfig.options = `${combinedBase} -c statement_timeout=${RESEARCH_COPILOT_PG_STATEMENT_TIMEOUT_MS} -c lock_timeout=${RESEARCH_COPILOT_PG_LOCK_TIMEOUT_MS}`; } return poolConfig; diff --git a/libs/data/postgres/test/research-copilot-executor.test.ts b/libs/data/postgres/test/research-copilot-executor.test.ts index c014d210..3ae8dea9 100644 --- a/libs/data/postgres/test/research-copilot-executor.test.ts +++ b/libs/data/postgres/test/research-copilot-executor.test.ts @@ -156,6 +156,58 @@ describe('openResearchCopilotExecutor', () => { } }); + test('applies validated postgresSchema to pool search_path options and rejects invalid schemas', async () => { + const previousPgOptions = process.env.PGOPTIONS; + delete process.env.PGOPTIONS; + try { + const capturedConfigs: PoolConfig[] = []; + const fake = createFakePool(); + + const handle = await openResearchCopilotExecutor( + { postgresUrl: VALID_URL, postgresSchema: 'm2_ec1_signoff' }, + { + createPool(poolConfig) { + capturedConfigs.push(poolConfig); + return fake.pool; + }, + } + ); + + expect(capturedConfigs).toHaveLength(1); + expect(capturedConfigs[0]?.options).toBe( + `-c search_path=m2_ec1_signoff,public -c statement_timeout=${RESEARCH_COPILOT_PG_STATEMENT_TIMEOUT_MS} -c lock_timeout=${RESEARCH_COPILOT_PG_LOCK_TIMEOUT_MS}` + ); + await handle.close(); + + let createPoolCalls = 0; + for (const badSchema of ['', 'UPPER', '1bad', 'a-b', 'public; DROP TABLE x', 'a b']) { + let caught: unknown; + try { + await openResearchCopilotExecutor( + { postgresUrl: VALID_URL, postgresSchema: badSchema }, + { + createPool() { + createPoolCalls += 1; + return createFakePool().pool; + }, + } + ); + } catch (err) { + caught = err; + } + assertNoSecretsLeaked(caught); + expect((caught as ResearchCopilotExecutorError).code).toBe('INVALID_CONFIG'); + } + expect(createPoolCalls).toBe(0); + } finally { + if (previousPgOptions === undefined) { + delete process.env.PGOPTIONS; + } else { + process.env.PGOPTIONS = previousPgOptions; + } + } + }); + test('rejects invalid URLs with INVALID_CONFIG before constructing a pool', async () => { const invalidUrls = [ '', diff --git a/libs/research/src/mcp/protocol.ts b/libs/research/src/mcp/protocol.ts index fe7efcd6..08051687 100644 --- a/libs/research/src/mcp/protocol.ts +++ b/libs/research/src/mcp/protocol.ts @@ -140,8 +140,11 @@ export const mcpInitializeParamsSchema = z .object({ name: z.string().min(1), version: z.string().min(1), + title: z.string().optional(), + description: z.string().optional(), + websiteUrl: z.string().optional(), }) - .strict() + .passthrough() .optional(), _meta: mcpRequestMetaSchema.optional(), }) diff --git a/libs/research/test/mcp-protocol.test.ts b/libs/research/test/mcp-protocol.test.ts index 511a8f7e..ba5bd659 100644 --- a/libs/research/test/mcp-protocol.test.ts +++ b/libs/research/test/mcp-protocol.test.ts @@ -60,6 +60,37 @@ describe('MCP protocol & server core', () => { }); }); + test('initialize accepts MCP Implementation clientInfo metadata fields (title, description, websiteUrl)', async () => { + const server = createMcpServer({ + name: 'stock-bot-research', + version: '0.1.0', + tools: [], + }); + + const raw = await server.handleMessage( + JSON.stringify({ + jsonrpc: '2.0', + id: 2, + method: 'initialize', + params: { + protocolVersion: MCP_PROTOCOL_VERSION, + capabilities: {}, + clientInfo: { + name: 'claude-code', + version: '2.1.84', + title: 'Claude Code', + description: 'Anthropic CLI client', + websiteUrl: 'https://claude.ai', + }, + }, + }) + ); + + const response = parseResponse(raw); + expect(response.error).toBeUndefined(); + expect(response.result?.protocolVersion).toBe(MCP_PROTOCOL_VERSION); + }); + test('notifications/initialized returns null (no response)', async () => { const server = createMcpServer({ name: 'stock-bot-research', diff --git a/scripts/test/verify-m2-quant.test.ts b/scripts/test/verify-m2-quant.test.ts index cb97a036..31da74ad 100644 --- a/scripts/test/verify-m2-quant.test.ts +++ b/scripts/test/verify-m2-quant.test.ts @@ -21,6 +21,7 @@ import { type VerifyM2QuantCliDeps, type VerifyM2QuantDdlOnlyReport, type VerifyM2QuantReport, + parseVerifyM2QuantArgs, runVerifyM2QuantCli, } from '../verify-m2-quant'; @@ -1614,5 +1615,48 @@ describe('scripts/verify-m2-quant.ts', () => { expect(await runVerifyM2QuantCli(nonUtcCutoff.deps)).toBe(1); assertSingleLineError(nonUtcCutoff.stderr.text()); expect(nonUtcCutoff.stderr.text()).toContain('UTC timestamp ending in'); + + const badNvdaWindow = createHarness(baseArgs({ '--nvda-from': '2024-06-10' })); + expect(await runVerifyM2QuantCli(badNvdaWindow.deps)).toBe(1); + assertSingleLineError(badNvdaWindow.stderr.text()); + expect(badNvdaWindow.stderr.text()).toContain('must straddle ex-date 2024-06-10'); + + const partialExtra = createHarness(baseArgs({ '--eod-split-label': 'AVGO.US' })); + expect(await runVerifyM2QuantCli(partialExtra.deps)).toBe(1); + assertSingleLineError(partialExtra.stderr.text()); + expect(partialExtra.stderr.text()).toContain('Incomplete extra EOD split case flags'); + }); + + test('supports explicit split window overrides and extra EOD split case', () => { + const parsed = parseVerifyM2QuantArgs( + baseArgs({ + '--nvda-from': '2024-05-20', + '--nvda-to': '2024-07-02', + '--nexm-from': '2025-06-17', + '--nexm-to': '2025-06-27', + '--eod-split-label': 'AVGO.US', + '--eod-split-listing-id': '10970', + '--eod-split-from': '2024-07-11', + '--eod-split-to': '2024-07-17', + '--eod-split-ex-date': '2024-07-15', + '--eod-split-ratio': '10:1', + }), + { cwd: '/tmp' } + ); + expect(parsed.kind).toBe('run'); + if (parsed.kind === 'run') { + expect(parsed.nvdaFromDate).toBe('2024-05-20'); + expect(parsed.nvdaToDate).toBe('2024-07-02'); + expect(parsed.nexmFromDate).toBe('2025-06-17'); + expect(parsed.nexmToDate).toBe('2025-06-27'); + expect(parsed.extraSplitCase).toEqual({ + label: 'AVGO.US', + listingId: 10970, + fromDate: '2024-07-11', + toDate: '2024-07-17', + exDate: '2024-07-15', + ratio: '10:1', + }); + } }); }); diff --git a/scripts/verify-m2-quant.ts b/scripts/verify-m2-quant.ts index f0e7c81f..8f7a1dda 100644 --- a/scripts/verify-m2-quant.ts +++ b/scripts/verify-m2-quant.ts @@ -87,13 +87,17 @@ export const REQUIRED_SHARD_PREFIXES = ['bars_1m', 'bars_1m_qm', 'fx_1m'] as con export type RequiredShardPrefix = (typeof REQUIRED_SHARD_PREFIXES)[number]; export interface SplitBoundaryCaseSpec { - readonly label: 'NVDA.US' | 'NEXM.V'; + readonly label: string; readonly fromDate: string; readonly toDate: string; readonly exDate: string; readonly ratio: string; } +export interface ExtraSplitBoundaryCase extends SplitBoundaryCaseSpec { + readonly listingId: number; +} + export const M2_SPLIT_BOUNDARY_CASES: readonly SplitBoundaryCaseSpec[] = [ { label: 'NVDA.US', @@ -134,6 +138,11 @@ export interface ParsedVerifyM2QuantRun { readonly vaultCutoffTs: number; readonly nvdaListingId: number; readonly nexmListingId: number; + readonly nvdaFromDate?: string; + readonly nvdaToDate?: string; + readonly nexmFromDate?: string; + readonly nexmToDate?: string; + readonly extraSplitCase?: ExtraSplitBoundaryCase; readonly benchListingId: number; readonly benchFrom: string; readonly benchTo: string; @@ -323,7 +332,7 @@ export interface SplitBoundarySessionComparison { } export interface SplitBoundaryCheckResult { - readonly label: 'NVDA.US' | 'NEXM.V'; + readonly label: string; readonly listingId: number; readonly fromDate: string; readonly toDate: string; @@ -439,6 +448,16 @@ export const VERIFY_M2_QUANT_USAGE = [ ' --apply-ddl Execute applyM2IntradayDDL before checks (full mode)', ` --warm-runs Number of warm 1y 1m benchmark reads (default: ${DEFAULT_WARM_RUNS})`, ` --wal-settle-timeout-ms WAL settle polling timeout in ms (default: ${DEFAULT_WAL_SETTLE_TIMEOUT_MS})`, + ' --nvda-from Optional NVDA.US split window start (< 2024-06-10)', + ' --nvda-to Optional NVDA.US split window end (>= 2024-06-10)', + ' --nexm-from Optional NEXM.V split window start (< 2025-06-20)', + ' --nexm-to Optional NEXM.V split window end (>= 2025-06-20)', + ' --eod-split-label