Exemplo n.º 1
0
        public async Task <WebCallResult <BtcTurkPlacedOrder> > PlaceOrderAsync(string pairSymbol, decimal quantity, BtcTurkOrderSide orderSide, BtcTurkOrderMethod orderMethod, decimal?price = null, decimal?stopPrice = null, string clientOrderId = null, CancellationToken ct = default)
        {
            var parameters = new Dictionary <string, object>
            {
                { "pairSymbol", pairSymbol },
                { "quantity", quantity.ToString(CultureInfo.InvariantCulture) },
                { "orderType", JsonConvert.SerializeObject(orderSide, new OrderSideConverter(false)) },
                { "orderMethod", JsonConvert.SerializeObject(orderMethod, new OrderMethodConverter(false)) },
            };

            parameters.AddOptionalParameter("price", price?.ToString(CultureInfo.InvariantCulture));
            parameters.AddOptionalParameter("stopPrice", stopPrice?.ToString(CultureInfo.InvariantCulture));
            parameters.AddOptionalParameter("newClientOrderId", clientOrderId);

            var result = await SendRequest <BtcTurkApiResponse <BtcTurkPlacedOrder> >(GetUrl(V1_Order_Endpoint, V1), method : HttpMethod.Post, cancellationToken : ct, parameters : parameters, checkResult : false, signed : true).ConfigureAwait(false);

            if (!result.Success)
            {
                return(WebCallResult <BtcTurkPlacedOrder> .CreateErrorResult(result.ResponseStatusCode, result.ResponseHeaders, result.Error));
            }

            return(new WebCallResult <BtcTurkPlacedOrder>(result.ResponseStatusCode, result.ResponseHeaders, result.Data.Data, null));
        }
Exemplo n.º 2
0
 public WebCallResult <BtcTurkPlacedOrder> PlaceOrder(string pairSymbol, decimal quantity, BtcTurkOrderSide orderSide, BtcTurkOrderMethod orderMethod, decimal?price = null, decimal?stopPrice = null, string clientOrderId = null, CancellationToken ct = default) => PlaceOrderAsync(pairSymbol, quantity, orderSide, orderMethod, price, stopPrice, clientOrderId, ct).Result;