diff --git a/tools/curate-etl/README.md b/tools/curate-etl/README.md index e9f56749..8f6b360c 100644 --- a/tools/curate-etl/README.md +++ b/tools/curate-etl/README.md @@ -810,13 +810,13 @@ cargo run --release -p curate-etl --offline -- bench-curate-fx [rows] 1. **Field & timestamp rules:** - Calls `build_corporate_actions` unchanged (`1:1` split no-ops, `0.0` cash dividends, and delistings without an outcome drop inside the builder; same-key multi-dividends stay separate; late declarations clamp to `ex_date` with `KnownAtSource::ExDateFallback`; local `currency` is preserved). - - Resolves `(mapping_source, key, ex_date) -> listing_id` via `ProviderMappingTable::cursor_for` / `ProviderMappingCursor::resolve` (one cursor per contiguous `key` run). - - For `otc_delist_transfer` rows, resolves `successor_key` at the same `ex_date` (Pass 6 `effectiveDate`, the successor's first OTC trading date) to `successor_listing_id`. Never emits an `otc_delist_transfer` with `successor_listing_id = None` or `successor_listing_id == listing_id`. + - Resolves `(mapping_source, key, ex_date) -> listing_id` via `ProviderMappingTable::cursor_for` / `ProviderMappingCursor::resolve` (one cursor per contiguous `key` run) for `split`, `dividend`, and terminal `delisting` rows. + - For `otc_delist_transfer` rows, Pass 6 anchors `ex_date` (and `known_at`) to `effectiveDate` (the successor's first OTC trading date), which normally falls after the outgoing listing's primary-venue `valid_to` (e.g. `SIVB.US` ends `2023-03-10`, `SIVBQ.US` starts `2023-03-28`). The outgoing `listing_id` therefore resolves to the latest `provider_mapping` range for `(mapping_source, key)` with `valid_from <= ex_date`, while `successor_key` is resolved strictly on `ex_date` to `successor_listing_id`. Never emits an `otc_delist_transfer` with `successor_listing_id = None` or `successor_listing_id == listing_id`. - Stamps `known_at_micros = et_session_close_utc_micros(known_at_date)` (`16:00:00 ET` of `known_at_date`, matching `bars_1d`'s conservative end-of-session convention because source corporate-action records carry no intraday announcement time) and carries `known_at_source` through unchanged. - Carries `ex_date`, `declared_date`, `kind`, `ratio`, `cash_amount`, `currency`, and `terminal_return` through bit-exactly (`"USD"`/`"CAD"` interned as `Cow::Borrowed`). 2. **Drop & collision policy (never panics or aborts on bad rows):** - Strict drop priority per built row: - 1. `dropped_unmapped`: no `provider_mapping` range covers `(mapping_source, key, ex_date)`. + 1. `dropped_unmapped`: no covering `provider_mapping` range for `(mapping_source, key, ex_date)` (or, for `otc_delist_transfer`, no range with `valid_from <= ex_date`). 2. `dropped_unmapped_successor`: `otc_delist_transfer` whose `successor_key` has no covering range on `ex_date`. 3. `dropped_self_successor`: `otc_delist_transfer` whose `successor_key` resolves to the row's own `listing_id`. 4. `dropped_known_at_out_of_range`: `known_at_date` falls outside `et_session_close_utc_micros`'s `1976-01-01..=2030-12-31` window. @@ -839,12 +839,12 @@ Command (`2026-11-28`, two back-to-back runs with identical checksum `0x0c22a1a1 - Input: `events=520000`, `splits=20262`, `dividends=494624`, `delistings=5114`, `keys=20000` - Builder: `rows_out=514224`, `splits_out=19938`, `split_noops=324`, `divs_out=489671`, `zero_div=4953`, `otc_out=2856`, `delist_out=1759`, `delist_no_outcome=499` - Output: `rows_out=494518` (`95.10%` retained), `listings_out=19996`, `files=1`, `row_groups=1`, `bytes=3802001`, `read_back_rows=494518` -- Curation stats: `unmapped=12887`, `unmapped_succ=510`, `self_succ=531`, `known_at_oor=2526`, `coll_collapsed=1398`, `coll_dropped=1854` +- Curation stats: `unmapped=12886`, `unmapped_succ=511`, `self_succ=531`, `known_at_oor=2526`, `coll_collapsed=1398`, `coll_dropped=1854` - Run 1: - - Stage (in-memory): `elapsed=243.00 ms`, `throughput=2139948 events/s`, `latency=467.30 ns/event`, `checksum=0x0c22a1a1ab7caad4` - - Parquet write: `elapsed=118.61 ms`, `throughput=4169410 rows/s` - - Combined (stage → Parquet): `elapsed=361.60 ms`, `throughput=1438042 events/s` + - Stage (in-memory): `elapsed=256.41 ms`, `throughput=2027993 events/s`, `latency=493.10 ns/event`, `checksum=0x0c22a1a1ab7caad4` + - Parquet write: `elapsed=127.16 ms`, `throughput=3888979 rows/s` + - Combined (stage → Parquet): `elapsed=383.57 ms`, `throughput=1355685 events/s` - Run 2: - - Stage (in-memory): `elapsed=244.15 ms`, `throughput=2129829 events/s`, `latency=469.52 ns/event`, `checksum=0x0c22a1a1ab7caad4` - - Parquet write: `elapsed=155.57 ms`, `throughput=3178815 rows/s` - - Combined (stage → Parquet): `elapsed=399.72 ms`, `throughput=1300918 events/s` + - Stage (in-memory): `elapsed=259.24 ms`, `throughput=2005895 events/s`, `latency=498.53 ns/event`, `checksum=0x0c22a1a1ab7caad4` + - Parquet write: `elapsed=126.13 ms`, `throughput=3920583 rows/s` + - Combined (stage → Parquet): `elapsed=385.37 ms`, `throughput=1349354 events/s` diff --git a/tools/curate-etl/src/curate_corporate_actions.rs b/tools/curate-etl/src/curate_corporate_actions.rs index 28fc9467..df89549c 100644 --- a/tools/curate-etl/src/curate_corporate_actions.rs +++ b/tools/curate-etl/src/curate_corporate_actions.rs @@ -13,10 +13,14 @@ //! [`ProviderMappingTable::cursor_for`] / [`crate::provider_mapping::ProviderMappingCursor::resolve`] //! (one cursor per contiguous `key` run, since `build_corporate_actions` emits rows sorted by //! `key` then `ex_date`). -//! - For [`CorporateActionKind::OtcDelistTransfer`] rows, resolves `successor_key` at the same -//! `ex_date` (Pass 6 `effectiveDate`, the successor's first OTC trading date) to -//! `successor_listing_id`. Unmapped successors (`dropped_unmapped_successor`) and successors that -//! alias to the row's own `listing_id` (`dropped_self_successor`) are dropped—never emitted with +//! - For [`CorporateActionKind::OtcDelistTransfer`] rows, Pass 6 anchors `ex_date` (and `known_at`) +//! to `effectiveDate` (the successor's first OTC trading date), which normally falls after the +//! outgoing listing's primary-venue `valid_to` (e.g. `SIVB.US` ends `2023-03-10`, `SIVBQ.US` +//! starts `2023-03-28`). The outgoing `listing_id` therefore resolves to the latest range for +//! `(mapping_source, key)` with `valid_from <= ex_date`, while `successor_key` is resolved +//! strictly on `ex_date` to `successor_listing_id`. Unmapped outgoing keys (`dropped_unmapped`), +//! unmapped successors (`dropped_unmapped_successor`), and successors that alias to the row's own +//! `listing_id` (`dropped_self_successor`) are dropped—never emitted with //! `successor_listing_id = None` or a self-link. //! - Stamps `known_at_micros = et_session_close_utc_micros(known_at_date)` (`16:00:00 ET` of //! `known_at_date`, matching `bars_1d`'s conservative end-of-session convention because source @@ -44,7 +48,7 @@ use crate::parquet_corporate_actions::{ write_corporate_actions_dataset, CorporateActionsParquetRow, CorporateActionsWriteOptions, CorporateActionsWriteStats, ParquetCorporateActionsError, }; -use crate::provider_mapping::ProviderMappingTable; +use crate::provider_mapping::{MappingRange, ProviderMappingTable}; use crate::session_close::et_session_close_utc_micros; /// Accounting summary produced alongside [`CurateCorporateActionsOutput::rows`]. @@ -159,6 +163,12 @@ impl From for CurateCorporateActionsWriteError { } } +#[inline] +fn resolve_on_or_before(ranges: &[MappingRange], date: i32) -> Option { + let idx = ranges.partition_point(|r| r.valid_from <= date); + idx.checked_sub(1).map(|i| ranges[i].listing_id) +} + #[inline] fn opt_f64_bits(value: Option) -> Option { value.map(f64::to_bits) @@ -240,12 +250,21 @@ where } // Strict drop priority: - // 1. Primary (mapping_source, key, ex_date) unmapped -> dropped_unmapped + // 1. Primary listing lookup -> dropped_unmapped. + // For `OtcDelistTransfer`, Pass 6 anchors `ex_date` to the successor's first OTC + // trading date (`effectiveDate`), after the outgoing listing's primary-venue mapping + // has typically ended (e.g. SIVB.US ends 2023-03-10, SIVBQ.US starts 2023-03-28), so + // resolve the outgoing listing as the latest range with `valid_from <= ex_date`. if cursor.ranges().is_empty() { stats.dropped_unmapped += 1; continue; } - let Some(listing_id) = cursor.resolve(row.ex_date) else { + let primary_listing_id = if row.kind == CorporateActionKind::OtcDelistTransfer { + resolve_on_or_before(cursor.ranges(), row.ex_date) + } else { + cursor.resolve(row.ex_date) + }; + let Some(listing_id) = primary_listing_id else { stats.dropped_unmapped += 1; continue; }; diff --git a/tools/curate-etl/src/curate_corporate_actions_tests.rs b/tools/curate-etl/src/curate_corporate_actions_tests.rs index 10514f98..426707cc 100644 --- a/tools/curate-etl/src/curate_corporate_actions_tests.rs +++ b/tools/curate-etl/src/curate_corporate_actions_tests.rs @@ -1,16 +1,17 @@ -use std::borrow::Cow; use std::error::Error; use std::fs::{self, File}; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicU64, Ordering as AtomicOrdering}; use parquet::basic::{Compression, ConvertedType, LogicalType, Repetition, TimeUnit, Type as PhysicalType}; -use parquet::column::reader::ColumnReader; use parquet::file::reader::{FileReader, SerializedFileReader}; use parquet::schema::types::Type; use super::*; use crate::corporate_actions::KnownAtSource; +use crate::parquet_corporate_actions::tests::{ + assert_no_transient_files, assert_row_bitwise_eq, read_parquet_rows, +}; use crate::provider_mapping::ProviderMappingRow; use crate::split::ymd_to_epoch_days; @@ -217,60 +218,6 @@ fn assert_conservation_and_order(out: &CurateCorporateActionsOutput) { } } -fn assert_row_bitwise_eq(actual: &CorporateActionsParquetRow, expected: &CorporateActionsParquetRow) { - assert_eq!(actual.listing_id, expected.listing_id); - assert_eq!(actual.ex_date, expected.ex_date); - assert_eq!(actual.declared_date, expected.declared_date); - assert_eq!(actual.kind, expected.kind); - assert_eq!(opt_f64_bits(actual.ratio), opt_f64_bits(expected.ratio)); - assert_eq!( - opt_f64_bits(actual.cash_amount), - opt_f64_bits(expected.cash_amount) - ); - assert_eq!(actual.currency, expected.currency); - assert_eq!(actual.successor_listing_id, expected.successor_listing_id); - assert_eq!( - opt_f64_bits(actual.terminal_return), - opt_f64_bits(expected.terminal_return) - ); - assert_eq!(actual.known_at_micros, expected.known_at_micros); - assert_eq!(actual.known_at_source, expected.known_at_source); -} - -fn assert_no_transient_files(dir: &Path) { - if !dir.exists() { - return; - } - for entry in fs::read_dir(dir).expect("read dir") { - let entry = entry.expect("dir entry"); - let name = entry.file_name().to_string_lossy().into_owned(); - assert!( - !name.ends_with(".tmp") && !name.ends_with(".bak") && name != ".write.lock", - "unexpected transient file remaining: {}", - entry.path().display() - ); - } -} - -fn parse_kind(s: &str) -> CorporateActionKind { - match s { - "split" => CorporateActionKind::Split, - "dividend" => CorporateActionKind::Dividend, - "otc_delist_transfer" => CorporateActionKind::OtcDelistTransfer, - "delisting" => CorporateActionKind::Delisting, - other => panic!("unexpected kind in Parquet: {other}"), - } -} - -fn parse_known_at_source(s: &str) -> KnownAtSource { - match s { - "declared_date" => KnownAtSource::DeclaredDate, - "ex_date_fallback" => KnownAtSource::ExDateFallback, - "delist_date" => KnownAtSource::DelistDate, - other => panic!("unexpected known_at_source in Parquet: {other}"), - } -} - fn assert_contract_schema(schema: &Type) { assert_eq!(schema.name(), "corporate_actions"); let fields = schema.get_fields(); @@ -314,7 +261,7 @@ fn assert_contract_schema(schema: &Type) { } } -fn read_parquet_rows(path: &Path) -> (usize, Vec) { +fn read_and_verify_curated_parquet(path: &Path) -> (usize, Vec) { let file = File::open(path).expect("open parquet file"); let reader = SerializedFileReader::new(file).expect("open parquet reader"); let metadata = reader.metadata(); @@ -332,155 +279,7 @@ fn read_parquet_rows(path: &Path) -> (usize, Vec) { } let footer_rows = metadata.file_metadata().num_rows() as usize; - let mut out = Vec::with_capacity(footer_rows); - - for rg_idx in 0..metadata.num_row_groups() { - let rg_reader = reader.get_row_group(rg_idx).expect("row group reader"); - let num_rows = metadata.row_group(rg_idx).num_rows() as usize; - - let read_i32 = |col_idx: usize| -> Vec { - let mut vals = Vec::with_capacity(num_rows); - match rg_reader.get_column_reader(col_idx).unwrap() { - ColumnReader::Int32ColumnReader(mut r) => { - let (read, _, _) = r.read_records(num_rows, None, None, &mut vals).unwrap(); - assert_eq!(read, num_rows); - } - _ => panic!("expected INT32 column at {col_idx}"), - } - vals - }; - let read_opt_i32 = |col_idx: usize| -> Vec> { - let mut vals = Vec::with_capacity(num_rows); - let mut def_levels = Vec::with_capacity(num_rows); - match rg_reader.get_column_reader(col_idx).unwrap() { - ColumnReader::Int32ColumnReader(mut r) => { - let (read, _, levels) = r - .read_records(num_rows, Some(&mut def_levels), None, &mut vals) - .unwrap(); - assert_eq!(read, num_rows); - assert_eq!(levels, num_rows); - } - _ => panic!("expected optional INT32 column at {col_idx}"), - } - let mut vi = 0; - let mut res = Vec::with_capacity(num_rows); - for lvl in def_levels { - if lvl == 1 { - res.push(Some(vals[vi])); - vi += 1; - } else { - res.push(None); - } - } - assert_eq!(vi, vals.len()); - res - }; - let read_i64 = |col_idx: usize| -> Vec { - let mut vals = Vec::with_capacity(num_rows); - match rg_reader.get_column_reader(col_idx).unwrap() { - ColumnReader::Int64ColumnReader(mut r) => { - let (read, _, _) = r.read_records(num_rows, None, None, &mut vals).unwrap(); - assert_eq!(read, num_rows); - } - _ => panic!("expected INT64 column at {col_idx}"), - } - vals - }; - let read_opt_f64 = |col_idx: usize| -> Vec> { - let mut vals = Vec::with_capacity(num_rows); - let mut def_levels = Vec::with_capacity(num_rows); - match rg_reader.get_column_reader(col_idx).unwrap() { - ColumnReader::DoubleColumnReader(mut r) => { - let (read, _, levels) = r - .read_records(num_rows, Some(&mut def_levels), None, &mut vals) - .unwrap(); - assert_eq!(read, num_rows); - assert_eq!(levels, num_rows); - } - _ => panic!("expected optional DOUBLE column at {col_idx}"), - } - let mut vi = 0; - let mut res = Vec::with_capacity(num_rows); - for lvl in def_levels { - if lvl == 1 { - res.push(Some(vals[vi])); - vi += 1; - } else { - res.push(None); - } - } - assert_eq!(vi, vals.len()); - res - }; - let read_req_str = |col_idx: usize| -> Vec { - let mut vals = Vec::with_capacity(num_rows); - match rg_reader.get_column_reader(col_idx).unwrap() { - ColumnReader::ByteArrayColumnReader(mut r) => { - let (read, _, _) = r.read_records(num_rows, None, None, &mut vals).unwrap(); - assert_eq!(read, num_rows); - } - _ => panic!("expected BYTE_ARRAY column at {col_idx}"), - } - vals.into_iter() - .map(|ba| String::from_utf8(ba.data().to_vec()).unwrap()) - .collect() - }; - let read_opt_str = |col_idx: usize| -> Vec> { - let mut vals = Vec::with_capacity(num_rows); - let mut def_levels = Vec::with_capacity(num_rows); - match rg_reader.get_column_reader(col_idx).unwrap() { - ColumnReader::ByteArrayColumnReader(mut r) => { - let (read, _, levels) = r - .read_records(num_rows, Some(&mut def_levels), None, &mut vals) - .unwrap(); - assert_eq!(read, num_rows); - assert_eq!(levels, num_rows); - } - _ => panic!("expected optional BYTE_ARRAY column at {col_idx}"), - } - let mut vi = 0; - let mut res = Vec::with_capacity(num_rows); - for lvl in def_levels { - if lvl == 1 { - res.push(Some(String::from_utf8(vals[vi].data().to_vec()).unwrap())); - vi += 1; - } else { - res.push(None); - } - } - assert_eq!(vi, vals.len()); - res - }; - - let listing_id = read_i32(0); - let ex_date = read_i32(1); - let declared_date = read_opt_i32(2); - let kind = read_req_str(3); - let ratio = read_opt_f64(4); - let cash_amount = read_opt_f64(5); - let currency = read_opt_str(6); - let successor_listing_id = read_opt_i32(7); - let terminal_return = read_opt_f64(8); - let known_at_micros = read_i64(9); - let known_at_source = read_req_str(10); - - for i in 0..num_rows { - out.push(CorporateActionsParquetRow { - listing_id: listing_id[i], - ex_date: ex_date[i], - declared_date: declared_date[i], - kind: parse_kind(&kind[i]), - ratio: ratio[i], - cash_amount: cash_amount[i], - currency: currency[i].clone().map(Cow::Owned), - successor_listing_id: successor_listing_id[i], - terminal_return: terminal_return[i], - known_at_micros: known_at_micros[i], - known_at_source: parse_known_at_source(&known_at_source[i]), - }); - } - } - + let out = read_parquet_rows(path); (footer_rows, out) } @@ -489,15 +288,16 @@ fn happy_path_all_kinds_est_edt_known_at_and_sources() { let d_est_decl = day(2024, 1, 10); // EST -> 21:00 UTC let d_est_ex = day(2024, 1, 25); // EST -> 21:00 UTC let d_edt_ex = day(2024, 6, 10); // EDT -> 20:00 UTC - let d_sivb_otc = day(2023, 3, 28); // EDT -> 20:00 UTC + let d_sivb_halt = day(2023, 3, 10); // Last Nasdaq print before halt + let d_sivb_otc = day(2023, 3, 28); // EDT -> 20:00 UTC (Pass 6 effectiveDate) let d_term_est = day(2024, 2, 15); // EST -> 21:00 UTC let d_term_edt = day(2024, 7, 15); // EDT -> 20:00 UTC let mapping = ProviderMappingTable::from_rows([ map_row("qm", "NVDA", day(2000, 1, 1), None, 10), map_row("qm", "RY.TO", day(2000, 1, 1), None, 20), - map_row("qm", "SIVB", day(2000, 1, 1), Some(d_sivb_otc), 30), - map_row("qm", "SIVBQ", d_sivb_otc, None, 31), + map_row("qm", "SIVB", day(1987, 10, 26), Some(d_sivb_halt), 30), + map_row("qm", "SIVBQ", d_sivb_otc, Some(day(2024, 11, 7)), 31), map_row("qm", "FAIL1", day(2000, 1, 1), Some(d_term_est), 40), map_row("qm", "FAIL2", day(2000, 1, 1), Some(d_term_edt), 50), ]) @@ -1098,7 +898,7 @@ fn parquet_round_trip_byte_identical_double_write_and_empty_input() { let mapping = ProviderMappingTable::from_rows([ map_row("qm", "NVDA", day(2015, 1, 1), None, 10), map_row("qm", "RY.TO", day(2015, 1, 1), None, 20), - map_row("qm", "SIVB", day(2015, 1, 1), Some(d3), 30), + map_row("qm", "SIVB", day(2015, 1, 1), Some(d3 - 18), 30), map_row("qm", "SIVBQ", d3, None, 31), map_row("qm", "FAIL", day(2015, 1, 1), Some(d4), 40), ]) @@ -1171,7 +971,7 @@ fn parquet_round_trip_byte_identical_double_write_and_empty_input() { assert_eq!(bytes_a, bytes_b, "double write must be byte-identical"); assert_eq!(bytes_a.len() as u64, report_a.write_stats.bytes_written); - let (footer_rows, read_back) = read_parquet_rows(&part_a); + let (footer_rows, read_back) = read_and_verify_curated_parquet(&part_a); assert_eq!(footer_rows, curated.rows.len()); assert_eq!(read_back.len(), curated.rows.len()); for (actual, expected) in read_back.iter().zip(&curated.rows) { @@ -1197,3 +997,64 @@ fn parquet_round_trip_byte_identical_double_write_and_empty_input() { assert_eq!(empty_report.write_stats, CorporateActionsWriteStats::default()); assert!(!empty_dir.exists(), "empty input must not create out_dir"); } + +#[test] +fn otc_delist_transfer_resolves_ended_outgoing_listing_sivb_to_sivbq() { + // Mirrors the security-master persistence fixture (test/postgres/security-master-persist.test.ts): + // SIVB.US ends on 2023-03-10 (halt / last Nasdaq print), SIVBQ.US begins OTC trading on + // 2023-03-28, and Pass 6 records the continuity transfer with effectiveDate = 2023-03-28. + let d_sivb_start = day(1987, 10, 26); + let d_sivb_end = day(2023, 3, 10); + let d_sivbq_start = day(2023, 3, 28); + let d_sivbq_end = day(2024, 11, 7); + let d_reuse_start = day(2025, 1, 2); + + let mapping = ProviderMappingTable::from_rows([ + map_row("eod", "SIVB.US", d_sivb_start, Some(d_sivb_end), 30), + // Later reuse of the same ticker must not be selected for the 2023-03-28 transfer. + map_row("eod", "SIVB.US", d_reuse_start, None, 39), + map_row("eod", "SIVBQ.US", d_sivbq_start, Some(d_sivbq_end), 31), + // Successor that starts one day after effectiveDate must still fail successor lookup. + map_row("eod", "SIVBQ_LATE.US", d_sivbq_start + 1, None, 32), + ]) + .unwrap(); + + let dividends = vec![ + // Non-transfer event on SIVB.US on 2023-03-28 (after valid_to = 2023-03-10) must still drop. + div_ev("SIVB.US", d_sivbq_start, 0.25, "USD", None), + ]; + let delistings = vec![ + // Real SIVB.US -> SIVBQ.US transfer: outgoing ended Mar 10, successor starts Mar 28. + otc_ev("SIVB.US", d_sivbq_start, "SIVBQ.US"), + // Transfer before outgoing valid_from (1987-10-26) -> dropped_unmapped. + otc_ev("SIVB.US", d_sivb_start - 1, "SIVBQ.US"), + // Successor lookup remains strictly anchored to effectiveDate (Mar 28) -> dropped_unmapped_successor. + otc_ev("SIVB.US", d_sivbq_start, "SIVBQ_LATE.US"), + ]; + + let out = curate_corporate_actions(empty_splits(), dividends, delistings, "eod", &mapping) + .unwrap(); + assert_conservation_and_order(&out); + + assert_eq!(out.stats.rows_in, 4); + assert_eq!(out.stats.rows_out, 1); + assert_eq!(out.stats.listings_out, 1); + assert_eq!(out.stats.dropped_unmapped, 2); + assert_eq!(out.stats.dropped_unmapped_successor, 1); + assert_eq!(out.stats.dropped_self_successor, 0); + assert_eq!(out.stats.dropped_known_at_out_of_range, 0); + assert_eq!(out.stats.listing_collision_collapsed, 0); + assert_eq!(out.stats.listing_collision_dropped, 0); + + let row = &out.rows[0]; + assert_eq!(row.listing_id, 30); + assert_eq!(row.successor_listing_id, Some(31)); + assert_eq!(row.kind, CorporateActionKind::OtcDelistTransfer); + assert_eq!(row.ex_date, d_sivbq_start); + assert_eq!(row.declared_date, None); + assert_eq!( + row.known_at_micros, + et_session_close_utc_micros(d_sivbq_start).unwrap() + ); + assert_eq!(row.known_at_source, KnownAtSource::DelistDate); +} diff --git a/tools/curate-etl/src/parquet_corporate_actions.rs b/tools/curate-etl/src/parquet_corporate_actions.rs index b5abbb7a..84e6def3 100644 --- a/tools/curate-etl/src/parquet_corporate_actions.rs +++ b/tools/curate-etl/src/parquet_corporate_actions.rs @@ -1146,7 +1146,7 @@ where } #[cfg(test)] -mod tests { +pub(crate) mod tests { use std::sync::atomic::{AtomicU64, Ordering as AtomicOrdering}; use parquet::basic::ConvertedType; @@ -1306,7 +1306,7 @@ mod tests { } } - pub(super) fn read_parquet_rows(path: &Path) -> Vec { + pub(crate) fn read_parquet_rows(path: &Path) -> Vec { let file = File::open(path).expect("open parquet file"); let reader = SerializedFileReader::new(file).expect("open parquet reader"); let metadata = reader.metadata(); @@ -1484,7 +1484,7 @@ mod tests { assert_eq!(actual.map(f64::to_bits), expected.map(f64::to_bits)); } - pub(super) fn assert_row_bitwise_eq( + pub(crate) fn assert_row_bitwise_eq( actual: &CorporateActionsParquetRow, expected: &CorporateActionsParquetRow, ) { @@ -1501,7 +1501,7 @@ mod tests { assert_eq!(actual.known_at_source, expected.known_at_source); } - pub(super) fn assert_no_transient_files(dir: &Path) { + pub(crate) fn assert_no_transient_files(dir: &Path) { if !dir.exists() { return; }