public void CalculateWithNullSeriesSizeShouldReturn0() { var series = GenerateTimeSeries.From(new double[] {}); var mdd = new MaximumDrawdownCriterion(); Assert.AreEqual(0d, mdd.Calculate(series, new TradingRecord()), TaTestsUtils.TaOffset); }
public void BetterThan() { IAnalysisCriterion criterion = new MaximumDrawdownCriterion(); Assert.IsTrue(criterion.BetterThan(0.9, 1.5)); Assert.IsFalse(criterion.BetterThan(1.2, 0.4)); }
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); }
public void CalculateWithNullSeriesSizeShouldReturn0() { MockTimeSeries series = new MockTimeSeries(new decimal[0]); MaximumDrawdownCriterion mdd = new MaximumDrawdownCriterion(); Assert.AreEqual(0M, mdd.Calculate(series, new BaseTradingRecord())); }
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())); }
public void BetterThan() { AbstractAnalysisCriterion criterion = new MaximumDrawdownCriterion(); Assert.IsTrue(criterion.BetterThan(0.9M, 1.5M)); Assert.IsFalse(criterion.BetterThan(1.2M, 0.4M)); }
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); }
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); }
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); }
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); }
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); }
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)); }
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)); }
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)); }
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)); }