From ab431db873964eceff6e0528a366ed253cfbfae5 Mon Sep 17 00:00:00 2001 From: Jacopo Cina Date: Fri, 10 Jan 2025 17:38:44 +0100 Subject: [PATCH] moved DerivedCfg as public readonly object in the MarketData --- .../Samples/DerivedTimeSerieTest.cs | 5 +-- Artesian/Artesian.SDK/Common/ArtesianUtils.cs | 4 +- .../Artesian.SDK/Dto/DerivedCfg/DerivedCfg.cs | 38 ++++++++++++++++++ .../Dto/DerivedCfg/DerivedCfgBase.cs | 6 +-- .../Dto/DerivedCfg/DerivedCfgCoalesce.cs | 4 +- .../DerivedCfg/DerivedCfgCoalesceReadOnly.cs | 4 +- .../Dto/DerivedCfg/DerivedCfgMuv.cs | 4 +- .../Dto/DerivedCfg/DerivedCfgMuvReadOnly.cs | 4 +- .../Dto/DerivedCfg/DerivedCfgSum.cs | 4 +- .../Dto/DerivedCfg/DerivedCfgSumReadOnly.cs | 4 +- .../DerivedCfg/DerivedCfgWithReferencedIds.cs | 2 +- .../Dto/DerivedCfg/Enums/DerivedAlgorithm.cs | 2 +- .../Serialize/DerivedCfgBaseConverter.cs | 4 +- .../Serialize/JsonPolymorphicConverter.cs | 2 +- .../Dto/MarketData/MarketDataEntity.cs | 2 +- .../MarketData/MarketDataEntityInputExt.cs | 4 +- Artesian/Artesian.SDK/Factory/BidAsk.cs | 2 +- Artesian/Artesian.SDK/Factory/IMarketData.cs | 6 ++- .../Artesian.SDK/Factory/MarketAssessment.cs | 2 +- Artesian/Artesian.SDK/Factory/MarketData.cs | 18 ++++++++- .../Factory/MarketDataMetadata.cs | 40 ------------------- .../Artesian.SDK/Service/Clients/Client.cs | 2 +- .../Configuration/ArtesianConstants.cs | 36 ++++++++--------- .../GMEPublicOffer/GMEPublicOfferService.cs | 2 +- .../Service/MarketData/IMarketDataService.cs | 2 +- .../MarketDataService.MarketData.cs | 1 - .../Service/MarketData/MarketDataService.cs | 2 +- .../QueryParamaters/ActualQueryParamaters.cs | 2 +- .../Service/Query/QueryService.cs | 2 +- README.md | 10 ++++- 30 files changed, 120 insertions(+), 100 deletions(-) create mode 100644 Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfg.cs diff --git a/Artesian/Artesian.SDK.Tests/Samples/DerivedTimeSerieTest.cs b/Artesian/Artesian.SDK.Tests/Samples/DerivedTimeSerieTest.cs index c058a8b..7c46102 100644 --- a/Artesian/Artesian.SDK.Tests/Samples/DerivedTimeSerieTest.cs +++ b/Artesian/Artesian.SDK.Tests/Samples/DerivedTimeSerieTest.cs @@ -1,5 +1,4 @@ using Artesian.SDK.Dto; -using Artesian.SDK.Dto.DerivedCfg; using Artesian.SDK.Factory; using Artesian.SDK.Service; @@ -135,7 +134,7 @@ public async Task CreateDerivedCoalesceTimeSeries() } // Update DerivedCfg - if (marketData.Metadata.DerivedCfgCoalesce != null) + if (marketData.DerivedCfg.DerivedCfgCoalesce != null) { curveIds.Reverse(); var derivedCfgUpdate = new DerivedCfgCoalesce() @@ -143,7 +142,7 @@ public async Task CreateDerivedCoalesceTimeSeries() OrderedReferencedMarketDataIds = curveIds.ToArray(), }; - if (!marketData.Metadata.DerivedCfgCoalesce.OrderedReferencedMarketDataIds.SequenceEqual(derivedCfgUpdate.OrderedReferencedMarketDataIds)) + if (!marketData.DerivedCfg.DerivedCfgCoalesce.OrderedReferencedMarketDataIds.SequenceEqual(derivedCfgUpdate.OrderedReferencedMarketDataIds)) { marketData.UpdateDerivedConfiguration(derivedCfgUpdate, false).ConfigureAwait(true).GetAwaiter().GetResult(); diff --git a/Artesian/Artesian.SDK/Common/ArtesianUtils.cs b/Artesian/Artesian.SDK/Common/ArtesianUtils.cs index 690bd70..87a0482 100644 --- a/Artesian/Artesian.SDK/Common/ArtesianUtils.cs +++ b/Artesian/Artesian.SDK/Common/ArtesianUtils.cs @@ -104,7 +104,7 @@ public static void IsValidString(string validStringCheck, int minLenght, int max throw new ArgumentException($"Invalid string '{validStringCheck}'. Must not be null or empty", callerParamName); if (validStringCheck.Length < minLenght || validStringCheck.Length > maxLenght) throw new ArgumentException($"Invalid string '{validStringCheck}'. Must be between 1 and 50 characters.", callerParamName); - if (!ArtesianConstants.StringValidator.Match(validStringCheck).Success) + if (!ArtesianConstants._stringValidator.Match(validStringCheck).Success) throw new ArgumentException($"Invalid string '{validStringCheck}'. Should not contain trailing or leading whitespaces or any of the following characters: ,:; '\"", callerParamName); } @@ -133,7 +133,7 @@ public static void IsValidMarketDataName(string name, int minLenght, int maxLeng throw new ArgumentException($"Invalid MarketData name {name}. Must not be null or empty", callerParamName); if (name.Length < minLenght || name.Length > maxLenght) throw new ArgumentException($"Invalid MarketData name {name}. Must be between 1 and 250 characters.", callerParamName); - if (!ArtesianConstants.MarketDataNameValidator.Match(name).Success) + if (!ArtesianConstants._marketDataNameValidator.Match(name).Success) throw new ArgumentException($"Invalid MarketData name '{name}'. Should not contain trailing or leading whitespaces and no other whitespace than in the middle.", callerParamName); } } diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfg.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfg.cs new file mode 100644 index 0000000..725f808 --- /dev/null +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfg.cs @@ -0,0 +1,38 @@ +namespace Artesian.SDK.Dto +{ + /// + /// The DerivedCfg containing the three type of derived configurations (DerivedCfgCoalesce, DerivedCfgSum, DerivedCfgMuv) + /// + public record DerivedCfg + { + /// + /// DerivedCfg constructor + /// + /// + internal DerivedCfg(DerivedCfgBase derivedCfg) + { + if (derivedCfg is DerivedCfgCoalesce) + DerivedCfgCoalesce = new DerivedCfgCoalesceReadOnly(derivedCfg as DerivedCfgCoalesce); + else if (derivedCfg is DerivedCfgSum) + DerivedCfgSum = new DerivedCfgSumReadOnly(derivedCfg as DerivedCfgSum); + else if (derivedCfg is DerivedCfgMuv) + DerivedCfgMuv = new DerivedCfgMuvReadOnly(derivedCfg as DerivedCfgMuv); + } + + /// + /// DerivedCfgCoalesce + /// + public DerivedCfgCoalesceReadOnly? DerivedCfgCoalesce { get; protected set; } = null; + + /// + /// DerivedCfgSum + /// + public DerivedCfgSumReadOnly? DerivedCfgSum { get; protected set; } = null; + + /// + /// DerivedCfgMuv + /// + public DerivedCfgMuvReadOnly? DerivedCfgMuv { get; protected set; } = null; + + } +} diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgBase.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgBase.cs index 83beb2f..62c1c88 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgBase.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgBase.cs @@ -1,11 +1,11 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; -using Artesian.SDK.Dto.DerivedCfg.Serialize; +using Artesian.SDK.Dto.Enums; +using Artesian.SDK.Dto.Serialize; using MessagePack; using Newtonsoft.Json; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// Base class for Derived Configuration. diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesce.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesce.cs index 1e5b969..7b15dbd 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesce.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesce.cs @@ -1,8 +1,8 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; +using Artesian.SDK.Dto.Enums; using MessagePack; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// Represents a derived configuration that uses the Coalesce algorithm. diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesceReadOnly.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesceReadOnly.cs index 8bff434..0d91183 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesceReadOnly.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgCoalesceReadOnly.cs @@ -1,8 +1,8 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; +using Artesian.SDK.Dto.Enums; using System.Collections.Generic; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// DerivedCoalesce Configuration Readonly diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuv.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuv.cs index 5b73ca4..2b410c6 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuv.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuv.cs @@ -1,8 +1,8 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; +using Artesian.SDK.Dto.Enums; using MessagePack; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// Represents the configuration for the MostUpdatedVersion derived algorithm. diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuvReadOnly.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuvReadOnly.cs index 7cf05cd..ec9193c 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuvReadOnly.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgMuvReadOnly.cs @@ -1,6 +1,6 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; +using Artesian.SDK.Dto.Enums; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// DerivedMuv Configuration Readonly diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSum.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSum.cs index 74d6895..0a9f27d 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSum.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSum.cs @@ -1,8 +1,8 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; +using Artesian.SDK.Dto.Enums; using MessagePack; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// Represents a derived configuration that uses the Sum algorithm. diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSumReadOnly.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSumReadOnly.cs index f010312..531176a 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSumReadOnly.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgSumReadOnly.cs @@ -1,8 +1,8 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; +using Artesian.SDK.Dto.Enums; using System.Collections.Generic; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// DerivedSum Configuration Readonly diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgWithReferencedIds.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgWithReferencedIds.cs index 6153e0e..7518e40 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgWithReferencedIds.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/DerivedCfgWithReferencedIds.cs @@ -1,6 +1,6 @@ using MessagePack; -namespace Artesian.SDK.Dto.DerivedCfg +namespace Artesian.SDK.Dto { /// /// Represents a configuration with referenced market data IDs for derived data. diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/Enums/DerivedAlgorithm.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/Enums/DerivedAlgorithm.cs index b30f5eb..f8e8953 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/Enums/DerivedAlgorithm.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/Enums/DerivedAlgorithm.cs @@ -1,4 +1,4 @@ -namespace Artesian.SDK.Dto.DerivedCfg.Enums +namespace Artesian.SDK.Dto.Enums { /// /// Enumeration for specifying the derived algorithm. diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/DerivedCfgBaseConverter.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/DerivedCfgBaseConverter.cs index 972a8b0..6eaafb2 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/DerivedCfgBaseConverter.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/DerivedCfgBaseConverter.cs @@ -1,11 +1,11 @@ -using Artesian.SDK.Dto.DerivedCfg.Enums; +using Artesian.SDK.Dto.Enums; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; -namespace Artesian.SDK.Dto.DerivedCfg.Serialize +namespace Artesian.SDK.Dto.Serialize { sealed class DerivedCfgBaseConverter : JsonCreationConverter { diff --git a/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/JsonPolymorphicConverter.cs b/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/JsonPolymorphicConverter.cs index 9229759..d9ae464 100644 --- a/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/JsonPolymorphicConverter.cs +++ b/Artesian/Artesian.SDK/Dto/DerivedCfg/Serialize/JsonPolymorphicConverter.cs @@ -2,7 +2,7 @@ using System; using System.Text.Json.Serialization; -namespace Artesian.SDK.Dto.DerivedCfg.Serialize +namespace Artesian.SDK.Dto.Serialize { internal abstract class JsonPolymorphicConverter : JsonConverter where TDiscriminatorEnum : struct, Enum diff --git a/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntity.cs b/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntity.cs index 3446c1f..b0b263f 100644 --- a/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntity.cs +++ b/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntity.cs @@ -1,7 +1,7 @@ // Copyright (c) ARK LTD. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for // license information. -using Artesian.SDK.Dto.DerivedCfg; +using Artesian.SDK.Dto; using MessagePack; using NodaTime; diff --git a/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntityInputExt.cs b/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntityInputExt.cs index f535908..5206967 100644 --- a/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntityInputExt.cs +++ b/Artesian/Artesian.SDK/Dto/MarketData/MarketDataEntityInputExt.cs @@ -1,6 +1,4 @@ -using Artesian.SDK.Dto.DerivedCfg; - -using System; +using System; namespace Artesian.SDK.Dto.MarketData { diff --git a/Artesian/Artesian.SDK/Factory/BidAsk.cs b/Artesian/Artesian.SDK/Factory/BidAsk.cs index 44af30d..bfa348c 100644 --- a/Artesian/Artesian.SDK/Factory/BidAsk.cs +++ b/Artesian/Artesian.SDK/Factory/BidAsk.cs @@ -85,7 +85,7 @@ public AddBidAskOperationResult AddData(Instant time, string product, BidAskValu private AddBidAskOperationResult _addBidAsk(LocalDateTime reportTime, string product, BidAskValue value) { //Relative products - if (ArtesianConstants.RelativeProductValidator.IsMatch(product)) + if (ArtesianConstants._relativeProductValidator.IsMatch(product)) throw new NotSupportedException("Relative Products are not supported"); if (_entity.OriginalGranularity.IsTimeGranularity()) diff --git a/Artesian/Artesian.SDK/Factory/IMarketData.cs b/Artesian/Artesian.SDK/Factory/IMarketData.cs index 8c07b63..efd09da 100644 --- a/Artesian/Artesian.SDK/Factory/IMarketData.cs +++ b/Artesian/Artesian.SDK/Factory/IMarketData.cs @@ -1,5 +1,4 @@ using Artesian.SDK.Dto; -using Artesian.SDK.Dto.DerivedCfg; using NodaTime; @@ -29,6 +28,11 @@ public interface IMarketData /// MarketDataMetadata Metadata { get; } + /// + /// DerivedCfg + /// + DerivedCfg DerivedCfg { get; } + /// /// MarketData Load Metadata /// diff --git a/Artesian/Artesian.SDK/Factory/MarketAssessment.cs b/Artesian/Artesian.SDK/Factory/MarketAssessment.cs index 8f39de1..16ed122 100644 --- a/Artesian/Artesian.SDK/Factory/MarketAssessment.cs +++ b/Artesian/Artesian.SDK/Factory/MarketAssessment.cs @@ -85,7 +85,7 @@ public AddAssessmentOperationResult AddData(Instant time, string product, Market private AddAssessmentOperationResult _addAssessment(LocalDateTime reportTime, string product, MarketAssessmentValue value) { //Relative products - if (ArtesianConstants.RelativeProductValidator.IsMatch(product)) + if (ArtesianConstants._relativeProductValidator.IsMatch(product)) throw new NotSupportedException("Relative Products are not supported"); if (_entity.OriginalGranularity.IsTimeGranularity()) diff --git a/Artesian/Artesian.SDK/Factory/MarketData.cs b/Artesian/Artesian.SDK/Factory/MarketData.cs index 55cb79c..b137939 100644 --- a/Artesian/Artesian.SDK/Factory/MarketData.cs +++ b/Artesian/Artesian.SDK/Factory/MarketData.cs @@ -1,6 +1,5 @@ using Artesian.SDK.Common; using Artesian.SDK.Dto; -using Artesian.SDK.Dto.DerivedCfg; using Artesian.SDK.Dto.MarketData; using Artesian.SDK.Service; @@ -34,6 +33,11 @@ public class MarketData : IMarketData /// public MarketDataMetadata Metadata { get; protected set; } + /// + /// DerivedCfg + /// + public DerivedCfg DerivedCfg { get; protected set; } + /// /// MarketData Constructor by Id /// @@ -71,6 +75,8 @@ public async Task Register(MarketDataEntity.Input metadata, CancellationToken ct _entity = await _marketDataService.RegisterMarketDataAsync(metadata, ctk).ConfigureAwait(false); + DerivedCfg = new DerivedCfg(_entity.DerivedCfg); + Metadata = new MarketDataMetadata(_entity); } @@ -106,7 +112,11 @@ public async Task Load(CancellationToken ctk = default) _entity = await _marketDataService.ReadMarketDataRegistryAsync(Identifier, ctk).ConfigureAwait(false); if (_entity != null) + { + DerivedCfg = new DerivedCfg(_entity.DerivedCfg); + Metadata = new MarketDataMetadata(_entity); + } } /// @@ -249,6 +259,8 @@ public async Task UpdateDerivedConfiguration(DerivedCfgMuv derivedCfg, bool forc _entity = await _marketDataService.UpdateDerivedConfigurationAsync(_entity.MarketDataId, derivedCfg, force, ctk).ConfigureAwait(false); + DerivedCfg = new DerivedCfg(_entity.DerivedCfg); + Metadata = new MarketDataMetadata(_entity); } @@ -276,6 +288,8 @@ public async Task UpdateDerivedConfiguration(DerivedCfgCoalesce derivedCfg, bool _entity = await _marketDataService.UpdateDerivedConfigurationAsync(_entity.MarketDataId, derivedCfg, force, ctk).ConfigureAwait(false); + DerivedCfg = new DerivedCfg(_entity.DerivedCfg); + Metadata = new MarketDataMetadata(_entity); } @@ -303,6 +317,8 @@ public async Task UpdateDerivedConfiguration(DerivedCfgSum derivedCfg, bool forc _entity = await _marketDataService.UpdateDerivedConfigurationAsync(_entity.MarketDataId, derivedCfg, force, ctk).ConfigureAwait(false); + DerivedCfg = new DerivedCfg(_entity.DerivedCfg); + Metadata = new MarketDataMetadata(_entity); } } diff --git a/Artesian/Artesian.SDK/Factory/MarketDataMetadata.cs b/Artesian/Artesian.SDK/Factory/MarketDataMetadata.cs index e51d808..8526033 100644 --- a/Artesian/Artesian.SDK/Factory/MarketDataMetadata.cs +++ b/Artesian/Artesian.SDK/Factory/MarketDataMetadata.cs @@ -1,5 +1,4 @@ using Artesian.SDK.Dto; -using Artesian.SDK.Dto.DerivedCfg; using NodaTime; @@ -90,44 +89,5 @@ internal MarketDataMetadata(MarketDataEntity.Output output) /// The time the market data has been created /// public Instant Created => _output.Created; - /// - /// The DerivedCfgCoalesce - /// - public DerivedCfgCoalesceReadOnly? DerivedCfgCoalesce - { - get - { - if (_output.DerivedCfg is DerivedCfgCoalesce) - return new DerivedCfgCoalesceReadOnly(_output.DerivedCfg as DerivedCfgCoalesce); - else - return null; - } - } - /// - /// The DerivedCfgSum - /// - public DerivedCfgSumReadOnly? DerivedCfgSum - { - get - { - if (_output.DerivedCfg is DerivedCfgSum) - return new DerivedCfgSumReadOnly(_output.DerivedCfg as DerivedCfgSum); - else - return null; - } - } - /// - /// The DerivedCfgMuv - /// - public DerivedCfgMuvReadOnly? DerivedCfgMuv - { - get - { - if (_output.DerivedCfg is DerivedCfgMuv) - return new DerivedCfgMuvReadOnly(_output.DerivedCfg as DerivedCfgMuv); - else - return null; - } - } } } diff --git a/Artesian/Artesian.SDK/Service/Clients/Client.cs b/Artesian/Artesian.SDK/Service/Clients/Client.cs index 4cee177..b106026 100644 --- a/Artesian/Artesian.SDK/Service/Clients/Client.cs +++ b/Artesian/Artesian.SDK/Service/Clients/Client.cs @@ -103,7 +103,7 @@ public Client(IArtesianServiceConfig config, string Url, ArtesianPolicyConfig po } _client = new FlurlClient(_url); - _client.WithTimeout(TimeSpan.FromMinutes(ArtesianConstants.ServiceRequestTimeOutMinutes)); + _client.WithTimeout(TimeSpan.FromMinutes(ArtesianConstants._serviceRequestTimeOutMinutes)); } diff --git a/Artesian/Artesian.SDK/Service/Configuration/ArtesianConstants.cs b/Artesian/Artesian.SDK/Service/Configuration/ArtesianConstants.cs index 0670b22..72ff048 100644 --- a/Artesian/Artesian.SDK/Service/Configuration/ArtesianConstants.cs +++ b/Artesian/Artesian.SDK/Service/Configuration/ArtesianConstants.cs @@ -17,39 +17,39 @@ public static partial class ArtesianConstants public readonly static string SDKVersionHeaderValue = $@"ArtesianSDK-C#:{Assembly.GetExecutingAssembly().GetName().Version},{Environment.OSVersion.Platform}:{Environment.OSVersion.Version},{_frameworkName?.Identifier}:{_frameworkName?.Version}"; #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member - internal const string QueryVersion = "v1.0"; - internal const string GMEPublicOfferVersion = "v2.0"; - internal const string QueryRoute = "query"; - internal const string GMEPublicOfferRoute = "gmepublicoffer"; - internal const string MetadataVersion = "v2.1"; - internal const int ServiceRequestTimeOutMinutes = 10; + internal const string _queryVersion = "v1.0"; + internal const string _gMEPublicOfferVersion = "v2.0"; + internal const string _queryRoute = "query"; + internal const string _gMEPublicOfferRoute = "gmepublicoffer"; + internal const string _metadataVersion = "v2.1"; + internal const int _serviceRequestTimeOutMinutes = 10; private static FrameworkName _frameworkName { get => new FrameworkName(Assembly.GetExecutingAssembly()?.GetCustomAttribute()?.FrameworkName); } - internal const string CharacterValidatorRegEx = @"^[^'"",:;\s](?:(?:[^'"",:;\s]| )*[^'"",:;\s])?$"; - internal const string MarketDataNameValidatorRegEx = @"^[^\s](?:(?:[^\s]| )*[^\s])?$"; - internal const string RelativeProductValidatorRegEx = @"\+\d+$"; + internal const string _characterValidatorRegEx = @"^[^'"",:;\s](?:(?:[^'"",:;\s]| )*[^'"",:;\s])?$"; + internal const string _marketDataNameValidatorRegEx = @"^[^\s](?:(?:[^\s]| )*[^\s])?$"; + internal const string _relativeProductValidatorRegEx = @"\+\d+$"; #if NET8_0_OR_GREATER - internal static readonly Regex StringValidator = StringValidatorGenerator(); - internal static readonly Regex MarketDataNameValidator = MarketDataNameValidatorGenerator(); - internal static readonly Regex RelativeProductValidator = RelativeProductValidatorGenerator(); + internal static readonly Regex _stringValidator = StringValidatorGenerator(); + internal static readonly Regex _marketDataNameValidator = MarketDataNameValidatorGenerator(); + internal static readonly Regex _relativeProductValidator = RelativeProductValidatorGenerator(); - [GeneratedRegex(CharacterValidatorRegEx, RegexOptions.CultureInvariant, 1000)] + [GeneratedRegex(_characterValidatorRegEx, RegexOptions.CultureInvariant, 1000)] private static partial Regex StringValidatorGenerator(); - [GeneratedRegex(MarketDataNameValidatorRegEx, RegexOptions.CultureInvariant, 1000)] + [GeneratedRegex(_marketDataNameValidatorRegEx, RegexOptions.CultureInvariant, 1000)] private static partial Regex MarketDataNameValidatorGenerator(); - [GeneratedRegex(RelativeProductValidatorRegEx, RegexOptions.CultureInvariant, 1000)] + [GeneratedRegex(_relativeProductValidatorRegEx, RegexOptions.CultureInvariant, 1000)] private static partial Regex RelativeProductValidatorGenerator(); #else - internal static readonly Regex StringValidator = new Regex(CharacterValidatorRegEx, RegexOptions.CultureInvariant | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); - internal static readonly Regex MarketDataNameValidator = new Regex(MarketDataNameValidatorRegEx, RegexOptions.CultureInvariant | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); - internal static readonly Regex RelativeProductValidator = new Regex(RelativeProductValidatorRegEx, RegexOptions.CultureInvariant | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); + internal static readonly Regex _stringValidator = new Regex(_characterValidatorRegEx, RegexOptions.CultureInvariant | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); + internal static readonly Regex _marketDataNameValidator = new Regex(_marketDataNameValidatorRegEx, RegexOptions.CultureInvariant | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); + internal static readonly Regex _relativeProductValidator = new Regex(_relativeProductValidatorRegEx, RegexOptions.CultureInvariant | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); #endif } diff --git a/Artesian/Artesian.SDK/Service/GMEPublicOffer/GMEPublicOfferService.cs b/Artesian/Artesian.SDK/Service/GMEPublicOffer/GMEPublicOfferService.cs index 51d346c..a927012 100644 --- a/Artesian/Artesian.SDK/Service/GMEPublicOffer/GMEPublicOfferService.cs +++ b/Artesian/Artesian.SDK/Service/GMEPublicOffer/GMEPublicOfferService.cs @@ -30,7 +30,7 @@ public GMEPublicOfferService(IArtesianServiceConfig cfg, ArtesianPolicyConfig po { _cfg = cfg; _policy = policy; - _client = new Client(cfg, ArtesianConstants.GMEPublicOfferRoute.AppendPathSegment(ArtesianConstants.GMEPublicOfferVersion), _policy); + _client = new Client(cfg, ArtesianConstants._gMEPublicOfferRoute.AppendPathSegment(ArtesianConstants._gMEPublicOfferVersion), _policy); } } diff --git a/Artesian/Artesian.SDK/Service/MarketData/IMarketDataService.cs b/Artesian/Artesian.SDK/Service/MarketData/IMarketDataService.cs index 3954e7f..e2a4ce2 100644 --- a/Artesian/Artesian.SDK/Service/MarketData/IMarketDataService.cs +++ b/Artesian/Artesian.SDK/Service/MarketData/IMarketDataService.cs @@ -3,7 +3,7 @@ // license information. using Artesian.SDK.Dto; -using Artesian.SDK.Dto.DerivedCfg; + using NodaTime; using System.Collections.Generic; diff --git a/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.MarketData.cs b/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.MarketData.cs index 4c80e8e..55fbf02 100644 --- a/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.MarketData.cs +++ b/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.MarketData.cs @@ -9,7 +9,6 @@ using System; using Flurl; using System.Globalization; -using Artesian.SDK.Dto.DerivedCfg; using Artesian.SDK.Dto.MarketData; namespace Artesian.SDK.Service diff --git a/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.cs b/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.cs index 33b7bc5..9db3429 100644 --- a/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.cs +++ b/Artesian/Artesian.SDK/Service/MarketData/MarketDataService.cs @@ -31,7 +31,7 @@ public MarketDataService(IArtesianServiceConfig cfg, ArtesianPolicyConfig policy { _cfg = cfg; _policy = policy; - _client = new Client(cfg, ArtesianConstants.MetadataVersion, _policy); + _client = new Client(cfg, ArtesianConstants._metadataVersion, _policy); } } } diff --git a/Artesian/Artesian.SDK/Service/Query/QueryParamaters/ActualQueryParamaters.cs b/Artesian/Artesian.SDK/Service/Query/QueryParamaters/ActualQueryParamaters.cs index eb9aee8..8a16d7c 100644 --- a/Artesian/Artesian.SDK/Service/Query/QueryParamaters/ActualQueryParamaters.cs +++ b/Artesian/Artesian.SDK/Service/Query/QueryParamaters/ActualQueryParamaters.cs @@ -2,7 +2,7 @@ // Licensed under the MIT License. See LICENSE in the project root for // license information. using Artesian.SDK.Dto; -using Artesian.SDK.Dto.DerivedCfg; + using System.Collections.Generic; diff --git a/Artesian/Artesian.SDK/Service/Query/QueryService.cs b/Artesian/Artesian.SDK/Service/Query/QueryService.cs index 84aa484..4b76df3 100644 --- a/Artesian/Artesian.SDK/Service/Query/QueryService.cs +++ b/Artesian/Artesian.SDK/Service/Query/QueryService.cs @@ -36,7 +36,7 @@ public QueryService(IArtesianServiceConfig cfg, ArtesianPolicyConfig policy) { _cfg = cfg; _policy = policy; - _client = new Client(cfg, ArtesianConstants.QueryRoute.AppendPathSegment(ArtesianConstants.QueryVersion), _policy); + _client = new Client(cfg, ArtesianConstants._queryRoute.AppendPathSegment(ArtesianConstants._queryVersion), _policy); } /// diff --git a/README.md b/README.md index 3059e5d..5fbf6d7 100644 --- a/README.md +++ b/README.md @@ -405,9 +405,15 @@ await marketData.Update(); await marketData.Load(); ``` -In marketData.Metadata, there are three different read-only properties: DerivedCfgCoalesce, DerivedCfgSum, and DerivedCfgMuv. When the TimeSerie is of type Derived, only the corresponding DerivedCfg property is populated. The other two properties remain null. +In marketData a public readonly parameter DerivedCfg contains the three possible DerivedCfg types. In case the MarketData is Derived, only one of the three types is populated. The other two are null. -Updating the DerivedCfg can be performed with `UpdateDerivedConfiguration` on MarketData. A validation will be done on the existing DerivedCfg of the MarketData, that should be not null and with same type as the update. +```csharp +marketData.DerivedCfg.DerivedCfgCoalesce +marketData.DerivedCfg.DerivedCfgSum +marketData.DerivedCfg.DerivedCfgMuv +``` + +Updating the DerivedCfg can be performed with `UpdateDerivedConfiguration` on MarketData. A validation will be done on the existing DerivedCfg of the MarketData, that should be not null and with same type as the one used for the update. ```csharp var derivedCfgUpdate = new DerivedCfgCoalesce()