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,
|
||||
|
||||
@@ -108,7 +108,7 @@ pub fn built_in_strategy_manual() -> StrategyAiManual {
|
||||
},
|
||||
ManualSection {
|
||||
title: "execution.matching_type / execution.slippage".to_string(),
|
||||
detail: "设置撮合模式和滑点。支持 execution.matching_type(\"next_tick_last\" | \"current_bar_close\" | \"next_bar_open\" | \"open_auction\"),其中 open_auction 使用当日集合竞价开盘价 day_open 进行撮合;滑点支持 execution.slippage(\"none\") / execution.slippage(\"price_ratio\", 0.001) / execution.slippage(\"tick_size\", 1)。".to_string(),
|
||||
detail: "设置撮合模式和滑点。支持 execution.matching_type(\"next_tick_last\" | \"current_bar_close\" | \"next_bar_open\" | \"open_auction\"),其中 open_auction 使用当日集合竞价开盘价 day_open 进行撮合,且不额外施加滑点;滑点支持 execution.slippage(\"none\") / execution.slippage(\"price_ratio\", 0.001) / execution.slippage(\"tick_size\", 1)。".to_string(),
|
||||
},
|
||||
ManualSection {
|
||||
title: "when / unless / else".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user