fix: fail closed on missing factor values

This commit is contained in:
boris
2026-08-31 14:30:33 +08:00
parent dff791b51f
commit d014bb2fbd
2 changed files with 59 additions and 2 deletions
+19
View File
@@ -4907,6 +4907,25 @@ mod tests {
assert!(data.factor_by_symbol_id(date, signal_id).is_none());
assert!(data.candidate_by_symbol_id(date, signal_id).is_none());
assert!(day.candidate(signal_id).is_none());
// `get_factor` must use the same symbol-id index as direct snapshot
// lookups. Sparse factor rows must not accidentally select another
// symbol's row or disappear when the date group contains gaps.
let market_cap = data.get_factor("000001.SZ", date, date, "MARKET_CAP");
assert_eq!(
market_cap
.iter()
.map(|row| (row.date, row.symbol.as_str(), row.value))
.collect::<Vec<_>>(),
vec![(date, "000001.SZ", 100.0)]
);
assert!(
data.get_factor("000300.SH", date, date, "market_cap")
.is_empty()
);
assert!(data
.get_factor("999999.SZ", date, date, "market_cap")
.is_empty());
}
#[test]