Add rqalpha-style position pnl runtime fields
This commit is contained in:
@@ -2129,6 +2129,9 @@ where
|
||||
.position_mut(symbol)
|
||||
.sell(leg.quantity, leg.price)
|
||||
.map_err(BacktestError::Execution)?;
|
||||
if let Some(position) = portfolio.position_mut_if_exists(symbol) {
|
||||
position.record_trade_cost(cost.total());
|
||||
}
|
||||
portfolio.apply_cash_delta(net_cash);
|
||||
|
||||
report.fill_events.push(FillEvent {
|
||||
@@ -3332,6 +3335,9 @@ where
|
||||
portfolio
|
||||
.position_mut(symbol)
|
||||
.buy(date, leg.quantity, leg.price);
|
||||
if let Some(position) = portfolio.position_mut_if_exists(symbol) {
|
||||
position.record_trade_cost(cost.total());
|
||||
}
|
||||
|
||||
report.fill_events.push(FillEvent {
|
||||
date,
|
||||
|
||||
Reference in New Issue
Block a user