diff --git a/config.default.ini b/config.default.ini index 39b6a748..845ff0d1 100644 --- a/config.default.ini +++ b/config.default.ini @@ -12,23 +12,23 @@ window_size = 2 [position] risk_reward_ratio = 1.618 -trade_duration = 1800 -twap_duration = 60 +trade_duration = 900 +twap_duration = 180 max_order_slice = 13 order_expiration_time = 8 max_order_breach = 3 stop_loss_threshold = 0.5 risk_factor = 0.618 tp_factor = 2.236 -sl_factor = 1.618 -trl_factor = 0.618 +sl_factor = 2.236 +trl_factor = 1.236 depth = 80 [portfolio] -risk_per_trade = 0.0005 +risk_per_trade = 0.005 account_size = 1000 cagr_threshold = 0.01 -sharpe_ratio_threshold = 0.3 +sharpe_ratio_threshold = 0.236 total_trades_threshold = 8 [system] diff --git a/strategy/generator/signal/bb/vwap_bb.py b/strategy/generator/signal/bb/vwap_bb.py index db62aef7..1dfbfbd1 100644 --- a/strategy/generator/signal/bb/vwap_bb.py +++ b/strategy/generator/signal/bb/vwap_bb.py @@ -9,6 +9,6 @@ class VwapBbSignal(Signal): type: SignalType = SignalType.VwapBb period: Parameter = StaticParameter(100.0) - bb_smooth: Parameter = StaticParameter(Smooth.EMA) + bb_smooth: Parameter = StaticParameter(Smooth.SMA) bb_period: Parameter = StaticParameter(50.0) factor: Parameter = StaticParameter(2.0) diff --git a/ta_lib/strategies/signal/src/reversal/dmi_reversal.rs b/ta_lib/strategies/signal/src/reversal/dmi_reversal.rs index 0b7b1b18..5128bd23 100644 --- a/ta_lib/strategies/signal/src/reversal/dmi_reversal.rs +++ b/ta_lib/strategies/signal/src/reversal/dmi_reversal.rs @@ -38,3 +38,85 @@ impl Signal for DmiReversalSignal { ) } } + +#[cfg(test)] +mod tests { + use super::*; + use core::prelude::*; + use std::collections::VecDeque; + + #[test] + fn test_signal_dmi_reversal() { + let signal = DmiReversalSignal::new(Smooth::SMMA, 3.0, 3.0); + let data = VecDeque::from([ + OHLCV { + open: 0.010631, + high: 0.010655, + low: 0.010612, + close: 0.010651, + volume: 100.0, + }, + OHLCV { + open: 0.010651, + high: 0.010671, + low: 0.010596, + close: 0.010665, + volume: 100.0, + }, + OHLCV { + open: 0.010665, + high: 0.010720, + low: 0.010661, + close: 0.010693, + volume: 100.0, + }, + OHLCV { + open: 0.010693, + high: 0.010711, + low: 0.010651, + close: 0.010698, + volume: 100.0, + }, + OHLCV { + open: 0.010698, + high: 0.010761, + low: 0.010675, + close: 0.010688, + volume: 100.0, + }, + OHLCV { + open: 0.010688, + high: 0.010688, + low: 0.010614, + close: 0.010625, + volume: 100.0, + }, + OHLCV { + open: 0.010625, + high: 0.010629, + low: 0.010533, + close: 0.010548, + volume: 100.0, + }, + OHLCV { + open: 0.010548, + high: 0.010563, + low: 0.010501, + close: 0.010515, + volume: 100.0, + }, + ]); + let series = OHLCVSeries::from_data(&data); + + let (dip, dim) = signal.generate(&series); + + let expected_long_signal = vec![false, false, false, false, false, false, false, false]; + let expected_short_signal = vec![false, false, false, false, false, true, false, false]; + + let result_long_signal: Vec = dip.into(); + let result_short_signal: Vec = dim.into(); + + assert_eq!(result_long_signal, expected_long_signal); + assert_eq!(result_short_signal, expected_short_signal); + } +}