Skip to content

Commit

Permalink
refactor(rust): refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaz001 committed Jun 27, 2024
1 parent 20a5b5f commit f8c83d9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
7 changes: 2 additions & 5 deletions rust/examples/gridtrading_backtest.rs
Original file line number Diff line number Diff line change
@@ -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,
},
Expand Down
14 changes: 3 additions & 11 deletions rust/src/backtest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub mod recorder;

mod evs;

pub use reader::DataSource;

#[cfg(any(feature = "unstable_l3", doc))]
mod l3backtest;

Expand All @@ -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<Event>),
}

/// Backtesting Asset
pub struct Asset<L: ?Sized, E: ?Sized> {
local: Box<L>,
Expand Down Expand Up @@ -145,7 +137,7 @@ where
}

/// Sets the feed data. Currently, only `DataSource::File` is supported.
pub fn data(mut self, data: Vec<DataSource>) -> Self {
pub fn data(mut self, data: Vec<DataSource<Event>>) -> Self {
for item in data {
match item {
DataSource::File(filename) => {
Expand Down
1 change: 0 additions & 1 deletion rust/src/backtest/models/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{
collections::{hash_map::Entry, HashMap},
marker::PhantomData,
};
use std::collections::VecDeque;

use crate::{
backtest::BacktestError,
Expand Down
2 changes: 0 additions & 2 deletions rust/src/backtest/proc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f8c83d9

Please sign in to comment.