public void CalculateWithNoTicksShouldReturn1() { var _series = GenerateTimeSeries.From(100, 95, 100, 80, 85, 70); IAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(1d, averageProfit.Calculate(_series, new TradingRecord()), TaTestsUtils.TaOffset); }
public void CalculateWithNoBarsShouldReturn1() { series = new MockTimeSeries(100, 95, 100, 80, 85, 70); AbstractAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(1M, averageProfit.Calculate(series, new BaseTradingRecord())); }
public void CalculateWithOneTrade() { series = new MockTimeSeries(100, 105); Trade trade = new Trade(Order.buyAt(0, series), Order.sellAt(1, series)); AbstractAnalysisCriterion average = new AverageProfitCriterion(); Assert.AreEqual(1.0246950765959598383221038678M, average.Calculate(series, trade)); }
public void CalculateWithASimpleTrade() { series = new MockTimeSeries(100M, 105M, 110M, 100M, 95M, 105M); ITradingRecord tradingRecord = new BaseTradingRecord(Order.buyAt(0, series), Order.sellAt(2, series)); AbstractAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(1.0322801154563671592135852251M, averageProfit.Calculate(series, tradingRecord)); // (decimal)Math.Pow(110d / 100, 1d / 3) }
public void CalculateWithOneTrade() { var _series = GenerateTimeSeries.From(100, 105); var trade = new Trade(Order.BuyAt(0), Order.SellAt(1)); IAnalysisCriterion average = new AverageProfitCriterion(); Assert.AreEqual(Math.Pow(105d / 100, 1d / 2), average.Calculate(_series, trade), TaTestsUtils.TaOffset); }
public void CalculateOnlyWithLossTrades() { var _series = GenerateTimeSeries.From(100, 95, 100, 80, 85, 70); var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(1), Order.BuyAt(2), Order.SellAt(5)); IAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(Math.Pow(95d / 100 * 70d / 100, 1d / 6), averageProfit.Calculate(_series, tradingRecord), TaTestsUtils.TaOffset); }
public void CalculateWithASimpleTrade() { var _series = GenerateTimeSeries.From(100d, 105d, 110d, 100d, 95d, 105d); var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(2)); IAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(Math.Pow(110d / 100, 1d / 3), averageProfit.Calculate(_series, tradingRecord), TaTestsUtils.TaOffset); }
public void CalculateOnlyWithGainTrades() { var _series = GenerateTimeSeries.From(100d, 105d, 110d, 100d, 95d, 105d); var tradingRecord = new TradingRecord(Order.BuyAt(0), Order.SellAt(2), Order.BuyAt(3), Order.SellAt(5)); IAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(1.0243, TaTestsUtils.TaOffset, averageProfit.Calculate(_series, tradingRecord)); }
public void CalculateOnlyWithLossTrades() { series = new MockTimeSeries(100, 95, 100, 80, 85, 70); ITradingRecord tradingRecord = new BaseTradingRecord( Order.buyAt(0, series), Order.sellAt(1, series), Order.buyAt(2, series), Order.sellAt(5, series)); AbstractAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(0.934265419203025064794086149M, averageProfit.Calculate(series, tradingRecord)); // (decimal)Math.Pow(95d / 100 * 70d / 100, 1d / 6) }
public void CalculateOnlyWithGainTrades() { series = new MockTimeSeries(100M, 105M, 110M, 100M, 95M, 105M); ITradingRecord tradingRecord = new BaseTradingRecord( Order.buyAt(0, series), Order.sellAt(2, series), Order.buyAt(3, series), Order.sellAt(5, series)); AbstractAnalysisCriterion averageProfit = new AverageProfitCriterion(); Assert.AreEqual(1.0243074482606615553441174081M, averageProfit.Calculate(series, tradingRecord)); }