Exemple #1
0
        public void UpdateExistingOhlcPoints_Day_NoExisting_ModifiesNothing()
        {
            // Act
            var existingPoints = new List <OhlcInstantChartPoint>();

            var updatedPoints = new List <OhlcInstantChartPoint>
            {
                new OhlcInstantChartPoint
                {
                    X     = Instant.Add(Instant.FromUnixTimeTicks(0), Duration.FromDays(100)),
                    Open  = 1000,
                    Low   = 500,
                    High  = 2000,
                    Close = 1500
                }
            };

            // Arrange
            var component = new SeriesChartComponent(null);

            component.UpdateExistingOhlcPoints(existingPoints, updatedPoints, Resolution.Daily);

            // assert
            Assert.AreEqual(1, updatedPoints.Count);
        }
Exemple #2
0
        public void UpdateExistingOhlcPoints_Day_SameDayExisting_ModifiesSameDay()
        {
            // Act
            var existingPoint = new OhlcInstantChartPoint
            {
                X     = Instant.Add(Instant.FromUnixTimeTicks(0), Duration.FromDays(100)),
                Open  = 1000,
                Low   = 500,
                High  = 2000,
                Close = 1500
            };

            var existingPoints = new List <OhlcInstantChartPoint>()
            {
                existingPoint
            };

            var updatedPoints = new List <OhlcInstantChartPoint>
            {
                new OhlcInstantChartPoint
                {
                    X     = Instant.Add(Instant.FromUnixTimeTicks(0), Duration.FromDays(100)),
                    Open  = 1500,
                    Low   = 250,
                    High  = 2500,
                    Close = 2000
                }
            };

            // Arrange
            var component = new SeriesChartComponent(null);

            component.UpdateExistingOhlcPoints(existingPoints, updatedPoints, Resolution.Daily);

            // assert
            Assert.AreEqual(1000, existingPoint.Open);  // Original open should be used
            Assert.AreEqual(250, existingPoint.Low);    // Lowest low should be used
            Assert.AreEqual(2500, existingPoint.High);  // Highest high should be used
            Assert.AreEqual(2000, existingPoint.Close); // Latest close should be used

            Assert.AreEqual(0, updatedPoints.Count);    // Modified entry should be removed from updates
        }