From f8c83d9caaa0b063d770210120f9a04dcc7e0e0c Mon Sep 17 00:00:00 2001 From: nkaz001 Date: Thu, 27 Jun 2024 11:39:04 -0400 Subject: [PATCH] refactor(rust): refactor. --- rust/examples/gridtrading_backtest.rs | 7 ++----- rust/src/backtest/mod.rs | 14 +++----------- rust/src/backtest/models/queue.rs | 1 - rust/src/backtest/proc/mod.rs | 2 -- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/rust/examples/gridtrading_backtest.rs b/rust/examples/gridtrading_backtest.rs index a3b4dcc..6bb3e68 100644 --- a/rust/examples/gridtrading_backtest.rs +++ b/rust/examples/gridtrading_backtest.rs @@ -1,14 +1,11 @@ -use std::time::Instant; - use algo::gridtrading; use hftbacktest::{ backtest::{ assettype::LinearAsset, - models::{IntpOrderLatency, PowerProbQueueFunc3, ProbQueueModel, QueuePos}, - reader::read_npz, + models::{IntpOrderLatency, PowerProbQueueFunc3, ProbQueueModel}, + reader::{read_npz, DataSource}, recorder::BacktestRecorder, AssetBuilder, - DataSource, ExchangeKind, MultiAssetMultiExchangeBacktest, }, diff --git a/rust/src/backtest/mod.rs b/rust/src/backtest/mod.rs index 26489a4..21d4ae4 100644 --- a/rust/src/backtest/mod.rs +++ b/rust/src/backtest/mod.rs @@ -40,6 +40,8 @@ pub mod recorder; mod evs; +pub use reader::DataSource; + #[cfg(any(feature = "unstable_l3", doc))] mod l3backtest; @@ -62,16 +64,6 @@ pub enum BacktestError { DataError(#[from] IoError), } -/// Data source for the [`reader`]. -#[derive(Clone, Debug)] -pub enum DataSource { - /// Data needs to be loaded from the specified file. It will be loaded when needed and released - /// when no processor is reading the data. - File(String), - /// Data is loaded and set by the user. - Data(Data), -} - /// Backtesting Asset pub struct Asset { local: Box, @@ -145,7 +137,7 @@ where } /// Sets the feed data. Currently, only `DataSource::File` is supported. - pub fn data(mut self, data: Vec) -> Self { + pub fn data(mut self, data: Vec>) -> Self { for item in data { match item { DataSource::File(filename) => { diff --git a/rust/src/backtest/models/queue.rs b/rust/src/backtest/models/queue.rs index 43d0a39..7d57c26 100644 --- a/rust/src/backtest/models/queue.rs +++ b/rust/src/backtest/models/queue.rs @@ -3,7 +3,6 @@ use std::{ collections::{hash_map::Entry, HashMap}, marker::PhantomData, }; -use std::collections::VecDeque; use crate::{ backtest::BacktestError, diff --git a/rust/src/backtest/proc/mod.rs b/rust/src/backtest/proc/mod.rs index b5f86c1..dc10dc6 100644 --- a/rust/src/backtest/proc/mod.rs +++ b/rust/src/backtest/proc/mod.rs @@ -16,9 +16,7 @@ mod l3_nopartialfillexchange; #[cfg(any(feature = "unstable_l3", doc))] pub use l3_local::L3Local; - #[cfg(any(feature = "unstable_l3", doc))] pub use l3_nopartialfillexchange::L3NoPartialFillExchange; - #[cfg(any(feature = "unstable_l3", doc))] pub use proc::GenLocalProcessor;