Report single-sided traded shares and taker notional by event and market

This commit is contained in:
2026-12-03 05:15:50 +08:00
parent 7fd67e7c8e
commit fae9f26829
9 changed files with 212 additions and 2 deletions
+32
View File
@@ -1642,3 +1642,35 @@ fn quote_cursor_replays_only_committed_changes_to_best_prices() {
assert_eq!(empty["points"], json!([]));
assert_eq!(empty["cursor"], two["cursor"]);
}
#[test]
fn catalog_and_ranked_volume_count_executions_once_across_conditions() {
let mut e = Exchange::open(":memory:").unwrap();
let mut result = Value::Null;
for line in include_str!("../../../docs/examples/football.jsonl")
.lines()
.chain(include_str!("../../../docs/examples/volume.jsonl").lines())
{
result = e.execute(serde_json::from_str(line).unwrap()).unwrap();
}
assert_eq!(
result["volume"]["all_time"],
json!({"matched_shares":5,"taker_shares":5,"taker_notional_cents":180,"unknown_role_shares":0})
);
assert_eq!(result["volume"]["all_time"], result["volume"]["last_24h"]);
assert_eq!(result["conditions"][0]["market"], "full-2-1");
assert_eq!(result["conditions"][1]["market"], "half-1-0");
let catalog = e
.execute(json!({"op":"catalog","event":"cup-a-b"}))
.unwrap();
assert_eq!(catalog["event"]["volume"], result["volume"]);
for condition in result["conditions"].as_array().unwrap() {
let listing = catalog["markets"]
.as_array()
.unwrap()
.iter()
.find(|m| m["market"] == condition["market"])
.unwrap();
assert_eq!(listing["volume"], condition["volume"]);
}
}