修复平台策略金额买入预算
This commit is contained in:
@@ -6876,19 +6876,11 @@ 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::Value {
|
||||||
order_intents.push(OrderIntent::Shares {
|
symbol: symbol.clone(),
|
||||||
symbol: symbol.clone(),
|
value: buy_cash,
|
||||||
quantity: filled_qty as i32,
|
reason: "daily_top_up_buy".to_string(),
|
||||||
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(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if filled_qty > 0 {
|
if filled_qty > 0 {
|
||||||
let spent = (cash_before_buy - projected.cash()).max(0.0);
|
let spent = (cash_before_buy - projected.cash()).max(0.0);
|
||||||
@@ -7005,19 +6997,11 @@ 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::Value {
|
||||||
order_intents.push(OrderIntent::Shares {
|
symbol: symbol.clone(),
|
||||||
symbol: symbol.clone(),
|
value: buy_cash,
|
||||||
quantity: filled_qty as i32,
|
reason: "periodic_rebalance_buy".to_string(),
|
||||||
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());
|
||||||
@@ -7073,19 +7057,11 @@ 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::Value {
|
||||||
order_intents.push(OrderIntent::Shares {
|
symbol: symbol.clone(),
|
||||||
symbol: symbol.clone(),
|
value: buy_cash,
|
||||||
quantity: filled_qty as i32,
|
reason: "periodic_rebalance_buy".to_string(),
|
||||||
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());
|
||||||
@@ -14233,11 +14209,11 @@ mod tests {
|
|||||||
assert!(
|
assert!(
|
||||||
decision.order_intents.iter().any(|intent| matches!(
|
decision.order_intents.iter().any(|intent| matches!(
|
||||||
intent,
|
intent,
|
||||||
OrderIntent::Shares {
|
OrderIntent::Value {
|
||||||
symbol,
|
symbol,
|
||||||
quantity,
|
value,
|
||||||
reason,
|
reason,
|
||||||
} if symbol == "000003.SZ" && *quantity > 0 && reason == "daily_top_up_buy"
|
} if symbol == "000003.SZ" && *value > 0.0 && reason == "daily_top_up_buy"
|
||||||
)),
|
)),
|
||||||
"{:?}",
|
"{:?}",
|
||||||
decision.order_intents
|
decision.order_intents
|
||||||
@@ -14867,13 +14843,13 @@ mod tests {
|
|||||||
assert!(
|
assert!(
|
||||||
decision.order_intents.iter().any(|intent| matches!(
|
decision.order_intents.iter().any(|intent| matches!(
|
||||||
intent,
|
intent,
|
||||||
OrderIntent::Shares {
|
OrderIntent::Value {
|
||||||
symbol,
|
symbol,
|
||||||
quantity,
|
value,
|
||||||
reason,
|
reason,
|
||||||
} if symbol == "000002.SZ"
|
} if symbol == "000002.SZ"
|
||||||
&& reason == "periodic_rebalance_buy"
|
&& reason == "periodic_rebalance_buy"
|
||||||
&& *quantity == 900
|
&& (*value - 10_000.0).abs() < 1e-6
|
||||||
)),
|
)),
|
||||||
"{:?}",
|
"{:?}",
|
||||||
decision.order_intents
|
decision.order_intents
|
||||||
|
|||||||
Reference in New Issue
Block a user