fix: fail closed on missing factor values
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user