Exemplo n.º 1
0
        public void DetectResolution_Tick_ReturnsTicks()
        {
            // Arrange
            var series = new SeriesDefinition
            {
                SeriesType = Monitor.Model.Charting.SeriesType.Line,
                Values     = new List <InstantChartPoint>
                {
                    new InstantChartPoint
                    {
                        X = Instant.FromDateTimeUtc(new DateTime(2017, 01, 01, 0, 0, 0, DateTimeKind.Utc)),
                        Y = 100
                    },
                    new InstantChartPoint
                    {
                        X = Instant.FromDateTimeUtc(new DateTime(2017, 01, 01, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(0.1)),
                        Y = 100
                    }
                }
            };

            // Act
            var resolution = SeriesChartComponent.DetectResolution(series);

            // Assert
            Assert.AreEqual(Resolution.Tick, resolution);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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
        }