Exemple #1
0
        public void CalculateArbitrationTests_26()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            Anx       anx     = new Anx();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook = askBook;
            anx.OrderBook  = bidBook;

            btce.TradeFee = 0.25m;
            anx.TradeFee  = 0.35m;

            askBook.Asks.Add(new Order(0.21482587m, 405.0m));

            bidBook.Bids.Add(new Order(0.35417808m, 410.0m));

            opportunity = hunter.CalculateArbitration(btce, anx, 0.12478543m, 25.01m, 0.01m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
            Assert.IsTrue(opportunity.BuyExchange == btce);
            Assert.IsTrue(opportunity.SellExchange == anx);
            Assert.IsTrue(opportunity.BuyPrice == 405m);
            Assert.IsTrue(opportunity.SellPrice == 410m);
            Assert.IsTrue(opportunity.BuyAmount == 0.06175308m);
            Assert.IsTrue(opportunity.SellAmount == 0.06159870m);
            Assert.IsTrue(opportunity.TotalBuyCost == 25.0099974m);
            Assert.IsTrue(opportunity.TotalSellCost == 25.1670728655m);
            Assert.IsTrue(opportunity.Profit == 0.1570754655m);
        }
Exemple #2
0
        public void BtceTradeFeeIsSet()
        {
            Btce btce = new Btce();

            Assert.IsTrue(btce.TradeFee > 0);
            Assert.IsTrue(btce.TradeFeeAsDecimal > 0);
        }
Exemple #3
0
        public void CalculateArbitrationTests_19()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            Anx       anx     = new Anx();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook = askBook;
            anx.OrderBook  = bidBook;

            btce.TradeFee = 0.25m;
            anx.TradeFee  = 0.35m;

            askBook.Asks.Add(new Order(1.0m, 405.0m));

            bidBook.Bids.Add(new Order(0.5m, 410.0m));

            opportunity = hunter.CalculateArbitration(btce, anx, 99m, 50m, 0.01m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
            Assert.IsTrue(opportunity.BuyExchange == btce);
            Assert.IsTrue(opportunity.SellExchange == anx);
            Assert.IsTrue(opportunity.BuyPrice == 405m);
            Assert.IsTrue(opportunity.SellPrice == 410m);
            Assert.IsTrue(opportunity.BuyAmount == 0.12345679m);
            Assert.IsTrue(opportunity.SellAmount == 0.12314815m);
            Assert.IsTrue(opportunity.TotalBuyCost == 49.99999995m);
            Assert.IsTrue(opportunity.TotalSellCost == 50.31402390475m);
            Assert.IsTrue(opportunity.Profit == 0.31402395475m);
        }
Exemple #4
0
        public void CalculateArbitrationTests_24()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            Anx       anx     = new Anx();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook = askBook;
            anx.OrderBook  = bidBook;

            btce.TradeFee = 0.25m;
            anx.TradeFee  = 0.35m;

            askBook.Asks.Add(new Order(0.21482587m, 405.0m));

            bidBook.Bids.Add(new Order(0.35417808m, 410.0m));

            opportunity = hunter.CalculateArbitration(btce, anx, 1000m, 2000m, 0.01m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
            Assert.IsTrue(opportunity.BuyExchange == btce);
            Assert.IsTrue(opportunity.SellExchange == anx);
            Assert.IsTrue(opportunity.BuyPrice == 405m);
            Assert.IsTrue(opportunity.SellPrice == 410m);
            Assert.IsTrue(opportunity.BuyAmount == 0.21482587m);
            Assert.IsTrue(opportunity.SellAmount == 0.21428881m);
            Assert.IsTrue(opportunity.TotalBuyCost == 87.00447735m);
            Assert.IsTrue(opportunity.TotalSellCost == 87.55090765765m);
            Assert.IsTrue(opportunity.Profit == 0.54643030765m);
        }
Exemple #5
0
        public void CalculateArbitrationTests_18()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            Anx       anx     = new Anx();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook = askBook;
            anx.OrderBook  = bidBook;

            btce.TradeFee = 0.25m;
            anx.TradeFee  = 0.35m;

            askBook.Asks.Add(new Order(0.99999375m, 405.0m));

            bidBook.Bids.Add(new Order(0.9975m, 410.0m));

            opportunity = hunter.CalculateArbitration(btce, anx, 99m, 1000m, 0.01m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
            Assert.IsTrue(opportunity.BuyExchange == btce);
            Assert.IsTrue(opportunity.SellExchange == anx);
            Assert.IsTrue(opportunity.BuyPrice == 405m);
            Assert.IsTrue(opportunity.SellPrice == 410m);
            Assert.IsTrue(opportunity.BuyAmount == 0.99999375m);
            Assert.IsTrue(opportunity.SellAmount == 0.99749377m);
            Assert.IsTrue(opportunity.TotalBuyCost == 404.99746875m);
            Assert.IsTrue(opportunity.TotalSellCost == 407.54104214005m);
            Assert.IsTrue(opportunity.Profit == 2.54357339005m);
        }
Exemple #6
0
        public void CalculateArbitrationTests_16()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            Anx       anx     = new Anx();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook = askBook;
            anx.OrderBook  = bidBook;

            btce.TradeFee = 0.25m;
            anx.TradeFee  = 0.35m;

            askBook.Asks.Add(new Order(1.1m, 405.0m));

            bidBook.Bids.Add(new Order(1.0m, 410.0m));

            opportunity = hunter.CalculateArbitration(btce, anx, 0.45127846m, 200m, 0.01m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
            Assert.IsTrue(opportunity.BuyExchange == btce);
            Assert.IsTrue(opportunity.SellExchange == anx);
            Assert.IsTrue(opportunity.BuyPrice == 405m);
            Assert.IsTrue(opportunity.SellPrice == 410m);
            Assert.IsTrue(opportunity.BuyAmount == 0.45240665m);
            Assert.IsTrue(opportunity.SellAmount == 0.45127563m);
            Assert.IsTrue(opportunity.TotalBuyCost == 183.22469325m);
            Assert.IsTrue(opportunity.TotalSellCost == 184.37542777095m);
            Assert.IsTrue(opportunity.Profit == 1.15073452095m);
        }
Exemple #7
0
        public void CalculateArbitrationTests_15()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            Anx       anx     = new Anx();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook = askBook;
            anx.OrderBook  = bidBook;

            btce.TradeFee = 0.25m;
            anx.TradeFee  = 0.35m;

            askBook.Asks.Add(new Order(1.0m, 405.0m));

            bidBook.Bids.Add(new Order(1.04m, 410.0m));

            opportunity = hunter.CalculateArbitration(btce, anx, 99m, 10.9872m, 0.01m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
            Assert.IsTrue(opportunity.BuyExchange == btce);
            Assert.IsTrue(opportunity.SellExchange == anx);
            Assert.IsTrue(opportunity.BuyPrice == 405m);
            Assert.IsTrue(opportunity.SellPrice == 410m);
            Assert.IsTrue(opportunity.BuyAmount == 0.02712888m);
            Assert.IsTrue(opportunity.SellAmount == 0.02706106m);
            Assert.IsTrue(opportunity.TotalBuyCost == 10.9871964m);
            Assert.IsTrue(opportunity.TotalSellCost == 11.0562019789m);
            Assert.IsTrue(opportunity.Profit == 0.0690055789m);
        }
Exemple #8
0
        public void BtceBalanceUpdateTest()
        {
            Btce btce = new Btce(FiatType.Usd);

            //If there is any problem connecting to the exchange, this will throw an error.
            btce.UpdateBalances();
        }
Exemple #9
0
        public void BtceGetTradeListTest()
        {
            Btce btce = new Btce();

            //If there is any problem connecting to the exchange, this will throw an error. The returning dictionary should never be null,
            //as there is a history on the account.
            Assert.IsNotNull(btce.GetTradeList(), "List of past trades could not be pulled from BTC-E.");
        }
Exemple #10
0
        public void BtceUpdateOrderBookTest()
        {
            Btce btce = new Btce();

            //If there is any problem connecting to the exchange, this will throw an error.
            btce.UpdateOrderBook(1);

            //This assumes that the exchange has at least 1 order on each side. Technically this can give a false negative, but it's unlikely.
            Assert.IsTrue(btce.OrderBook.Asks.Count == 1);
            Assert.IsTrue(btce.OrderBook.Bids.Count == 1);
        }
Exemple #11
0
        public void SimulateBuyTestHappyPath()
        {
            decimal initialPaymiumBtcBalance  = 9.98763156454m;
            decimal initialPaymiumFiatBalance = 245.63m;
            decimal buyBtcAmount = 0.5687489732163m;
            decimal totalBuyCost = 45.21m;

            Btce btce = new Btce();

            btce.AvailableBtc  = initialPaymiumBtcBalance;
            btce.AvailableFiat = initialPaymiumFiatBalance;
            btce.SimulatedBuy(buyBtcAmount, totalBuyCost);

            Assert.IsTrue(btce.AvailableBtc == initialPaymiumBtcBalance + buyBtcAmount);
            Assert.IsTrue(btce.AvailableFiat == initialPaymiumFiatBalance - totalBuyCost);
        }
Exemple #12
0
        public void SimulateSellTestHappyPath()
        {
            decimal initialPaymiumBtcBalance  = 4.689812874641m;
            decimal initialPaymiumFiatBalance = 148.28m;
            decimal sellBtcAmount             = 0.987316397m;
            decimal totalSellCost             = 45.21m;

            Btce btce = new Btce();

            btce.AvailableBtc  = initialPaymiumBtcBalance;
            btce.AvailableFiat = initialPaymiumFiatBalance;
            btce.SimulatedSell(sellBtcAmount, totalSellCost);

            Assert.IsTrue(btce.AvailableBtc == initialPaymiumBtcBalance - sellBtcAmount);
            Assert.IsTrue(btce.AvailableFiat == initialPaymiumFiatBalance + totalSellCost);
        }
Exemple #13
0
        public void CompleteTransfersTest()
        {
            Btce    buyExchange  = new Btce();
            Kraken  sellExchange = new Kraken();
            decimal initialBuyExchangeBTCBalance  = 10;
            decimal initialSellExchangeBTCBalance = 10;

            buyExchange.AvailableBtc  = initialBuyExchangeBTCBalance;
            sellExchange.AvailableBtc = initialSellExchangeBTCBalance;

            List <Transfer> transferList = new List <Transfer>();
            Transfer        transfer1    = TransferManager.OnTimeTransfer_Simulate(buyExchange, sellExchange, 2.01m);;
            Transfer        transfer2    = TransferManager.OnTimeTransfer_Simulate(buyExchange, sellExchange, 1.022m);
            Transfer        transfer3    = TransferManager.OnTimeTransfer_Simulate(buyExchange, sellExchange, 0.654968519m);
            Transfer        transfer4    = TransferManager.OnTimeTransfer_Simulate(buyExchange, sellExchange, 3.6549871m);

            try
            {
                transfer1.CompleteDateTime = DateTime.Now.AddHours(-1);
                transfer4.CompleteDateTime = DateTime.Now.AddHours(-1);

                //Calcualte expected balances
                decimal expectedBuyExchangeBtcBalance   = initialBuyExchangeBTCBalance - transfer1.Amount - transfer2.Amount - transfer3.Amount - transfer4.Amount;
                decimal expectedSellExchangeBtcTransfer = transfer1.Amount - transfer1.OriginExchange.BtcTransferFee + transfer2.Amount - transfer2.OriginExchange.BtcTransferFee + transfer3.Amount - transfer3.OriginExchange.BtcTransferFee + transfer4.Amount - transfer4.OriginExchange.BtcTransferFee;
                decimal expectedSellExchangeBtcBalance  = initialSellExchangeBTCBalance + transfer1.Amount - transfer1.OriginExchange.BtcTransferFee + transfer4.Amount - transfer4.OriginExchange.BtcTransferFee;
                decimal expectedSellBtcInTransferAfterTransferCompletion = transfer2.Amount - transfer2.OriginExchange.BtcTransferFee + transfer3.Amount - transfer3.OriginExchange.BtcTransferFee;

                //Make sure the btce has been placed in transit and removed from the origin exchange
                Assert.IsTrue(buyExchange.AvailableBtc == expectedBuyExchangeBtcBalance);
                Assert.IsTrue(sellExchange.BTCInTransfer == expectedSellExchangeBtcTransfer);

                transferList.Add(transfer1);
                transferList.Add(transfer2);
                transferList.Add(transfer3);
                transferList.Add(transfer4);

                TransferManager.CompleteTransfers(transferList);

                Assert.IsTrue(transferList.Count == 2);
                Assert.IsTrue(sellExchange.AvailableBtc == expectedSellExchangeBtcBalance);
                Assert.IsTrue(sellExchange.BTCInTransfer == expectedSellBtcInTransferAfterTransferCompletion);
            }
            finally
            {
                DatabaseManager.ExecuteNonQuery(String.Format("delete from TRANSFER where ID in ({0}, {1}, {2}, {3})", DatabaseManager.FormatNullableIntegerForDb((transfer1.Id)), DatabaseManager.FormatNullableIntegerForDb((transfer2.Id)), DatabaseManager.FormatNullableIntegerForDb((transfer3.Id)), DatabaseManager.FormatNullableIntegerForDb((transfer4.Id))));
            }
        }
        private async void UpdatePrice()
        {
            Status      = "Fetching Bitcoin Price...";
            Errors      = string.Empty;
            IsReceiving = true;

            PriceApi api = null;

            switch (Settings.SelectedPriceApi)
            {
            case PriceServiceNames.Bitfinex:
                api = new Bitfinex();
                break;

            case PriceServiceNames.Btce:
                api = new Btce();
                break;

            case PriceServiceNames.Coindesk:
                api = new Coindesk();
                break;

            default:
                api = new Bitfinex();
                break;
            }

            Response <decimal> resp = await api.UpdatePriceAsync();

            if (resp.Errors.Any())
            {
                Errors = resp.Errors.GetErrors();
                Status = "Encountered an error!";
            }
            else
            {
                Settings.BitcoinPriceInUSD = resp.Result;
                RaisePropertyChanged("BitcoinPrice");
                Status = "Price Update Success!";
            }

            IsReceiving = false;
        }
Exemple #15
0
        public void BtceOrdersDoNotGetCheckedForFulfillment()
        {
            int    requiredRoundsForValidarion = 3;
            Btce   btce   = new Btce();
            Kraken kraken = new Kraken();
            List <BaseExchange> exchangeList = new List <BaseExchange>();

            exchangeList.Add(btce);
            exchangeList.Add(kraken);

            OpportunityValidator   opportunityValidator = new OpportunityValidator(requiredRoundsForValidarion, exchangeList);
            ArbitrationOpportunity testOpportunity      = new ArbitrationOpportunity(btce, btce, 0.1m, 10.22m, 1.022m, 20.00m, 2.00m, 78m, 1);

            //Set the buy and sell order id to 0 to mimic the behavior of immediately filled orders for Btce.
            testOpportunity.BuyOrderId  = "0";
            testOpportunity.SellOrderId = "0";

            //This will throw an error if it is not correct.
            opportunityValidator.ValidateArbitrationTradeOrderExecution(testOpportunity);
        }
Exemple #16
0
        static void Main(string[] args)
        {
            var apiSecret = "Your_Secret";
            var apiKey    = "Your_Key";
            var btce      = new Btce(apiKey, apiSecret);

            var depth = btce.BtcUsd.Fee();
            //var t = depth;
            //var info = btce.GetInfo();

            //var activeOrders = btce.ActiveOrders(Pair.btc_usd);

            //var transactionsHistory = btce.TransactionsHistory();

            // var tradeHistory = btce.TradeHistory();

            // var trade = btce.Trade(Pair.btc_usd, OperationType.buy, 10.1, 1.1);

            // var cancelOrder = btce.CancelOrder(222052617);
        }
Exemple #17
0
        public void CalculateArbitrationTests_14()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            Anx       anx     = new Anx();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook = askBook;
            anx.OrderBook  = bidBook;

            //Test case 13: Amount is floor rounded to the minimum of the two exchanges
            btce.TradeFee = 0.25m;
            anx.TradeFee  = 0.35m;

            askBook.Asks.Add(new Order(1.1m, 398.0m));
            askBook.Asks.Add(new Order(0.8m, 402.0m));
            askBook.Asks.Add(new Order(1.0m, 410.0m));

            bidBook.Bids.Add(new Order(0.65479204m, 401.0m));
            bidBook.Bids.Add(new Order(1.0m, 399m));
            bidBook.Bids.Add(new Order(2.8m, 398m));

            opportunity = hunter.CalculateArbitration(btce, anx, 99m, 999999m, 0.30m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
            Assert.IsTrue(opportunity.BuyExchange == btce);
            Assert.IsTrue(opportunity.SellExchange == anx);
            Assert.IsTrue(opportunity.BuyPrice == 398m);
            Assert.IsTrue(opportunity.SellPrice == 401m);
            Assert.IsTrue(opportunity.BuyAmount == 0.65642902m);
            Assert.IsTrue(opportunity.SellAmount == 0.65478795m);
            Assert.IsTrue(opportunity.TotalBuyCost == 261.25874996m);
            Assert.IsTrue(opportunity.TotalSellCost == 261.650973062175m);
            Assert.IsTrue(opportunity.Profit == 0.392223102175m);
        }
Exemple #18
0
        public void Current()
        {
            ArbitrationHunter hunter = new ArbitrationHunter(null);
            Btce btce = new Btce();
            ArbitrationOpportunity opportunity;
            ItBit     itBit   = new ItBit();
            OrderBook askBook = new OrderBook();
            OrderBook bidBook = new OrderBook();

            btce.OrderBook  = askBook;
            itBit.OrderBook = bidBook;

            btce.TradeFee  = 0.2m;
            itBit.TradeFee = 0.2m;

            askBook.Asks.Add(new Order(43.01161324m, 400.00m));

            bidBook.Bids.Add(new Order(50m, 403.00m));

            opportunity = hunter.CalculateArbitration(btce, itBit, 0.1m, 20.00m, 0.01m, false);

            //Make sure opportunity was found correctly
            Assert.IsTrue(opportunity != null);
        }
        public void PersistArbitrationOpportunity()
        {
            //Arbitraty test values
            decimal  buyAmount         = 351.654316m;
            decimal  sellAmount        = 351.654316m;
            decimal  buyPrice          = 409.21m;
            decimal  sellPrice         = 410.87m;
            decimal  totalBuyCost      = 1201.14m;
            decimal  totalSellCost     = 1301.54m;
            decimal  profit            = totalSellCost - totalBuyCost;
            string   buyOrderId        = "Abc-123";
            string   sellOrderId       = "123-Abc";
            DateTime executionDateTime = DateTime.Now;

            Bitstamp               buyExchange          = new Bitstamp();
            Btce                   sellExchange         = new Btce();
            ArbitrationRun         testRun              = null;
            ArbitrationRun         updateTestRun        = null;
            ArbitrationOpportunity testArbitrationTrade = null;

            try
            {
                testRun              = TestsHelper.CreateArbitrationRun();
                updateTestRun        = TestsHelper.CreateArbitrationRun();
                testArbitrationTrade = new ArbitrationOpportunity(buyExchange, sellExchange);

                testArbitrationTrade.BuyAmount         = buyAmount;
                testArbitrationTrade.SellAmount        = sellAmount;
                testArbitrationTrade.ArbitrationRunId  = testRun.Id.Value;
                testArbitrationTrade.BuyPrice          = buyPrice;
                testArbitrationTrade.ExecutionDateTime = executionDateTime;
                testArbitrationTrade.Profit            = profit;
                testArbitrationTrade.SellPrice         = sellPrice;
                testArbitrationTrade.TotalBuyCost      = totalBuyCost;
                testArbitrationTrade.TotalSellCost     = totalSellCost;
                testArbitrationTrade.BuyOrderId        = buyOrderId;
                testArbitrationTrade.SellOrderId       = sellOrderId;

                //Now that the arbitration trade has been set up, save it to the db.
                testArbitrationTrade.PersistToDb();

                //Ensure an id was set after the initial insert
                Assert.IsTrue(testArbitrationTrade.Id != null);

                string insertFetchSql = string.Format("" +
                                                      "select " +
                                                      "   ID, " +
                                                      "   CREATE_DATETIME, " +
                                                      "   LAST_MODIFIED_DATETIME " +
                                                      "from " +
                                                      "   ARBITRATION_TRADE " +
                                                      "where " +
                                                      "   ID = {0} AND " +
                                                      "   BUY_AMOUNT = {1} AND " +
                                                      "   BUY_PRICE = {2} AND " +
                                                      "   SELL_PRICE = {3} AND" +
                                                      "   TOTAL_BUY_COST = {4} AND " +
                                                      "   TOTAL_SELL_COST = {5} AND " +
                                                      "   PROFIT = {6} AND " +
                                                      "   EXECUTION_DATETIME = '{7}' AND " +
                                                      "   SELL_EXCHANGE = '{8}' AND " +
                                                      "   BUY_EXCHANGE = '{9}' AND " +
                                                      "   BUY_ORDER_ID = '{10}' AND " +
                                                      "   SELL_ORDER_ID = '{11}' AND " +
                                                      "   ARBITRATION_RUN_ID = {12} AND " +
                                                      "   SELL_AMOUNT = {13}", testArbitrationTrade.Id.Value, buyAmount, buyPrice, sellPrice, totalBuyCost, totalSellCost, profit, executionDateTime.ToString("yyy-MM-dd HH:mm:ss"), sellExchange.Name, buyExchange.Name, buyOrderId, sellOrderId, testRun.Id.Value, sellAmount);

                //Ensure all the values were properly inserted.
                DataTable result = DatabaseManager.ExecuteQuery(insertFetchSql);
                Assert.IsTrue(result != null && Convert.ToInt32(result.Rows[0]["ID"]) == testArbitrationTrade.Id.Value);

                //Create some bogus dates for CREATE_DATETIME and LAST_MODIFIED_DATETIME
                DateTime createDateTime       = new DateTime(2014, 1, 1, 13, 25, 05);
                DateTime lastModifiedDateTime = new DateTime(2014, 1, 1, 13, 25, 05);

                //In order to test that CREATE_DATETIME and LAST_MODIFIED_DATETIME behave properly on updates, need to put some bogus data in there:
                DatabaseManager.ExecuteNonQuery(string.Format("update ARBITRATION_TRADE set CREATE_DATETIME = '{0}', LAST_MODIFIED_DATETIME = '{1}' where ID = {2}", createDateTime.ToString("yyy-MM-dd HH:mm:ss"), lastModifiedDateTime.ToString("yyy-MM-dd HH:mm:ss"), testArbitrationTrade.Id.Value));

                //Update properties with arbitraty test values.
                buyAmount         = 103264798.175785743216m;
                sellAmount        = 103264798.175785743216m;
                buyPrice          = 1.02m;
                sellPrice         = 10.02m;
                totalBuyCost      = 2.01m;
                totalSellCost     = 18.01m;
                profit            = totalSellCost - totalBuyCost;
                executionDateTime = DateTime.Now;
                buyOrderId        = "Choctaw-47";
                sellOrderId       = "Apache-48";

                //Update arbitration trade to have new values
                testArbitrationTrade.BuyAmount         = buyAmount;
                testArbitrationTrade.SellAmount        = sellAmount;
                testArbitrationTrade.ArbitrationRunId  = updateTestRun.Id.Value;
                testArbitrationTrade.BuyPrice          = buyPrice;
                testArbitrationTrade.ExecutionDateTime = executionDateTime;
                testArbitrationTrade.Profit            = profit;
                testArbitrationTrade.SellPrice         = sellPrice;
                testArbitrationTrade.TotalBuyCost      = totalBuyCost;
                testArbitrationTrade.TotalSellCost     = totalSellCost;
                testArbitrationTrade.BuyOrderId        = buyOrderId;
                testArbitrationTrade.SellOrderId       = sellOrderId;

                testArbitrationTrade.PersistToDb();

                string updateFetchSql = string.Format("" +
                                                      "select " +
                                                      "   ID, " +
                                                      "   CREATE_DATETIME, " +
                                                      "   LAST_MODIFIED_DATETIME " +
                                                      "from " +
                                                      "   ARBITRATION_TRADE " +
                                                      "where " +
                                                      "   ID = {0} AND " +
                                                      "   BUY_AMOUNT = {1} AND " +
                                                      "   BUY_PRICE = {2} AND " +
                                                      "   SELL_PRICE = {3} AND" +
                                                      "   TOTAL_BUY_COST = {4} AND " +
                                                      "   TOTAL_SELL_COST = {5} AND " +
                                                      "   PROFIT = {6} AND " +
                                                      "   EXECUTION_DATETIME = '{7}' AND " +
                                                      "   SELL_EXCHANGE = '{8}' AND " +
                                                      "   BUY_EXCHANGE = '{9}' AND " +
                                                      "   BUY_ORDER_ID = '{10}' AND " +
                                                      "   SELL_ORDER_ID = '{11}' AND " +
                                                      "   ARBITRATION_RUN_ID = {12} AND " +
                                                      "   SELL_AMOUNT = {13}", testArbitrationTrade.Id.Value, buyAmount, buyPrice, sellPrice, totalBuyCost, totalSellCost, profit, executionDateTime.ToString("yyy-MM-dd HH:mm:ss"), sellExchange.Name, buyExchange.Name, buyOrderId, sellOrderId, updateTestRun.Id.Value, sellAmount);

                result = DatabaseManager.ExecuteQuery(updateFetchSql);

                //Ensure a record was found with all the updated values
                Assert.IsTrue(result != null);

                //Ensure the CREATE_DATETIME is the same, but the LAST_MODIFIED_DATETIME is different
                Assert.IsTrue(createDateTime == (DateTime)result.Rows[0]["CREATE_DATETIME"]);
                Assert.IsTrue(lastModifiedDateTime != (DateTime)result.Rows[0]["LAST_MODIFIED_DATETIME"]);
            }
            finally
            {
                //Remove test data from the database
                if (testArbitrationTrade.Id != null)
                {
                    TestsHelper.DeleteArbitrationTrade(testArbitrationTrade.Id.Value);
                }

                if (testRun.Id != null)
                {
                    TestsHelper.DeleteArbitrationRun(testRun.Id.Value);
                }

                if (updateTestRun.Id != null)
                {
                    TestsHelper.DeleteArbitrationRun(updateTestRun.Id.Value);
                }
            }
        }
Exemple #20
0
        public void BtceIsOrderFulfilledReturnsTrueForCompletedOrder()
        {
            Btce btce = new Btce();

            Assert.IsTrue(btce.IsOrderFulfilled("957745724"));
        }
Exemple #21
0
        public void BtceGetAllOpenOrdersTest()
        {
            Btce btce = new Btce();

            List <Dictionary <string, dynamic> > openOrders = btce.GetAllOpenOrders();
        }
Exemple #22
0
        public void SimulatedSellTestWithNoFiat()
        {
            Btce btce = new Btce();

            btce.SimulatedSell(2.0m, 234.00m);
        }
Exemple #23
0
        public void SimulatedBuyTestWithNotBtc()
        {
            Btce btce = new Btce();

            btce.SimulatedBuy(2.0m, 234.00m);
        }