public void CalculateWithOneTrade()
        {
            var trade           = new Trade();
            var tradesCriterion = new NumberOfTradesCriterion();

            Assert.AreEqual(1d, tradesCriterion.Calculate(null, trade), TaTestsUtils.TaOffset);
        }
        public void CalculateWithOneTrade()
        {
            Trade trade = new Trade();
            NumberOfTradesCriterion tradesCriterion = new NumberOfTradesCriterion();

            Assert.AreEqual(1M, tradesCriterion.Calculate(null, trade));
        }
        public void CalculateWithNoTrades()
        {
            var series = GenerateTimeSeries.From(100, 105, 110, 100, 95, 105);

            IAnalysisCriterion buyAndHold = new NumberOfTradesCriterion();

            Assert.AreEqual(0d, buyAndHold.Calculate(series, new TradingRecord()), TaTestsUtils.TaOffset);
        }
        public void CalculateWithNoTrades()
        {
            MockTimeSeries series = new MockTimeSeries(100, 105, 110, 100, 95, 105);

            AbstractAnalysisCriterion buyAndHold = new NumberOfTradesCriterion();

            Assert.AreEqual(0M, buyAndHold.Calculate(series, new BaseTradingRecord()));
        }
        public void CalculateWithTwoTrades()
        {
            var series        = GenerateTimeSeries.From(100, 105, 110, 100, 95, 105);
            var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(2), Order.BuyAt(3), Order.SellAt(5));

            IAnalysisCriterion buyAndHold = new NumberOfTradesCriterion();

            Assert.AreEqual(2d, buyAndHold.Calculate(series, tradingRecord), TaTestsUtils.TaOffset);
        }
        public void CalculateWithTwoTrades()
        {
            MockTimeSeries series        = new MockTimeSeries(100, 105, 110, 100, 95, 105);
            ITradingRecord tradingRecord = new BaseTradingRecord(
                Order.buyAt(0, series), Order.sellAt(2, series),
                Order.buyAt(3, series), Order.sellAt(5, series));

            AbstractAnalysisCriterion buyAndHold = new NumberOfTradesCriterion();

            Assert.AreEqual(2M, buyAndHold.Calculate(series, tradingRecord));
        }