Align jq microcap sizing and snapshot pricing

This commit is contained in:
boris
2026-04-21 06:36:17 -07:00
parent ba36bd5981
commit 3652f80d85
2 changed files with 16 additions and 52 deletions

View File

@@ -121,23 +121,10 @@ where
if self.execution_price_field == PriceField::Last
&& self.intraday_execution_start_time.is_some()
{
let tick = snapshot.effective_price_tick();
let base_price = snapshot.price(PriceField::Last);
let adjusted = match side {
OrderSide::Buy => base_price + tick * 2.0,
OrderSide::Sell => base_price - tick,
return match side {
OrderSide::Buy => self.buy_price(snapshot),
OrderSide::Sell => self.sell_price(snapshot),
};
let lower = if snapshot.lower_limit.is_finite() && snapshot.lower_limit > 0.0 {
snapshot.lower_limit
} else {
tick
};
let upper = if snapshot.upper_limit.is_finite() && snapshot.upper_limit > 0.0 {
snapshot.upper_limit
} else {
f64::INFINITY
};
return adjusted.clamp(lower, upper);
}
match side {
@@ -1053,8 +1040,7 @@ where
quantity = quantity.saturating_sub(lot);
continue;
}
let cost = self.cost_model.calculate(OrderSide::Buy, gross);
if gross + cost.total() <= cash + 1e-6 {
if gross <= cash + 1e-6 {
return quantity;
}
quantity = quantity.saturating_sub(lot);
@@ -1251,8 +1237,7 @@ where
take_qty = take_qty.saturating_sub(lot);
continue;
}
let candidate_cost = self.cost_model.calculate(OrderSide::Buy, candidate_gross);
if candidate_gross + candidate_cost.total() <= cash + 1e-6 {
if candidate_gross <= cash + 1e-6 {
break;
}
take_qty = take_qty.saturating_sub(lot);
@@ -1284,9 +1269,7 @@ where
residual_qty = residual_qty.saturating_sub(lot);
continue;
}
let candidate_cost =
self.cost_model.calculate(OrderSide::Buy, candidate_gross);
if candidate_gross + candidate_cost.total() <= cash + 1e-6 {
if candidate_gross <= cash + 1e-6 {
break;
}
residual_qty = residual_qty.saturating_sub(lot);