Resolve outcome tokens to CLOB markets and expose their execution parameters
This commit is contained in:
@@ -3057,3 +3057,62 @@ fn batch_book_reads_keep_complementary_depth_on_one_revision() {
|
||||
assert_eq!(books[0]["bids"], json!([]));
|
||||
assert_eq!(books[1]["asks"], json!([]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clob_parameters_follow_the_market_across_both_tokens_and_restart() {
|
||||
let dir = tempdir().unwrap();
|
||||
let path = dir.path().join("market-info.db");
|
||||
let mut writer = Exchange::open(&path).unwrap();
|
||||
let reader = Exchange::open(&path).unwrap();
|
||||
for line in include_str!("../../../docs/examples/football.jsonl")
|
||||
.lines()
|
||||
.take(2)
|
||||
{
|
||||
let mut cmd: Value = serde_json::from_str(line).unwrap();
|
||||
if cmd["op"] == "list" {
|
||||
cmd["tick_size"] = json!("0.005");
|
||||
cmd["min_order_size"] = json!("2.5");
|
||||
cmd["taker_fee_rate_ppm"] = json!(25000);
|
||||
}
|
||||
writer.execute(cmd).unwrap();
|
||||
}
|
||||
let market = "full-2-1";
|
||||
let pair = reader.market_by_token("eb:NO:full-2-1").unwrap().unwrap();
|
||||
assert_eq!(
|
||||
pair,
|
||||
reader.market_by_token("eb:YES:full-2-1").unwrap().unwrap()
|
||||
);
|
||||
assert_eq!(pair["condition_id"], market);
|
||||
let info = reader.clob_market_info(market).unwrap().unwrap();
|
||||
assert_eq!(
|
||||
info["t"],
|
||||
json!([{"t":pair["primary_token_id"],"o":"2:1"},{"t":pair["secondary_token_id"],"o":"其他比分"}])
|
||||
);
|
||||
assert_eq!(info["mts"], json!(0.005));
|
||||
assert_eq!(info["mos"], json!(2.5));
|
||||
assert_eq!(info["fd"], json!({"r":0.025,"e":1,"to":true}));
|
||||
assert_eq!(info["gst"], "2027-01-15T08:00:00.000Z");
|
||||
writer
|
||||
.execute(
|
||||
json!({"op":"tick_size_change","id":"change","asset_id":"eb:NO:full-2-1",
|
||||
"old_tick_size":"0.005","new_tick_size":"0.001","timestamp":"1"}),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
reader.clob_market_info(market).unwrap().unwrap()["mts"],
|
||||
json!(0.001)
|
||||
);
|
||||
for line in include_str!("../../../docs/examples/neg-risk.jsonl")
|
||||
.lines()
|
||||
.take(5)
|
||||
{
|
||||
writer.execute(serde_json::from_str(line).unwrap()).unwrap();
|
||||
}
|
||||
drop(reader);
|
||||
let reopened = Exchange::open(&path).unwrap();
|
||||
let topic = reopened.clob_market_info("a").unwrap().unwrap();
|
||||
assert_eq!(topic["nr"], true);
|
||||
assert_eq!(topic["t"][0]["o"], "是");
|
||||
assert!(topic["gst"].is_null());
|
||||
assert!(topic.get("fd").is_none());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user