Пример #1
0
 public MatchAggregate(string tickerSymbol, decimal initialPrice = 0.0m,
                       double initialVolume = 0.0d, int sampleSize = DefaultSampleSize)
 {
     TickerSymbol = tickerSymbol;
     AvgPrice     = EMWAm.Init(sampleSize, initialPrice);
     AvgVolume    = EMWA.Init(sampleSize, initialVolume);
 }
        public void EMWA_should_diverge_with_different_alphas()
        {
            var e1 = EMWA.Init(10, 1);
            var e2 = EMWA.Init(25, 1);

            var percentages = new List <double>();

            foreach (var i in Enumerable.Range(2, 35))
            {
                e1 += i;
                e2 += i;
                percentages.Add(e1 % e2);
            }

            // differences should diverge over time
            percentages.All(x => x > 0.0d).Should().BeTrue();
        }
        public void EMWA_percentage_difference_order_matters()
        {
            var e1 = EMWA.Init(10, 1);
            var e2 = EMWA.Init(25, 1);

            foreach (var i in Enumerable.Range(2, 35))
            {
                e1 += i;
                e2 += i;
            }

            var p1 = e1 % e2;
            var p2 = e2 % e1;

            p1.Should().NotBe(p2);

            // in this scenario, p2 should be negative as it includes many more "smaller" values in its weight
            p2.Should().BeLessThan(p1);
        }