按顺序结算多笔现金应收

This commit is contained in:
boris
2026-08-25 15:25:18 +08:00
parent e368bad7e4
commit 2574b9375d
3 changed files with 35 additions and 19 deletions
+6 -4
View File
@@ -3242,14 +3242,16 @@ where
notes: &mut Vec<String>,
) -> Result<BrokerExecutionReport, BacktestError> {
let mut report = BrokerExecutionReport::default();
let settled = portfolio.settle_cash_receivables(date);
for receivable in settled {
let due = portfolio.take_due_cash_receivables(date);
for receivable in due {
let cash_before = portfolio.cash();
portfolio
.settle_cash_receivable(&receivable)
.map_err(BacktestError::Execution)?;
let mut note = format!(
"cash_receivable_settled {} ex_date={} payable_date={} cash={:.2}",
receivable.symbol, receivable.ex_date, receivable.payable_date, receivable.amount
);
let cash_before = portfolio.cash() - receivable.amount;
if self.dividend_reinvestment
&& receivable.reason.starts_with("cash_dividend")
&& receivable.amount > 0.0