Align jq microcap sizing and snapshot pricing
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user