修复涨停持仓普通调仓提前卖出
This commit is contained in:
@@ -2319,27 +2319,6 @@ impl PlatformExprStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mark_highlimit_for_delayed_exit_at_time(
|
|
||||||
&mut self,
|
|
||||||
ctx: &StrategyContext<'_>,
|
|
||||||
date: NaiveDate,
|
|
||||||
symbol: &str,
|
|
||||||
execution_time: NaiveTime,
|
|
||||||
) -> Result<(), BacktestError> {
|
|
||||||
if !self.config.delayed_limit_open_exit_enabled
|
|
||||||
|| self.pending_highlimit_holdings.contains(symbol)
|
|
||||||
{
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
if matches!(
|
|
||||||
self.stock_is_at_upper_limit_at_time(ctx, date, symbol, execution_time)?,
|
|
||||||
Some(true)
|
|
||||||
) {
|
|
||||||
self.pending_highlimit_holdings.insert(symbol.to_string());
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn stock_state_with_factor_date_and_time(
|
fn stock_state_with_factor_date_and_time(
|
||||||
&self,
|
&self,
|
||||||
ctx: &StrategyContext<'_>,
|
ctx: &StrategyContext<'_>,
|
||||||
@@ -7484,12 +7463,14 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
if position.quantity == 0 || delayed_sold_symbols.contains(&position.symbol) {
|
if position.quantity == 0 || delayed_sold_symbols.contains(&position.symbol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
self.mark_highlimit_for_delayed_exit_at_time(
|
if self.regular_sell_should_wait_due_to_highlimit(
|
||||||
ctx,
|
ctx,
|
||||||
execution_date,
|
execution_date,
|
||||||
&position.symbol,
|
&position.symbol,
|
||||||
self.intraday_execution_start_time(),
|
self.intraday_execution_start_time(),
|
||||||
)?;
|
)? {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if pending_full_close_symbols.contains(&position.symbol) {
|
if pending_full_close_symbols.contains(&position.symbol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -7768,6 +7749,14 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
if stock_list.iter().any(|candidate| candidate == symbol) {
|
if stock_list.iter().any(|candidate| candidate == symbol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if self.regular_sell_should_wait_due_to_highlimit(
|
||||||
|
ctx,
|
||||||
|
execution_date,
|
||||||
|
symbol,
|
||||||
|
self.intraday_execution_start_time(),
|
||||||
|
)? {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if !self.can_sell_position(ctx, execution_date, symbol) {
|
if !self.can_sell_position(ctx, execution_date, symbol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -11725,7 +11714,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn platform_aiquant_weak_market_allows_pending_highlimit_partial_target_adjust() {
|
fn platform_aiquant_weak_market_waits_pending_highlimit_target_adjust() {
|
||||||
let prev_date = d(2023, 5, 4);
|
let prev_date = d(2023, 5, 4);
|
||||||
let date = d(2023, 5, 5);
|
let date = d(2023, 5, 5);
|
||||||
let symbol = "600148.SH";
|
let symbol = "600148.SH";
|
||||||
@@ -11864,7 +11853,7 @@ mod tests {
|
|||||||
let decision = strategy.on_day(&ctx).expect("platform decision");
|
let decision = strategy.on_day(&ctx).expect("platform decision");
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
decision.order_intents.iter().any(|intent| matches!(
|
!decision.order_intents.iter().any(|intent| matches!(
|
||||||
intent,
|
intent,
|
||||||
OrderIntent::Shares {
|
OrderIntent::Shares {
|
||||||
symbol: intent_symbol,
|
symbol: intent_symbol,
|
||||||
@@ -11881,7 +11870,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn platform_aiquant_weak_market_marks_intraday_highlimit_before_target_adjust() {
|
fn platform_aiquant_weak_market_waits_when_intraday_highlimit_reached() {
|
||||||
let prev_date = d(2023, 5, 4);
|
let prev_date = d(2023, 5, 4);
|
||||||
let date = d(2023, 5, 5);
|
let date = d(2023, 5, 5);
|
||||||
let symbol = "600148.SH";
|
let symbol = "600148.SH";
|
||||||
@@ -12020,7 +12009,7 @@ mod tests {
|
|||||||
let decision = strategy.on_day(&ctx).expect("platform decision");
|
let decision = strategy.on_day(&ctx).expect("platform decision");
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
decision.order_intents.iter().any(|intent| matches!(
|
!decision.order_intents.iter().any(|intent| matches!(
|
||||||
intent,
|
intent,
|
||||||
OrderIntent::Shares {
|
OrderIntent::Shares {
|
||||||
symbol: intent_symbol,
|
symbol: intent_symbol,
|
||||||
|
|||||||
Reference in New Issue
Block a user