Exemplo n.º 1
0
        public void CumulativePAndLWithoutParameters()
        {
            List <CumulativeDatedPAndL> capitalsForGivenStrategy = _capitalService.GetCumulativePAndLByDate(new PAndLRequestModel {
                Region = "", StartDate = ""
            });

            List <CumulativeDatedPAndL> expectedCumulativePandL = new List <CumulativeDatedPAndL> {
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-01-01"), Value = 50
                },
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-01-02"), Value = 115
                },
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-01-03"), Value = 115
                },
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-01-04"), Value = 215
                },
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-01-07"), Value = 230
                },
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-01-08"), Value = 240
                },
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-02-02"), Value = 295
                },
                new CumulativeDatedPAndL {
                    Region = "EU", Date = DateTime.Parse("2017-03-10"), Value = 375
                },
                new CumulativeDatedPAndL {
                    Region = "US", Date = DateTime.Parse("2017-01-01"), Value = 120
                },
                new CumulativeDatedPAndL {
                    Region = "US", Date = DateTime.Parse("2017-01-02"), Value = 130
                },
                new CumulativeDatedPAndL {
                    Region = "US", Date = DateTime.Parse("2017-01-04"), Value = 290
                },
            };

            CollectionAssert.AreEquivalent(expectedCumulativePandL, capitalsForGivenStrategy);
        }
Exemplo n.º 2
0
        public IActionResult GetCumulativePAndL([FromQuery] PAndLRequestModel pAndLModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var resultingCumulatedPandLs = _capitalService.GetCumulativePAndLByDate(pAndLModel)
                                           .Select(cumulatedPandL => new
            {
                region        = cumulatedPandL.Region,
                date          = cumulatedPandL.Date.ToString("yyyy-MM-dd"),
                cumulativePnl = cumulatedPandL.Value
            });

            return(Ok(resultingCumulatedPandLs));
        }