Freeze CLOB price history at market close

This commit is contained in:
2026-12-05 04:31:00 +08:00
parent 31af9ad9cf
commit e6a914b381
8 changed files with 634 additions and 27 deletions
+12 -10
View File
@@ -1553,21 +1553,23 @@ fn legacy_history_samples_the_book_without_fills_and_appends_the_latest_mark() {
exchange
.execute(json!({"op":"close","id":"close","market":"mid-example"}))
.unwrap();
db.execute("UPDATE chart_closures SET at_ms=273000", [])
.unwrap();
db.execute(
"UPDATE quote_events SET at_ms=273000 WHERE yes_bid IS NULL AND yes_ask IS NULL",
[],
)
.unwrap();
let before_close = vec![json!({"t":240,"p":0.915})];
assert_eq!(read(&exchange, "NO", 180.001, 400.0), before_close);
exchange
.execute(json!({"op":"finalize","id":"verdict","market":"mid-example","winner":"NO"}))
.unwrap();
db.execute("UPDATE price_settlements SET at_ms=273000", [])
.unwrap();
drop(exchange);
let reopened = Exchange::open(path).unwrap();
assert_eq!(
read(&reopened, "NO", 180.001, 240.0),
vec![json!({"t":240,"p":0.915}), json!({"t":273,"p":1})]
);
assert_eq!(
read(&reopened, "YES", 5.0, 5.0),
vec![json!({"t":273,"p":0})]
);
assert_eq!(read(&reopened, "NO", 180.001, 400.0), before_close);
assert!(read(&reopened, "YES", 273.0, 400.0).is_empty());
assert!(read(&reopened, "YES", 5.0, 5.0).is_empty());
}
#[test]