chore(m2): execute host/quant verification, fix live blockers, and record M2 closure evidence (T-215)
This commit is contained in:
parent
87ae19e5f9
commit
a5184bb417
21 changed files with 1370 additions and 74 deletions
|
|
@ -58,7 +58,9 @@ use crate::run_curate_adj::CurateAdjFactorsArgs;
|
|||
use crate::run_curate_bars::{
|
||||
default_curate_bars_threads, CurateBars1dArgs, DEFAULT_CURATE_BARS_REL_TOLERANCE,
|
||||
};
|
||||
use crate::run_curate_bars_1m::{CurateBars1mArgs, DEFAULT_BARS_1M_MAPPING_SOURCE};
|
||||
use crate::run_curate_bars_1m::{
|
||||
CurateBars1mArgs, EodIntradaySplitMode, DEFAULT_BARS_1M_MAPPING_SOURCE,
|
||||
};
|
||||
use crate::run_curate_corporate_actions::CurateCorporateActionsArgs;
|
||||
use crate::run_curate_events::{CurateEventsArgs, DEFAULT_EVENTS_MAPPING_SOURCE};
|
||||
use crate::run_curate_fundamentals::{
|
||||
|
|
@ -171,9 +173,9 @@ pub fn format_usage(name: &str, version: &str) -> String {
|
|||
{name} curate-events --qm-filings <path> --qm-earnings <path> --provider-mapping <path> --out <dir> --filings-form-type-field <name> [--filings-key-field <name>] [--filings-timefiled-field <name>] [--filings-filing-id-field <name>] [--filings-url-field <name>] [--earnings-key-field <name>] [--earnings-report-date-field <name>] [--earnings-announce-time-field <name>] [--earnings-fiscal-period-end-field <name>] [--earnings-actual-eps-field <name>] [--earnings-revenue-field <name>] [--mapping-source <name>]\n\
|
||||
{name} curate-events --from-mongo [--mongo-uri-env <VAR> | --mongo-uri <uri>] [--batch-size <N>] [--limit <N>] [--date-gte <YYYY-MM-DD>] [--date-lt <YYYY-MM-DD>] --provider-mapping <path> --out <dir> --filings-form-type-field <name> [--filings-key-field <name>] [--filings-timefiled-field <name>] [--filings-filing-id-field <name>] [--filings-url-field <name>] [--earnings-key-field <name>] [--earnings-report-date-field <name>] [--earnings-announce-time-field <name>] [--earnings-fiscal-period-end-field <name>] [--earnings-actual-eps-field <name>] [--earnings-revenue-field <name>] [--mapping-source <name>]\n\
|
||||
Curate events from qmFilings + qmEarnings BSON or read-only MongoDB + provider_mapping TSV into events/year=YYYY/part.parquet (defaults: --filings-key-field {DEFAULT_FILINGS_KEY_FIELD}, --filings-timefiled-field {DEFAULT_FILINGS_TIMEFILED_FIELD}, --earnings-key-field {DEFAULT_EARNINGS_KEY_FIELD}, --earnings-report-date-field {DEFAULT_EARNINGS_REPORT_DATE_FIELD}, --earnings-announce-time-field {DEFAULT_EARNINGS_ANNOUNCE_TIME_FIELD}, --mapping-source {DEFAULT_EVENTS_MAPPING_SOURCE})\n\
|
||||
{name} curate-bars-1m --eod-intraday <path> --qm-splits <path> (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
{name} curate-bars-1m --from-mongo [--mongo-uri-env <VAR> | --mongo-uri <uri>] [--batch-size <N>] [--limit <N>] [--date-gte <YYYY-MM-DD>] [--date-lt <YYYY-MM-DD>] (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
Curate split-unadjusted 1-minute bars from eodIntraday1M + qmSplits BSON or read-only MongoDB + provider_mapping TSV into bars_1m.shard-<NN>.ilp (default --mapping-source: {DEFAULT_BARS_1M_MAPPING_SOURCE})\n\
|
||||
{name} curate-bars-1m --eod-intraday <path> [--qm-splits <path>] [--split-mode <raw|unadjust>] (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
{name} curate-bars-1m --from-mongo [--mongo-uri-env <VAR> | --mongo-uri <uri>] [--batch-size <N>] [--limit <N>] [--date-gte <YYYY-MM-DD>] [--date-lt <YYYY-MM-DD>] [--split-mode <raw|unadjust>] (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
Curate 1-minute bars from eodIntraday1M (+ optional qmSplits when --split-mode unadjust) BSON or read-only MongoDB + provider_mapping TSV into bars_1m.shard-<NN>.ilp (defaults: --split-mode raw, --mapping-source: {DEFAULT_BARS_1M_MAPPING_SOURCE})\n\
|
||||
{name} curate-qm-bars-1m --qm-intraday <path> (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
{name} curate-qm-bars-1m --from-mongo [--mongo-uri-env <VAR> | --mongo-uri <uri>] [--batch-size <N>] [--limit <N>] [--date-gte <YYYY-MM-DD>] [--date-lt <YYYY-MM-DD>] (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
Curate raw 1-minute QuoteMedia bars from qmIntraday BSON or read-only MongoDB + provider_mapping TSV into bars_1m_qm.shard-<NN>.ilp (default --mapping-source: {DEFAULT_QM_BARS_1M_MAPPING_SOURCE})\n\
|
||||
|
|
@ -239,7 +241,7 @@ pub fn format_usage_stderr(name: &str) -> String {
|
|||
{name} curate-fx-1d --eod-prices <path> --te-market-data <path> [--te-symbol <sym>] --out <dir>\n\
|
||||
{name} curate-shorts --ceo-shorts <path> --provider-mapping <path> --out <dir> --shares-short-field <name> [--key-field <name>] [--report-date-field <name>] [--net-change-field <name>] [--pct-float-field <name>] [--mapping-source <name>]\n\
|
||||
{name} curate-events --qm-filings <path> --qm-earnings <path> --provider-mapping <path> --out <dir> --filings-form-type-field <name> [--filings-key-field <name>] [--filings-timefiled-field <name>] [--filings-filing-id-field <name>] [--filings-url-field <name>] [--earnings-key-field <name>] [--earnings-report-date-field <name>] [--earnings-announce-time-field <name>] [--earnings-fiscal-period-end-field <name>] [--earnings-actual-eps-field <name>] [--earnings-revenue-field <name>] [--mapping-source <name>]\n\
|
||||
{name} curate-bars-1m --eod-intraday <path> --qm-splits <path> (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
{name} curate-bars-1m --eod-intraday <path> [--qm-splits <path>] [--split-mode <raw|unadjust>] (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
{name} curate-qm-bars-1m --qm-intraday <path> (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --shards <N> --known-at-micros <i64> [--mapping-source <name>]\n\
|
||||
{name} curate-fx-1m --eod-intraday <path> --out <dir> --shards <N>\n\
|
||||
{name} curate-posts --ceo-posts <path> (--curate-inputs <dir> | --provider-mapping <path>) --out <dir> --timestamp-unit <seconds|millis> [--key-field <name>] [--spiel-id-field <name>] [--timestamp-field <name>] [--edited-field <name>] [--bot-field <name>] [--user-id-field <name>] [--text-field <name>] [--mapping-source <name>]\n\
|
||||
|
|
@ -2160,6 +2162,7 @@ fn parse_curate_bars_1m_args(args: &[&str]) -> Result<CliAction, String> {
|
|||
let mut shard_count: Option<usize> = None;
|
||||
let mut known_at_micros: Option<i64> = None;
|
||||
let mut mapping_source: Option<String> = None;
|
||||
let mut split_mode: Option<EodIntradaySplitMode> = None;
|
||||
|
||||
let mut i = 0usize;
|
||||
while i < args.len() {
|
||||
|
|
@ -2252,10 +2255,29 @@ fn parse_curate_bars_1m_args(args: &[&str]) -> Result<CliAction, String> {
|
|||
known_at_micros = Some(parsed);
|
||||
}
|
||||
"--mapping-source" => set_name(&mut mapping_source, "--mapping-source", value)?,
|
||||
"--split-mode" => {
|
||||
if split_mode.is_some() {
|
||||
return Err("duplicate flag '--split-mode'".to_string());
|
||||
}
|
||||
if value.is_empty() {
|
||||
return Err("empty value for flag '--split-mode'".to_string());
|
||||
}
|
||||
split_mode = Some(match value {
|
||||
"raw" => EodIntradaySplitMode::Raw,
|
||||
"unadjust" => EodIntradaySplitMode::Unadjust,
|
||||
_ => {
|
||||
return Err(format!(
|
||||
"invalid --split-mode '{value}' (expected 'raw' or 'unadjust')"
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
other => return Err(format!("unknown flag '{other}' for curate-bars-1m")),
|
||||
}
|
||||
}
|
||||
|
||||
let resolved_split_mode = split_mode.unwrap_or(EodIntradaySplitMode::Raw);
|
||||
|
||||
if mongo.from_mongo {
|
||||
if intraday_path.is_some() || splits_path.is_some() {
|
||||
return Err(
|
||||
|
|
@ -2278,6 +2300,7 @@ fn parse_curate_bars_1m_args(args: &[&str]) -> Result<CliAction, String> {
|
|||
.unwrap_or_else(|| DEFAULT_BARS_1M_MAPPING_SOURCE.to_string()),
|
||||
shard_count,
|
||||
known_at_micros,
|
||||
split_mode: resolved_split_mode,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
}));
|
||||
|
|
@ -2289,8 +2312,12 @@ fn parse_curate_bars_1m_args(args: &[&str]) -> Result<CliAction, String> {
|
|||
|
||||
let intraday_path =
|
||||
intraday_path.ok_or_else(|| "missing required flag '--eod-intraday'".to_string())?;
|
||||
let splits_path =
|
||||
splits_path.ok_or_else(|| "missing required flag '--qm-splits'".to_string())?;
|
||||
let splits_path = match resolved_split_mode {
|
||||
EodIntradaySplitMode::Raw => splits_path.unwrap_or_default(),
|
||||
EodIntradaySplitMode::Unadjust => {
|
||||
splits_path.ok_or_else(|| "missing required flag '--qm-splits'".to_string())?
|
||||
}
|
||||
};
|
||||
let provider_mapping_path =
|
||||
resolve_provider_mapping_input(curate_inputs, provider_mapping_path)?;
|
||||
let out_dir = out_dir.ok_or_else(|| "missing required flag '--out'".to_string())?;
|
||||
|
|
@ -2308,6 +2335,7 @@ fn parse_curate_bars_1m_args(args: &[&str]) -> Result<CliAction, String> {
|
|||
.unwrap_or_else(|| DEFAULT_BARS_1M_MAPPING_SOURCE.to_string()),
|
||||
shard_count,
|
||||
known_at_micros,
|
||||
split_mode: resolved_split_mode,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
}))
|
||||
|
|
@ -4855,6 +4883,7 @@ mod tests {
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 4,
|
||||
known_at_micros: 1_735_689_600_000_000,
|
||||
split_mode: EodIntradaySplitMode::Raw,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
})
|
||||
|
|
@ -4864,6 +4893,7 @@ mod tests {
|
|||
"curate-bars-1m",
|
||||
"--eod-intraday=i2.bson",
|
||||
"--qm-splits=s2.bson",
|
||||
"--split-mode=unadjust",
|
||||
"--provider-mapping=m2.tsv",
|
||||
"--out=o2",
|
||||
"--shards=2",
|
||||
|
|
@ -4882,10 +4912,34 @@ mod tests {
|
|||
mapping_source: "eod_alt".to_string(),
|
||||
shard_count: 2,
|
||||
known_at_micros: i64::MAX,
|
||||
split_mode: EodIntradaySplitMode::Unadjust,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
})
|
||||
);
|
||||
|
||||
// Default raw split mode allows omitting --qm-splits.
|
||||
let parsed_raw = parse_args(&to_args(&[
|
||||
"curate-bars-1m",
|
||||
"--eod-intraday",
|
||||
"i3.bson",
|
||||
"--provider-mapping",
|
||||
"m3.tsv",
|
||||
"--out",
|
||||
"o3",
|
||||
"--shards",
|
||||
"2",
|
||||
"--known-at-micros",
|
||||
"1735689600000000",
|
||||
]))
|
||||
.expect("valid raw curate-bars-1m without --qm-splits");
|
||||
assert!(matches!(
|
||||
parsed_raw,
|
||||
CliAction::CurateBars1m(CurateBars1mArgs {
|
||||
split_mode: EodIntradaySplitMode::Raw,
|
||||
..
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -4933,7 +4987,7 @@ mod tests {
|
|||
];
|
||||
|
||||
for omit in 0..required.len() {
|
||||
let mut argv: Vec<&str> = vec!["curate-bars-1m"];
|
||||
let mut argv: Vec<&str> = vec!["curate-bars-1m", "--split-mode", "unadjust"];
|
||||
for (idx, &(flag, val)) in required.iter().enumerate() {
|
||||
if idx != omit {
|
||||
argv.push(flag);
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ pub use run_curate_bars::{
|
|||
pub mod run_curate_bars_1m;
|
||||
pub use run_curate_bars_1m::{
|
||||
format_curate_bars_1m_report, run_curate_bars_1m, run_curate_bars_1m_from_readers_to_dir,
|
||||
run_curate_bars_1m_with_readers, CurateBars1mArgs, CurateBars1mRunReport,
|
||||
run_curate_bars_1m_with_readers, CurateBars1mArgs, CurateBars1mRunReport, EodIntradaySplitMode,
|
||||
RunCurateBars1mError, DEFAULT_BARS_1M_MAPPING_SOURCE,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,18 @@ use crate::split::SplitTable;
|
|||
/// Required `provider_mapping` source namespace for `eodIntraday1M` bars.
|
||||
pub const DEFAULT_BARS_1M_MAPPING_SOURCE: &str = "eod";
|
||||
|
||||
/// Controls whether `curate-bars-1m` preserves raw `eodIntraday1M` OHLCV verbatim
|
||||
/// (`Raw`, default — empirically verified on live QA MongoDB across forward and reverse splits)
|
||||
/// or applies `qmSplits` un-adjustment (`Unadjust`) for legacy split-adjusted dumps.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
pub enum EodIntradaySplitMode {
|
||||
/// Preserve input OHLCV without applying split un-adjustment.
|
||||
#[default]
|
||||
Raw,
|
||||
/// Un-adjust pre-split OHLCV via `qmSplits` (`price * factor`, `volume / factor`).
|
||||
Unadjust,
|
||||
}
|
||||
|
||||
/// Arguments for [`run_curate_bars_1m`] and [`run_curate_bars_1m_with_readers`].
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CurateBars1mArgs {
|
||||
|
|
@ -91,6 +103,7 @@ pub struct CurateBars1mArgs {
|
|||
pub mapping_source: String,
|
||||
pub shard_count: usize,
|
||||
pub known_at_micros: i64,
|
||||
pub split_mode: EodIntradaySplitMode,
|
||||
pub stream_options: BsonStreamOptions,
|
||||
pub ilp_options: IlpWriterOptions,
|
||||
}
|
||||
|
|
@ -507,9 +520,13 @@ where
|
|||
let intraday_bytes_read = reader.bytes_read();
|
||||
drop(reader);
|
||||
|
||||
let splits_opt = match args.split_mode {
|
||||
EodIntradaySplitMode::Raw => None,
|
||||
EodIntradaySplitMode::Unadjust => Some(&reference.splits),
|
||||
};
|
||||
let outcome = sorter
|
||||
.finish_and_write(
|
||||
Some(&reference.splits),
|
||||
splits_opt,
|
||||
BARS_1M_SOURCE_EOD,
|
||||
&mut writer,
|
||||
args.known_at_micros,
|
||||
|
|
@ -827,6 +844,17 @@ pub fn run_curate_bars_1m(
|
|||
) -> Result<CurateBars1mRunReport, RunCurateBars1mError> {
|
||||
validate_file_mode_args(args)?;
|
||||
|
||||
if args.split_mode == EodIntradaySplitMode::Raw && args.splits_path.as_os_str().is_empty() {
|
||||
let intraday_file = File::open(&args.intraday_path).map_err(|source| {
|
||||
RunCurateBars1mError::OpenInput {
|
||||
label: "eod-intraday",
|
||||
path: args.intraday_path.clone(),
|
||||
source,
|
||||
}
|
||||
})?;
|
||||
return run_curate_bars_1m_from_readers_to_dir(args, intraday_file, io::empty());
|
||||
}
|
||||
|
||||
let splits_file = File::open(&args.splits_path).map_err(|source| {
|
||||
RunCurateBars1mError::OpenInput {
|
||||
label: "qm-splits",
|
||||
|
|
|
|||
|
|
@ -127,11 +127,68 @@ fn make_args(
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count,
|
||||
known_at_micros,
|
||||
split_mode: EodIntradaySplitMode::Unadjust,
|
||||
stream_options,
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raw_split_mode_preserves_already_raw_pre_split_ohlcv_without_double_unadjusting() {
|
||||
let tmp = TempDirGuard::new("bars-1m-raw-mode");
|
||||
// AVGO.US 10:1 split on 2024-07-15; raw pre-split bar on 2024-07-12 has close=1700.87, vol=60072.
|
||||
let mapping_path = write_mapping_tsv(
|
||||
tmp.path(),
|
||||
&[
|
||||
"eod\tAVGO.US\t2009-08-06\t2025-08-12\t10970",
|
||||
"qm\tAVGO\t2009-08-06\t2025-06-27\t10970",
|
||||
],
|
||||
);
|
||||
let splits_path = tmp.path().join("qmSplits.bson");
|
||||
fs::write(
|
||||
&splits_path,
|
||||
concat_docs(&[make_split_doc("AVGO", "2024-07-15", 1.0, 10.0)]),
|
||||
)
|
||||
.expect("write splits");
|
||||
let pre_ts_sec = et_ts_sec(2024, 7, 12, 15, 59);
|
||||
let intraday_path = tmp.path().join("eodIntraday1M.bson");
|
||||
fs::write(
|
||||
&intraday_path,
|
||||
concat_docs(&[make_intraday_doc(
|
||||
"AVGO.US",
|
||||
pre_ts_sec,
|
||||
1700.50,
|
||||
1701.00,
|
||||
1700.25,
|
||||
1700.87,
|
||||
60_072.0,
|
||||
)]),
|
||||
)
|
||||
.expect("write intraday");
|
||||
|
||||
let out_dir = tmp.path().join("out-raw");
|
||||
let args = CurateBars1mArgs {
|
||||
intraday_path,
|
||||
splits_path,
|
||||
provider_mapping_path: mapping_path,
|
||||
out_dir: out_dir.clone(),
|
||||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 1,
|
||||
known_at_micros: 1_750_000_000_000_000,
|
||||
split_mode: EodIntradaySplitMode::Raw,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
};
|
||||
let report = run_curate_bars_1m(&args).expect("raw mode run_curate_bars_1m");
|
||||
assert_eq!(report.rows_written, 1);
|
||||
let shard_bytes = fs::read(out_dir.join("bars_1m.shard-00.ilp")).expect("read shard-00");
|
||||
let rows = decode_ilp_bars_1m(&shard_bytes);
|
||||
assert_eq!(rows.len(), 1);
|
||||
assert_eq!(rows[0].listing_id, 10970);
|
||||
assert_eq!(rows[0].close, 1700.87, "raw mode must not multiply by 10x split factor");
|
||||
assert_eq!(rows[0].volume, 60_072.0, "raw mode must not divide volume by 10x split factor");
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
struct DecodedIlpBar1m {
|
||||
listing_id: i32,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use crate::run_curate_bars::{
|
|||
};
|
||||
use crate::run_curate_bars_1m::{
|
||||
run_curate_bars_1m_from_readers_to_dir, CurateBars1mArgs, CurateBars1mRunReport,
|
||||
RunCurateBars1mError,
|
||||
EodIntradaySplitMode, RunCurateBars1mError,
|
||||
};
|
||||
use crate::run_curate_corporate_actions::{
|
||||
run_curate_corporate_actions_with_readers, CurateCorporateActionsRunReport,
|
||||
|
|
@ -48,9 +48,11 @@ use crate::run_curate_fx::{
|
|||
use crate::run_curate_fx_1m::{
|
||||
run_curate_fx_1m_from_reader_to_dir, CurateFx1mArgs, CurateFx1mRunReport, RunCurateFx1mError,
|
||||
};
|
||||
#[cfg(test)]
|
||||
use crate::run_curate_macro::run_curate_macro_from_reader;
|
||||
use crate::run_curate_macro::{
|
||||
load_macro_series_map_file, run_curate_macro_from_reader, run_curate_macro_with_parsed_map,
|
||||
CurateMacroRunReport, RunCurateMacroError,
|
||||
load_macro_series_map_file, run_curate_macro_with_parsed_map, CurateMacroRunReport,
|
||||
RunCurateMacroError,
|
||||
};
|
||||
use crate::run_curate_posts::{
|
||||
run_curate_posts_with_reader, CuratePostsRunReport, RunCuratePostsError,
|
||||
|
|
@ -293,6 +295,7 @@ pub struct CurateBars1mMongoArgs {
|
|||
pub mapping_source: String,
|
||||
pub shard_count: usize,
|
||||
pub known_at_micros: i64,
|
||||
pub split_mode: EodIntradaySplitMode,
|
||||
pub stream_options: BsonStreamOptions,
|
||||
pub ilp_options: IlpWriterOptions,
|
||||
}
|
||||
|
|
@ -307,6 +310,7 @@ impl CurateBars1mMongoArgs {
|
|||
mapping_source: self.mapping_source.clone(),
|
||||
shard_count: self.shard_count,
|
||||
known_at_micros: self.known_at_micros,
|
||||
split_mode: self.split_mode,
|
||||
stream_options: self.stream_options,
|
||||
ilp_options: self.ilp_options,
|
||||
}
|
||||
|
|
@ -845,6 +849,7 @@ pub(crate) fn macro_read_spec(args: &CurateMacroMongoArgs) -> MongoReadSpec {
|
|||
.to_read_spec_for_collection(SourceCollection::TeData, None, true)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn run_curate_macro_mongo_with_reader<R: io::Read>(
|
||||
args: &CurateMacroMongoArgs,
|
||||
te_data_reader: R,
|
||||
|
|
@ -907,42 +912,47 @@ pub fn run_curate_bars_1m_mongo(
|
|||
args: &CurateBars1mMongoArgs,
|
||||
) -> Result<CurateBars1mRunReport, RunMongoCurateError> {
|
||||
let (splits_spec, intraday_spec) = bars_1m_read_specs(args);
|
||||
with_mongo_client(
|
||||
&args.mongo,
|
||||
&[
|
||||
let specs: Vec<(SourceCollection, MongoReadSpec)> = match args.split_mode {
|
||||
EodIntradaySplitMode::Raw => vec![(SourceCollection::EodIntraday1M, intraday_spec.clone())],
|
||||
EodIntradaySplitMode::Unadjust => vec![
|
||||
(SourceCollection::QmSplits, splits_spec.clone()),
|
||||
(SourceCollection::EodIntraday1M, intraday_spec.clone()),
|
||||
],
|
||||
|client| {
|
||||
let use_key_chunks = args.mongo.limit.is_none();
|
||||
let eod_keys = if use_key_chunks {
|
||||
unique_mapping_keys_for_source(&args.provider_mapping_path, &args.mapping_source)
|
||||
.map_err(|e| RunMongoCurateError::Bars1m(RunCurateBars1mError::LoadReference(e)))?
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
};
|
||||
with_mongo_client(&args.mongo, &specs, |client| {
|
||||
let use_key_chunks = args.mongo.limit.is_none();
|
||||
let eod_keys = if use_key_chunks {
|
||||
unique_mapping_keys_for_source(&args.provider_mapping_path, &args.mapping_source)
|
||||
.map_err(|e| RunMongoCurateError::Bars1m(RunCurateBars1mError::LoadReference(e)))?
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let splits_reader = client
|
||||
.open_raw_cursor(SourceCollection::QmSplits, &splits_spec)
|
||||
let splits_reader: Box<dyn io::Read> = match args.split_mode {
|
||||
EodIntradaySplitMode::Raw => Box::new(io::empty()),
|
||||
EodIntradaySplitMode::Unadjust => Box::new(
|
||||
client
|
||||
.open_raw_cursor(SourceCollection::QmSplits, &splits_spec)
|
||||
.map_err(RunMongoCurateError::Mongo)?,
|
||||
),
|
||||
};
|
||||
if use_key_chunks {
|
||||
let intraday_reader = client
|
||||
.open_raw_cursor_for_keys(
|
||||
SourceCollection::EodIntraday1M,
|
||||
&intraday_spec,
|
||||
&eod_keys,
|
||||
250,
|
||||
)
|
||||
.map_err(RunMongoCurateError::Mongo)?;
|
||||
if use_key_chunks {
|
||||
let intraday_reader = client
|
||||
.open_raw_cursor_for_keys(
|
||||
SourceCollection::EodIntraday1M,
|
||||
&intraday_spec,
|
||||
&eod_keys,
|
||||
250,
|
||||
)
|
||||
.map_err(RunMongoCurateError::Mongo)?;
|
||||
run_curate_bars_1m_mongo_with_readers(args, intraday_reader, splits_reader)
|
||||
} else {
|
||||
let intraday_reader = client
|
||||
.open_raw_cursor(SourceCollection::EodIntraday1M, &intraday_spec)
|
||||
.map_err(RunMongoCurateError::Mongo)?;
|
||||
run_curate_bars_1m_mongo_with_readers(args, intraday_reader, splits_reader)
|
||||
}
|
||||
},
|
||||
)
|
||||
run_curate_bars_1m_mongo_with_readers(args, intraday_reader, splits_reader)
|
||||
} else {
|
||||
let intraday_reader = client
|
||||
.open_raw_cursor(SourceCollection::EodIntraday1M, &intraday_spec)
|
||||
.map_err(RunMongoCurateError::Mongo)?;
|
||||
run_curate_bars_1m_mongo_with_readers(args, intraday_reader, splits_reader)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn qm_bars_1m_read_spec(args: &CurateQmBars1mMongoArgs) -> MongoReadSpec {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use crate::mongo_stream::{
|
|||
SliceRawDocumentSource, SourceCollection, VecRawDocumentSource,
|
||||
};
|
||||
use crate::run_curate_bars_1m::{
|
||||
run_curate_bars_1m, CurateBars1mArgs, DEFAULT_BARS_1M_MAPPING_SOURCE,
|
||||
run_curate_bars_1m, CurateBars1mArgs, EodIntradaySplitMode, DEFAULT_BARS_1M_MAPPING_SOURCE,
|
||||
};
|
||||
use crate::run_curate_fundamentals::{
|
||||
run_curate_fundamentals, CurateFundamentalsArgs, CurateFundamentalsFiscalPeriod,
|
||||
|
|
@ -474,6 +474,7 @@ fn parity_curate_1m_ilp_mongo_cursors_match_file_mode_byte_for_byte() {
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 2,
|
||||
known_at_micros: known_at,
|
||||
split_mode: EodIntradaySplitMode::Unadjust,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
})
|
||||
|
|
@ -486,6 +487,7 @@ fn parity_curate_1m_ilp_mongo_cursors_match_file_mode_byte_for_byte() {
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 2,
|
||||
known_at_micros: known_at,
|
||||
split_mode: EodIntradaySplitMode::Unadjust,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
},
|
||||
|
|
@ -598,6 +600,7 @@ fn m2_mongo_read_specs_enforce_filter_types_and_key_scoping() {
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 2,
|
||||
known_at_micros: 1,
|
||||
split_mode: EodIntradaySplitMode::Unadjust,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
};
|
||||
|
|
@ -791,6 +794,7 @@ fn m2_mongo_runners_fail_closed_on_trading_admin_and_unauthenticated_qa_uris() {
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 2,
|
||||
known_at_micros: 1,
|
||||
split_mode: EodIntradaySplitMode::Raw,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
})
|
||||
|
|
@ -1505,6 +1509,7 @@ fn parity_curate_1m_ilp_filtered_multi_key_cross_chunk_matches_economic_rows_and
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 2,
|
||||
known_at_micros: known_at,
|
||||
split_mode: EodIntradaySplitMode::Unadjust,
|
||||
stream_options: small_chunks,
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
};
|
||||
|
|
@ -1548,6 +1553,7 @@ fn parity_curate_1m_ilp_filtered_multi_key_cross_chunk_matches_economic_rows_and
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count: 2,
|
||||
known_at_micros: known_at,
|
||||
split_mode: EodIntradaySplitMode::Unadjust,
|
||||
stream_options: small_chunks,
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use std::sync::atomic::{AtomicU64, Ordering};
|
|||
use bson::raw::{cstr, RawDocumentBuf};
|
||||
use curate_etl::{
|
||||
et_to_utc_micros, format_curate_bars_1m_report, run_curate_bars_1m, ymd_to_epoch_days,
|
||||
BsonStreamOptions, CurateBars1mArgs, IlpWriterOptions, DEFAULT_BARS_1M_MAPPING_SOURCE,
|
||||
BsonStreamOptions, CurateBars1mArgs, EodIntradaySplitMode, IlpWriterOptions,
|
||||
DEFAULT_BARS_1M_MAPPING_SOURCE,
|
||||
};
|
||||
|
||||
static TEST_DIR_SEQ: AtomicU64 = AtomicU64::new(0);
|
||||
|
|
@ -231,6 +232,7 @@ fn curate_bars_1m_binary_matches_direct_runner_bytes_and_report() {
|
|||
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
||||
shard_count,
|
||||
known_at_micros,
|
||||
split_mode: EodIntradaySplitMode::Raw,
|
||||
stream_options: BsonStreamOptions::default(),
|
||||
ilp_options: IlpWriterOptions::default(),
|
||||
};
|
||||
|
|
@ -510,7 +512,12 @@ fn curate_bars_1m_binary_writes_known_at_verbatim_and_unadjusts_nvda_split() {
|
|||
let fx = write_nvda_fixture(tmp.path());
|
||||
let out = tmp.path().join("out");
|
||||
|
||||
let output = run_bin(&bin_args(&fx, &out, "1700000000123456", &[]));
|
||||
let output = run_bin(&bin_args(
|
||||
&fx,
|
||||
&out,
|
||||
"1700000000123456",
|
||||
&["--split-mode", "unadjust"],
|
||||
));
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"stderr: {}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue