Expose exact midpoint quotes for individual and batched assets

This commit is contained in:
2026-12-03 09:59:12 +08:00
parent d26c801888
commit b47058d75e
8 changed files with 180 additions and 49 deletions
+25
View File
@@ -3116,3 +3116,28 @@ fn clob_parameters_follow_the_market_across_both_tokens_and_restart() {
assert!(topic["gst"].is_null());
assert!(topic.get("fd").is_none());
}
#[test]
fn midpoint_keeps_half_a_tick_after_reopening_the_book() {
let dir = tempdir().unwrap();
let path = dir.path().join("midpoint.db");
let mut exchange = Exchange::open(&path).unwrap();
for line in include_str!("../../../docs/examples/midpoint.jsonl").lines() {
exchange
.execute(serde_json::from_str(line).unwrap())
.unwrap();
}
let tokens = [
"eb:YES:mid-example".to_owned(),
"eb:NO:mid-example".to_owned(),
];
exchange
.execute(json!({"op":"order","id":"fine-bid","asset_id":tokens[0],
"account":"mid-yes","side":"buy","price_micros":80100,"qty":1}))
.unwrap();
drop(exchange);
let reopened = Exchange::open(&path).unwrap();
let prices = reopened.midpoints(&tokens).unwrap();
assert_eq!(prices[&tokens[0]].as_deref(), Some("0.08505"));
assert_eq!(prices[&tokens[1]].as_deref(), Some("0.91495"));
}