Ejemplo n.º 1
0
        /// <summary>
        /// Use it to place margin order
        /// </summary>
        /// <param name="productId">product id</param>
        /// <param name="orderSide">order side</param>
        /// <param name="orderType">order type</param>
        /// <param name="leverageLevel">Valid levels: 2,4,5,10,25</param>
        /// <param name="fundingCurrency">Currency used to fund the trade with. Default is quoted currency (e.g a trade in BTCUSD product will use USD as the funding currency as default)</param>
        /// <param name="quantity"></param>
        /// <param name="price"></param>
        /// <param name="priceRange">use it to place TrailingStop order</param>
        /// <param name="orderDirection">one_direction, two_direction or netout.</param>
        /// <returns></returns>
        public async Task <CallResult <LiquidQuoinePlacedOrder> > PlaceMarginOrderAsync(int productId, OrderSide orderSide, OrderType orderType, LeverageLevel leverageLevel, string fundingCurrency, decimal quantity, decimal price, decimal?priceRange = null, OrderDirection?orderDirection = null)
        {
            var parameters = new Dictionary <string, object>()
            {
                { "order_type", JsonConvert.SerializeObject(orderType, new OrderTypeConverter()) },
                { "product_id", productId },
                { "side", JsonConvert.SerializeObject(orderSide, new OrderSideConverter()) },
                { "quantity", quantity },
                { "price", price },
                { "leverage_level", JsonConvert.SerializeObject(leverageLevel) },
                { "funding_currency", fundingCurrency },
            };

            if (priceRange.HasValue && orderType != OrderType.MarketWithRange)
            {
                return(new CallResult <LiquidQuoinePlacedOrder>(null, new ServerError("priceRange parameter can be used only for OrderType.MarketWithRange only, slippage of the order")));
            }
            parameters.AddOptionalParameter("price_range", priceRange);
            parameters.AddOptionalParameter("order_direction", orderDirection);
            var order = new Dictionary <string, object>()
            {
                { "order", parameters }
            };

            var result = await ExecuteRequest <LiquidQuoinePlacedOrder>(GetUrl(PlaceOrderEndpoint), "POST", order, true).ConfigureAwait(false);

            return(new CallResult <LiquidQuoinePlacedOrder>(result.Data, result.Error));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Use it to place margin order
 /// </summary>
 /// <param name="productId">product id</param>
 /// <param name="orderSide">order side</param>
 /// <param name="orderType">order type</param>
 /// <param name="leverageLevel">Valid levels: 2,4,5,10,25</param>
 /// <param name="fundingCurrency">Currency used to fund the trade with. Default is quoted currency (e.g a trade in BTCUSD product will use USD as the funding currency as default)</param>
 /// <param name="quantity"></param>
 /// <param name="price"></param>
 /// <param name="priceRange">use it to place TrailingStop order</param>
 /// <param name="orderDirection">one_direction, two_direction or netout.</param>
 /// <returns></returns>
 public CallResult <LiquidQuoinePlacedOrder> PlaceMarginOrder(int productId, OrderSide orderSide, OrderType orderType, LeverageLevel leverageLevel, string fundingCurrency, decimal quantity, decimal price, decimal?priceRange = null, OrderDirection?orderDirection = null)
 => PlaceMarginOrderAsync(productId, orderSide, orderType, leverageLevel, fundingCurrency, quantity, price, priceRange, orderDirection).Result;