修正FIDC执行日风控配置
This commit is contained in:
@@ -185,6 +185,7 @@ pub struct BrokerSimulator<C, R> {
|
||||
liquidity_limit: bool,
|
||||
strict_value_budget: bool,
|
||||
rebalance_cash_mode: RebalanceCashMode,
|
||||
sell_then_buy_delay_slippage_rate: f64,
|
||||
aiquant_execution_rules: bool,
|
||||
same_day_buy_close_mark_at_fill: bool,
|
||||
risk_config: FidcRiskControlConfig,
|
||||
@@ -213,6 +214,7 @@ impl<C, R> BrokerSimulator<C, R> {
|
||||
liquidity_limit: true,
|
||||
strict_value_budget: false,
|
||||
rebalance_cash_mode: RebalanceCashMode::default(),
|
||||
sell_then_buy_delay_slippage_rate: 0.0,
|
||||
aiquant_execution_rules: false,
|
||||
same_day_buy_close_mark_at_fill: false,
|
||||
risk_config: FidcRiskControlConfig::default(),
|
||||
@@ -245,6 +247,7 @@ impl<C, R> BrokerSimulator<C, R> {
|
||||
liquidity_limit: true,
|
||||
strict_value_budget: false,
|
||||
rebalance_cash_mode: RebalanceCashMode::default(),
|
||||
sell_then_buy_delay_slippage_rate: 0.0,
|
||||
aiquant_execution_rules: false,
|
||||
same_day_buy_close_mark_at_fill: false,
|
||||
risk_config: FidcRiskControlConfig::default(),
|
||||
@@ -284,6 +287,15 @@ impl<C, R> BrokerSimulator<C, R> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_sell_then_buy_delay_slippage_rate(mut self, rate: f64) -> Self {
|
||||
self.sell_then_buy_delay_slippage_rate = if rate.is_finite() && rate > 0.0 {
|
||||
rate.min(0.999_999)
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_aiquant_execution_rules(mut self, enabled: bool) -> Self {
|
||||
self.aiquant_execution_rules = enabled;
|
||||
self
|
||||
@@ -533,7 +545,7 @@ where
|
||||
}
|
||||
|
||||
let order_value = quantity.and_then(|qty| (qty > 0).then_some(raw_price * qty as f64));
|
||||
let adjusted = match self.slippage_model {
|
||||
let mut adjusted = match self.slippage_model {
|
||||
SlippageModel::None => raw_price,
|
||||
SlippageModel::PriceRatio(ratio) => {
|
||||
let ratio = ratio.max(0.0);
|
||||
@@ -559,6 +571,12 @@ where
|
||||
}
|
||||
}
|
||||
};
|
||||
if side == OrderSide::Buy
|
||||
&& self.effective_rebalance_cash_mode() == RebalanceCashMode::SellThenBuy
|
||||
&& self.sell_then_buy_delay_slippage_rate > 0.0
|
||||
{
|
||||
adjusted *= 1.0 + self.sell_then_buy_delay_slippage_rate;
|
||||
}
|
||||
|
||||
self.clamp_execution_price(snapshot, side, adjusted)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user