Refine open auction execution semantics
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user