Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 203e17ce87 | |||
| 32a417d6d1 |
@@ -400,6 +400,8 @@ struct DayExpressionState {
|
|||||||
benchmark_ma10: f64,
|
benchmark_ma10: f64,
|
||||||
benchmark_ma20: f64,
|
benchmark_ma20: f64,
|
||||||
benchmark_ma30: f64,
|
benchmark_ma30: f64,
|
||||||
|
signal_ma_short: f64,
|
||||||
|
signal_ma_long: f64,
|
||||||
signal_ma5: f64,
|
signal_ma5: f64,
|
||||||
signal_ma10: f64,
|
signal_ma10: f64,
|
||||||
signal_ma20: f64,
|
signal_ma20: f64,
|
||||||
@@ -890,6 +892,8 @@ impl PlatformExprStrategy {
|
|||||||
| "signal_ma10"
|
| "signal_ma10"
|
||||||
| "signal_ma20"
|
| "signal_ma20"
|
||||||
| "signal_ma30"
|
| "signal_ma30"
|
||||||
|
| "signal_ma_short"
|
||||||
|
| "signal_ma_long"
|
||||||
| "benchmark_ma5"
|
| "benchmark_ma5"
|
||||||
| "benchmark_ma10"
|
| "benchmark_ma10"
|
||||||
| "benchmark_ma20"
|
| "benchmark_ma20"
|
||||||
@@ -2672,6 +2676,14 @@ impl PlatformExprStrategy {
|
|||||||
.data
|
.data
|
||||||
.market_decision_close_moving_average(date, &self.config.signal_symbol, 5)
|
.market_decision_close_moving_average(date, &self.config.signal_symbol, 5)
|
||||||
.unwrap_or(benchmark_ma5);
|
.unwrap_or(benchmark_ma5);
|
||||||
|
let signal_ma_short = ctx
|
||||||
|
.data
|
||||||
|
.market_decision_close_moving_average(
|
||||||
|
date,
|
||||||
|
&self.config.signal_symbol,
|
||||||
|
self.config.benchmark_short_ma_days,
|
||||||
|
)
|
||||||
|
.unwrap_or(signal_ma5);
|
||||||
let signal_ma10 = ctx
|
let signal_ma10 = ctx
|
||||||
.data
|
.data
|
||||||
.market_decision_close_moving_average(date, &self.config.signal_symbol, 10)
|
.market_decision_close_moving_average(date, &self.config.signal_symbol, 10)
|
||||||
@@ -2684,6 +2696,14 @@ impl PlatformExprStrategy {
|
|||||||
.data
|
.data
|
||||||
.market_decision_close_moving_average(date, &self.config.signal_symbol, 30)
|
.market_decision_close_moving_average(date, &self.config.signal_symbol, 30)
|
||||||
.unwrap_or(benchmark_ma30);
|
.unwrap_or(benchmark_ma30);
|
||||||
|
let signal_ma_long = ctx
|
||||||
|
.data
|
||||||
|
.market_decision_close_moving_average(
|
||||||
|
date,
|
||||||
|
&self.config.signal_symbol,
|
||||||
|
self.config.benchmark_long_ma_days,
|
||||||
|
)
|
||||||
|
.unwrap_or(signal_ma30);
|
||||||
let account = ctx.account();
|
let account = ctx.account();
|
||||||
let cash = account.cash;
|
let cash = account.cash;
|
||||||
let market_value = account.market_value;
|
let market_value = account.market_value;
|
||||||
@@ -2708,6 +2728,8 @@ impl PlatformExprStrategy {
|
|||||||
benchmark_ma10,
|
benchmark_ma10,
|
||||||
benchmark_ma20,
|
benchmark_ma20,
|
||||||
benchmark_ma30,
|
benchmark_ma30,
|
||||||
|
signal_ma_short,
|
||||||
|
signal_ma_long,
|
||||||
signal_ma5,
|
signal_ma5,
|
||||||
signal_ma10,
|
signal_ma10,
|
||||||
signal_ma20,
|
signal_ma20,
|
||||||
@@ -3129,6 +3151,8 @@ impl PlatformExprStrategy {
|
|||||||
scope.push("signal_ma5", day.signal_ma5);
|
scope.push("signal_ma5", day.signal_ma5);
|
||||||
scope.push("signal_ma10", day.signal_ma10);
|
scope.push("signal_ma10", day.signal_ma10);
|
||||||
scope.push("signal_ma20", day.signal_ma20);
|
scope.push("signal_ma20", day.signal_ma20);
|
||||||
|
scope.push("signal_ma_short", day.signal_ma_short);
|
||||||
|
scope.push("signal_ma_long", day.signal_ma_long);
|
||||||
scope.push("benchmark_ma5", day.benchmark_ma5);
|
scope.push("benchmark_ma5", day.benchmark_ma5);
|
||||||
scope.push("benchmark_ma10", day.benchmark_ma10);
|
scope.push("benchmark_ma10", day.benchmark_ma10);
|
||||||
scope.push("benchmark_ma20", day.benchmark_ma20);
|
scope.push("benchmark_ma20", day.benchmark_ma20);
|
||||||
@@ -3256,6 +3280,8 @@ impl PlatformExprStrategy {
|
|||||||
day_factors.insert("signal_ma10".into(), Dynamic::from(day.signal_ma10));
|
day_factors.insert("signal_ma10".into(), Dynamic::from(day.signal_ma10));
|
||||||
day_factors.insert("signal_ma20".into(), Dynamic::from(day.signal_ma20));
|
day_factors.insert("signal_ma20".into(), Dynamic::from(day.signal_ma20));
|
||||||
day_factors.insert("signal_ma30".into(), Dynamic::from(day.signal_ma30));
|
day_factors.insert("signal_ma30".into(), Dynamic::from(day.signal_ma30));
|
||||||
|
day_factors.insert("signal_ma_short".into(), Dynamic::from(day.signal_ma_short));
|
||||||
|
day_factors.insert("signal_ma_long".into(), Dynamic::from(day.signal_ma_long));
|
||||||
day_factors.insert("benchmark_ma5".into(), Dynamic::from(day.benchmark_ma5));
|
day_factors.insert("benchmark_ma5".into(), Dynamic::from(day.benchmark_ma5));
|
||||||
day_factors.insert("benchmark_ma10".into(), Dynamic::from(day.benchmark_ma10));
|
day_factors.insert("benchmark_ma10".into(), Dynamic::from(day.benchmark_ma10));
|
||||||
day_factors.insert("benchmark_ma20".into(), Dynamic::from(day.benchmark_ma20));
|
day_factors.insert("benchmark_ma20".into(), Dynamic::from(day.benchmark_ma20));
|
||||||
@@ -8487,6 +8513,7 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
if self.config.aiquant_transaction_cost
|
if self.config.aiquant_transaction_cost
|
||||||
&& self.config.rotation_enabled
|
&& self.config.rotation_enabled
|
||||||
&& trading_ratio > 0.0
|
&& trading_ratio > 0.0
|
||||||
|
&& trading_ratio < 1.0
|
||||||
&& selection_limit > 0
|
&& selection_limit > 0
|
||||||
{
|
{
|
||||||
for position in ctx.portfolio.positions().values() {
|
for position in ctx.portfolio.positions().values() {
|
||||||
@@ -8526,6 +8553,7 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
if self.config.aiquant_transaction_cost
|
if self.config.aiquant_transaction_cost
|
||||||
&& self.config.rotation_enabled
|
&& self.config.rotation_enabled
|
||||||
&& trading_ratio > 0.0
|
&& trading_ratio > 0.0
|
||||||
|
&& trading_ratio < 1.0
|
||||||
&& selection_limit > 0
|
&& selection_limit > 0
|
||||||
&& !ctx.portfolio.positions().is_empty()
|
&& !ctx.portfolio.positions().is_empty()
|
||||||
{
|
{
|
||||||
@@ -9270,8 +9298,8 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
"platform_expr signal={} last={:.2} ma_short={:.2} ma_long={:.2} band={:.2}-{:.2} tr={:.2}",
|
"platform_expr signal={} last={:.2} ma_short={:.2} ma_long={:.2} band={:.2}-{:.2} tr={:.2}",
|
||||||
self.config.signal_symbol,
|
self.config.signal_symbol,
|
||||||
day.signal_close,
|
day.signal_close,
|
||||||
day.benchmark_ma_short,
|
day.signal_ma_short,
|
||||||
day.benchmark_ma_long,
|
day.signal_ma_long,
|
||||||
band_low,
|
band_low,
|
||||||
band_high,
|
band_high,
|
||||||
trading_ratio
|
trading_ratio
|
||||||
@@ -22365,6 +22393,228 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn platform_delayed_open_partial_exit_releases_top_up_slot() {
|
||||||
|
let prev_date = d(2025, 5, 5);
|
||||||
|
let date = d(2025, 5, 6);
|
||||||
|
let delayed_symbol = "000001.SZ";
|
||||||
|
let held_symbol = "000002.SZ";
|
||||||
|
let buy_symbol = "000003.SZ";
|
||||||
|
let symbols = [delayed_symbol, held_symbol, buy_symbol];
|
||||||
|
let data = DataSet::from_components_with_actions_and_quotes(
|
||||||
|
symbols
|
||||||
|
.iter()
|
||||||
|
.map(|symbol| Instrument {
|
||||||
|
symbol: (*symbol).to_string(),
|
||||||
|
name: (*symbol).to_string(),
|
||||||
|
board: "SZ".to_string(),
|
||||||
|
round_lot: 100,
|
||||||
|
listed_at: Some(d(2020, 1, 1)),
|
||||||
|
delisted_at: None,
|
||||||
|
status: "active".to_string(),
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
symbols
|
||||||
|
.iter()
|
||||||
|
.map(|symbol| DailyMarketSnapshot {
|
||||||
|
date,
|
||||||
|
symbol: (*symbol).to_string(),
|
||||||
|
timestamp: Some("2025-05-06 10:18:00".to_string()),
|
||||||
|
day_open: 10.0,
|
||||||
|
open: 10.0,
|
||||||
|
high: 11.0,
|
||||||
|
low: 9.0,
|
||||||
|
close: 10.0,
|
||||||
|
last_price: 10.0,
|
||||||
|
bid1: 10.0,
|
||||||
|
ask1: 10.0,
|
||||||
|
prev_close: 10.0,
|
||||||
|
volume: 1_000_000,
|
||||||
|
minute_volume: 10_000,
|
||||||
|
bid1_volume: 2_000,
|
||||||
|
ask1_volume: 2_000,
|
||||||
|
trading_phase: Some("continuous".to_string()),
|
||||||
|
paused: false,
|
||||||
|
upper_limit: 11.0,
|
||||||
|
lower_limit: 9.0,
|
||||||
|
price_tick: 0.01,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
symbols
|
||||||
|
.iter()
|
||||||
|
.map(|symbol| DailyFactorSnapshot {
|
||||||
|
date,
|
||||||
|
symbol: (*symbol).to_string(),
|
||||||
|
market_cap_bn: if *symbol == buy_symbol {
|
||||||
|
7.0
|
||||||
|
} else if *symbol == delayed_symbol {
|
||||||
|
8.0
|
||||||
|
} else {
|
||||||
|
9.0
|
||||||
|
},
|
||||||
|
free_float_cap_bn: 10.0,
|
||||||
|
pe_ttm: 8.0,
|
||||||
|
turnover_ratio: Some(1.0),
|
||||||
|
effective_turnover_ratio: Some(1.0),
|
||||||
|
extra_factors: BTreeMap::new(),
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
symbols
|
||||||
|
.iter()
|
||||||
|
.map(|symbol| CandidateEligibility {
|
||||||
|
date,
|
||||||
|
symbol: (*symbol).to_string(),
|
||||||
|
is_st: false,
|
||||||
|
is_star_st: false,
|
||||||
|
is_new_listing: false,
|
||||||
|
is_paused: false,
|
||||||
|
allow_buy: true,
|
||||||
|
allow_sell: true,
|
||||||
|
is_kcb: false,
|
||||||
|
is_one_yuan: false,
|
||||||
|
risk_level_code: None,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
vec![BenchmarkSnapshot {
|
||||||
|
date,
|
||||||
|
benchmark: "000852.SH".to_string(),
|
||||||
|
open: 1000.0,
|
||||||
|
close: 1002.0,
|
||||||
|
prev_close: 998.0,
|
||||||
|
volume: 1_000_000,
|
||||||
|
}],
|
||||||
|
Vec::new(),
|
||||||
|
vec![
|
||||||
|
IntradayExecutionQuote {
|
||||||
|
date,
|
||||||
|
symbol: delayed_symbol.to_string(),
|
||||||
|
timestamp: date.and_hms_opt(9, 31, 0).expect("valid timestamp"),
|
||||||
|
last_price: 10.5,
|
||||||
|
bid1: 10.5,
|
||||||
|
ask1: 10.51,
|
||||||
|
bid1_volume: 10_000,
|
||||||
|
ask1_volume: 10_000,
|
||||||
|
volume_delta: 400,
|
||||||
|
amount_delta: 4_200.0,
|
||||||
|
trading_phase: Some("continuous".to_string()),
|
||||||
|
},
|
||||||
|
IntradayExecutionQuote {
|
||||||
|
date,
|
||||||
|
symbol: held_symbol.to_string(),
|
||||||
|
timestamp: date.and_hms_opt(10, 18, 0).expect("valid timestamp"),
|
||||||
|
last_price: 10.0,
|
||||||
|
bid1: 10.0,
|
||||||
|
ask1: 10.01,
|
||||||
|
bid1_volume: 10_000,
|
||||||
|
ask1_volume: 10_000,
|
||||||
|
volume_delta: 10_000,
|
||||||
|
amount_delta: 100_000.0,
|
||||||
|
trading_phase: Some("continuous".to_string()),
|
||||||
|
},
|
||||||
|
IntradayExecutionQuote {
|
||||||
|
date,
|
||||||
|
symbol: buy_symbol.to_string(),
|
||||||
|
timestamp: date.and_hms_opt(10, 18, 0).expect("valid timestamp"),
|
||||||
|
last_price: 10.0,
|
||||||
|
bid1: 10.0,
|
||||||
|
ask1: 10.01,
|
||||||
|
bid1_volume: 10_000,
|
||||||
|
ask1_volume: 10_000,
|
||||||
|
volume_delta: 10_000,
|
||||||
|
amount_delta: 100_000.0,
|
||||||
|
trading_phase: Some("continuous".to_string()),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.expect("dataset");
|
||||||
|
|
||||||
|
let mut portfolio = PortfolioState::new(20_000.0);
|
||||||
|
portfolio
|
||||||
|
.position_mut(delayed_symbol)
|
||||||
|
.buy(prev_date, 1_000, 10.0);
|
||||||
|
portfolio
|
||||||
|
.position_mut(held_symbol)
|
||||||
|
.buy(prev_date, 100, 10.0);
|
||||||
|
let subscriptions = BTreeSet::new();
|
||||||
|
let ctx = StrategyContext {
|
||||||
|
execution_date: date,
|
||||||
|
decision_date: date,
|
||||||
|
decision_index: 20,
|
||||||
|
data: &data,
|
||||||
|
portfolio: &portfolio,
|
||||||
|
futures_account: None,
|
||||||
|
open_orders: &[],
|
||||||
|
dynamic_universe: None,
|
||||||
|
subscriptions: &subscriptions,
|
||||||
|
process_events: &[],
|
||||||
|
active_process_event: None,
|
||||||
|
active_datetime: None,
|
||||||
|
order_events: &[],
|
||||||
|
fills: &[],
|
||||||
|
};
|
||||||
|
let mut cfg = PlatformExprStrategyConfig::microcap_rotation();
|
||||||
|
cfg.signal_symbol = delayed_symbol.to_string();
|
||||||
|
cfg.refresh_rate = 99;
|
||||||
|
cfg.max_positions = 2;
|
||||||
|
cfg.benchmark_short_ma_days = 1;
|
||||||
|
cfg.benchmark_long_ma_days = 1;
|
||||||
|
cfg.market_cap_lower_expr = "0".to_string();
|
||||||
|
cfg.market_cap_upper_expr = "100".to_string();
|
||||||
|
cfg.selection_limit_expr = "2".to_string();
|
||||||
|
cfg.stock_filter_expr = "close > 0".to_string();
|
||||||
|
cfg.exposure_expr = "1.0".to_string();
|
||||||
|
cfg.stop_loss_expr = "false".to_string();
|
||||||
|
cfg.take_profit_expr = "false".to_string();
|
||||||
|
cfg.daily_top_up_enabled = true;
|
||||||
|
cfg.release_slot_on_exit_signal = true;
|
||||||
|
cfg.aiquant_transaction_cost = true;
|
||||||
|
cfg.risk_config.trading_constraints.volume_limit_enabled = true;
|
||||||
|
cfg.risk_config.trading_constraints.volume_percent = 0.25;
|
||||||
|
cfg.risk_config.trading_constraints.liquidity_limit_enabled = false;
|
||||||
|
cfg.intraday_execution_time = Some(NaiveTime::from_hms_opt(10, 18, 0).unwrap());
|
||||||
|
cfg.delayed_limit_open_exit_enabled = true;
|
||||||
|
cfg.delayed_limit_open_exit_time = Some(NaiveTime::from_hms_opt(9, 31, 0).unwrap());
|
||||||
|
let mut strategy = PlatformExprStrategy::new(cfg);
|
||||||
|
strategy.rebalance_day_counter = 2;
|
||||||
|
strategy
|
||||||
|
.pending_highlimit_holdings
|
||||||
|
.insert(delayed_symbol.to_string());
|
||||||
|
|
||||||
|
let decision = strategy.on_day(&ctx).expect("platform decision");
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
decision.order_intents.iter().any(|intent| matches!(
|
||||||
|
intent,
|
||||||
|
OrderIntent::AlgoValue {
|
||||||
|
symbol,
|
||||||
|
reason,
|
||||||
|
start_time,
|
||||||
|
..
|
||||||
|
} if symbol == delayed_symbol
|
||||||
|
&& reason == "delayed_limit_open_sell"
|
||||||
|
&& *start_time == Some(NaiveTime::from_hms_opt(9, 31, 0).unwrap())
|
||||||
|
)),
|
||||||
|
"{:?}",
|
||||||
|
decision.order_intents
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
decision.order_intents.iter().any(|intent| matches!(
|
||||||
|
intent,
|
||||||
|
OrderIntent::Value {
|
||||||
|
symbol,
|
||||||
|
reason,
|
||||||
|
..
|
||||||
|
} if symbol == buy_symbol && reason == "daily_top_up_buy"
|
||||||
|
)),
|
||||||
|
"{:?}",
|
||||||
|
decision.order_intents
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
strategy.pending_highlimit_holdings.contains(delayed_symbol),
|
||||||
|
"partial delayed exit must keep residual pending"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn platform_daily_top_up_releases_unsellable_stop_loss_slot() {
|
fn platform_daily_top_up_releases_unsellable_stop_loss_slot() {
|
||||||
let prev_date = d(2026, 3, 31);
|
let prev_date = d(2026, 3, 31);
|
||||||
|
|||||||
@@ -1219,6 +1219,17 @@ fn stock_volume_ma_expr(days: usize) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn normalize_index_throttle_exposure_expr(expr: &str) -> String {
|
||||||
|
let mut normalized = expr.to_string();
|
||||||
|
for suffix in ["short", "long", "5", "10", "20", "30"] {
|
||||||
|
normalized = normalized.replace(
|
||||||
|
&format!("benchmark_ma{suffix}"),
|
||||||
|
&format!("signal_ma{suffix}"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
normalized
|
||||||
|
}
|
||||||
|
|
||||||
fn infer_expression_windows(
|
fn infer_expression_windows(
|
||||||
cfg: &mut PlatformExprStrategyConfig,
|
cfg: &mut PlatformExprStrategyConfig,
|
||||||
benchmark_short_explicit: bool,
|
benchmark_short_explicit: bool,
|
||||||
@@ -1230,6 +1241,7 @@ fn infer_expression_windows(
|
|||||||
let mut benchmark_days = Vec::new();
|
let mut benchmark_days = Vec::new();
|
||||||
for expr in [&cfg.exposure_expr, &cfg.buy_scale_expr] {
|
for expr in [&cfg.exposure_expr, &cfg.buy_scale_expr] {
|
||||||
benchmark_days.extend(prefixed_ma_lookbacks(expr, "benchmark_ma"));
|
benchmark_days.extend(prefixed_ma_lookbacks(expr, "benchmark_ma"));
|
||||||
|
benchmark_days.extend(prefixed_ma_lookbacks(expr, "signal_ma"));
|
||||||
benchmark_days.extend(rolling_mean_lookbacks(expr, "benchmark_close"));
|
benchmark_days.extend(rolling_mean_lookbacks(expr, "benchmark_close"));
|
||||||
}
|
}
|
||||||
let benchmark_days = sorted_unique_positive(benchmark_days);
|
let benchmark_days = sorted_unique_positive(benchmark_days);
|
||||||
@@ -1539,7 +1551,16 @@ pub fn platform_expr_config_from_spec(
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.filter(|value| !value.trim().is_empty())
|
.filter(|value| !value.trim().is_empty())
|
||||||
{
|
{
|
||||||
cfg.exposure_expr = expr.clone();
|
cfg.exposure_expr = if spec
|
||||||
|
.engine_config
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|engine| engine.index_throttle.as_ref())
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
|
normalize_index_throttle_exposure_expr(expr)
|
||||||
|
} else {
|
||||||
|
expr.clone()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
if let Some(expr) = risk
|
if let Some(expr) = risk
|
||||||
.stop_loss_expr
|
.stop_loss_expr
|
||||||
@@ -1715,7 +1736,7 @@ pub fn platform_expr_config_from_spec(
|
|||||||
let defensive = index_throttle.defensive_exposure.unwrap_or(0.5);
|
let defensive = index_throttle.defensive_exposure.unwrap_or(0.5);
|
||||||
let full = index_throttle.full_exposure.unwrap_or(1.0);
|
let full = index_throttle.full_exposure.unwrap_or(1.0);
|
||||||
cfg.exposure_expr = format!(
|
cfg.exposure_expr = format!(
|
||||||
"benchmark_ma_short < benchmark_ma_long * {} ? {} : {}",
|
"signal_ma_short < signal_ma_long * {} ? {} : {}",
|
||||||
ratio, defensive, full
|
ratio, defensive, full
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2963,6 +2984,40 @@ mod tests {
|
|||||||
assert_eq!(cfg.stock_long_ma_days, 21);
|
assert_eq!(cfg.stock_long_ma_days, 21);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn index_throttle_uses_signal_ma_not_performance_benchmark_ma() {
|
||||||
|
let spec = serde_json::json!({
|
||||||
|
"signalSymbol": "000852.SH",
|
||||||
|
"benchmark": {
|
||||||
|
"instrumentId": "932000.CSI"
|
||||||
|
},
|
||||||
|
"engineConfig": {
|
||||||
|
"profileName": "aiquant",
|
||||||
|
"indexThrottle": {
|
||||||
|
"shortDays": 10,
|
||||||
|
"longDays": 30,
|
||||||
|
"defensiveExposure": 0.5,
|
||||||
|
"fullExposure": 1.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimeExpressions": {
|
||||||
|
"risk": {
|
||||||
|
"exposureExpr": "if benchmark_ma10 > benchmark_ma30 { 1.0 } else { 0.5 }"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let cfg = platform_expr_config_from_value("strategy88", "", &spec).expect("config");
|
||||||
|
|
||||||
|
assert_eq!(cfg.signal_symbol, "000852.SH");
|
||||||
|
assert_eq!(
|
||||||
|
cfg.exposure_expr,
|
||||||
|
"if signal_ma10 > signal_ma30 { 1.0 } else { 0.5 }"
|
||||||
|
);
|
||||||
|
assert_eq!(cfg.benchmark_short_ma_days, 10);
|
||||||
|
assert_eq!(cfg.benchmark_long_ma_days, 30);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parses_daily_schedule_time_for_aiquant_execution_quotes() {
|
fn parses_daily_schedule_time_for_aiquant_execution_quotes() {
|
||||||
let spec = serde_json::json!({
|
let spec = serde_json::json!({
|
||||||
|
|||||||
Reference in New Issue
Block a user