修正AiQuant兼容买入数量语义
This commit is contained in:
@@ -6614,11 +6614,6 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
if buy_cash <= 0.0 {
|
if buy_cash <= 0.0 {
|
||||||
break;
|
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());
|
intraday_attempted_buys.insert(symbol.clone());
|
||||||
attempted_any = true;
|
attempted_any = true;
|
||||||
let cash_before_buy = projected.cash();
|
let cash_before_buy = projected.cash();
|
||||||
@@ -6630,6 +6625,21 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
buy_cash,
|
buy_cash,
|
||||||
&mut projected_execution_state,
|
&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 {
|
let spent = if filled_qty > 0 {
|
||||||
(cash_before_buy - projected.cash()).max(0.0)
|
(cash_before_buy - projected.cash()).max(0.0)
|
||||||
} else {
|
} else {
|
||||||
@@ -6738,11 +6748,6 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
if !self.stock_passes_expr(ctx, &day, &decision_stock)? {
|
if !self.stock_passes_expr(ctx, &day, &decision_stock)? {
|
||||||
continue;
|
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 cash_before_buy = projected.cash();
|
||||||
let filled_qty = self.project_order_value(
|
let filled_qty = self.project_order_value(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -6753,6 +6758,19 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
&mut projected_execution_state,
|
&mut projected_execution_state,
|
||||||
);
|
);
|
||||||
if filled_qty > 0 {
|
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);
|
let spent = (cash_before_buy - projected.cash()).max(0.0);
|
||||||
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
|
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
|
||||||
intraday_attempted_buys.insert(symbol.clone());
|
intraday_attempted_buys.insert(symbol.clone());
|
||||||
@@ -6798,11 +6816,6 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
if !self.stock_passes_expr(ctx, &day, &decision_stock)? {
|
if !self.stock_passes_expr(ctx, &day, &decision_stock)? {
|
||||||
continue;
|
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 cash_before_buy = projected.cash();
|
||||||
let filled_qty = self.project_order_value(
|
let filled_qty = self.project_order_value(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -6813,6 +6826,19 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
&mut projected_execution_state,
|
&mut projected_execution_state,
|
||||||
);
|
);
|
||||||
if filled_qty > 0 {
|
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);
|
let spent = (cash_before_buy - projected.cash()).max(0.0);
|
||||||
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
|
aiquant_available_cash = (aiquant_available_cash - spent).max(0.0);
|
||||||
rebalance_working_symbols.insert(symbol.clone());
|
rebalance_working_symbols.insert(symbol.clone());
|
||||||
|
|||||||
Reference in New Issue
Block a user