Exemple #1
0
        /// <summary>
        /// Place new order
        /// </summary>
        /// <param name="symbol">Trading symbol</param>
        /// <param name="side">sell buy</param>
        /// <param name="quantity">Order quantity</param>
        /// <param name="price">Order price. Required for limit types.</param>
        /// <param name="stopPrice">Required for stop types.</param>
        /// <param name="timeInForce">Optional. Default - GDC. One of: GTC, IOC, FOK, Day, GTD</param>
        /// <param name="expireTime">Required for GTD timeInForce.</param>
        /// <param name="clientOrderId">Optional parameter, if skipped - will be generated by server. Uniqueness must be guaranteed within a single trading day, including all active orders.</param>
        /// <param name="strictValidate">Price and quantity will be checked that they increment within tick size and quantity step. See symbol tickSize and quantityIncrement</param>
        /// <param name="cancellationToken">Token for cancel operation</param>
        /// <returns></returns>
        public async Task <HitResponse <HitOrder> > CreateNewOrderAsync(string symbol, HitSide side, decimal quantity, decimal price = -1, decimal stopPrice = -1,
                                                                        HitTimeInForce timeInForce = HitTimeInForce.Day, DateTime expireTime = default, string clientOrderId = null, bool strictValidate = true, CancellationToken cancellationToken = default)
        {
            HitOrderType orderType = HitOrderType.Market;

            if (price != -1 && stopPrice == -1)
            {
                orderType = HitOrderType.Limit;
            }
            else if (price == -1 && stopPrice != -1)
            {
                orderType = HitOrderType.StopMarket;
            }
            else if (price != -1 && stopPrice != -1)
            {
                orderType = HitOrderType.StopLimit;
            }

            var parameters = new HitNewOrderParameters
            {
                ClientOrderId  = clientOrderId,
                Symbol         = symbol,
                Side           = side,
                OrderType      = orderType,
                TimeInForce    = timeInForce,
                Quantity       = quantity,
                Price          = price,
                StopPrice      = stopPrice,
                ExpireTime     = expireTime,
                StrictValidate = strictValidate
            };

            return(await this.MakeRequestAuthorizedAsync <HitOrder>(HttpMethod.Post, cancellationToken, "order", postParameters : parameters));
        }
Exemple #2
0
        private string ConvertOrderType(HitOrderType hitOrderType)
        {
            switch (hitOrderType)
            {
            case HitOrderType.Market:
            default:
                return(OrderType.Market);

            case HitOrderType.Limit:
                return(OrderType.Limit);

            case HitOrderType.StopMarket:
                return(OrderType.Stop);

            case HitOrderType.StopLimit:
                return(OrderType.StopLimit);
            }
        }