Пример #1
0
 public void NameSaves()
 {
     // just testing that we get the right name out
     const string name = "name";
     var target = new TestIndicator(name);
     Assert.AreEqual(name, target.Name);
 }
Пример #2
0
        public void NameSaves()
        {
            // just testing that we get the right name out
            const string name   = "name";
            var          target = new TestIndicator(name);

            Assert.AreEqual(name, target.Name);
        }
Пример #3
0
        public void ThrowsOnPastTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            target.Update(new IndicatorDataPoint(time, 1m));
            target.Update(new IndicatorDataPoint(time.AddMilliseconds(-1), 2m));
        }
Пример #4
0
        public void ThrowsOnDifferentDataType()
        {
            var target = new TestIndicator();

            Assert.Throws <ArgumentException>(() =>
            {
                target.Update(new Tick());
            }, "expected to be of type");
        }
Пример #5
0
        public void ThrowsOnPastTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            target.Update(new IndicatorDataPoint(time, 1m));
            target.Update(new IndicatorDataPoint(time.AddMilliseconds(-1), 2m));
        }
Пример #6
0
        public void ThrowsOnPastTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            target.Update(new IndicatorDataPoint(time, TimeZone.Utc, 1m));

            Action act = () => target.Update(new IndicatorDataPoint(time.AddMilliseconds(-1), TimeZone.Utc, 2m));

            act.ShouldThrow <ArgumentException>()
            .Where(x => x.Message.StartsWith("This is a forward only indicator:"));
        }
Пример #7
0
        public void EqualsMethodShouldNotThrowExceptions()
        {
            var indicator = new TestIndicator();
            var res       = true;

            try {
                res = indicator.Equals(new Exception(""));
            } catch (InvalidCastException) {
                Assert.Fail();
            }

            Assert.IsFalse(res);
        }
Пример #8
0
        public void PassesOnDuplicateTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            const decimal value1 = 1m;
            var data = new IndicatorDataPoint(time, value1);
            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);

            // this won't update because we told it to ignore duplicate
            // data based on time
            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);
        }
Пример #9
0
        public void PassesOnDuplicateTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            const decimal value1 = 1m;
            var           data   = new IndicatorDataPoint(time, value1);

            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);

            // this won't update because we told it to ignore duplicate
            // data based on time
            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);
        }
Пример #10
0
        private static void TestComparisonOperators <TValue>()
        {
            var indicator = new TestIndicator();

            TestOperator(indicator, default(TValue), "GreaterThan", true, false);
            TestOperator(indicator, default(TValue), "GreaterThan", false, false);
            TestOperator(indicator, default(TValue), "GreaterThanOrEqual", true, true);
            TestOperator(indicator, default(TValue), "GreaterThanOrEqual", false, true);
            TestOperator(indicator, default(TValue), "LessThan", true, false);
            TestOperator(indicator, default(TValue), "LessThan", false, false);
            TestOperator(indicator, default(TValue), "LessThanOrEqual", true, true);
            TestOperator(indicator, default(TValue), "LessThanOrEqual", false, true);
            TestOperator(indicator, default(TValue), "Equality", true, true);
            TestOperator(indicator, default(TValue), "Equality", false, true);
            TestOperator(indicator, default(TValue), "Inequality", true, false);
            TestOperator(indicator, default(TValue), "Inequality", false, false);
        }
Пример #11
0
        public void GetCurrentView_ReturnsArrayOfGrayCharactersMadeOfStringArray()
        {
            // arrange
            var indicator = new TestIndicator();

            // act
            var result = indicator.GetCurrentView();

            // assert
            var expectedResult = new[, ]
            {
                {
                    new ColoredCharacter('H', ConsoleColor.Gray),
                    new ColoredCharacter('w', ConsoleColor.Gray),
                },
                {
                    new ColoredCharacter('e', ConsoleColor.Gray),
                    new ColoredCharacter('o', ConsoleColor.Gray),
                },
                {
                    new ColoredCharacter('l', ConsoleColor.Gray),
                    new ColoredCharacter('r', ConsoleColor.Gray),
                },
                {
                    new ColoredCharacter('l', ConsoleColor.Gray),
                    new ColoredCharacter('l', ConsoleColor.Gray),
                },
                {
                    new ColoredCharacter('o', ConsoleColor.Gray),
                    new ColoredCharacter('d', ConsoleColor.Gray),
                },
                {
                    default(ColoredCharacter),
                    new ColoredCharacter('!', ConsoleColor.Gray),
                },
            };

            for (var x = 0; x < expectedResult.GetLength(0); x++)
            {
                for (var y = 0; y < expectedResult.GetLength(1); y++)
                {
                    Assert.AreEqual(expectedResult[x, y], result[x, y]);
                }
            }
        }
Пример #12
0
        public void UpdatesProperly()
        {
            // we want to make sure the initialized value is the default value
            // for a datapoint, and also verify the our indicator updates as we
            // expect it to, in this case, it should return identity
            var target = new TestIndicator();

            Assert.AreEqual(DateTime.MinValue, target.Current.Time);
            Assert.AreEqual(0m, target.Current.Value);

            var time = DateTime.UtcNow;
            var data = new IndicatorDataPoint(time, 1m);

            target.Update(data);
            Assert.AreEqual(1m, target.Current.Value);

            target.Update(new IndicatorDataPoint(time.AddMilliseconds(1), 2m));
            Assert.AreEqual(2m, target.Current.Value);
        }
Пример #13
0
        public void UpdatesProperly()
        {
            // we want to make sure the initialized value is the default value
            // for a datapoint, and also verify the our indicator updates as we
            // expect it to, in this case, it should return identity
            var target = new TestIndicator();

            Assert.AreEqual(DateTime.MinValue, target.Current.Time);
            Assert.AreEqual(0m, target.Current.Value);

            var time = DateTime.UtcNow;
            var data = new IndicatorDataPoint(time, 1m);

            target.Update(data);
            Assert.AreEqual(1m, target.Current.Value);

            target.Update(new IndicatorDataPoint(time.AddMilliseconds(1), 2m));
            Assert.AreEqual(2m, target.Current.Value);
        }
        public static WalkerIndicator getIndicatorByString(string input)
        {
            string[] args;

            if (input.Contains("_") == false)
            {
                args = new string[] { input }
            }
            ;
            else
            {
                args = input.Split('_');
            }

            WalkerIndicator selected = null;

            if (args[0] == BolingerBandsIndicator.Name)
            {
                selected = new BolingerBandsIndicator(long.Parse(args[1]), double.Parse(args[2]));
            }

            if (args[0] == MACDContinousIndicator.Name)
            {
                selected = new MACDContinousIndicator(long.Parse(args[1]), long.Parse(args[2]), long.Parse(args[3]));
            }

            if (args[0] == MACDIndicator.Name)
            {
                selected = new MACDIndicator(long.Parse(args[1]), long.Parse(args[2]), long.Parse(args[3]));
            }

            if (args[0] == MovingAverageIndicator.Name)
            {
                selected = new MovingAverageIndicator(long.Parse(args[1]));
            }

            if (args[0] == MovingAveragePriceSubtractionIndicator.Name)
            {
                selected = new MovingAveragePriceSubtractionIndicator(long.Parse(args[1]));
            }

            if (args[0] == MovingAverageSubtractionIndicator.Name)
            {
                selected = new MovingAverageSubtractionIndicator(long.Parse(args[1]), long.Parse(args[2]));
            }

            if (args[0] == MovingAverageSubtractionCrossoverIndicator.Name)
            {
                selected = new MovingAverageSubtractionCrossoverIndicator(long.Parse(args[1]), long.Parse(args[2]));
            }

            if (args[0] == RangeIndicator.Name)
            {
                selected = new RangeIndicator(long.Parse(args[1]));
            }

            if (args[0] == RSIBorderCrossoverIndicator.Name)
            {
                selected = new RSIBorderCrossoverIndicator(long.Parse(args[1]), double.Parse(args[2]));
            }

            if (args[0] == RSIBorderIndicator.Name)
            {
                selected = new RSIBorderIndicator(long.Parse(args[1]), double.Parse(args[2]));
            }

            if (args[0] == RSIIndicator.Name)
            {
                selected = new RSIIndicator(long.Parse(args[1]));
            }

            if (args[0] == RSIMACrossoverContinousIndicator.Name)
            {
                selected = new RSIMACrossoverContinousIndicator(long.Parse(args[1]), long.Parse(args[2]));
            }

            if (args[0] == RSIMACrossoverIndicator.Name)
            {
                selected = new RSIMACrossoverIndicator(long.Parse(args[1]), long.Parse(args[2]));
            }

            if (args[0] == StandartDeviationIndicator.Name)
            {
                selected = new StandartDeviationIndicator(long.Parse(args[1]));
            }

            if (args[0] == StochBorderCrossoverIndicator.Name)
            {
                selected = new StochBorderCrossoverIndicator(long.Parse(args[1]), double.Parse(args[2]));
            }

            if (args[0] == StochBorderIndicator.Name)
            {
                selected = new StochBorderIndicator(long.Parse(args[1]), double.Parse(args[2]));
            }

            if (args[0] == StochIndicator.Name)
            {
                selected = new StochIndicator(long.Parse(args[1]));
            }

            if (args[0] == TestIndicator.Name)
            {
                selected = new TestIndicator();
            }

            if (args[0] == TimeDayOfWeekIndicator.Name)
            {
                selected = new TimeDayOfWeekIndicator();
            }

            if (args[0] == TimeOfDayIndicator.Name)
            {
                selected = new TimeOfDayIndicator();
            }

            if (args[0] == TimeOpeningHoursIndicator.Name)
            {
                selected = new TimeOpeningHoursIndicator();
            }

            if (args[0] == VolumeAtPriceIndicator.Name)
            {
                selected = new VolumeAtPriceIndicator(long.Parse(args[1]), double.Parse(args[2]), long.Parse(args[3]));
            }

            if (selected == null)
            {
                throw new Exception("Name not found: " + args[0]);
            }

            if (selected.getName() != input)
            {
                throw new Exception(input + " != " + selected.getName());
            }

            return(selected);
        }
 private void SetupIndicators()
 {
     const string title = "Тест №";
     int number = 1;
     foreach (Guid testId in this.controller.Task.Tests)
     {
         TestIndicator testIndicator = new TestIndicator(testId, title + number);
         this.indicators.Add(testIndicator);
         this.TestsPanel.Children.Add(testIndicator);
         number++;
     }
 }
Пример #16
0
 private void RunHistory()
 {
     History   = _history = new TestHistory(this);
     Indicator = _indicator = new TestIndicator();
 }
Пример #17
0
        public void ThrowsOnDifferentDataType()
        {
            var target = new TestIndicator();

            target.Update(new Tick());
        }