test(cli): pin the exact mc R-bootstrap grade — byte-identity anchor (#210)
The fourth and last verb dissolution (mc's R-bootstrap path) reroutes the inline `walkforward_family -> pooled_oos_trade_rs -> r_bootstrap` through the campaign `[std::sweep(argmax), std::walk_forward, std::monte_carlo]` process, whose terminal monte_carlo stage does the identical `StageBootstrap::PooledOos(r_bootstrap(...))` seeded from the campaign seed. Before that rewire, this pins the EXACT current bootstrap grade of a fixed 2025 GER40 invocation (block_len=5, resamples=1000, seed=42, multi-point fast 3,5 x slow 12,20 grid) so the dissolution must reproduce it byte-for-byte (the acceptance gate). The load-bearing subtlety the dissolution rests on: the campaign path uses ONE campaign seed for both the wf-stage deflation and the mc-stage bootstrap, whereas the inline path uses a fixed DEFLATION_SEED for the wf winners and the mc `--seed` for the bootstrap. This reconciles because the wf winners are argmax (deflation only annotates provenance), so they are seed-independent — the walkforward anchor already proved it (the campaign path at seed 0 reproduced the inline DEFLATION_SEED winners byte-for-byte). So `campaign.seed = mc --seed` leaves the pooled OOS series unchanged and makes the bootstrap match. n_trades=20681 matches the walkforward multi-grid anchor, confirming mc pools the same OOS-R series. Deterministic; gated on the local GER40 archive, skips cleanly on a data refusal. refs #210
This commit is contained in:
@@ -5222,3 +5222,59 @@ fn exit_codes_partition_usage_two_from_runtime_one() {
|
||||
"no data for a valid command is a runtime failure → 1; stderr: {}",
|
||||
String::from_utf8_lossy(&runtime.stderr));
|
||||
}
|
||||
|
||||
/// Characterization pin (byte-identity anchor for the mc R-bootstrap dissolution,
|
||||
/// #210, the last verb). The current `aura mc --strategy r-sma --real` runs the
|
||||
/// inline rolling walk-forward, pools the per-window OOS trade-R series, and
|
||||
/// r-bootstraps E[R] (`mc_r_bootstrap_report`). The dissolution reroutes this
|
||||
/// through the campaign `[std::sweep(argmax), std::walk_forward, std::monte_carlo]`
|
||||
/// process, whose terminal monte_carlo stage does the identical
|
||||
/// `StageBootstrap::PooledOos(r_bootstrap(...))` seeded from the campaign seed -- so
|
||||
/// the campaign seed must carry the mc `--seed`. The wf winners are
|
||||
/// deflation-seed-independent (argmax), so the pooled series, and thus the
|
||||
/// bootstrap, is stable across that seed remap (the walkforward anchor already
|
||||
/// proved winner seed-independence). The multi-point grid makes the per-window
|
||||
/// winner selection non-degenerate. This pins the EXACT current bootstrap grade of
|
||||
/// a fixed 2025 GER40 invocation; after the dissolution the same command must
|
||||
/// reproduce these bytes (the acceptance gate). Gated on the GER40 archive; skips
|
||||
/// cleanly on a data refusal.
|
||||
#[test]
|
||||
fn mc_r_bootstrap_real_e2e_pins_the_exact_current_grade() {
|
||||
const FROM_MS: &str = "1735689600000";
|
||||
const TO_MS: &str = "1767225599000";
|
||||
let cwd = temp_cwd("mc-r-bootstrap-exact-grade");
|
||||
let out = std::process::Command::new(env!("CARGO_BIN_EXE_aura"))
|
||||
.args([
|
||||
"mc", "--strategy", "r-sma", "--real", "GER40",
|
||||
"--fast", "3,5", "--slow", "12,20", "--stop-length", "14", "--stop-k", "2.0",
|
||||
"--block-len", "5", "--resamples", "1000", "--seed", "42",
|
||||
"--from", FROM_MS, "--to", TO_MS,
|
||||
])
|
||||
.current_dir(&cwd)
|
||||
.output()
|
||||
.expect("spawn aura");
|
||||
if out.status.code() == Some(1) {
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(
|
||||
stderr.contains("no local data") || stderr.contains("no recorded geometry"),
|
||||
"exit 1 must be a data refusal, got: {stderr}"
|
||||
);
|
||||
eprintln!("skip: no local GER40 data");
|
||||
return;
|
||||
}
|
||||
assert_eq!(out.status.code(), Some(0), "exit: {:?}", out.status);
|
||||
let stdout = String::from_utf8(out.stdout).expect("utf-8 stdout");
|
||||
let grade_line = stdout
|
||||
.lines()
|
||||
.find(|l| l.starts_with("{\"mc_r_bootstrap\":"))
|
||||
.unwrap_or_else(|| panic!("the mc_r_bootstrap grade line: {stdout}"));
|
||||
let v: serde_json::Value = serde_json::from_str(grade_line).expect("grade line parses as JSON");
|
||||
let mc = &v["mc_r_bootstrap"];
|
||||
assert_eq!(mc["block_len"].as_u64(), Some(5), "block_len: {grade_line}");
|
||||
assert_eq!(mc["n_resamples"].as_u64(), Some(1000), "n_resamples: {grade_line}");
|
||||
assert_eq!(mc["n_trades"].as_u64(), Some(20681), "pooled OOS trade count: {grade_line}");
|
||||
// EXACT bootstrap floats -- the byte-identity anchor the dissolution must preserve.
|
||||
assert_eq!(mc["e_r"]["mean"].as_f64(), Some(-0.0025753095301594307), "E[R] mean: {grade_line}");
|
||||
assert_eq!(mc["e_r"]["p50"].as_f64(), Some(-0.0023049902245975227), "E[R] median: {grade_line}");
|
||||
assert_eq!(mc["prob_le_zero"].as_f64(), Some(0.558), "P(E[R] <= 0): {grade_line}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user