Serve the CLOB price history protocol with minute-based fidelity

This commit is contained in:
2026-12-03 10:18:43 +08:00
parent 74749bfdb8
commit fe69e31929
10 changed files with 201 additions and 1 deletions
+23
View File
@@ -1532,6 +1532,25 @@ fn prices_history_keeps_the_terminal_tick_and_pins_pages_before_settlement() {
let wire = |engine: &Exchange, params: Value| {
engine.public_price_history(serde_json::from_value(params).unwrap())
};
let clob = |engine: &Exchange, start: f64, end: f64, minutes: i64| {
engine
.clob_price_history(
serde_json::from_value(json!({
"market":"eb:YES:e","startTs":start,"endTs":end,"fidelity":minutes
}))
.unwrap(),
)
.unwrap()
};
assert_eq!(
clob(&e, 120.0, 245.0, 1),
json!({"history":[{"t":149,"p":0.47},{"t":245,"p":0.55}]})
);
assert_eq!(clob(&e, 149.001, 244.999, 1), json!({"history":[]}));
assert_eq!(
clob(&e, 120.0, 245.0, 10),
json!({"history":[{"t":245,"p":0.55}]})
);
let first_wire = wire(
&e,
json!({"tokenId":"eb:YES:e","start":120,"end":290,"bucketSeconds":60,"limit":1}),
@@ -1563,6 +1582,10 @@ fn prices_history_keeps_the_terminal_tick_and_pins_pages_before_settlement() {
.unwrap();
drop(e);
let mut e = Exchange::open(&path).unwrap();
assert_eq!(
clob(&e, 120.0, 290.0, 1),
json!({"history":[{"t":149,"p":0.47},{"t":273,"p":0.5}]})
);
let second_wire = wire(
&e,
json!({"token_id":"eb:YES:e","start":120,"end":290,"cursor":saved,"limit":99}),