Exemplo n.º 1
0
        public void TestGetTotalReturn()
        {
            var gri       = new PeriodicalGrowthRateIndicator(this._closePrice, 5);
            var expResult = 0.9564;
            var result    = gri.TotalReturn;

            Assert.AreEqual(expResult, result, 0.01);
        }
Exemplo n.º 2
0
        public void testGetTotalReturn()
        {
            PeriodicalGrowthRateIndicator gri = new PeriodicalGrowthRateIndicator(this.closePrice, 5);
            decimal expResult = 0.9564173504382084670954600099M;
            decimal result    = gri.getTotalReturn();

            Assert.AreEqual(expResult, result);
        }
Exemplo n.º 3
0
        public void TestCalculation()
        {
            var gri = new PeriodicalGrowthRateIndicator(this._closePrice, 5);

            Assert.AreEqual(gri.GetValue(0), Decimal.NaNRenamed);
            Assert.AreEqual(gri.GetValue(4), Decimal.NaNRenamed);
            TaTestsUtils.AssertDecimalEquals(gri.GetValue(5), -0.0268);
            TaTestsUtils.AssertDecimalEquals(gri.GetValue(6), 0.0541);
            TaTestsUtils.AssertDecimalEquals(gri.GetValue(10), -0.0495);
            TaTestsUtils.AssertDecimalEquals(gri.GetValue(21), 0.2009);
            TaTestsUtils.AssertDecimalEquals(gri.GetValue(24), 0.0220);
            Assert.AreEqual(gri.GetValue(25), Decimal.NaNRenamed);
            Assert.AreEqual(gri.GetValue(26), Decimal.NaNRenamed);
        }
Exemplo n.º 4
0
        public void testCalculation()
        {
            PeriodicalGrowthRateIndicator gri = new PeriodicalGrowthRateIndicator(this.closePrice, 5);

            Assert.AreEqual(gri.GetValue(0), Decimals.NaN);
            Assert.AreEqual(gri.GetValue(4), Decimals.NaN);
            Assert.AreEqual(gri.GetValue(5), -0.0267887419464225161071549678M);
            Assert.AreEqual(gri.GetValue(6), 0.0541392592141212378648022663M);
            Assert.AreEqual(gri.GetValue(10), -0.0494773519163763066202090592M);
            Assert.AreEqual(gri.GetValue(21), 0.2008897443121698431008904856M);
            Assert.AreEqual(gri.GetValue(24), 0.0220305258907783215778947842M);
            Assert.AreEqual(gri.GetValue(25), Decimals.NaN);
            Assert.AreEqual(gri.GetValue(26), Decimals.NaN);
        }
Exemplo n.º 5
0
        public void TestStrategies()
        {
            var gri = new PeriodicalGrowthRateIndicator(this._closePrice, 5);

            // Rules
            IRule buyingRule  = new CrossedUpIndicatorRule(gri, Decimal.Zero);
            IRule sellingRule = new CrossedDownIndicatorRule(gri, Decimal.Zero);

            var strategy = new Strategy(buyingRule, sellingRule);

            // Check trades
            var result    = _mockdata.Run(strategy).TradeCount;
            var expResult = 3;

            Assert.AreEqual(expResult, result);
        }
Exemplo n.º 6
0
        public void testStrategies()
        {
            PeriodicalGrowthRateIndicator gri = new PeriodicalGrowthRateIndicator(this.closePrice, 5);

            // Rules
            IRule buyingRule  = new CrossedUpIndicatorRule(gri, Decimals.ZERO);
            IRule sellingRule = new CrossedDownIndicatorRule(gri, Decimals.ZERO);

            IStrategy strategy = new BaseStrategy(buyingRule, sellingRule);

            // Check trades
            int result    = seriesManager.Run(strategy).GetTradeCount();
            int expResult = 3;

            Assert.AreEqual(expResult, result);
        }