using System; using System.Collections.Generic; namespace NT8.Core.Intelligence { /// /// Volatility classification for current market conditions. /// public enum VolatilityRegime { /// /// Very low volatility, expansion likely. /// Low = 0, /// /// Below normal volatility. /// BelowNormal = 1, /// /// Normal volatility band. /// Normal = 2, /// /// Elevated volatility, caution required. /// Elevated = 3, /// /// High volatility. /// High = 4, /// /// Extreme volatility, defensive posture. /// Extreme = 5 } /// /// Trend classification for current market direction and strength. /// public enum TrendRegime { /// /// Strong uptrend. /// StrongUp = 0, /// /// Weak uptrend. /// WeakUp = 1, /// /// Ranging or neutral market. /// Range = 2, /// /// Weak downtrend. /// WeakDown = 3, /// /// Strong downtrend. /// StrongDown = 4 } /// /// Quality score for observed trend structure. /// public enum TrendQuality { /// /// No reliable trend quality signal. /// Poor = 0, /// /// Trend quality is fair. /// Fair = 1, /// /// Trend quality is good. /// Good = 2, /// /// Trend quality is excellent. /// Excellent = 3 } /// /// Snapshot of current market regime for a symbol. /// public class RegimeState { /// /// Instrument symbol. /// public string Symbol { get; set; } /// /// Current volatility regime. /// public VolatilityRegime VolatilityRegime { get; set; } /// /// Current trend regime. /// public TrendRegime TrendRegime { get; set; } /// /// Volatility score relative to normal baseline. /// public double VolatilityScore { get; set; } /// /// Trend strength from -1.0 (strong down) to +1.0 (strong up). /// public double TrendStrength { get; set; } /// /// Time the regime state was last updated. /// public DateTime LastUpdate { get; set; } /// /// Time spent in the current regime. /// public TimeSpan RegimeDuration { get; set; } /// /// Supporting indicator values for diagnostics. /// public Dictionary Indicators { get; set; } /// /// Creates a new regime state. /// /// Instrument symbol. /// Volatility regime. /// Trend regime. /// Volatility score relative to normal. /// Trend strength in range [-1.0, +1.0]. /// Last update timestamp. /// Current regime duration. /// Supporting indicators map. public RegimeState( string symbol, VolatilityRegime volatilityRegime, TrendRegime trendRegime, double volatilityScore, double trendStrength, DateTime lastUpdate, TimeSpan regimeDuration, Dictionary indicators) { if (string.IsNullOrEmpty(symbol)) throw new ArgumentNullException("symbol"); if (trendStrength < -1.0 || trendStrength > 1.0) throw new ArgumentException("trendStrength must be between -1.0 and 1.0", "trendStrength"); Symbol = symbol; VolatilityRegime = volatilityRegime; TrendRegime = trendRegime; VolatilityScore = volatilityScore; TrendStrength = trendStrength; LastUpdate = lastUpdate; RegimeDuration = regimeDuration; Indicators = indicators ?? new Dictionary(); } } /// /// Represents a transition event between two regime states. /// public class RegimeTransition { /// /// Symbol where transition occurred. /// public string Symbol { get; set; } /// /// Previous volatility regime. /// public VolatilityRegime PreviousVolatilityRegime { get; set; } /// /// New volatility regime. /// public VolatilityRegime CurrentVolatilityRegime { get; set; } /// /// Previous trend regime. /// public TrendRegime PreviousTrendRegime { get; set; } /// /// New trend regime. /// public TrendRegime CurrentTrendRegime { get; set; } /// /// Transition timestamp. /// public DateTime TransitionTime { get; set; } /// /// Optional transition reason. /// public string Reason { get; set; } /// /// Creates a regime transition record. /// /// Instrument symbol. /// Previous volatility regime. /// Current volatility regime. /// Previous trend regime. /// Current trend regime. /// Transition time. /// Transition reason. public RegimeTransition( string symbol, VolatilityRegime previousVolatilityRegime, VolatilityRegime currentVolatilityRegime, TrendRegime previousTrendRegime, TrendRegime currentTrendRegime, DateTime transitionTime, string reason) { if (string.IsNullOrEmpty(symbol)) throw new ArgumentNullException("symbol"); Symbol = symbol; PreviousVolatilityRegime = previousVolatilityRegime; CurrentVolatilityRegime = currentVolatilityRegime; PreviousTrendRegime = previousTrendRegime; CurrentTrendRegime = currentTrendRegime; TransitionTime = transitionTime; Reason = reason ?? string.Empty; } } /// /// Historical regime timeline for one symbol. /// public class RegimeHistory { /// /// Symbol associated with history. /// public string Symbol { get; set; } /// /// Current state snapshot. /// public RegimeState CurrentState { get; set; } /// /// Historical transition events. /// public List Transitions { get; set; } /// /// Creates a regime history model. /// /// Instrument symbol. /// Current regime state. /// Transition timeline. public RegimeHistory( string symbol, RegimeState currentState, List transitions) { if (string.IsNullOrEmpty(symbol)) throw new ArgumentNullException("symbol"); Symbol = symbol; CurrentState = currentState; Transitions = transitions ?? new List(); } } }