From bfb44474882053312a4b7750f50da5fe63cb813b Mon Sep 17 00:00:00 2001 From: nkaz001 Date: Sun, 4 Aug 2024 03:40:53 -0400 Subject: [PATCH] refactor: refactor the visibility of the fee models. --- hftbacktest/Cargo.toml | 2 +- hftbacktest/examples/gridtrading_backtest.rs | 3 ++- hftbacktest/examples/gridtrading_backtest_args.rs | 3 ++- hftbacktest/src/backtest/mod.rs | 2 +- hftbacktest/src/backtest/models/mod.rs | 10 +++++++++- hftbacktest/src/backtest/proc/l3_local.rs | 2 +- .../src/backtest/proc/l3_nopartialfillexchange.rs | 2 +- hftbacktest/src/backtest/proc/local.rs | 2 +- hftbacktest/src/backtest/proc/nopartialfillexchange.rs | 2 +- hftbacktest/src/backtest/proc/partialfillexchange.rs | 2 +- hftbacktest/src/backtest/state.rs | 2 +- py-hftbacktest/src/lib.rs | 5 ++++- 12 files changed, 25 insertions(+), 12 deletions(-) diff --git a/hftbacktest/Cargo.toml b/hftbacktest/Cargo.toml index 98fce30..d440dd3 100644 --- a/hftbacktest/Cargo.toml +++ b/hftbacktest/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hftbacktest" -version = "0.3.0" +version = "0.3.1" edition = "2021" authors = ["nkaz001 "] license = "MIT" diff --git a/hftbacktest/examples/gridtrading_backtest.rs b/hftbacktest/examples/gridtrading_backtest.rs index 6d43202..d1886de 100644 --- a/hftbacktest/examples/gridtrading_backtest.rs +++ b/hftbacktest/examples/gridtrading_backtest.rs @@ -4,10 +4,11 @@ use hftbacktest::{ assettype::LinearAsset, data::{read_npz_file, DataSource}, models::{ - fee::{CommonFees, TradingValueFeeModel}, + CommonFees, IntpOrderLatency, PowerProbQueueFunc3, ProbQueueModel, + TradingValueFeeModel, }, recorder::BacktestRecorder, AssetBuilder, diff --git a/hftbacktest/examples/gridtrading_backtest_args.rs b/hftbacktest/examples/gridtrading_backtest_args.rs index 21528d0..9a51da9 100644 --- a/hftbacktest/examples/gridtrading_backtest_args.rs +++ b/hftbacktest/examples/gridtrading_backtest_args.rs @@ -5,10 +5,11 @@ use hftbacktest::{ assettype::LinearAsset, data::read_npz_file, models::{ - fee::{CommonFees, TradingValueFeeModel}, + CommonFees, IntpOrderLatency, PowerProbQueueFunc3, ProbQueueModel, + TradingValueFeeModel, }, recorder::BacktestRecorder, AssetBuilder, diff --git a/hftbacktest/src/backtest/mod.rs b/hftbacktest/src/backtest/mod.rs index 76a0529..98f4854 100644 --- a/hftbacktest/src/backtest/mod.rs +++ b/hftbacktest/src/backtest/mod.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, io::Error as IoError, marker::PhantomData}; pub use data::DataSource; use data::{Cache, Reader}; -use models::fee::FeeModel; +use models::FeeModel; use thiserror::Error; use crate::{ diff --git a/hftbacktest/src/backtest/models/mod.rs b/hftbacktest/src/backtest/models/mod.rs index c9981f4..bbfcddc 100644 --- a/hftbacktest/src/backtest/models/mod.rs +++ b/hftbacktest/src/backtest/models/mod.rs @@ -3,10 +3,18 @@ //! Please find more details in the documents below. //! * [Latency Models](https://hftbacktest.readthedocs.io/en/latest/latency_models.html) //! * [Order Fill](https://hftbacktest.readthedocs.io/en/latest/order_fill.html) -pub mod fee; +mod fee; mod latency; mod queue; +pub use fee::{ + CommonFees, + DirectionalFees, + FeeModel, + FlatPerTradeFeeModel, + TradingQtyFeeModel, + TradingValueFeeModel, +}; pub use latency::{ConstantLatency, IntpOrderLatency, LatencyModel, OrderLatencyRow}; #[cfg(any(feature = "unstable_l3", doc))] pub use queue::{L3FIFOQueueModel, L3OrderId, L3OrderSource, L3QueueModel}; diff --git a/hftbacktest/src/backtest/proc/l3_local.rs b/hftbacktest/src/backtest/proc/l3_local.rs index 8a7c165..4729335 100644 --- a/hftbacktest/src/backtest/proc/l3_local.rs +++ b/hftbacktest/src/backtest/proc/l3_local.rs @@ -7,7 +7,7 @@ use crate::{ backtest::{ assettype::AssetType, data::{Data, Reader}, - models::{fee::FeeModel, LatencyModel}, + models::{FeeModel, LatencyModel}, order::OrderBus, proc::{LocalProcessor, Processor}, state::State, diff --git a/hftbacktest/src/backtest/proc/l3_nopartialfillexchange.rs b/hftbacktest/src/backtest/proc/l3_nopartialfillexchange.rs index ff13eea..d455662 100644 --- a/hftbacktest/src/backtest/proc/l3_nopartialfillexchange.rs +++ b/hftbacktest/src/backtest/proc/l3_nopartialfillexchange.rs @@ -5,7 +5,7 @@ use crate::{ assettype::AssetType, data::{Data, Reader}, models::{ - fee::FeeModel, + FeeModel, L3FIFOQueueModel, L3OrderId, L3OrderSource, diff --git a/hftbacktest/src/backtest/proc/local.rs b/hftbacktest/src/backtest/proc/local.rs index 92bc77a..980c30c 100644 --- a/hftbacktest/src/backtest/proc/local.rs +++ b/hftbacktest/src/backtest/proc/local.rs @@ -7,7 +7,7 @@ use crate::{ backtest::{ assettype::AssetType, data::{Data, Reader}, - models::{fee::FeeModel, LatencyModel}, + models::{FeeModel, LatencyModel}, order::OrderBus, proc::{LocalProcessor, Processor}, state::State, diff --git a/hftbacktest/src/backtest/proc/nopartialfillexchange.rs b/hftbacktest/src/backtest/proc/nopartialfillexchange.rs index a789d34..e54455b 100644 --- a/hftbacktest/src/backtest/proc/nopartialfillexchange.rs +++ b/hftbacktest/src/backtest/proc/nopartialfillexchange.rs @@ -10,7 +10,7 @@ use crate::{ backtest::{ assettype::AssetType, data::{Data, Reader}, - models::{fee::FeeModel, LatencyModel, QueueModel}, + models::{FeeModel, LatencyModel, QueueModel}, order::OrderBus, proc::Processor, state::State, diff --git a/hftbacktest/src/backtest/proc/partialfillexchange.rs b/hftbacktest/src/backtest/proc/partialfillexchange.rs index 4c1e043..6b834c5 100644 --- a/hftbacktest/src/backtest/proc/partialfillexchange.rs +++ b/hftbacktest/src/backtest/proc/partialfillexchange.rs @@ -10,7 +10,7 @@ use crate::{ backtest::{ assettype::AssetType, data::{Data, Reader}, - models::{fee::FeeModel, LatencyModel, QueueModel}, + models::{FeeModel, LatencyModel, QueueModel}, order::OrderBus, proc::Processor, state::State, diff --git a/hftbacktest/src/backtest/state.rs b/hftbacktest/src/backtest/state.rs index 0315e87..cdfa2dd 100644 --- a/hftbacktest/src/backtest/state.rs +++ b/hftbacktest/src/backtest/state.rs @@ -1,5 +1,5 @@ use crate::{ - backtest::{assettype::AssetType, models::fee::FeeModel}, + backtest::{assettype::AssetType, models::FeeModel}, types::{Order, StateValues}, }; diff --git a/py-hftbacktest/src/lib.rs b/py-hftbacktest/src/lib.rs index b0a580e..60f01fc 100644 --- a/py-hftbacktest/src/lib.rs +++ b/py-hftbacktest/src/lib.rs @@ -7,8 +7,9 @@ use hftbacktest::{ assettype::{InverseAsset, LinearAsset}, data::{read_npz_file, Cache, Data, DataPtr, Reader}, models::{ - fee::{CommonFees, FlatPerTradeFeeModel, TradingQtyFeeModel, TradingValueFeeModel}, + CommonFees, ConstantLatency, + FlatPerTradeFeeModel, IntpOrderLatency, LogProbQueueFunc, LogProbQueueFunc2, @@ -18,6 +19,8 @@ use hftbacktest::{ PowerProbQueueFunc3, ProbQueueModel, RiskAdverseQueueModel, + TradingQtyFeeModel, + TradingValueFeeModel, }, order::OrderBus, proc::{Local, LocalProcessor, NoPartialFillExchange, PartialFillExchange, Processor},