Esempio n. 1
0
        public void GetAndCancelOpenTradeTest()
        {
            var symbol = "DCC-BTC";

            var orders = _repo.GetOpenOrders(symbol).Result;

            Assert.True(orders != null);

            if (orders.openBuys.Length > 0)
            {
                var orderId = orders.openBuys[0].orderId;

                var cancelDetail = _repo.DeleteTrade(symbol, orderId, orders.openBuys[0].type).Result;

                Assert.True(cancelDetail != null);
            }

            if (orders.openSells.Length > 0)
            {
                var orderId = orders.openSells[0].orderId;

                var cancelDetail = _repo.DeleteTrade(symbol, orderId, orders.openSells[0].type).Result;

                Assert.True(cancelDetail != null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Delete a trade
        /// </summary>
        /// <param name="tradeParams">CancelTradeParams object</param>
        /// <returns>TradeResponse object</returns>
        public TradeResponse DeleteTrade(CancelTradeParams tradeParams)
        {
            if (_thisExchange == Exchange.BINANCE)
            {
                var response = _bianceRepo.DeleteTrade(tradeParams).Result;

                return(response);
            }
            else if (_thisExchange == Exchange.GDAX)
            {
                var response = _gdaxRepo.CancelAllTradesRest().Result;

                var tradeResponse = new TradeResponse();

                if (response != null)
                {
                    tradeResponse.clientOrderId = response.OrderIds.ToList().FirstOrDefault().ToString();
                }

                return(tradeResponse);
            }
            else if (_thisExchange == Exchange.KUCOIN)
            {
                var response = _kuRepo.DeleteTrade(tradeParams.symbol, tradeParams.origClientOrderId, tradeParams.type).Result;

                var tradeResponse = new TradeResponse();

                if (response.code.Equals("OK"))
                {
                    tradeResponse.clientOrderId = tradeParams.origClientOrderId;
                }

                return(tradeResponse);
            }
            else
            {
                return(null);
            }
        }