复用已预载执行报价

This commit is contained in:
boris
2026-06-21 01:59:51 +08:00
parent d264e39285
commit d0ab59669f
2 changed files with 208 additions and 2 deletions
+25 -2
View File
@@ -1,6 +1,6 @@
use std::collections::{BTreeMap, BTreeSet};
use chrono::{Datelike, NaiveDate, NaiveTime};
use chrono::{Datelike, Duration, NaiveDate, NaiveTime};
use serde::Serialize;
use thiserror::Error;
@@ -561,7 +561,12 @@ where
return false;
}
if start_time.is_some() && end_time.is_none() {
return true;
return !has_execution_quote_near_start_time(
&self.data,
execution_date,
symbol,
start_time.expect("checked start_time"),
);
}
!has_execution_quote_in_window(&self.data, execution_date, symbol, start_time, end_time)
});
@@ -3348,6 +3353,24 @@ fn has_execution_quote_in_window(
})
}
fn has_execution_quote_near_start_time(
data: &DataSet,
date: NaiveDate,
symbol: &str,
start_time: NaiveTime,
) -> bool {
let cursor = date.and_time(start_time);
let Some(latest) = data
.execution_quotes_on(date, symbol)
.iter()
.filter(|quote| quote.timestamp <= cursor)
.max_by_key(|quote| quote.timestamp)
else {
return false;
};
cursor.signed_duration_since(latest.timestamp) <= Duration::seconds(90)
}
fn decision_has_algo_execution(decision: &StrategyDecision) -> bool {
decision.order_intents.iter().any(|intent| {
matches!(