From 6c768ecdd22b3cd18a7280f1ec6dc11969015000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Andr=C3=A9s=20Marino=20Rojas?= <47573394+Marinovsky@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:54:22 -0500 Subject: [PATCH 1/3] First draft of the solution --- Common/Data/SubscriptionDataConfig.cs | 12 ++++++++++++ .../Enumerators/LiveMappingEventProvider.cs | 2 +- Engine/RealTime/LiveTradingRealTimeHandler.cs | 7 ++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Common/Data/SubscriptionDataConfig.cs b/Common/Data/SubscriptionDataConfig.cs index fd007df68077..0ef34ea507ee 100644 --- a/Common/Data/SubscriptionDataConfig.cs +++ b/Common/Data/SubscriptionDataConfig.cs @@ -401,6 +401,18 @@ public override string ToString() return Invariant($"{Symbol.Value},#{ContractDepthOffset},{MappedSymbol},{Resolution},{Type.Name},{TickType},{DataNormalizationMode},{DataMappingMode}{(IsInternalFeed ? ",Internal" : string.Empty)}"); } + public string ToStringWithCanonicalSymbol() + { + if (Symbol.HasCanonical()) + { + return Invariant($"{Symbol.Canonical},#{ContractDepthOffset},{MappedSymbol},{Resolution},{Type.Name},{TickType},{DataNormalizationMode},{DataMappingMode}{(IsInternalFeed ? ",Internal" : string.Empty)}"); + } + else + { + return ToString(); + } + } + /// /// New base class for all event classes. /// diff --git a/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs b/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs index 85e0dd513374..e1f9526d74e7 100644 --- a/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs +++ b/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs @@ -38,7 +38,7 @@ public override IEnumerable GetEvents(NewTradableDateEventArgs eventAr InitializeMapFile(); var newInstance = MapFile; - Log.Trace($"LiveMappingEventProvider({Config}): new tradable date {eventArgs.Date:yyyyMMdd}. " + + Log.Trace($"LiveMappingEventProvider({Config.ToStringWithCanonicalSymbol()}): new tradable date {eventArgs.Date:yyyyMMdd}. " + $"New MapFile: {!ReferenceEquals(currentInstance, newInstance)}. " + $"MapFile.Count Old: {currentInstance?.Count()} New: {newInstance?.Count()}"); diff --git a/Engine/RealTime/LiveTradingRealTimeHandler.cs b/Engine/RealTime/LiveTradingRealTimeHandler.cs index 9cbceb6e06c4..973bc6d8200b 100644 --- a/Engine/RealTime/LiveTradingRealTimeHandler.cs +++ b/Engine/RealTime/LiveTradingRealTimeHandler.cs @@ -145,7 +145,8 @@ protected virtual void RefreshMarketHours(DateTime date) UpdateMarketHours(security); var localMarketHours = security.Exchange.Hours.GetMarketHours(date); - Log.Trace($"LiveTradingRealTimeHandler.RefreshMarketHoursToday({security.Type}): Market hours set: Symbol: {security.Symbol} {localMarketHours} ({security.Exchange.Hours.TimeZone})"); + var symbol = security.Symbol.HasCanonical() ? security.Symbol.Canonical : security.Symbol; + Log.Trace($"LiveTradingRealTimeHandler.RefreshMarketHoursToday({security.Type}): Market hours set: Symbol: {symbol} {localMarketHours} ({security.Exchange.Hours.TimeZone})"); } } @@ -165,9 +166,9 @@ protected virtual void RefreshSymbolProperties() { var security = kvp.Value; UpdateSymbolProperties(security); - + var symbol = security.Symbol.HasCanonical() ? security.Symbol.Canonical : security.Symbol; Log.Trace($"LiveTradingRealTimeHandler.RefreshSymbolPropertiesToday(): Symbol properties set: " + - $"Symbol: {security.Symbol} {security.SymbolProperties}"); + $"Symbol: {symbol} {security.SymbolProperties}"); } } From 252d4a46cf051effca9579b6360a349c744a33c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Andr=C3=A9s=20Marino=20Rojas?= <47573394+Marinovsky@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:11:34 -0500 Subject: [PATCH 2/3] Address requests --- Common/Data/SubscriptionDataConfig.cs | 18 ++++++++---------- .../Enumerators/LiveMappingEventProvider.cs | 6 +++++- Engine/RealTime/LiveTradingRealTimeHandler.cs | 10 ++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Common/Data/SubscriptionDataConfig.cs b/Common/Data/SubscriptionDataConfig.cs index 0ef34ea507ee..4c869cee6c28 100644 --- a/Common/Data/SubscriptionDataConfig.cs +++ b/Common/Data/SubscriptionDataConfig.cs @@ -398,19 +398,17 @@ public override int GetHashCode() /// 2 public override string ToString() { - return Invariant($"{Symbol.Value},#{ContractDepthOffset},{MappedSymbol},{Resolution},{Type.Name},{TickType},{DataNormalizationMode},{DataMappingMode}{(IsInternalFeed ? ",Internal" : string.Empty)}"); + return ToString(Symbol.Value); } - public string ToStringWithCanonicalSymbol() + /// + /// Returns a string that represents the current object. + /// + /// Symbol to use in the string representation of the object + /// /// A string that represents the current object. + public string ToString(string symbol) { - if (Symbol.HasCanonical()) - { - return Invariant($"{Symbol.Canonical},#{ContractDepthOffset},{MappedSymbol},{Resolution},{Type.Name},{TickType},{DataNormalizationMode},{DataMappingMode}{(IsInternalFeed ? ",Internal" : string.Empty)}"); - } - else - { - return ToString(); - } + return Invariant($"{symbol},#{ContractDepthOffset},{MappedSymbol},{Resolution},{Type.Name},{TickType},{DataNormalizationMode},{DataMappingMode}{(IsInternalFeed ? ",Internal" : string.Empty)}"); } /// diff --git a/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs b/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs index e1f9526d74e7..5e27a364709c 100644 --- a/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs +++ b/Engine/DataFeeds/Enumerators/LiveMappingEventProvider.cs @@ -38,7 +38,11 @@ public override IEnumerable GetEvents(NewTradableDateEventArgs eventAr InitializeMapFile(); var newInstance = MapFile; - Log.Trace($"LiveMappingEventProvider({Config.ToStringWithCanonicalSymbol()}): new tradable date {eventArgs.Date:yyyyMMdd}. " + + // All future and option contracts sharing the same canonical symbol, share the same configuration too. Thus, in + // order to reduce logs, we log the configuration using the canonical symbol. See the optional parameter + // "overrideMessageFloodProtection" in Log.Trace() method for more information + var symbol = Config.Symbol.HasCanonical() ? Config.Symbol.Canonical.Value : Config.Symbol.Value; + Log.Trace($"LiveMappingEventProvider({Config.ToString(symbol)}): new tradable date {eventArgs.Date:yyyyMMdd}. " + $"New MapFile: {!ReferenceEquals(currentInstance, newInstance)}. " + $"MapFile.Count Old: {currentInstance?.Count()} New: {newInstance?.Count()}"); diff --git a/Engine/RealTime/LiveTradingRealTimeHandler.cs b/Engine/RealTime/LiveTradingRealTimeHandler.cs index 973bc6d8200b..684beca83e2c 100644 --- a/Engine/RealTime/LiveTradingRealTimeHandler.cs +++ b/Engine/RealTime/LiveTradingRealTimeHandler.cs @@ -145,6 +145,11 @@ protected virtual void RefreshMarketHours(DateTime date) UpdateMarketHours(security); var localMarketHours = security.Exchange.Hours.GetMarketHours(date); + + // All future and option contracts sharing the same canonical symbol, share the same market + // hours too. Thus, in order to reduce logs, we log the market hours using the canonical + // symbol. See the optional parameter "overrideMessageFloodProtection" in Log.Trace() + // method for further information var symbol = security.Symbol.HasCanonical() ? security.Symbol.Canonical : security.Symbol; Log.Trace($"LiveTradingRealTimeHandler.RefreshMarketHoursToday({security.Type}): Market hours set: Symbol: {symbol} {localMarketHours} ({security.Exchange.Hours.TimeZone})"); } @@ -166,6 +171,11 @@ protected virtual void RefreshSymbolProperties() { var security = kvp.Value; UpdateSymbolProperties(security); + + // All future and option contracts sharing the same canonical symbol, share the same symbol + // properties too. Thus, in order to reduce logs, we log the symbol properties using the + // canonical symbol. See the optional parameter "overrideMessageFloodProtection" in + // Log.Trace() method for further information var symbol = security.Symbol.HasCanonical() ? security.Symbol.Canonical : security.Symbol; Log.Trace($"LiveTradingRealTimeHandler.RefreshSymbolPropertiesToday(): Symbol properties set: " + $"Symbol: {symbol} {security.SymbolProperties}"); From 4af98f19b03867d91fb6b036e28a984837536652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Andr=C3=A9s=20Marino=20Rojas?= <47573394+Marinovsky@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:16:34 -0500 Subject: [PATCH 3/3] Reduce more enrequired logs --- Engine/DataFeeds/Enumerators/LiveDelistingEventProvider.cs | 6 +++++- Engine/DataFeeds/Enumerators/LiveDividendEventProvider.cs | 6 +++++- Engine/DataFeeds/Enumerators/LiveSplitEventProvider.cs | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Engine/DataFeeds/Enumerators/LiveDelistingEventProvider.cs b/Engine/DataFeeds/Enumerators/LiveDelistingEventProvider.cs index edbdf85f7eb3..f4c157aec2ef 100644 --- a/Engine/DataFeeds/Enumerators/LiveDelistingEventProvider.cs +++ b/Engine/DataFeeds/Enumerators/LiveDelistingEventProvider.cs @@ -40,7 +40,11 @@ public override IEnumerable GetEvents(NewTradableDateEventArgs eventAr if (currentInstance?.LastOrDefault()?.Date != newInstance?.LastOrDefault()?.Date) { - Log.Trace($"LiveDelistingEventProvider({Config}): new tradable date {eventArgs.Date:yyyyMMdd}. " + + // All future and option contracts sharing the same canonical symbol, share the same configuration too. Thus, in + // order to reduce logs, we log the configuration using the canonical symbol. See the optional parameter + // "overrideMessageFloodProtection" in Log.Trace() method for more information + var symbol = Config.Symbol.HasCanonical() ? Config.Symbol.Canonical.Value : Config.Symbol.Value; + Log.Trace($"LiveDelistingEventProvider({Config.ToString(symbol)}): new tradable date {eventArgs.Date:yyyyMMdd}. " + $"MapFile.LastDate Old: {currentInstance?.LastOrDefault()?.Date:yyyyMMdd} New: {newInstance?.LastOrDefault()?.Date:yyyyMMdd}"); } diff --git a/Engine/DataFeeds/Enumerators/LiveDividendEventProvider.cs b/Engine/DataFeeds/Enumerators/LiveDividendEventProvider.cs index 2b1e87d94214..ec0e03b959d7 100644 --- a/Engine/DataFeeds/Enumerators/LiveDividendEventProvider.cs +++ b/Engine/DataFeeds/Enumerators/LiveDividendEventProvider.cs @@ -42,7 +42,11 @@ public override IEnumerable GetEvents(NewTradableDateEventArgs eventAr if (currentInstance?.Count() != newInstance?.Count()) { - Log.Trace($"LiveDividendEventProvider({Config}): new tradable date {eventArgs.Date:yyyyMMdd}. " + + // All future and option contracts sharing the same canonical symbol, share the same configuration too. Thus, in + // order to reduce logs, we log the configuration using the canonical symbol. See the optional parameter + // "overrideMessageFloodProtection" in Log.Trace() method for more information + var symbol = Config.Symbol.HasCanonical() ? Config.Symbol.Canonical.Value : Config.Symbol.Value; + Log.Trace($"LiveDividendEventProvider({Config.ToString(symbol)}): new tradable date {eventArgs.Date:yyyyMMdd}. " + $"New FactorFile: {!ReferenceEquals(currentInstance, newInstance)}. " + $"FactorFile.Count Old: {currentInstance?.Count()} New: {newInstance?.Count()}"); } diff --git a/Engine/DataFeeds/Enumerators/LiveSplitEventProvider.cs b/Engine/DataFeeds/Enumerators/LiveSplitEventProvider.cs index dc19108580dc..b02439834c20 100644 --- a/Engine/DataFeeds/Enumerators/LiveSplitEventProvider.cs +++ b/Engine/DataFeeds/Enumerators/LiveSplitEventProvider.cs @@ -42,7 +42,11 @@ public override IEnumerable GetEvents(NewTradableDateEventArgs eventAr if(currentInstance?.Count() != newInstance?.Count()) { - Log.Trace($"LiveSplitEventProvider({Config}): new tradable date {eventArgs.Date:yyyyMMdd}. " + + // All future and option contracts sharing the same canonical symbol, share the same configuration too. Thus, in + // order to reduce logs, we log the configuration using the canonical symbol. See the optional parameter + // "overrideMessageFloodProtection" in Log.Trace() method for more information + var symbol = Config.Symbol.HasCanonical() ? Config.Symbol.Canonical.Value : Config.Symbol.Value; + Log.Trace($"LiveSplitEventProvider({Config.ToString(symbol)}): new tradable date {eventArgs.Date:yyyyMMdd}. " + $"New FactorFile: {!ReferenceEquals(currentInstance, newInstance)}. " + $"FactorFile.Count Old: {currentInstance?.Count()} New: {newInstance?.Count()}"); }