nautilus_trading/examples/strategies/hurst_vpin_directional/config.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Configuration for the Hurst/VPIN directional strategy.
17
18use nautilus_model::{
19 data::BarType,
20 identifiers::{InstrumentId, StrategyId},
21 types::Quantity,
22};
23
24use crate::strategy::StrategyConfig;
25
26/// Configuration for the Hurst/VPIN directional strategy.
27///
28/// Combines a rescaled-range Hurst regime filter on dollar bars with a
29/// VPIN-derived informed-flow signal, and gates entry timing on the
30/// live quote stream.
31#[derive(Debug, Clone, bon::Builder)]
32#[cfg_attr(
33 feature = "python",
34 pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.trading", from_py_object)
35)]
36#[cfg_attr(
37 feature = "python",
38 pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.trading")
39)]
40pub struct HurstVpinDirectionalConfig {
41 /// Base strategy configuration.
42 #[builder(default = StrategyConfig {
43 strategy_id: Some(StrategyId::from("HURST_VPIN-001")),
44 order_id_tag: Some("001".to_string()),
45 ..Default::default()
46 })]
47 pub base: StrategyConfig,
48 /// Instrument to subscribe to and trade.
49 pub instrument_id: InstrumentId,
50 /// Dollar bar type (value aggregation sourced from trades).
51 pub bar_type: BarType,
52 /// Order quantity for each entry.
53 pub trade_size: Quantity,
54 /// Rolling window of dollar bar returns used to estimate the Hurst exponent.
55 #[builder(default = 128)]
56 pub hurst_window: usize,
57 /// Lag set used for rescaled range regression.
58 #[builder(default = vec![4, 8, 16, 32])]
59 pub hurst_lags: Vec<usize>,
60 /// Hurst threshold for entering a position (trending regime).
61 #[builder(default = 0.55)]
62 pub hurst_enter: f64,
63 /// Hurst threshold for exiting an open position (regime decay).
64 #[builder(default = 0.50)]
65 pub hurst_exit: f64,
66 /// Number of completed volume buckets averaged for VPIN.
67 #[builder(default = 50)]
68 pub vpin_window: usize,
69 /// Minimum VPIN value required to treat a bucket imbalance as informed flow.
70 #[builder(default = 0.30)]
71 pub vpin_threshold: f64,
72 /// Maximum time (seconds) a position is held before forced flatten.
73 #[builder(default = 3600)]
74 pub max_holding_secs: u64,
75}