Beispiel #1
0
        /// <summary>
        /// Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
        /// </summary>
        /// <param name="symbol">Symbol of Coin.</param>
        /// <param name="side">Order Side [BUY, SELL]</param>
        /// <param name="type">Order Type [LIMIT, MARKET, STOP_LOSS , STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER]</param>
        /// <param name="price">The price of the coin at the time the order is entered.</param>
        /// <param name="quantity">The quantity of assets to buy or sell in the limit order.</param>
        /// <param name="quoteOrderQty">MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty.
        /// Using BTCUSDT as an example:
        /// On the BUY side, the order will buy as many BTC as quoteOrderQty USDT can.
        /// On the SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT.
        /// </param>
        /// <param name="icebergQty">A conditional order to buy or sell a large amount of assets in smaller predetermined quantities in order to conceal the total order quantity.</param>
        /// <param name="stopPrice">When the asset’s price reaches the given stop price, the stop-limit order is executed to buy or sell the asset at the given limit price or better.</param>
        /// <param name="orderResponseType">ACK, RESULT or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.</param>
        /// <param name="timeInForce">Any order with an icebergQty MUST have timeInForce set to GTC.</param>
        /// <param name="recvWindow">The value cannot be greater than 60000</param>
        /// <returns></returns>
        public async Task <dynamic> TestNewOrder(string symbol, OrderSide side, OrderType type, decimal?price = null, decimal?quantity = null, decimal?quoteOrderQty = null, decimal?icebergQty = null, decimal?stopPrice = null, OrderResponseType?orderResponseType = OrderResponseType.ACK, TimeInForce timeInForce = TimeInForce.GTC, long?recvWindow = 5000)
        {
            var parameters = $"symbol={symbol.ToUpper()}&side={side.GetMemberAttr()}&type={type.GetMemberAttr()}&recvWindow={recvWindow}"
                             + ((type == OrderType.LIMIT || type == OrderType.STOP_LOSS_LIMIT || type == OrderType.TAKE_PROFIT_LIMIT) ? $"&timeInForce={timeInForce.GetMemberAttr()}" : "")
                             + ((type == OrderType.LIMIT || type == OrderType.MARKET || type == OrderType.STOP_LOSS || type == OrderType.STOP_LOSS_LIMIT || type == OrderType.TAKE_PROFIT || type == OrderType.TAKE_PROFIT_LIMIT || type == OrderType.LIMIT_MAKER) && quantity > 0m ? $"&quantity={quantity}" : "")
                             + ((type == OrderType.MARKET) && quoteOrderQty > 0m ? $"&quoteOrderQty={quoteOrderQty}" : "")
                             + ((type == OrderType.LIMIT || type == OrderType.STOP_LOSS_LIMIT || type == OrderType.TAKE_PROFIT_LIMIT || type == OrderType.LIMIT_MAKER) && price > 0m ? $"&price={price}" : "")
                             + ((type == OrderType.STOP_LOSS || type == OrderType.STOP_LOSS_LIMIT || type == OrderType.TAKE_PROFIT || type == OrderType.TAKE_PROFIT_LIMIT) && stopPrice > 0m ? $"&stopPrice={stopPrice}" : "")
                             + ((type == OrderType.LIMIT || type == OrderType.STOP_LOSS_LIMIT || type == OrderType.TAKE_PROFIT_LIMIT) && icebergQty > 0m ? $"&icebergQty={icebergQty}" : "")
                             + ((orderResponseType.HasValue) ? $"&newOrderRespType={orderResponseType.GetMemberAttr()}" : "");


            return(await _httpConfiguration.SendAsyncRequest <dynamic>(HttpMethod.Post, Endpoint.TestOrder, parameters, true));
        }