using System; using System.Collections.Generic; namespace NT8.Core.Intelligence { /// /// Types of confluence factors used in intelligence scoring. /// public enum FactorType { /// /// Base setup quality (for example ORB validity). /// Setup = 0, /// /// Trend alignment quality. /// Trend = 1, /// /// Volatility regime suitability. /// Volatility = 2, /// /// Session and timing quality. /// Timing = 3, /// /// Execution quality and slippage context. /// ExecutionQuality = 4, /// /// Liquidity and microstructure quality. /// Liquidity = 5, /// /// Risk regime and portfolio context. /// Risk = 6, /// /// Additional custom factor. /// Custom = 99 } /// /// Trade grade produced from weighted confluence score. /// public enum TradeGrade { /// /// Exceptional setup, score 0.90 and above. /// APlus = 6, /// /// Strong setup, score 0.80 and above. /// A = 5, /// /// Good setup, score 0.70 and above. /// B = 4, /// /// Acceptable setup, score 0.60 and above. /// C = 3, /// /// Marginal setup, score 0.50 and above. /// D = 2, /// /// Reject setup, score below 0.50. /// F = 1 } /// /// Weight configuration for a factor type. /// public class FactorWeight { /// /// Factor type this weight applies to. /// public FactorType Type { get; set; } /// /// Weight value (must be positive). /// public double Weight { get; set; } /// /// Human-readable reason for this weighting. /// public string Reason { get; set; } /// /// Last update timestamp in UTC. /// public DateTime UpdatedAtUtc { get; set; } /// /// Creates a new factor weight. /// /// Factor type. /// Weight value greater than zero. /// Reason for this weight. public FactorWeight(FactorType type, double weight, string reason) { if (weight <= 0) throw new ArgumentException("Weight must be greater than zero", "weight"); Type = type; Weight = weight; Reason = reason ?? string.Empty; UpdatedAtUtc = DateTime.UtcNow; } } /// /// Represents one contributing factor in a confluence calculation. /// public class ConfluenceFactor { /// /// Factor category. /// public FactorType Type { get; set; } /// /// Factor display name. /// public string Name { get; set; } /// /// Raw factor score in range [0.0, 1.0]. /// public double Score { get; set; } /// /// Weight importance for this factor. /// public double Weight { get; set; } /// /// Explanation for score value. /// public string Reason { get; set; } /// /// Additional details for diagnostics. /// public Dictionary Details { get; set; } /// /// Creates a new confluence factor. /// /// Factor type. /// Factor name. /// Score in range [0.0, 1.0]. /// Weight greater than zero. /// Reason for the score. /// Extended details dictionary. public ConfluenceFactor( FactorType type, string name, double score, double weight, string reason, Dictionary details) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); if (score < 0.0 || score > 1.0) throw new ArgumentException("Score must be between 0.0 and 1.0", "score"); if (weight <= 0.0) throw new ArgumentException("Weight must be greater than zero", "weight"); Type = type; Name = name; Score = score; Weight = weight; Reason = reason ?? string.Empty; Details = details ?? new Dictionary(); } } /// /// Represents an overall confluence score and grade for a trading decision. /// public class ConfluenceScore { /// /// Unweighted aggregate score in range [0.0, 1.0]. /// public double RawScore { get; set; } /// /// Weighted aggregate score in range [0.0, 1.0]. /// public double WeightedScore { get; set; } /// /// Grade derived from weighted score. /// public TradeGrade Grade { get; set; } /// /// Factor breakdown used to produce the score. /// public List Factors { get; set; } /// /// Calculation timestamp in UTC. /// public DateTime CalculatedAt { get; set; } /// /// Additional metadata and diagnostics. /// public Dictionary Metadata { get; set; } /// /// Creates a new confluence score model. /// /// Unweighted score in [0.0, 1.0]. /// Weighted score in [0.0, 1.0]. /// Trade grade. /// Contributing factors. /// Calculation timestamp. /// Additional metadata. public ConfluenceScore( double rawScore, double weightedScore, TradeGrade grade, List factors, DateTime calculatedAt, Dictionary metadata) { if (rawScore < 0.0 || rawScore > 1.0) throw new ArgumentException("RawScore must be between 0.0 and 1.0", "rawScore"); if (weightedScore < 0.0 || weightedScore > 1.0) throw new ArgumentException("WeightedScore must be between 0.0 and 1.0", "weightedScore"); RawScore = rawScore; WeightedScore = weightedScore; Grade = grade; Factors = factors ?? new List(); CalculatedAt = calculatedAt; Metadata = metadata ?? new Dictionary(); } } }