移除回测兼容语义残留

This commit is contained in:
boris
2026-06-26 13:39:21 +08:00
parent 7f40cfdab0
commit 380c34aa66
15 changed files with 265 additions and 300 deletions
+22 -22
View File
@@ -170,7 +170,7 @@ pub struct BrokerSimulator<C, R> {
inactive_limit: bool,
liquidity_limit: bool,
strict_value_budget: bool,
aiquant_rqalpha_execution_rules: bool,
aiquant_execution_rules: bool,
same_day_buy_close_mark_at_fill: bool,
intraday_execution_start_time: Option<NaiveTime>,
runtime_intraday_start_time: Cell<Option<NaiveTime>>,
@@ -193,7 +193,7 @@ impl<C, R> BrokerSimulator<C, R> {
inactive_limit: true,
liquidity_limit: true,
strict_value_budget: false,
aiquant_rqalpha_execution_rules: false,
aiquant_execution_rules: false,
same_day_buy_close_mark_at_fill: false,
intraday_execution_start_time: None,
runtime_intraday_start_time: Cell::new(None),
@@ -220,7 +220,7 @@ impl<C, R> BrokerSimulator<C, R> {
inactive_limit: true,
liquidity_limit: true,
strict_value_budget: false,
aiquant_rqalpha_execution_rules: false,
aiquant_execution_rules: false,
same_day_buy_close_mark_at_fill: false,
intraday_execution_start_time: None,
runtime_intraday_start_time: Cell::new(None),
@@ -250,8 +250,8 @@ impl<C, R> BrokerSimulator<C, R> {
self
}
pub fn with_aiquant_rqalpha_execution_rules(mut self, enabled: bool) -> Self {
self.aiquant_rqalpha_execution_rules = enabled;
pub fn with_aiquant_execution_rules(mut self, enabled: bool) -> Self {
self.aiquant_execution_rules = enabled;
self
}
@@ -362,7 +362,7 @@ where
symbol: &str,
snapshot: &crate::data::DailyMarketSnapshot,
) -> f64 {
if self.aiquant_rqalpha_execution_rules && self.execution_price_field == PriceField::Last {
if self.aiquant_execution_rules && self.execution_price_field == PriceField::Last {
let start_cursor = self
.runtime_intraday_start_time
.get()
@@ -2088,7 +2088,7 @@ where
candidate: &crate::data::CandidateEligibility,
instrument: Option<&Instrument>,
) -> RuleCheck {
let check_price = if self.aiquant_rqalpha_execution_rules {
let check_price = if self.aiquant_execution_rules {
self.aiquant_limit_check_price(snapshot, OrderSide::Buy)
} else {
ChinaAShareRiskControl::buy_check_price(snapshot, self.execution_price_field)
@@ -2102,7 +2102,7 @@ where
) {
return RuleCheck::reject(reason);
}
if !self.aiquant_rqalpha_execution_rules {
if !self.aiquant_execution_rules {
return self
.rules
.can_buy(date, snapshot, candidate, self.execution_price_field);
@@ -2120,7 +2120,7 @@ where
instrument: Option<&Instrument>,
algo_request: Option<&AlgoExecutionRequest>,
) -> RuleCheck {
let check_price = if self.aiquant_rqalpha_execution_rules {
let check_price = if self.aiquant_execution_rules {
self.aiquant_order_limit_check_price(
date,
data,
@@ -2141,7 +2141,7 @@ where
) {
return RuleCheck::reject(reason);
}
if !self.aiquant_rqalpha_execution_rules {
if !self.aiquant_execution_rules {
return self
.rules
.can_buy(date, snapshot, candidate, self.execution_price_field);
@@ -2160,10 +2160,10 @@ where
position: &crate::portfolio::Position,
algo_request: Option<&AlgoExecutionRequest>,
) -> RuleCheck {
if !self.aiquant_rqalpha_execution_rules && !candidate.allow_sell {
if !self.aiquant_execution_rules && !candidate.allow_sell {
return RuleCheck::reject("sell_disabled");
}
let check_price = if self.aiquant_rqalpha_execution_rules {
let check_price = if self.aiquant_execution_rules {
self.aiquant_order_limit_check_price(
date,
data,
@@ -2185,7 +2185,7 @@ where
) {
return RuleCheck::reject(reason);
}
if !self.aiquant_rqalpha_execution_rules {
if !self.aiquant_execution_rules {
return self.rules.can_sell(
date,
snapshot,
@@ -2991,7 +2991,7 @@ where
return Ok(());
}
let current_value = if self.aiquant_rqalpha_execution_rules {
let current_value = if self.aiquant_execution_rules {
let valuation_price = self.target_value_valuation_price(date, data, symbol, snapshot);
valuation_price * current_qty as f64
} else {
@@ -4805,7 +4805,7 @@ where
return Ok(0);
}
if self.inactive_limit && snapshot.tick_volume == 0 {
if self.inactive_limit && snapshot.minute_volume == 0 {
return Err("minute no volume".to_string());
}
@@ -4832,7 +4832,7 @@ where
}
if self.volume_limit {
let raw_limit = ((snapshot.tick_volume as f64) * self.volume_percent).round() as i64
let raw_limit = ((snapshot.minute_volume as f64) * self.volume_percent).round() as i64
- consumed_turnover as i64;
if raw_limit <= 0 {
return Err("minute volume limit".to_string());
@@ -5418,7 +5418,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -5512,7 +5512,7 @@ mod tests {
}
#[test]
fn target_value_valuation_uses_daily_snapshot_but_value_order_sizing_uses_intraday_tick() {
fn target_value_valuation_uses_daily_snapshot_but_value_order_sizing_uses_intraday_minute() {
let date = chrono::NaiveDate::from_ymd_opt(2025, 1, 2).expect("valid date");
let broker = BrokerSimulator::new_with_execution_price(
ChinaAShareCostModel::default(),
@@ -5645,7 +5645,7 @@ mod tests {
.with_intraday_execution_start_time(date.and_hms_opt(10, 40, 0).unwrap().time())
.with_slippage_model(SlippageModel::PriceRatio(0.002))
.with_strict_value_budget(true)
.with_aiquant_rqalpha_execution_rules(true)
.with_aiquant_execution_rules(true)
.with_volume_limit(false)
.with_liquidity_limit(false)
.with_inactive_limit(false);
@@ -5663,7 +5663,7 @@ mod tests {
ask1: 5.83,
prev_close: 5.85,
volume: 1_000_000,
tick_volume: 262,
minute_volume: 262,
bid1_volume: 54,
ask1_volume: 143,
trading_phase: Some("continuous".to_string()),
@@ -6068,7 +6068,7 @@ mod tests {
ChinaEquityRuleHooks,
PriceField::Last,
)
.with_aiquant_rqalpha_execution_rules(true);
.with_aiquant_execution_rules(true);
let aiquant_rule = aiquant_broker.buy_rule_check(date, &snapshot, &candidate, None);
assert!(!aiquant_rule.allowed);
assert_eq!(aiquant_rule.reason.as_deref(), Some("buy_disabled"));
@@ -6131,7 +6131,7 @@ mod tests {
ChinaEquityRuleHooks,
PriceField::Last,
)
.with_aiquant_rqalpha_execution_rules(true)
.with_aiquant_execution_rules(true)
.with_intraday_execution_start_time(date.and_hms_opt(10, 18, 0).unwrap().time())
.with_volume_limit(false)
.with_liquidity_limit(false)
+1 -1
View File
@@ -53,7 +53,7 @@ impl Default for ChinaAShareCostModel {
}
impl ChinaAShareCostModel {
pub fn aiquant_rqalpha_default() -> Self {
pub fn aiquant_default() -> Self {
Self {
commission_rate: 0.00025,
stamp_tax_rate_before_change: 0.0005,
+13 -10
View File
@@ -106,7 +106,7 @@ pub struct DailyMarketSnapshot {
pub ask1: f64,
pub prev_close: f64,
pub volume: u64,
pub tick_volume: u64,
pub minute_volume: u64,
pub bid1_volume: u64,
pub ask1_volume: u64,
pub trading_phase: Option<String>,
@@ -519,7 +519,7 @@ struct SymbolPriceSeries {
bid1s: Vec<f64>,
ask1s: Vec<f64>,
volumes: Vec<u64>,
tick_volumes: Vec<u64>,
minute_volumes: Vec<u64>,
bid1_volumes: Vec<u64>,
ask1_volumes: Vec<u64>,
trading_phases: Vec<Option<String>>,
@@ -557,7 +557,10 @@ impl SymbolPriceSeries {
let bid1s = sorted.iter().map(|row| row.bid1).collect::<Vec<_>>();
let ask1s = sorted.iter().map(|row| row.ask1).collect::<Vec<_>>();
let volumes = sorted.iter().map(|row| row.volume).collect::<Vec<_>>();
let tick_volumes = sorted.iter().map(|row| row.tick_volume).collect::<Vec<_>>();
let minute_volumes = sorted
.iter()
.map(|row| row.minute_volume)
.collect::<Vec<_>>();
let bid1_volumes = sorted.iter().map(|row| row.bid1_volume).collect::<Vec<_>>();
let ask1_volumes = sorted.iter().map(|row| row.ask1_volume).collect::<Vec<_>>();
let trading_phases = sorted
@@ -592,7 +595,7 @@ impl SymbolPriceSeries {
bid1s,
ask1s,
volumes,
tick_volumes,
minute_volumes,
bid1_volumes,
ask1_volumes,
trading_phases,
@@ -816,7 +819,7 @@ impl SymbolPriceSeries {
ask1: self.ask1s[index],
prev_close: self.prev_closes[index],
volume: self.volumes[index],
tick_volume: self.tick_volumes[index],
minute_volume: self.minute_volumes[index],
bid1_volume: self.bid1_volumes[index],
ask1_volume: self.ask1_volumes[index],
trading_phase: self.trading_phases[index].clone(),
@@ -837,7 +840,7 @@ impl SymbolPriceSeries {
"last" | "last_price" => Some(self.last_prices[index]),
"prev_close" | "pre_close" => Some(self.prev_closes[index]),
"volume" => Some(self.volumes[index] as f64),
"tick_volume" => Some(self.tick_volumes[index] as f64),
"minute_volume" => Some(self.minute_volumes[index] as f64),
"bid1" => Some(self.bid1s[index]),
"ask1" => Some(self.ask1s[index]),
"bid1_volume" => Some(self.bid1_volumes[index] as f64),
@@ -2695,7 +2698,7 @@ fn read_market(path: &Path) -> Result<Vec<DailyMarketSnapshot>, DataSetError> {
ask1: row.parse_optional_f64(14).unwrap_or(close),
prev_close,
volume: row.parse_u64(7)?,
tick_volume: row.parse_optional_u64(17).unwrap_or_default(),
minute_volume: row.parse_optional_u64(17).unwrap_or_default(),
bid1_volume: row.parse_optional_u64(18).unwrap_or_default(),
ask1_volume: row.parse_optional_u64(19).unwrap_or_default(),
trading_phase: row
@@ -3727,7 +3730,7 @@ mod tests {
ask1: prev_close,
prev_close,
volume,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: None,
@@ -3915,7 +3918,7 @@ mod tests {
ask1: prev_close,
prev_close,
volume: 100_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -3995,7 +3998,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 100_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
+110 -114
View File
@@ -391,7 +391,7 @@ struct StockExpressionState {
free_float_cap_bn: f64,
pe_ttm: f64,
volume: f64,
tick_volume: i64,
minute_volume: i64,
bid1_volume: i64,
ask1_volume: i64,
turnover_ratio: f64,
@@ -830,7 +830,6 @@ impl PlatformExprStrategy {
| "volume"
| "minute_volume"
| "intraday_volume"
| "tick_volume"
| "bid1_volume"
| "ask1_volume"
| "turnover_ratio"
@@ -1015,7 +1014,7 @@ impl PlatformExprStrategy {
fn cost_model(&self) -> ChinaAShareCostModel {
let mut model = if self.config.aiquant_transaction_cost {
ChinaAShareCostModel::aiquant_rqalpha_default()
ChinaAShareCostModel::aiquant_default()
} else {
ChinaAShareCostModel::default()
};
@@ -2465,7 +2464,7 @@ impl PlatformExprStrategy {
free_float_cap_bn,
pe_ttm: factor.pe_ttm,
volume: expression_volume,
tick_volume: market.tick_volume as i64,
minute_volume: market.minute_volume as i64,
bid1_volume: market.bid1_volume as i64,
ask1_volume: market.ask1_volume as i64,
turnover_ratio: factor.turnover_ratio.unwrap_or(0.0),
@@ -2873,9 +2872,8 @@ impl PlatformExprStrategy {
scope.push("free_float_market_cap", stock.free_float_cap);
scope.push("pe_ttm", stock.pe_ttm);
scope.push("volume", stock.volume);
scope.push("minute_volume", stock.tick_volume);
scope.push("intraday_volume", stock.tick_volume);
scope.push("tick_volume", stock.tick_volume);
scope.push("minute_volume", stock.minute_volume);
scope.push("intraday_volume", stock.minute_volume);
scope.push("bid1_volume", stock.bid1_volume);
scope.push("ask1_volume", stock.ask1_volume);
scope.push("turnover", stock.turnover_ratio);
@@ -2976,9 +2974,8 @@ impl PlatformExprStrategy {
);
factors.insert("pe_ttm".into(), Dynamic::from(stock.pe_ttm));
factors.insert("volume".into(), Dynamic::from(stock.volume));
factors.insert("minute_volume".into(), Dynamic::from(stock.tick_volume));
factors.insert("intraday_volume".into(), Dynamic::from(stock.tick_volume));
factors.insert("tick_volume".into(), Dynamic::from(stock.tick_volume));
factors.insert("minute_volume".into(), Dynamic::from(stock.minute_volume));
factors.insert("intraday_volume".into(), Dynamic::from(stock.minute_volume));
factors.insert("bid1_volume".into(), Dynamic::from(stock.bid1_volume));
factors.insert("ask1_volume".into(), Dynamic::from(stock.ask1_volume));
factors.insert("turnover".into(), Dynamic::from(stock.turnover_ratio));
@@ -5978,7 +5975,7 @@ impl PlatformExprStrategy {
"free_float_cap_bn" => Some(stock.free_float_cap_bn),
"pe_ttm" => Some(stock.pe_ttm),
"volume" => Some(stock.volume),
"minute_volume" | "intraday_volume" | "tick_volume" => Some(stock.tick_volume as f64),
"minute_volume" | "intraday_volume" => Some(stock.minute_volume as f64),
"bid1_volume" => Some(stock.bid1_volume as f64),
"ask1_volume" => Some(stock.ask1_volume as f64),
"turnover" | "turnover_ratio" => Some(stock.turnover_ratio),
@@ -6320,7 +6317,7 @@ impl PlatformExprStrategy {
for name in Self::extract_identifier_candidates(&expr) {
match name.as_str() {
"last" | "last_price" | "bid1" | "ask1" | "bid1_volume" | "ask1_volume"
| "minute_volume" | "intraday_volume" | "tick_volume" => {
| "minute_volume" | "intraday_volume" => {
return StockFilterQuoteUsage::IntradayQuote;
}
"at_upper_limit" | "at_lower_limit" => {
@@ -6522,7 +6519,6 @@ impl PlatformExprStrategy {
| "volume"
| "minute_volume"
| "intraday_volume"
| "tick_volume"
| "bid1_volume"
| "ask1_volume"
| "turnover"
@@ -8279,7 +8275,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.0,
volume: 1_000_000,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: None,
@@ -8302,7 +8298,7 @@ mod tests {
ask1: 1_000.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: None,
@@ -8454,7 +8450,7 @@ mod tests {
ask1: 5.12,
prev_close: 5.00,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 324,
ask1_volume: 1_717,
trading_phase: Some("continuous".to_string()),
@@ -8595,7 +8591,7 @@ mod tests {
ask1: 6.5369,
prev_close: 6.72,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 10_000,
ask1_volume: 10_000,
trading_phase: Some("continuous".to_string()),
@@ -8741,7 +8737,7 @@ mod tests {
ask1: 11.93,
prev_close: 11.40,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -8837,7 +8833,7 @@ mod tests {
ask1: 12.00,
prev_close: 11.40,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -8950,7 +8946,7 @@ mod tests {
ask1: 23.99,
prev_close: 21.81,
volume: 100_161,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9068,7 +9064,7 @@ mod tests {
ask1: 23.99,
prev_close: 21.81,
volume: 100_161,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9182,7 +9178,7 @@ mod tests {
ask1: 23.99,
prev_close: 21.81,
volume: 100_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9205,7 +9201,7 @@ mod tests {
ask1: 23.21,
prev_close: 23.99,
volume: 200_000,
tick_volume: 2_000,
minute_volume: 2_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9442,7 +9438,7 @@ mod tests {
ask1: 14.51,
prev_close: 13.30,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9465,7 +9461,7 @@ mod tests {
ask1: 8.02,
prev_close: 7.95,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9488,7 +9484,7 @@ mod tests {
ask1: 2905.1,
prev_close: 2898.0,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9733,7 +9729,7 @@ mod tests {
ask1: 14.63,
prev_close: 13.30,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9756,7 +9752,7 @@ mod tests {
ask1: 8.02,
prev_close: 7.95,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9779,7 +9775,7 @@ mod tests {
ask1: 2905.1,
prev_close: 2898.0,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -9987,7 +9983,7 @@ mod tests {
ask1: 47.42,
prev_close: 47.04,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10010,7 +10006,7 @@ mod tests {
ask1: 46.75,
prev_close: 47.41,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10234,7 +10230,7 @@ mod tests {
ask1: 6.06,
prev_close: 5.86,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10352,7 +10348,7 @@ mod tests {
ask1: 9.21,
prev_close: 10.00,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10490,7 +10486,7 @@ mod tests {
ask1: last_price,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10596,7 +10592,7 @@ mod tests {
ask1: 15.05,
prev_close: 14.53,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10694,7 +10690,7 @@ mod tests {
ask1: 9.9,
prev_close: 9.7,
volume: 12_300,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: Some("close".to_string()),
@@ -10717,7 +10713,7 @@ mod tests {
ask1: 19.06,
prev_close: 9.9,
volume: 45_600,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10832,7 +10828,7 @@ mod tests {
ask1: 12.0,
prev_close: 10.0,
volume: 120_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -10956,7 +10952,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 120_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -11067,7 +11063,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -11198,7 +11194,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -11316,7 +11312,7 @@ mod tests {
ask1: 10.81,
prev_close: 10.5,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -11430,7 +11426,7 @@ mod tests {
ask1: 0.0,
prev_close: 10.4,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -11543,7 +11539,7 @@ mod tests {
ask1: 10.51,
prev_close: 10.4,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -11680,7 +11676,7 @@ mod tests {
ask1: 10.01,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -11842,7 +11838,7 @@ mod tests {
ask1: 11.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 10_000,
ask1_volume: 10_000,
trading_phase: Some("continuous".to_string()),
@@ -11998,7 +11994,7 @@ mod tests {
ask1: 11.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 10_000,
ask1_volume: 10_000,
trading_phase: Some("continuous".to_string()),
@@ -12154,7 +12150,7 @@ mod tests {
ask1: 10.8,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 10_000,
ask1_volume: 10_000,
trading_phase: Some("continuous".to_string()),
@@ -12314,7 +12310,7 @@ mod tests {
ask1: 10.01,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -12473,7 +12469,7 @@ mod tests {
ask1: 10.81,
prev_close: 10.5,
volume: 200_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -12627,7 +12623,7 @@ mod tests {
ask1: 6.5369,
prev_close: 6.72,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 10_000,
ask1_volume: 10_000,
trading_phase: Some("continuous".to_string()),
@@ -12739,7 +12735,7 @@ mod tests {
}
#[test]
fn platform_aiquant_stock_expr_uses_scheduled_tick_price_for_limit_check() {
fn platform_aiquant_stock_expr_uses_scheduled_minute_price_for_limit_check() {
let date = d(2024, 1, 30);
let symbol = "002087.SZ";
let data = DataSet::from_components_with_actions_and_quotes(
@@ -12766,7 +12762,7 @@ mod tests {
ask1: 1.36,
prev_close: 1.42,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 7_000,
ask1_volume: 4_000,
trading_phase: Some("continuous".to_string()),
@@ -12886,7 +12882,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -13036,7 +13032,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -13133,7 +13129,7 @@ mod tests {
ask1: 5.83,
prev_close: 5.85,
volume: 1_000_000,
tick_volume: 262,
minute_volume: 262,
bid1_volume: 54,
ask1_volume: 143,
trading_phase: Some("continuous".to_string()),
@@ -13259,7 +13255,7 @@ mod tests {
ask1: last_price,
prev_close: last_price,
volume: 1_000_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 10_000,
ask1_volume: 10_000,
trading_phase: Some("continuous".to_string()),
@@ -13547,7 +13543,7 @@ mod tests {
ask1: 19.06,
prev_close: 21.17,
volume: 16_173,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -13646,7 +13642,7 @@ mod tests {
ask1: 3.63,
prev_close: 3.49,
volume: 10_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -13761,7 +13757,7 @@ mod tests {
ask1: 20.01,
prev_close: 19.8,
volume: 10_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -13863,7 +13859,7 @@ mod tests {
ask1: 8.0,
prev_close: 8.0,
volume: 0,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: Some("suspended".to_string()),
@@ -14045,7 +14041,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -14218,7 +14214,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -14241,7 +14237,7 @@ mod tests {
ask1: 4000.2,
prev_close: 3995.0,
volume: 100_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 100,
ask1_volume: 100,
trading_phase: Some("continuous".to_string()),
@@ -14423,7 +14419,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -14565,7 +14561,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -14687,7 +14683,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -14710,7 +14706,7 @@ mod tests {
ask1: 100.01,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -14865,7 +14861,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -15004,7 +15000,7 @@ mod tests {
ask1: 10.2 + index as f64,
prev_close: 10.0 + index as f64,
volume: 100 + index as u64 * 100,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: None,
@@ -15148,7 +15144,7 @@ mod tests {
ask1: 10.0 + index as f64,
prev_close: if index == 0 { 9.8 } else { 9.0 + index as f64 },
volume: 1000 + index as u64 * 100,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: None,
@@ -15295,7 +15291,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -15430,7 +15426,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -15563,7 +15559,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -15723,7 +15719,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -15856,7 +15852,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -16015,7 +16011,7 @@ mod tests {
ask1: 10.01,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -16175,7 +16171,7 @@ mod tests {
ask1: 10.01,
prev_close: 11.11,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -16324,7 +16320,7 @@ mod tests {
ask1: 9.51,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -16492,7 +16488,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -16730,7 +16726,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -16896,7 +16892,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -17038,7 +17034,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -17219,7 +17215,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -17395,7 +17391,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -17619,7 +17615,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -17769,7 +17765,7 @@ mod tests {
ask1: 10.0,
prev_close: 10.0,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -17920,7 +17916,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -18161,7 +18157,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -18347,7 +18343,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -18499,7 +18495,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -18638,7 +18634,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -18768,7 +18764,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -18903,7 +18899,7 @@ mod tests {
ask1: 0.0,
prev_close: 17.11,
volume: 0,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: Some("paused".to_string()),
@@ -19005,7 +19001,7 @@ mod tests {
ask1: 0.0,
prev_close: 7.63,
volume: 1_000_000,
tick_volume: 0,
minute_volume: 0,
bid1_volume: 0,
ask1_volume: 0,
trading_phase: Some("continuous".to_string()),
@@ -19119,7 +19115,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -19291,7 +19287,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.9,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -19478,7 +19474,7 @@ mod tests {
ask1: 10.01,
prev_close: 10.0,
volume: 1_000,
tick_volume: 1_000,
minute_volume: 1_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: None,
@@ -19613,7 +19609,7 @@ mod tests {
ask1: 10.22,
prev_close: 9.9,
volume: 100_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 2_500,
ask1_volume: 2_500,
trading_phase: Some("continuous".to_string()),
@@ -19733,7 +19729,7 @@ mod tests {
ask1: 10.22,
prev_close: 9.9,
volume: 100_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 2_500,
ask1_volume: 2_500,
trading_phase: Some("continuous".to_string()),
@@ -19877,7 +19873,7 @@ mod tests {
ask1: 1001.5,
prev_close: 999.0,
volume: 100_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 2_500,
ask1_volume: 2_500,
trading_phase: Some("continuous".to_string()),
@@ -19984,7 +19980,7 @@ mod tests {
ask1: 1001.5,
prev_close: 999.0,
volume: 100_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 2_500,
ask1_volume: 2_500,
trading_phase: Some("continuous".to_string()),
@@ -20086,7 +20082,7 @@ mod tests {
ask1: 1001.5,
prev_close: 999.0,
volume: 100_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 2_500,
ask1_volume: 2_500,
trading_phase: Some("continuous".to_string()),
@@ -20187,7 +20183,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("open_auction".to_string()),
@@ -20311,7 +20307,7 @@ mod tests {
ask1: 10.0,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("open_auction".to_string()),
@@ -20426,7 +20422,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -20549,7 +20545,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -20690,7 +20686,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -20818,7 +20814,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -20941,7 +20937,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -21058,7 +21054,7 @@ mod tests {
ask1: 10.05,
prev_close: 9.95,
volume: 1_000_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -21191,7 +21187,7 @@ mod tests {
ask1: 10.05 + index as f64,
prev_close: 9.95 + index as f64,
volume: 1_000_000 + index as u64 * 100_000,
tick_volume: 5_000,
minute_volume: 5_000,
bid1_volume: 1_000,
ask1_volume: 1_000,
trading_phase: Some("continuous".to_string()),
@@ -21348,7 +21344,7 @@ mod tests {
}
#[test]
fn selection_quote_plan_filters_daily_part_before_tick_candidates() {
fn selection_quote_plan_filters_daily_part_before_minute_candidates() {
let date = d(2025, 1, 3);
let symbols = ["000001.SZ", "000002.SZ", "000003.SZ", "000004.SZ"];
let data = DataSet::from_components(
@@ -21396,7 +21392,7 @@ mod tests {
},
prev_close: reference_price,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 2_000,
ask1_volume: 2_000,
trading_phase: Some("continuous".to_string()),
@@ -135,7 +135,7 @@ const RESERVED_SCOPE_NAMES: &[&str] = &[
"free_float_cap",
"pe_ttm",
"volume",
"tick_volume",
"minute_volume",
"bid1_volume",
"ask1_volume",
"turnover_ratio",
+20 -54
View File
@@ -43,8 +43,6 @@ pub struct StrategyRuntimeSpec {
pub struct StrategyBenchmarkSpec {
#[serde(default)]
pub instrument_id: Option<String>,
#[serde(default)]
pub fallback_instrument_id: Option<String>,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
@@ -64,8 +62,6 @@ pub struct StrategyRebalanceSpec {
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StrategyExecutionSpec {
#[serde(default)]
pub compatibility_profile: Option<String>,
#[serde(default)]
pub matching_type: Option<String>,
#[serde(default)]
@@ -96,8 +92,6 @@ pub struct StrategyEngineConfig {
#[serde(default)]
pub template_id: Option<String>,
#[serde(default)]
pub compatibility_profile: Option<String>,
#[serde(default)]
pub profile_name: Option<String>,
#[serde(default)]
pub benchmark_symbol: Option<String>,
@@ -393,10 +387,10 @@ fn valid_non_negative(value: Option<f64>) -> Option<f64> {
value.filter(|item| item.is_finite() && *item >= 0.0)
}
fn is_aiquant_compatibility_profile(value: Option<&str>) -> bool {
fn is_aiquant_profile(value: Option<&str>) -> bool {
value
.map(|item| item.trim().to_ascii_lowercase().replace('-', "_"))
.is_some_and(|item| item == "aiquant_rqalpha" || item == "aiquant")
.is_some_and(|item| item == "aiquant")
}
fn apply_cost_overrides(
@@ -789,14 +783,6 @@ pub fn platform_expr_config_from_spec(
{
cfg.signal_symbol = spec_signal_symbol.clone();
}
if cfg.signal_symbol.trim().is_empty()
&& let Some(spec_signal_symbol) = benchmark
.fallback_instrument_id
.as_ref()
.filter(|value| !value.trim().is_empty())
{
cfg.signal_symbol = spec_signal_symbol.clone();
}
}
if let Some(universe) = spec.universe.as_ref() {
cfg.universe_exclude = universe
@@ -1111,20 +1097,12 @@ pub fn platform_expr_config_from_spec(
if !cfg.benchmark_symbol.trim().is_empty() {
cfg.benchmark_symbol = normalize_symbol(&cfg.benchmark_symbol, None);
}
let aiquant_compat = is_aiquant_compatibility_profile(
spec.execution
.as_ref()
.and_then(|execution| execution.compatibility_profile.as_deref()),
) || is_aiquant_compatibility_profile(
spec.engine_config
.as_ref()
.and_then(|engine| engine.compatibility_profile.as_deref()),
) || is_aiquant_compatibility_profile(
let aiquant_profile = is_aiquant_profile(
spec.engine_config
.as_ref()
.and_then(|engine| engine.profile_name.as_deref()),
);
if aiquant_compat {
if aiquant_profile {
cfg.aiquant_transaction_cost = true;
let trading = spec
.runtime_expressions
@@ -1150,7 +1128,7 @@ pub fn platform_expr_config_from_spec(
.and_then(|runtime_expr| runtime_expr.trading.as_ref())
.and_then(|trading| trading.delayed_limit_open_exit)
.is_some();
if aiquant_compat && !delayed_limit_open_exit_explicit && trade_times.len() > 1 {
if aiquant_profile && !delayed_limit_open_exit_explicit && trade_times.len() > 1 {
let delayed_time = trade_times[0];
if trade_times
.last()
@@ -1588,7 +1566,7 @@ mod tests {
"signalSymbol": "000852.SH",
"benchmark": { "instrumentId": "000852.SH" },
"universe": { "exclude": ["paused", "st", "kcb", "one_yuan"] },
"execution": { "compatibilityProfile": "aiquant_rqalpha" },
"engineConfig": { "profileName": "aiquant" },
"runtimeExpressions": {
"prelude": "let stocknum = 8;",
"selection": {
@@ -1653,13 +1631,13 @@ mod tests {
fn parses_execution_cost_overrides_into_platform_config() {
let spec = serde_json::json!({
"execution": {
"compatibilityProfile": "aiquant_rqalpha",
"commissionRate": 0.0003,
"minimumCommission": 5.0,
"stampTaxRateBeforeChange": 0.0005,
"stampTaxRateAfterChange": 0.0005
},
"engineConfig": {
"profileName": "aiquant",
"commissionRate": 0.0008
}
});
@@ -1677,13 +1655,13 @@ mod tests {
fn parses_execution_slippage_overrides_into_platform_config() {
let spec = serde_json::json!({
"execution": {
"compatibilityProfile": "aiquant_rqalpha",
"matchingType": "next_minute_last",
"slippageModel": "price_ratio",
"slippageValue": 0.001,
"strictValueBudget": true
},
"engineConfig": {
"profileName": "aiquant",
"matchingType": "current_bar_close",
"slippageModel": "none",
"slippageValue": 0.0,
@@ -1744,8 +1722,8 @@ mod tests {
#[test]
fn aiquant_profile_defaults_to_daily_top_up_and_empty_retry() {
let spec = serde_json::json!({
"execution": {
"compatibilityProfile": "aiquant_rqalpha"
"engineConfig": {
"profileName": "aiquant"
}
});
@@ -1756,8 +1734,8 @@ mod tests {
assert!(cfg.retry_empty_rebalance);
let explicit_off = serde_json::json!({
"execution": {
"compatibilityProfile": "aiquant_rqalpha"
"engineConfig": {
"profileName": "aiquant"
},
"runtimeExpressions": {
"trading": {
@@ -1774,22 +1752,10 @@ mod tests {
}
#[test]
fn engine_config_aiquant_profile_enables_aiquant_semantics() {
fn engine_config_profile_name_enables_aiquant_semantics() {
let spec = serde_json::json!({
"engineConfig": {
"compatibilityProfile": "aiquant_rqalpha"
}
});
let cfg = platform_expr_config_from_value("", "", &spec).expect("config");
assert!(cfg.aiquant_transaction_cost);
assert!(cfg.daily_top_up_enabled);
assert!(cfg.retry_empty_rebalance);
let spec = serde_json::json!({
"engineConfig": {
"profileName": "aiquant-rqalpha"
"profileName": "aiquant"
}
});
@@ -1801,8 +1767,8 @@ mod tests {
#[test]
fn runtime_expressions_infer_ma_windows_from_literal_strategy_logic() {
let spec = serde_json::json!({
"execution": {
"compatibilityProfile": "aiquant_rqalpha"
"engineConfig": {
"profileName": "aiquant"
},
"runtimeExpressions": {
"selection": {
@@ -1856,7 +1822,7 @@ mod tests {
#[test]
fn parses_daily_schedule_time_for_aiquant_execution_quotes() {
let spec = serde_json::json!({
"execution": { "compatibilityProfile": "aiquant_rqalpha" },
"engineConfig": { "profileName": "aiquant" },
"runtimeExpressions": {
"schedule": { "frequency": "daily", "time": "09:33" }
}
@@ -1876,7 +1842,7 @@ mod tests {
#[test]
fn parses_aiquant_rebalance_trade_times_for_delayed_limit_exit() {
let spec = serde_json::json!({
"execution": { "compatibilityProfile": "aiquant_rqalpha" },
"engineConfig": { "profileName": "aiquant" },
"rebalance": { "tradeTimes": ["10:31", "10:40"] },
"runtimeExpressions": {
"schedule": { "frequency": "daily", "time": "10:40" }
@@ -1899,7 +1865,7 @@ mod tests {
#[test]
fn parses_explicit_delayed_limit_open_exit() {
let spec = serde_json::json!({
"execution": { "compatibilityProfile": "aiquant_rqalpha" },
"engineConfig": { "profileName": "aiquant" },
"runtimeExpressions": {
"schedule": { "frequency": "daily", "time": "10:40" },
"trading": {
@@ -1925,7 +1891,7 @@ mod tests {
#[test]
fn explicit_delayed_limit_open_exit_false_overrides_aiquant_trade_times() {
let spec = serde_json::json!({
"execution": { "compatibilityProfile": "aiquant_rqalpha" },
"engineConfig": { "profileName": "aiquant" },
"rebalance": { "tradeTimes": ["10:31", "10:40"] },
"runtimeExpressions": {
"schedule": { "frequency": "daily", "time": "10:40" },
+7 -7
View File
@@ -981,7 +981,7 @@ mod tests {
}
#[test]
fn cash_dividend_can_preserve_avg_cost_for_aiquant_compatibility() {
fn cash_dividend_can_preserve_avg_cost_for_aiquant_rules() {
let date = NaiveDate::from_ymd_opt(2025, 1, 2).unwrap();
let mut position = Position::new("603102.SH");
position.buy(date, 1000, 46.45);
@@ -1033,7 +1033,7 @@ mod tests {
ask1: 10.01,
prev_close: 9.8,
volume: 1000,
tick_volume: 1000,
minute_volume: 1000,
bid1_volume: 1000,
ask1_volume: 1000,
trading_phase: None,
@@ -1056,7 +1056,7 @@ mod tests {
ask1: 10.51,
prev_close: 10.0,
volume: 1000,
tick_volume: 1000,
minute_volume: 1000,
bid1_volume: 1000,
ask1_volume: 1000,
trading_phase: None,
@@ -1144,7 +1144,7 @@ mod tests {
ask1: 10.51,
prev_close: 10.0,
volume: 1000,
tick_volume: 1000,
minute_volume: 1000,
bid1_volume: 1000,
ask1_volume: 1000,
trading_phase: None,
@@ -1228,7 +1228,7 @@ mod tests {
ask1: 10.31,
prev_close: 10.0,
volume: 1000,
tick_volume: 1000,
minute_volume: 1000,
bid1_volume: 1000,
ask1_volume: 1000,
trading_phase: None,
@@ -1297,7 +1297,7 @@ mod tests {
ask1: 3.02,
prev_close: 2.98,
volume: 152_975,
tick_volume: 152_975,
minute_volume: 152_975,
bid1_volume: 338,
ask1_volume: 2476,
trading_phase: None,
@@ -1320,7 +1320,7 @@ mod tests {
ask1: 3.07,
prev_close: 3.06,
volume: 160_000,
tick_volume: 160_000,
minute_volume: 160_000,
bid1_volume: 1000,
ask1_volume: 1000,
trading_phase: None,
+1 -1
View File
@@ -174,7 +174,7 @@ mod tests {
ask1: last_price,
prev_close: 6.25,
volume: 1_000_000,
tick_volume: 10_000,
minute_volume: 10_000,
bid1_volume: 10_000,
ask1_volume: 10_000,
trading_phase: Some("continuous".to_string()),
+2 -2
View File
@@ -1969,7 +1969,7 @@ impl OmniMicroCapStrategy {
return Some(0);
}
let snapshot = ctx.data.market(date, symbol)?;
if snapshot.tick_volume == 0 {
if snapshot.minute_volume == 0 {
return None;
}
@@ -1991,7 +1991,7 @@ impl OmniMicroCapStrategy {
let consumed_turnover = *execution_state.intraday_turnover.get(symbol).unwrap_or(&0);
let raw_limit =
((snapshot.tick_volume as f64) * 0.25).round() as i64 - consumed_turnover as i64;
((snapshot.minute_volume as f64) * 0.25).round() as i64 - consumed_turnover as i64;
if raw_limit <= 0 {
return None;
}