完善平台策略回测撮合和滑点

This commit is contained in:
boris
2026-05-28 08:59:14 +08:00
parent 3499d4aa74
commit 200d5d1f41
8 changed files with 786 additions and 92 deletions
+28 -1
View File
@@ -1,4 +1,4 @@
use std::collections::{BTreeMap, HashMap};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::fs;
use std::path::Path;
@@ -1179,6 +1179,33 @@ impl DataSet {
.unwrap_or(&[])
}
pub fn execution_quote_key_set(&self) -> HashSet<(NaiveDate, String)> {
self.execution_quotes_index.keys().cloned().collect()
}
pub fn add_execution_quotes(&mut self, quotes: Vec<IntradayExecutionQuote>) -> usize {
let mut added = 0usize;
let mut touched = HashSet::<(NaiveDate, String)>::new();
for quote in quotes {
let key = (quote.date, quote.symbol.clone());
let rows = self.execution_quotes_index.entry(key.clone()).or_default();
if rows.iter().any(|existing| {
existing.timestamp == quote.timestamp && existing.symbol == quote.symbol
}) {
continue;
}
rows.push(quote);
touched.insert(key);
added += 1;
}
for key in touched {
if let Some(rows) = self.execution_quotes_index.get_mut(&key) {
rows.sort_by_key(|quote| quote.timestamp);
}
}
added
}
pub fn order_book_depth_on(
&self,
date: NaiveDate,