public void ValidationCheck_UpsertCurveData_MarketAssesment_with_Auction() { using (var httpTest = new HttpTest()) { var mds = new MarketDataService(_cfg); //Create invalid MarketAssessment by populating AutioonRows var data = new UpsertCurveData() { ID = new MarketDataIdentifier("test", "testName"), Timezone = "CET", DownloadedAt = SystemClock.Instance.GetCurrentInstant(), AuctionRows = new Dictionary <LocalDateTime, AuctionBids>(), MarketAssessment = new Dictionary <LocalDateTime, IDictionary <string, MarketAssessmentValue> >() }; var localDateTime = new LocalDateTime(2018, 09, 24, 00, 00); var bid = new List <AuctionBidValue>(); var offer = new List <AuctionBidValue>(); bid.Add(new AuctionBidValue(100, 10)); offer.Add(new AuctionBidValue(120, 12)); data.AuctionRows.Add(localDateTime, new AuctionBids(localDateTime, bid.ToArray(), offer.ToArray())); data.MarketAssessment.Add(localDateTime, new Dictionary <string, MarketAssessmentValue>()); data.MarketAssessment[localDateTime].Add("test", new MarketAssessmentValue()); var ex = Assert.Throws <ArgumentException>(() => mds.UpsertCurveDataAsync(data).ConfigureAwait(true).GetAwaiter().GetResult()); Assert.AreEqual("UpsertCurveData Auctions must be NULL if MarketAssessment are Valorized", ex.Message); } }
public void ValidationCheck_UpsertCurveData_Versioned_with_BidAsk() { using (var httpTest = new HttpTest()) { var mds = new MarketDataService(_cfg); //Create invalid Version by populating BidAsk var data = new UpsertCurveData() { ID = new MarketDataIdentifier("test", "testName"), Timezone = "CET", DownloadedAt = SystemClock.Instance.GetCurrentInstant(), Rows = new Dictionary <LocalDateTime, double?>() { { new LocalDateTime(2018, 01, 01, 0, 0), 21.4 } }, BidAsk = new Dictionary <LocalDateTime, IDictionary <string, BidAskValue> >(), Version = new LocalDateTime(2018, 09, 25, 12, 0, 0, 123).PlusNanoseconds(100) }; var localDateTime = new LocalDateTime(2018, 09, 24, 00, 00); data.BidAsk.Add(localDateTime, new Dictionary <string, BidAskValue>()); data.BidAsk[localDateTime].Add("test", new BidAskValue()); var ex = Assert.Throws <ArgumentException>(() => mds.UpsertCurveDataAsync(data).ConfigureAwait(true).GetAwaiter().GetResult()); Assert.AreEqual("UpsertCurveData BidAsk must be NULL if Rows are Valorized", ex.Message); } }
public void UpsertCurve_UpsertCurveDataAsync_Versioned() { using (var httpTest = new HttpTest()) { var mds = new MarketDataService(_cfg); //Create Version var data = new UpsertCurveData() { ID = new MarketDataIdentifier("test", "testName"), Timezone = "CET", DownloadedAt = SystemClock.Instance.GetCurrentInstant(), Rows = new Dictionary <LocalDateTime, double?>() { { new LocalDateTime(2018, 01, 01, 0, 0), 21.4 } }, Version = new LocalDateTime(2018, 09, 25, 12, 0, 0, 123).PlusNanoseconds(100) }; mds.UpsertCurveDataAsync(data).ConfigureAwait(true).GetAwaiter().GetResult(); httpTest.ShouldHaveCalledPath($"{_cfg.BaseAddress}v2.1/marketdata/upsertdata") .WithVerb(HttpMethod.Post) .Times(1); } }
public void UpsertCurve_UpsertCurveDataAsync_Auction() { using (var httpTest = new HttpTest()) { var mds = new MarketDataService(_cfg); var data = new UpsertCurveData() { ID = new MarketDataIdentifier("test", "testName"), Timezone = "CET", DownloadedAt = SystemClock.Instance.GetCurrentInstant(), AuctionRows = new Dictionary <LocalDateTime, AuctionBids>() }; var localDateTime = new LocalDateTime(2018, 09, 24, 00, 00); var bid = new List <AuctionBidValue>(); var offer = new List <AuctionBidValue>(); bid.Add(new AuctionBidValue(100, 10)); offer.Add(new AuctionBidValue(120, 12)); data.AuctionRows.Add(localDateTime, new AuctionBids(localDateTime, bid.ToArray(), offer.ToArray())); mds.UpsertCurveDataAsync(data).ConfigureAwait(true).GetAwaiter().GetResult(); httpTest.ShouldHaveCalledPath($"{_cfg.BaseAddress}v2.1/marketdata/upsertdata") .WithVerb(HttpMethod.Post) .Times(1); } }
public void UpsertCurve_UpsertCurveDataAsync_MarketAssessment() { using (var httpTest = new HttpTest()) { var mds = new MarketDataService(_cfg); var data = new UpsertCurveData() { ID = new MarketDataIdentifier("test", "testName"), Timezone = "CET", DownloadedAt = SystemClock.Instance.GetCurrentInstant(), MarketAssessment = new Dictionary <LocalDateTime, IDictionary <string, MarketAssessmentValue> >() }; var localDateTime = new LocalDateTime(2018, 09, 24, 00, 00); data.MarketAssessment.Add(localDateTime, new Dictionary <string, MarketAssessmentValue>()); data.MarketAssessment[localDateTime].Add("test", new MarketAssessmentValue()); mds.UpsertCurveDataAsync(data).ConfigureAwait(true).GetAwaiter().GetResult(); httpTest.ShouldHaveCalledPath($"{_cfg.BaseAddress}v2.1/marketdata/upsertdata") .WithVerb(HttpMethod.Post) .Times(1); } }
/// <summary> /// Upsert the curve data supplied in <paramref name="data"/> /// </summary> /// <remarks> /// Unified controller for saving curve data /// ID, TimeZone and DownloadedAt fields should not be null /// - Market Data Assessment: MarketAssessment field should not be null, other fields should be null /// - Actual TimeSerie: Rows field should not be null, other fields should be null- /// - Versioned TimeSerie: Rows and Version fields should not be null, other fields should be null /// </remarks> /// <param name="data"> /// An object that represents MarketDataAssessment, ActualTimeSerie or VersionedTimeSerie /// </param> /// <param name="ctk">CancellationToken</param> /// <returns></returns> public Task UpsertCurveDataAsync(UpsertCurveData data, CancellationToken ctk = default) { data.Validate(); var url = "/marketdata/upsertdata"; return(_client.Exec(HttpMethod.Post, url, data, ctk: ctk)); }
/// <summary> /// MarketData Save /// </summary> /// <remarks> /// Save the Data of the current MarketData /// </remarks> /// <param name="downloadedAt">Downloaded at</param> /// <param name="deferCommandExecution">DeferCommandExecution</param> /// <param name="deferDataGeneration">DeferDataGeneration</param> /// <param name="keepNulls">if <see langword="false"/> nulls are ignored (server-side). That is the default behaviour.</param> /// <param name="ctk">The Cancellation Token</param> /// <returns></returns> public async Task Save(Instant downloadedAt, bool deferCommandExecution = false, bool deferDataGeneration = true, bool keepNulls = false, CancellationToken ctk = default) { Ensure.Any.IsNotNull(_entity); if (Bids.Any()) { var data = new UpsertCurveData(_identifier) { Timezone = _entity.OriginalGranularity.IsTimeGranularity() ? "UTC" : _entity.OriginalTimezone, DownloadedAt = downloadedAt, AuctionRows = _bids, DeferCommandExecution = deferCommandExecution, DeferDataGeneration = deferDataGeneration, KeepNulls = keepNulls }; await _marketDataService.UpsertCurveDataAsync(data, ctk); } }
/// <summary> /// MarketData Save /// </summary> /// <remarks> /// Save the Data of the current MarketData /// </remarks> /// <param name="downloadedAt">Downloaded at</param> /// <param name="deferCommandExecution">DeferCommandExecution</param> /// <param name="deferDataGeneration">DeferDataGeneration</param> /// <param name="keepNulls">if <see langword="false"/> nulls are ignored (server-side). That is the default behaviour.</param> /// <param name="ctk">The Cancellation Token</param> /// <returns></returns> public async Task Save(Instant downloadedAt, bool deferCommandExecution = false, bool deferDataGeneration = true, bool keepNulls = false, CancellationToken ctk = default) { Ensure.Any.IsNotNull(_entity); if (BidAsks.Any()) { var data = new UpsertCurveData(_identifier) { Timezone = _entity.OriginalGranularity.IsTimeGranularity() ? "UTC" : _entity.OriginalTimezone, DownloadedAt = downloadedAt, DeferCommandExecution = deferCommandExecution, BidAsk = new Dictionary <LocalDateTime, IDictionary <string, BidAskValue> >(), KeepNulls = keepNulls }; foreach (var reportTime in BidAsks.GroupBy(g => g.ReportTime)) { var BidAsks = reportTime.ToDictionary(key => key.Product.ToString(), value => value.Value); data.BidAsk.Add(reportTime.Key, BidAsks); } await _marketDataService.UpsertCurveDataAsync(data, ctk); } }
/// <summary> /// MarketData Save /// </summary> /// <remarks> /// Save the Data of the current MarketData /// </remarks> /// <param name="downloadedAt">Downloaded at</param> /// <param name="deferCommandExecution">DeferCommandExecution</param> /// <param name="deferDataGeneration">DeferDataGeneration</param> /// <param name="keepNulls">if <see langword="false"/> nulls are ignored (server-side). That is the default behaviour.</param> /// <param name="ctk">The Cancellation Token</param> /// <returns></returns> public async Task Save(Instant downloadedAt, bool deferCommandExecution = false, bool deferDataGeneration = true, bool keepNulls = false, CancellationToken ctk = default) { if (!SelectedVersion.HasValue) { throw new VersionedTimeSerieException("No Version has been selected to save Data"); } if (Values.Any()) { var data = new UpsertCurveData(_identifier, SelectedVersion.Value) { Timezone = _entity.OriginalGranularity.IsTimeGranularity() ? "UTC" : _entity.OriginalTimezone, DownloadedAt = downloadedAt, Rows = _values, DeferCommandExecution = deferCommandExecution, DeferDataGeneration = deferDataGeneration, KeepNulls = keepNulls }; await _marketDataService.UpsertCurveDataAsync(data, ctk); } //else // _logger.Warn("No Data to be saved."); }
public Task UpsertCurveDataAsync(UpsertCurveData data, CancellationToken ctk = default) { throw new NotImplementedException(); }