Exemplo n.º 1
0
        public void PostTradeTest()
        {
            var symbol      = "DCC-BTC";
            var tradeParams = new TradeParams
            {
                price    = 0.00000400M,
                quantity = 3000,
                symbol   = symbol,
                type     = "BUY"
            };

            var orderDetail = _repo.PostTrade(tradeParams).Result;

            Assert.True(orderDetail != null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Place a Trade
        /// </summary>
        /// <param name="tradeParams">TradeParams object</param>
        /// <returns>TradeResponse object</returns>
        public TradeResponse PlaceTrade(TradeParams tradeParams)
        {
            if (_thisExchange == Exchange.BINANCE)
            {
                var response = _bianceRepo.PostTrade(tradeParams).Result;

                return(response);
            }
            else if (_thisExchange == Exchange.GDAX)
            {
                // TODO use new trade api
                if (tradeParams.type == "STOPLOSS")
                {
                    var gdaxParams = new GDAXStopLossParams
                    {
                        stop       = "loss",
                        stop_price = tradeParams.price,
                        price      = tradeParams.price,
                        product_id = tradeParams.symbol,
                        side       = tradeParams.side.ToLower(),
                        size       = tradeParams.quantity,
                        post_only  = true
                    };
                    GDAXOrderResponse response = _gdaxRepo.PlaceStopLimit(gdaxParams).Result;

                    return(GdaxRestOrderResponseToTradeResponse(response));
                }
                else
                {
                    var gdaxParams = new GDAXTradeParams
                    {
                        price      = tradeParams.price,
                        product_id = tradeParams.symbol,
                        side       = tradeParams.side.ToLower(),
                        size       = tradeParams.quantity,
                        type       = "limit",
                        post_only  = true
                    };
                    GDAXOrderResponse response = _gdaxRepo.PlaceRestTrade(gdaxParams).Result;

                    return(GdaxRestOrderResponseToTradeResponse(response));
                }
            }
            else if (_thisExchange == Exchange.KUCOIN)
            {
                var response = _kuRepo.PostTrade(tradeParams).Result;

                if (response.msg.Equals("Operation succeeded.") || response.msg.Equals("OK"))
                {
                    var tradeResponse = new TradeResponse
                    {
                        clientOrderId = response.data["orderOid"],
                        origQty       = tradeParams.quantity,
                        price         = tradeParams.price,
                        side          = (TradeType)Enum.Parse(typeof(TradeType), tradeParams.side),
                        symbol        = tradeParams.symbol,
                        type          = (OrderType)Enum.Parse(typeof(OrderType), tradeParams.type)
                    };
                    return(tradeResponse);
                }
                return(null);
            }
            else
            {
                return(null);
            }
        }