Пример #1
0
        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);
        }
Пример #2
0
        public void TradeForExchangeWithLowestBtc_Rule_OpportunityList_Empty()
        {
            List <BaseExchange> exchangeList = CreateExchangeList(new Anx(), new Btce(), new Bitstamp());

            //Pass in a non empty exchange list
            ArbitrationOpportunity result = ArbitrationFilter.TradeForExchangeWithLowestBtc(new List <ArbitrationOpportunity>(), exchangeList);

            Assert.IsTrue(result == null);
        }
Пример #3
0
        public void TradeForExchangeWithLowestBtc_Rule_ExchangeList_Empty()
        {
            //Create a list of opportunities with at least 1 opportunity
            List <ArbitrationOpportunity> opportunityList = new List <ArbitrationOpportunity>();
            ArbitrationOpportunity        opportunity1    = new ArbitrationOpportunity(new Anx(), new Bitstamp());

            opportunityList.Add(opportunity1);

            ArbitrationOpportunity result = ArbitrationFilter.TradeForExchangeWithLowestBtc(opportunityList, new List <BaseExchange>());

            Assert.IsTrue(result == null);
        }
Пример #4
0
 public void TradeForExchangeWithLowestBtc_Rule_ExchangeList_Null()
 {
     ArbitrationOpportunity result = ArbitrationFilter.TradeForExchangeWithLowestBtc(new List <ArbitrationOpportunity>(), null);
 }
Пример #5
0
 public void TradeForExchangeWithLowestBtc_Rule_OpportunityList_Null()
 {
     ArbitrationOpportunity result = ArbitrationFilter.TradeForExchangeWithLowestBtc(null, new List <BaseExchange>());
 }