5b5f034be9
Run the Phase-1 session-breakout node vocabulary over REAL GER40 M1 bars
from the data-server archive — the first real-data exercise of the shipped
strategy nodes (Resample/Delay/Gt/Session/EqConst/And/Latch + SimBroker).
It is a pure composition of shipped aura-std nodes (no project-specific
signal code), so it lives in the engine repo's examples/ carveout (C9), not
a separate consumer crate. The breakout FlatGraph is reused VERBATIM from
aura-engine/tests/ger40_breakout.rs; only the sources change — four real
M1FieldSource (open/high/low/close, in the fixed C4 merge order) replace the
synthetic VecSources, with pip_size = 1.0 (GER40 is an index).
- examples/ger40_breakout_real.rs — runnable demo over a Sept-2024 window:
prints the RunReport metrics plus a per-session entry/exit trace.
- examples/shared/breakout_real.rs — the single 13-node wiring (the proven
11 + two trace taps), shared by the example and the test via #[path] so it
is never duplicated.
- tests/ger40_breakout_real.rs — gated determinism test (mirrors
real_bars.rs): skips where the archive is absent; where present, asserts
finite metrics, binary Latch exposure (held in {0.0, 1.0}), and
bit-identical C1 reruns of both the report and the recorded series.
chrono / chrono-tz added as aura-ingest dev-dependencies (the Session
timezone and the UTC window bounds), test-only — never on the normal path.
89 lines
4.0 KiB
Rust
89 lines
4.0 KiB
Rust
//! Gated integration test: the GER40 15m session-breakout strategy — the
|
|
//! Phase-1 `aura-std` node vocabulary wired VERBATIM from
|
|
//! `aura-engine/tests/ger40_breakout.rs` — driven over REAL GER40 M1 bars from
|
|
//! the local data-server archive (September 2024). Mirrors `real_bars.rs`:
|
|
//! skips with a note where the local Pepperstone archive is absent, so
|
|
//! `cargo test --workspace` stays green anywhere; exercises the real ingestion
|
|
//! path where the files exist.
|
|
//!
|
|
//! The breakout FlatGraph is built once in the shared module (`shared/
|
|
//! breakout_real.rs`) and reused by both this test and the runnable example, so
|
|
//! the 11-node wiring is never duplicated.
|
|
|
|
use std::sync::Arc;
|
|
|
|
use data_server::{DataServer, DEFAULT_DATA_PATH};
|
|
|
|
#[path = "../examples/shared/breakout_real.rs"]
|
|
mod breakout_real;
|
|
use breakout_real::*;
|
|
|
|
// September 2024 (inclusive), the same window the example demonstrates.
|
|
const YEAR: i32 = 2024;
|
|
const MONTH: u32 = 9;
|
|
|
|
/// Build the real breakout harness, run it over `[from_ms, to_ms]`, and return
|
|
/// the folded `RunReport` plus the drained per-bar `(held, equity)` series. A
|
|
/// fresh build per call keeps the two determinism runs disjoint (C1).
|
|
fn run_real(
|
|
server: &Arc<DataServer>,
|
|
from_ms: i64,
|
|
to_ms: i64,
|
|
) -> (aura_engine::RunReport, Vec<(f64, f64)>) {
|
|
let sources =
|
|
open_ohlc_sources(server, from_ms, to_ms).expect("GER40 has data in the Sept-2024 window");
|
|
let (mut h, taps) = build_harness();
|
|
h.run(sources);
|
|
|
|
// Drain the trace once; fold the report from the same trace via the shared
|
|
// helper so the mpsc channels are consumed exactly once and the report shape
|
|
// matches the example's byte-for-byte.
|
|
let trace = drain_trace(&taps);
|
|
let report = report_from_trace(&trace, from_ms, to_ms);
|
|
let series: Vec<(f64, f64)> = trace.iter().map(|b| (b.held, b.equity)).collect();
|
|
(report, series)
|
|
}
|
|
|
|
/// Property: the real-bar GER40 breakout harness runs end-to-end over a real
|
|
/// data-server month and is **deterministic** (C1) — two disjoint runs over the
|
|
/// byte-identical archive window produce bit-identical reports AND bit-identical
|
|
/// recorded series. Also pins two observable invariants of the composed
|
|
/// vocabulary on real data: the metrics are finite, and the Latch output
|
|
/// (`held`) is *exactly* 0.0 or 1.0 every bar (a binary exposure register, never
|
|
/// a fractional or NaN value). This protects the whole node composition —
|
|
/// Resample / Delay / Gt / Session / EqConst / And / Latch / SimBroker — against
|
|
/// any regression that would only surface on real (irregular, gap-laden) M1
|
|
/// data, which the synthetic single-session capstone cannot reach.
|
|
#[test]
|
|
fn ger40_breakout_real_bars_run_is_deterministic() {
|
|
let server = Arc::new(DataServer::new(DEFAULT_DATA_PATH));
|
|
if !server.has_symbol(SYMBOL) {
|
|
eprintln!("skip: no local data at {DEFAULT_DATA_PATH} (symbol {SYMBOL} absent)");
|
|
return; // hermetic elsewhere; exercises the real path where files exist
|
|
}
|
|
|
|
let (from_ms, to_ms) = utc_month_window_ms(YEAR, MONTH);
|
|
|
|
let (r1, s1) = run_real(&server, from_ms, to_ms);
|
|
assert!(!s1.is_empty(), "window resolved to zero bars");
|
|
|
|
// Metrics are finite — a backtest actually ran over real bars.
|
|
assert!(r1.metrics.total_pips.is_finite(), "total_pips finite");
|
|
assert!(r1.metrics.max_drawdown.is_finite(), "max_drawdown finite");
|
|
|
|
// Latch output is a binary exposure register: every recorded `held` is
|
|
// exactly 0.0 or 1.0 — never fractional, never NaN.
|
|
for (held, _) in &s1 {
|
|
assert!(
|
|
*held == 0.0 || *held == 1.0,
|
|
"held must be exactly 0.0 or 1.0 (Latch register), got {held}"
|
|
);
|
|
}
|
|
|
|
// C1 determinism: a fresh disjoint run over the identical window is
|
|
// bit-identical in both the folded report and the raw recorded series.
|
|
let (r2, s2) = run_real(&server, from_ms, to_ms);
|
|
assert_eq!(r1.to_json(), r2.to_json(), "report bit-identical across runs (C1)");
|
|
assert_eq!(s1, s2, "recorded (held, equity) series bit-identical across runs (C1)");
|
|
}
|