Match fractional share lots and preserve order quantities across restart

This commit is contained in:
2026-12-03 07:01:24 +08:00
parent 2c4179a64e
commit 064b301ebd
27 changed files with 343 additions and 111 deletions
+2 -8
View File
@@ -57,10 +57,6 @@ impl MinimumSize {
.to_owned()
}
pub fn check_shares(&self, qty: i64) -> Result<()> {
self.check_microshares(qty * SCALE)
}
pub fn check_microshares(&self, shares: i64) -> Result<()> {
ensure!(
shares >= self.0,
@@ -71,11 +67,9 @@ impl MinimumSize {
}
pub fn check_budget(&self, cents: i64, max_price: i64, fee_rate: i64) -> Result<()> {
// Whole shares are the simulator's executable quantity unit. The
// submitted cash cap includes the taker fee at the protection price.
let qty = (self.0 + SCALE - 1) / SCALE;
let lots = (self.0 + crate::lots::MICROS - 1) / crate::lots::MICROS;
let required =
qty * max_price * 10000 + crate::fees::micros(fee_rate, max_price * 10000, qty);
lots * max_price * 100 + crate::fees::lot_fee(fee_rate, max_price * 10000, lots);
ensure!(
cents * 10000 >= required,
"cash budget at protection price is below min_order_size of {} shares",