Refine open auction execution semantics

This commit is contained in:
boris
2026-04-23 00:05:41 -07:00
parent fa4126a662
commit df1054ab8a
3 changed files with 35 additions and 4 deletions

View File

@@ -169,6 +169,10 @@ where
self.apply_slippage(snapshot, side, raw_price)
}
fn is_open_auction_matching(&self) -> bool {
self.execution_price_field == PriceField::DayOpen
}
fn apply_slippage(
&self,
snapshot: &crate::data::DailyMarketSnapshot,
@@ -179,6 +183,10 @@ where
return raw_price;
}
if self.is_open_auction_matching() {
return self.clamp_execution_price(snapshot, side, raw_price);
}
let adjusted = match self.slippage_model {
SlippageModel::None => raw_price,
SlippageModel::PriceRatio(ratio) => {
@@ -882,7 +890,12 @@ where
date,
cash_before,
cash_after: portfolio.cash(),
total_equity: self.total_equity_at(date, portfolio, data, PriceField::Open)?,
total_equity: self.total_equity_at(
date,
portfolio,
data,
self.account_mark_price_field(),
)?,
note: format!("sell {symbol} {reason}"),
});
Ok(())
@@ -1251,7 +1264,12 @@ where
date,
cash_before,
cash_after: portfolio.cash(),
total_equity: self.total_equity_at(date, portfolio, data, PriceField::Open)?,
total_equity: self.total_equity_at(
date,
portfolio,
data,
self.account_mark_price_field(),
)?,
note: format!("buy {symbol} {reason}"),
});
Ok(())
@@ -1305,6 +1323,14 @@ where
.unwrap_or(self.board_lot_size.max(1))
}
fn account_mark_price_field(&self) -> PriceField {
if self.is_open_auction_matching() {
PriceField::DayOpen
} else {
PriceField::Open
}
}
fn round_buy_quantity(
&self,
quantity: u32,