复用已预载执行报价
This commit is contained in:
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user