对齐 AiQuant RQAlpha 回测语义

This commit is contained in:
boris
2026-05-15 11:48:10 +08:00
parent 94662b6e75
commit 4577657c90
7 changed files with 1377 additions and 69 deletions

View File

@@ -1780,11 +1780,23 @@ impl OmniMicroCapStrategy {
if !sizing_price.is_finite() || sizing_price <= 0.0 {
return 0;
}
let snapshot_requested_qty = self.round_lot_quantity(
let mut snapshot_requested_qty = self.round_lot_quantity(
((projected.cash().min(order_value)) / sizing_price).floor() as u32,
minimum_order_quantity,
order_step_size,
);
while snapshot_requested_qty > 0 {
let gross_amount = sizing_price * snapshot_requested_qty as f64;
let cash_out = gross_amount + self.buy_commission(gross_amount);
if cash_out <= order_value + 1e-6 && cash_out <= projected.cash() + 1e-6 {
break;
}
snapshot_requested_qty = self.decrement_order_quantity(
snapshot_requested_qty,
minimum_order_quantity,
order_step_size,
);
}
let projected_execution_price = self.projected_execution_price(market, OrderSide::Buy);
let projected_fill = self.projected_select_execution_fill(
ctx,
@@ -1796,14 +1808,15 @@ impl OmniMicroCapStrategy {
minimum_order_quantity,
order_step_size,
false,
Some(projected.cash()),
Some(order_value + 400.0),
Some(projected.cash().min(order_value)),
Some(order_value),
execution_state,
);
let mut quantity = snapshot_requested_qty;
while quantity > 0 {
let gross_amount = projected_execution_price * quantity as f64;
if gross_amount <= order_value + 400.0 && gross_amount <= projected.cash() + 1e-6 {
let cash_out = gross_amount + self.buy_commission(gross_amount);
if cash_out <= order_value + 1e-6 && cash_out <= projected.cash() + 1e-6 {
break;
}
quantity =
@@ -1818,7 +1831,8 @@ impl OmniMicroCapStrategy {
.unwrap_or(projected_execution_price);
while quantity > 0 {
let gross_amount = execution_price * quantity as f64;
if gross_amount <= projected.cash() + 1e-6 {
let cash_out = gross_amount + self.buy_commission(gross_amount);
if cash_out <= order_value + 1e-6 && cash_out <= projected.cash() + 1e-6 {
break;
}
quantity =
@@ -1834,7 +1848,7 @@ impl OmniMicroCapStrategy {
};
let gross_amount = fill.price * fill.quantity as f64;
let cash_out = gross_amount + self.buy_commission(gross_amount);
if gross_amount > projected.cash() + 1e-6 {
if cash_out > projected.cash() + 1e-6 || cash_out > order_value + 1e-6 {
return 0;
}
projected.apply_cash_delta(-cash_out);