Respect commissions in jq buy sizing
This commit is contained in:
@@ -1004,7 +1004,8 @@ where
|
||||
quantity = quantity.saturating_sub(lot);
|
||||
continue;
|
||||
}
|
||||
if gross <= cash + 1e-6 {
|
||||
let cost = self.cost_model.calculate(OrderSide::Buy, gross);
|
||||
if gross + cost.total() <= cash + 1e-6 {
|
||||
return quantity;
|
||||
}
|
||||
quantity = quantity.saturating_sub(lot);
|
||||
|
||||
@@ -580,7 +580,7 @@ impl JqMicroCapStrategy {
|
||||
let mut quantity = self.round_lot_quantity((cash / sizing_price).floor() as u32, 100);
|
||||
while quantity > 0 {
|
||||
let gross_amount = execution_price * quantity as f64;
|
||||
if gross_amount <= cash + 1e-6 {
|
||||
if gross_amount + self.buy_commission(gross_amount) <= cash + 1e-6 {
|
||||
return quantity;
|
||||
}
|
||||
quantity = quantity.saturating_sub(100);
|
||||
@@ -825,7 +825,8 @@ impl JqMicroCapStrategy {
|
||||
take_qty = take_qty.saturating_sub(round_lot.max(1));
|
||||
continue;
|
||||
}
|
||||
if candidate_gross <= cash + 1e-6 {
|
||||
let candidate_cash = candidate_gross + self.buy_commission(candidate_gross);
|
||||
if candidate_cash <= cash + 1e-6 {
|
||||
break;
|
||||
}
|
||||
take_qty = take_qty.saturating_sub(round_lot.max(1));
|
||||
@@ -904,7 +905,7 @@ impl JqMicroCapStrategy {
|
||||
take_qty = take_qty.saturating_sub(lot);
|
||||
continue;
|
||||
}
|
||||
if candidate_gross <= cash + 1e-6 {
|
||||
if candidate_gross + self.buy_commission(candidate_gross) <= cash + 1e-6 {
|
||||
break;
|
||||
}
|
||||
take_qty = take_qty.saturating_sub(lot);
|
||||
|
||||
Reference in New Issue
Block a user