修正AiQuant兼容买入数量语义

This commit is contained in:
boris
2026-06-16 05:45:15 +08:00
parent 2e036783bf
commit df949ab8ee
+41 -15
View File
@@ -6614,11 +6614,6 @@ impl Strategy for PlatformExprStrategy {
if buy_cash <= 0.0 {
break;
}
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "daily_top_up_buy".to_string(),
});
intraday_attempted_buys.insert(symbol.clone());
attempted_any = true;
let cash_before_buy = projected.cash();
@@ -6630,6 +6625,21 @@ impl Strategy for PlatformExprStrategy {
buy_cash,
&mut projected_execution_state,
);
if filled_qty > 0 {
if self.config.aiquant_transaction_cost {
order_intents.push(OrderIntent::Shares {
symbol: symbol.clone(),
quantity: filled_qty as i32,
reason: "daily_top_up_buy".to_string(),
});
} else {
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "daily_top_up_buy".to_string(),
});
}
}
let spent = if filled_qty > 0 {
(cash_before_buy - projected.cash()).max(0.0)
} else {
@@ -6738,11 +6748,6 @@ impl Strategy for PlatformExprStrategy {
if !self.stock_passes_expr(ctx, &day, &decision_stock)? {
continue;
}
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "periodic_rebalance_buy".to_string(),
});
let cash_before_buy = projected.cash();
let filled_qty = self.project_order_value(
ctx,
@@ -6753,6 +6758,19 @@ impl Strategy for PlatformExprStrategy {
&mut projected_execution_state,
);
if filled_qty > 0 {
if self.config.aiquant_transaction_cost {
order_intents.push(OrderIntent::Shares {
symbol: symbol.clone(),
quantity: filled_qty as i32,
reason: "periodic_rebalance_buy".to_string(),
});
} else {
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "periodic_rebalance_buy".to_string(),
});
}
let spent = (cash_before_buy - projected.cash()).max(0.0);
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
intraday_attempted_buys.insert(symbol.clone());
@@ -6798,11 +6816,6 @@ impl Strategy for PlatformExprStrategy {
if !self.stock_passes_expr(ctx, &day, &decision_stock)? {
continue;
}
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "periodic_rebalance_buy".to_string(),
});
let cash_before_buy = projected.cash();
let filled_qty = self.project_order_value(
ctx,
@@ -6813,6 +6826,19 @@ impl Strategy for PlatformExprStrategy {
&mut projected_execution_state,
);
if filled_qty > 0 {
if self.config.aiquant_transaction_cost {
order_intents.push(OrderIntent::Shares {
symbol: symbol.clone(),
quantity: filled_qty as i32,
reason: "periodic_rebalance_buy".to_string(),
});
} else {
order_intents.push(OrderIntent::Value {
symbol: symbol.clone(),
value: buy_cash,
reason: "periodic_rebalance_buy".to_string(),
});
}
let spent = (cash_before_buy - projected.cash()).max(0.0);
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
rebalance_working_symbols.insert(symbol.clone());