将股票执行资金切换为定点账本
This commit is contained in:
@@ -3217,7 +3217,9 @@ where
|
||||
});
|
||||
if outcome.cash_delta.abs() > f64::EPSILON {
|
||||
let cash_before = portfolio.cash();
|
||||
portfolio.apply_cash_delta(outcome.cash_delta);
|
||||
portfolio
|
||||
.apply_cash_delta(outcome.cash_delta)
|
||||
.map_err(BacktestError::Execution)?;
|
||||
report.account_events.push(AccountEvent {
|
||||
date,
|
||||
cash_before,
|
||||
@@ -3279,7 +3281,9 @@ where
|
||||
if reinvest_quantity > 0 {
|
||||
let reinvest_cash = reinvest_quantity as f64 * price;
|
||||
let residual_cash = receivable.amount - reinvest_cash;
|
||||
portfolio.apply_cash_delta(-reinvest_cash);
|
||||
portfolio
|
||||
.apply_cash_delta(-reinvest_cash)
|
||||
.map_err(BacktestError::Execution)?;
|
||||
portfolio.position_mut(&receivable.symbol).buy(
|
||||
date,
|
||||
reinvest_quantity,
|
||||
|
||||
Reference in New Issue
Block a user