Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
m5l14i11 committed Apr 22, 2024
1 parent a38d5f4 commit d3d4318
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 7 deletions.
12 changes: 6 additions & 6 deletions config.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion strategy/generator/signal/bb/vwap_bb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
82 changes: 82 additions & 0 deletions ta_lib/strategies/signal/src/reversal/dmi_reversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> = dip.into();
let result_short_signal: Vec<bool> = dim.into();

assert_eq!(result_long_signal, expected_long_signal);
assert_eq!(result_short_signal, expected_short_signal);
}
}

0 comments on commit d3d4318

Please sign in to comment.