public void MostProfitableTrade_Rule_OpportunityList_Null_Or_Empty() { ArbitrationOpportunity result = ArbitrationFilter.MostProfitableTrade(null); Assert.IsTrue(result == null); result = ArbitrationFilter.MostProfitableTrade(new List <ArbitrationOpportunity>()); Assert.IsTrue(result == null); }
public void TradeForExchangeWithLowestBtc_Rule_Validate() { List <BaseExchange> exchangeList = CreateExchangeList(new Anx(), new Bitstamp(), new Btce(), new ItBit(), new Btce(), new Kraken(), new Anx()); List <ArbitrationOpportunity> opportunityList = new List <ArbitrationOpportunity>(); ArbitrationOpportunity result; exchangeList[0].AvailableBtc = 0.6524987m; exchangeList[1].AvailableBtc = 0.9654689m; exchangeList[2].AvailableBtc = 1.069509478320m; exchangeList[3].AvailableBtc = 8.657849810m; exchangeList[4].AvailableBtc = 98.14651m; exchangeList[5].AvailableBtc = 9.98163521m; exchangeList[6].AvailableBtc = 0.0m; ArbitrationOpportunity opportunity1 = new ArbitrationOpportunity(exchangeList[0], exchangeList[1]); opportunity1.Profit = 7.87m; opportunity1.SellExchange = exchangeList[1]; opportunityList.Add(opportunity1); //Test case: only 1 opportunity in list result = ArbitrationFilter.MostProfitableTrade(opportunityList); Assert.IsTrue(result == opportunity1); ArbitrationOpportunity opportunity2 = new ArbitrationOpportunity(exchangeList[3], exchangeList[2]); opportunity2.Profit = 7.48m; opportunityList.Add(opportunity2); ArbitrationOpportunity opportunity3 = new ArbitrationOpportunity(exchangeList[5], exchangeList[0]); opportunity3.Profit = 4.57m; opportunityList.Add(opportunity3); ArbitrationOpportunity opportunity4 = new ArbitrationOpportunity(exchangeList[1], exchangeList[4]); opportunity4.Profit = 87.00m; opportunityList.Add(opportunity4); //Test case: no exchanges in the exchangelist map to any sell exchanges for an opportunity List <BaseExchange> exchangeList2 = CreateExchangeList(new ItBit(), new Kraken(), new ItBit(), new Kraken()); result = ArbitrationFilter.TradeForExchangeWithLowestBtc(opportunityList, exchangeList2); Assert.IsTrue(result == null); //Test case: Correct opportunity is in the middle of the opportunity list result = ArbitrationFilter.TradeForExchangeWithLowestBtc(opportunityList, exchangeList); Assert.IsTrue(result == opportunity3); //Test case: All opportunities have the same profit, opportunity for UseCryptos is returned because it has the least balance ArbitrationOpportunity opportunity5 = new ArbitrationOpportunity(exchangeList[1], exchangeList[6]); opportunity4.Profit = 87.00m; opportunityList.Add(opportunity5); result = ArbitrationFilter.TradeForExchangeWithLowestBtc(opportunityList, exchangeList); Assert.IsTrue(result == opportunity5); }
public void MostProfitableTrade_Rule_Validate() { List <BaseExchange> exchangeList = CreateExchangeList(new Anx(), new Bitstamp(), new Btce(), new ItBit(), new Kraken()); List <ArbitrationOpportunity> opportunityList = null; ArbitrationOpportunity result; result = ArbitrationFilter.MostProfitableTrade(opportunityList); Assert.IsTrue(result == null); opportunityList = new List <ArbitrationOpportunity>(); result = ArbitrationFilter.MostProfitableTrade(opportunityList); Assert.IsTrue(result == null); ArbitrationOpportunity opportunity1 = new ArbitrationOpportunity(exchangeList[0], exchangeList[1]); opportunity1.Profit = 7.87m; ArbitrationOpportunity opportunity2 = new ArbitrationOpportunity(exchangeList[3], exchangeList[2]); opportunity2.Profit = 7.48m; ArbitrationOpportunity opportunity3 = new ArbitrationOpportunity(exchangeList[4], exchangeList[3]); opportunity3.Profit = 4.57m; ArbitrationOpportunity opportunity4 = new ArbitrationOpportunity(exchangeList[1], exchangeList[4]); opportunity4.Profit = 87.00m; opportunityList.Add(opportunity1); opportunityList.Add(opportunity2); opportunityList.Add(opportunity3); opportunityList.Add(opportunity4); result = ArbitrationFilter.MostProfitableTrade(opportunityList); Assert.IsTrue(result == opportunity4); opportunity2.Profit = 87.01m; result = ArbitrationFilter.MostProfitableTrade(opportunityList); Assert.IsTrue(result == opportunity2); opportunity1.Profit = 1000.00m; result = ArbitrationFilter.MostProfitableTrade(opportunityList); Assert.IsTrue(result == opportunity1); }