we ball again
This commit is contained in:
@@ -23,55 +23,61 @@ pub fn get_all_symbols() -> Vec<&'static str> {
|
||||
symbols.extend_from_slice(SP500_ENERGY);
|
||||
symbols
|
||||
}
|
||||
// Strategy Parameters - Further tweaked for better performance
|
||||
pub const RSI_PERIOD: usize = 14; // Standard reliable period
|
||||
pub const RSI_OVERSOLD: f64 = 30.0; // Standard to reduce false entries
|
||||
pub const RSI_OVERBOUGHT: f64 = 70.0; // Standard to reduce false signals
|
||||
pub const RSI_PULLBACK_LOW: f64 = 35.0; // Slight adjustment
|
||||
pub const RSI_PULLBACK_HIGH: f64 = 60.0; // Slight adjustment
|
||||
// Strategy Parameters — Regime-Adaptive Dual Signal
|
||||
// RSI-14 for trend assessment, RSI-2 for mean-reversion entries (Connors)
|
||||
pub const RSI_PERIOD: usize = 14;
|
||||
pub const RSI_SHORT_PERIOD: usize = 2; // Connors RSI-2 for mean reversion
|
||||
pub const RSI_OVERSOLD: f64 = 30.0;
|
||||
pub const RSI_OVERBOUGHT: f64 = 70.0;
|
||||
pub const RSI2_OVERSOLD: f64 = 10.0; // Extreme oversold for mean reversion entries
|
||||
pub const RSI2_OVERBOUGHT: f64 = 90.0; // Extreme overbought for mean reversion exits
|
||||
pub const MACD_FAST: usize = 12;
|
||||
pub const MACD_SLOW: usize = 26;
|
||||
pub const MACD_SIGNAL: usize = 9;
|
||||
pub const MOMENTUM_PERIOD: usize = 63;
|
||||
pub const EMA_SHORT: usize = 9; // Standard short EMA
|
||||
pub const EMA_SHORT: usize = 9;
|
||||
pub const EMA_LONG: usize = 21;
|
||||
pub const EMA_TREND: usize = 50;
|
||||
// ADX - Trend Strength
|
||||
// ADX — Regime Detection
|
||||
// ADX < RANGE_THRESHOLD = ranging (use mean reversion)
|
||||
// ADX > TREND_THRESHOLD = trending (use momentum/pullback)
|
||||
// Between = transition zone (reduce size, be cautious)
|
||||
pub const ADX_PERIOD: usize = 14;
|
||||
pub const ADX_THRESHOLD: f64 = 20.0;
|
||||
pub const ADX_STRONG: f64 = 35.0;
|
||||
pub const ADX_RANGE_THRESHOLD: f64 = 20.0; // Below this = range-bound
|
||||
pub const ADX_TREND_THRESHOLD: f64 = 25.0; // Above this = trending
|
||||
pub const ADX_STRONG: f64 = 40.0; // Strong trend for bonus conviction
|
||||
// Bollinger Bands
|
||||
pub const BB_PERIOD: usize = 20;
|
||||
pub const BB_STD: f64 = 2.0;
|
||||
// ATR for volatility-based stops
|
||||
// ATR
|
||||
pub const ATR_PERIOD: usize = 14;
|
||||
pub const MIN_ATR_PCT: f64 = 0.005;
|
||||
// Volume filter
|
||||
pub const VOLUME_MA_PERIOD: usize = 20;
|
||||
pub const VOLUME_THRESHOLD: f64 = 0.8;
|
||||
// Momentum Ranking
|
||||
pub const TOP_MOMENTUM_COUNT: usize = 8;
|
||||
pub const TOP_MOMENTUM_COUNT: usize = 10; // Wider pool for more opportunities
|
||||
// Risk Management
|
||||
pub const MAX_POSITION_SIZE: f64 = 0.22;
|
||||
pub const MAX_POSITION_SIZE: f64 = 0.25; // Slightly larger for concentrated bets
|
||||
pub const MIN_CASH_RESERVE: f64 = 0.05;
|
||||
pub const STOP_LOSS_PCT: f64 = 0.025;
|
||||
pub const MAX_LOSS_PCT: f64 = 0.04;
|
||||
pub const MAX_LOSS_PCT: f64 = 0.05; // Wider max loss — let mean reversion work
|
||||
pub const TRAILING_STOP_ACTIVATION: f64 = 0.06;
|
||||
pub const TRAILING_STOP_DISTANCE: f64 = 0.04;
|
||||
// ATR-based risk management
|
||||
pub const RISK_PER_TRADE: f64 = 0.008;
|
||||
pub const ATR_STOP_MULTIPLIER: f64 = 2.5;
|
||||
pub const ATR_TRAIL_MULTIPLIER: f64 = 1.5;
|
||||
pub const ATR_TRAIL_ACTIVATION_MULTIPLIER: f64 = 1.5;
|
||||
pub const RISK_PER_TRADE: f64 = 0.012; // More aggressive sizing for higher conviction
|
||||
pub const ATR_STOP_MULTIPLIER: f64 = 3.0; // Wider stops — research shows tighter stops hurt
|
||||
pub const ATR_TRAIL_MULTIPLIER: f64 = 2.0; // Wider trail to let winners run
|
||||
pub const ATR_TRAIL_ACTIVATION_MULTIPLIER: f64 = 2.0; // Activate after 2x ATR gain
|
||||
// Portfolio-level controls
|
||||
pub const MAX_CONCURRENT_POSITIONS: usize = 5;
|
||||
pub const MAX_CONCURRENT_POSITIONS: usize = 7; // More positions for diversification
|
||||
pub const MAX_SECTOR_POSITIONS: usize = 2;
|
||||
pub const MAX_DRAWDOWN_HALT: f64 = 0.10;
|
||||
pub const DRAWDOWN_HALT_BARS: usize = 35;
|
||||
pub const MAX_DRAWDOWN_HALT: f64 = 0.12; // Wider drawdown tolerance
|
||||
pub const DRAWDOWN_HALT_BARS: usize = 20; // Shorter cooldown to get back in
|
||||
// Time-based exit
|
||||
pub const TIME_EXIT_BARS: usize = 30;
|
||||
pub const REENTRY_COOLDOWN_BARS: usize = 7;
|
||||
pub const RAMPUP_PERIOD_BARS: usize = 30;
|
||||
pub const TIME_EXIT_BARS: usize = 40; // Longer patience for mean reversion
|
||||
pub const REENTRY_COOLDOWN_BARS: usize = 5; // Shorter cooldown
|
||||
pub const RAMPUP_PERIOD_BARS: usize = 15; // Faster ramp-up
|
||||
// Backtester slippage
|
||||
pub const SLIPPAGE_BPS: f64 = 10.0;
|
||||
// Trading intervals
|
||||
@@ -110,6 +116,7 @@ pub fn get_sector(symbol: &str) -> &'static str {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct IndicatorParams {
|
||||
pub rsi_period: usize,
|
||||
pub rsi_short_period: usize, // RSI-2 for mean reversion
|
||||
pub macd_fast: usize,
|
||||
pub macd_slow: usize,
|
||||
pub macd_signal: usize,
|
||||
@@ -126,7 +133,8 @@ impl IndicatorParams {
|
||||
/// Create parameters for daily timeframe.
|
||||
pub fn daily() -> Self {
|
||||
Self {
|
||||
rsi_period: 14, // Standard
|
||||
rsi_period: 14,
|
||||
rsi_short_period: 2, // Connors RSI-2
|
||||
macd_fast: 12,
|
||||
macd_slow: 26,
|
||||
macd_signal: 9,
|
||||
@@ -143,8 +151,9 @@ impl IndicatorParams {
|
||||
/// Create parameters for hourly timeframe.
|
||||
pub fn hourly() -> Self {
|
||||
Self {
|
||||
rsi_period: 14, // Standard even for intraday to reduce noise
|
||||
macd_fast: 12, // Standard for balance
|
||||
rsi_period: 14,
|
||||
rsi_short_period: 3, // Slightly longer for hourly noise
|
||||
macd_fast: 12,
|
||||
macd_slow: 26,
|
||||
macd_signal: 9,
|
||||
momentum_period: 63,
|
||||
|
||||
Reference in New Issue
Block a user