对齐除权除息到账顺序

This commit is contained in:
boris
2026-07-01 14:46:10 +08:00
parent 9f188f6313
commit eae82128ee
2 changed files with 169 additions and 30 deletions
+21 -30
View File
@@ -1702,18 +1702,18 @@ where
&mut corporate_action_notes,
);
self.extend_result(&mut result, pending_cash_flow_report);
let receivable_report = self.settle_cash_receivables(
execution_date,
&mut portfolio,
&mut corporate_action_notes,
)?;
self.extend_result(&mut result, receivable_report);
let corporate_action_report = self.apply_corporate_actions(
execution_date,
&mut portfolio,
&mut corporate_action_notes,
)?;
self.extend_result(&mut result, corporate_action_report);
let receivable_report = self.settle_cash_receivables(
execution_date,
&mut portfolio,
&mut corporate_action_notes,
)?;
self.extend_result(&mut result, receivable_report);
let delisting_report = self.settle_delisted_positions(
execution_date,
&mut portfolio,
@@ -2875,30 +2875,21 @@ where
};
if cash_delta.abs() > f64::EPSILON {
let payable_date = action.payable_date.unwrap_or(date);
let immediate_cash = payable_date <= date;
let note = if immediate_cash {
portfolio.apply_cash_delta(cash_delta);
format!(
"cash_dividend {} share_cash={:.6} quantity={} cash={:.2}",
action.symbol, action.share_cash, quantity_after, cash_delta
)
} else {
portfolio.add_cash_receivable(CashReceivable {
symbol: action.symbol.clone(),
ex_date: date,
payable_date,
amount: cash_delta,
reason: format!("cash_dividend {:.6}", action.share_cash),
});
format!(
"cash_dividend_receivable {} share_cash={:.6} quantity={} payable_date={} cash={:.2}",
action.symbol,
action.share_cash,
quantity_after,
payable_date,
cash_delta
)
};
portfolio.add_cash_receivable(CashReceivable {
symbol: action.symbol.clone(),
ex_date: date,
payable_date,
amount: cash_delta,
reason: format!("cash_dividend {:.6}", action.share_cash),
});
let note = format!(
"cash_dividend_receivable {} share_cash={:.6} quantity={} payable_date={} cash={:.2}",
action.symbol,
action.share_cash,
quantity_after,
payable_date,
cash_delta
);
notes.push(note.clone());
report.account_events.push(AccountEvent {
date,