Preview market sweeps and execute protected share sales

This commit is contained in:
2026-12-03 04:31:07 +08:00
parent c0b8a0f229
commit ea6383f089
10 changed files with 278 additions and 7 deletions
+38 -1
View File
@@ -137,7 +137,44 @@ pub(crate) fn apply(tx: &Transaction, books: &Books, command: Command) -> Result
expiration,
post_only,
},
),
)
.map(|result| result.receipt()),
Command::MarketSell {
market,
account,
outcome,
qty,
min_price,
tif,
} => {
let tif = tif.unwrap_or(crate::command::TimeInForce::Fak);
ensure!(
matches!(
tif,
crate::command::TimeInForce::Fak | crate::command::TimeInForce::Fok
),
"market sell requires FAK or FOK"
);
let result = book::submit(
tx,
books,
book::NewOrder {
market,
account,
outcome,
side: "sell".to_owned(),
price: min_price,
qty,
tif,
expiration: None,
post_only: false,
},
)?;
let mut receipt = result.receipt();
receipt["proceeds_cents"] = json!(result.gross_cents);
receipt["unsold_shares"] = json!(qty - result.filled);
Ok(receipt)
}
Command::MarketBuy {
market,
outcome,