修复ALV日内补仓循环次数
This commit is contained in:
@@ -2241,7 +2241,7 @@ impl PlatformExprStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn try_daily_top_up_once(
|
fn try_daily_top_up_at_position(
|
||||||
&mut self,
|
&mut self,
|
||||||
ctx: &StrategyContext<'_>,
|
ctx: &StrategyContext<'_>,
|
||||||
day: &DayExpressionState,
|
day: &DayExpressionState,
|
||||||
@@ -2274,12 +2274,14 @@ impl PlatformExprStrategy {
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut submitted_any = false;
|
||||||
|
loop {
|
||||||
let mut budget_working_symbols = slot_working_symbols.clone();
|
let mut budget_working_symbols = slot_working_symbols.clone();
|
||||||
budget_working_symbols.extend(same_bar_buy_symbols.iter().cloned());
|
budget_working_symbols.extend(same_bar_buy_symbols.iter().cloned());
|
||||||
if Self::effective_slot_count(&budget_working_symbols, pending_full_close_symbols)
|
if Self::effective_slot_count(&budget_working_symbols, pending_full_close_symbols)
|
||||||
>= selection_limit
|
>= selection_limit
|
||||||
{
|
{
|
||||||
return Ok(false);
|
break;
|
||||||
}
|
}
|
||||||
let value_symbols = budget_working_symbols.clone();
|
let value_symbols = budget_working_symbols.clone();
|
||||||
let active_value = if debug_daily_top_up {
|
let active_value = if debug_daily_top_up {
|
||||||
@@ -2321,9 +2323,11 @@ impl PlatformExprStrategy {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
if slot_buy_cash <= 0.0 || available_buy_cash < slot_buy_cash * 0.5 {
|
if slot_buy_cash <= 0.0 || available_buy_cash < slot_buy_cash * 0.5 {
|
||||||
return Ok(false);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut attempted_any = false;
|
||||||
|
let mut filled_any = false;
|
||||||
for symbol in stock_list {
|
for symbol in stock_list {
|
||||||
if current_position_symbol
|
if current_position_symbol
|
||||||
.map(|current| current == symbol)
|
.map(|current| current == symbol)
|
||||||
@@ -2364,9 +2368,10 @@ impl PlatformExprStrategy {
|
|||||||
)?;
|
)?;
|
||||||
let buy_cash = available_buy_cash * self.buy_scale(ctx, day, &decision_stock)?;
|
let buy_cash = available_buy_cash * self.buy_scale(ctx, day, &decision_stock)?;
|
||||||
if buy_cash <= 0.0 {
|
if buy_cash <= 0.0 {
|
||||||
return Ok(false);
|
return Ok(submitted_any);
|
||||||
}
|
}
|
||||||
intraday_attempted_buys.insert(symbol.clone());
|
intraday_attempted_buys.insert(symbol.clone());
|
||||||
|
attempted_any = true;
|
||||||
let cash_before_buy = projected.cash();
|
let cash_before_buy = projected.cash();
|
||||||
let order_result = self.project_order_value(
|
let order_result = self.project_order_value(
|
||||||
ctx,
|
ctx,
|
||||||
@@ -2399,11 +2404,17 @@ impl PlatformExprStrategy {
|
|||||||
*aiquant_available_cash
|
*aiquant_available_cash
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return Ok(true);
|
submitted_any = true;
|
||||||
|
filled_any = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !attempted_any || !filled_any {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(false)
|
Ok(submitted_any)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn effective_slot_count(
|
fn effective_slot_count(
|
||||||
@@ -8697,7 +8708,7 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
unresolved_stop_loss_symbols.insert(position.symbol.clone());
|
unresolved_stop_loss_symbols.insert(position.symbol.clone());
|
||||||
}
|
}
|
||||||
if daily_top_up_active {
|
if daily_top_up_active {
|
||||||
self.try_daily_top_up_once(
|
self.try_daily_top_up_at_position(
|
||||||
ctx,
|
ctx,
|
||||||
&day,
|
&day,
|
||||||
&stock_list,
|
&stock_list,
|
||||||
@@ -8762,7 +8773,7 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if daily_top_up_active {
|
if daily_top_up_active {
|
||||||
self.try_daily_top_up_once(
|
self.try_daily_top_up_at_position(
|
||||||
ctx,
|
ctx,
|
||||||
&day,
|
&day,
|
||||||
&stock_list,
|
&stock_list,
|
||||||
|
|||||||
Reference in New Issue
Block a user