Exemplo n.º 1
0
        public void CalculateWithNullSeriesSizeShouldReturn0()
        {
            var series = GenerateTimeSeries.From(new double[] {});
            var mdd    = new MaximumDrawdownCriterion();

            Assert.AreEqual(0d, mdd.Calculate(series, new TradingRecord()), TaTestsUtils.TaOffset);
        }
Exemplo n.º 2
0
        public void CalculateWithNullSeriesSizeShouldReturn0()
        {
            MockTimeSeries           series = new MockTimeSeries(new decimal[0]);
            MaximumDrawdownCriterion mdd    = new MaximumDrawdownCriterion();

            Assert.AreEqual(0M, mdd.Calculate(series, new BaseTradingRecord()));
        }
Exemplo n.º 3
0
        public void CalculateWithNoTrades()
        {
            var series = GenerateTimeSeries.From(1, 2, 3, 6, 5, 20, 3);
            var mdd    = new MaximumDrawdownCriterion();

            Assert.AreEqual(0d, mdd.Calculate(series, new TradingRecord()), TaTestsUtils.TaOffset);
        }
Exemplo n.º 4
0
        public void CalculateWithNoTrades()
        {
            MockTimeSeries           series = new MockTimeSeries(1, 2, 3, 6, 5, 20, 3);
            MaximumDrawdownCriterion mdd    = new MaximumDrawdownCriterion();

            Assert.AreEqual(0M, mdd.Calculate(series, new BaseTradingRecord()));
        }
Exemplo n.º 5
0
        public void WithSimpleTrades()
        {
            var series        = GenerateTimeSeries.From(1, 10, 5, 6, 1);
            var mdd           = new MaximumDrawdownCriterion();
            var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(1), Order.BuyAt(1), Order.SellAt(2), Order.BuyAt(2), Order.SellAt(3), Order.BuyAt(3), Order.SellAt(4));

            Assert.AreEqual(.9d, mdd.Calculate(series, tradingRecord), TaTestsUtils.TaOffset);
        }
Exemplo n.º 6
0
        public void WithTradesThatSellBeforeBuying()
        {
            var series        = GenerateTimeSeries.From(2, 1, 3, 5, 6, 3, 20);
            var mdd           = new MaximumDrawdownCriterion();
            var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(1), Order.BuyAt(3), Order.SellAt(4), Order.SellAt(5), Order.BuyAt(6));

            Assert.AreEqual(.91, mdd.Calculate(series, tradingRecord), TaTestsUtils.TaOffset);
        }
Exemplo n.º 7
0
        public void CalculateShouldWork()
        {
            var series        = GenerateTimeSeries.From(1, 2, 3, 6, 5, 20, 3);
            var mdd           = new MaximumDrawdownCriterion();
            var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(1), Order.BuyAt(3), Order.SellAt(4), Order.BuyAt(5), Order.SellAt(6));

            Assert.AreEqual(.875d, mdd.Calculate(series, tradingRecord), TaTestsUtils.TaOffset);
        }
Exemplo n.º 8
0
        public void CalculateWithOnlyGains()
        {
            var series        = GenerateTimeSeries.From(1, 2, 3, 6, 8, 20, 3);
            var mdd           = new MaximumDrawdownCriterion();
            var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(1), Order.BuyAt(2), Order.SellAt(5));

            Assert.AreEqual(0d, mdd.Calculate(series, tradingRecord), TaTestsUtils.TaOffset);
        }
Exemplo n.º 9
0
        public void WithConstrainedTimeSeries()
        {
            var sampleSeries  = GenerateTimeSeries.From(new double[] { 1, 1, 1, 1, 1, 10, 5, 6, 1, 1, 1 });
            var subSeries     = sampleSeries.Subseries(4, 8);
            var mdd           = new MaximumDrawdownCriterion();
            var tradingRecord = new TradingRecord(Order.BuyAt(4), Order.SellAt(5), Order.BuyAt(5), Order.SellAt(6), Order.BuyAt(6), Order.SellAt(7), Order.BuyAt(7), Order.SellAt(8));

            Assert.AreEqual(.9d, mdd.Calculate(subSeries, tradingRecord), TaTestsUtils.TaOffset);
        }
Exemplo n.º 10
0
        public void CalculateWithOnlyGains()
        {
            MockTimeSeries           series        = new MockTimeSeries(1, 2, 3, 6, 8, 20, 3);
            MaximumDrawdownCriterion mdd           = new MaximumDrawdownCriterion();
            ITradingRecord           tradingRecord = new BaseTradingRecord(
                Order.buyAt(0, series), Order.sellAt(1, series),
                Order.buyAt(2, series), Order.sellAt(5, series));

            Assert.AreEqual(0M, mdd.Calculate(series, tradingRecord));
        }
Exemplo n.º 11
0
        public void WithTradesThatSellBeforeBuying()
        {
            MockTimeSeries           series        = new MockTimeSeries(2, 1, 3, 5, 6, 3, 20);
            MaximumDrawdownCriterion mdd           = new MaximumDrawdownCriterion();
            ITradingRecord           tradingRecord = new BaseTradingRecord(
                Order.buyAt(0, series), Order.sellAt(1, series),
                Order.buyAt(3, series), Order.sellAt(4, series),
                Order.sellAt(5, series), Order.buyAt(6, series));

            Assert.AreEqual(.91M, mdd.Calculate(series, tradingRecord));
        }
Exemplo n.º 12
0
        public void CalculateShouldWork()
        {
            MockTimeSeries           series        = new MockTimeSeries(1, 2, 3, 6, 5, 20, 3);
            MaximumDrawdownCriterion mdd           = new MaximumDrawdownCriterion();
            ITradingRecord           tradingRecord = new BaseTradingRecord(
                Order.buyAt(0, series), Order.sellAt(1, series),
                Order.buyAt(3, series), Order.sellAt(4, series),
                Order.buyAt(5, series), Order.sellAt(6, series));

            Assert.AreEqual(.875M, mdd.Calculate(series, tradingRecord));
        }
Exemplo n.º 13
0
        public void WithSimpleTrades()
        {
            MockTimeSeries           series        = new MockTimeSeries(1, 10, 5, 6, 1);
            MaximumDrawdownCriterion mdd           = new MaximumDrawdownCriterion();
            ITradingRecord           tradingRecord = new BaseTradingRecord(
                Order.buyAt(0, series), Order.sellAt(1, series),
                Order.buyAt(1, series), Order.sellAt(2, series),
                Order.buyAt(2, series), Order.sellAt(3, series),
                Order.buyAt(3, series), Order.sellAt(4, series));

            Assert.AreEqual(.9M, mdd.Calculate(series, tradingRecord));
        }