Example #1
0
        /// <summary>
        /// Create new order
        /// </summary>
        /// <param name="symbolName"> Trading symbol</param>
        /// <param name="quantity"> Order quantity</param>
        /// <param name="side">sell buy</param>
        /// <param name="type"></param>
        /// <param name="timeInForce">Time in force is a special instruction used when placing a trade to indicate how long an order will remain active before it is executed or expires </param>
        /// <param name="price"></param>
        /// <param name="stopPrice"></param>
        /// <param name="expireTime"></param>
        /// <param name="clientOrderId">Unique identifier for Order as assigned by trader. Uniqueness must be guaranteed within a single trading day, including all active orders.</param>
        /// <param name="strictValidate"></param>
        /// <returns></returns>
        public async Task <Order> PostOrders(string symbolName, string quantity,
                                             PublicEnum.EnTradingSide side = PublicEnum.EnTradingSide.buy,
                                             PublicEnum.EnTradingType type = PublicEnum.EnTradingType.limit,
                                             PublicEnum.EnTradingTimeInForce timeInForce = PublicEnum.EnTradingTimeInForce.GTC,
                                             string price         = null, string stopPrice    = null, string expireTime = null,
                                             string clientOrderId = null, bool strictValidate = false)
        {
            var request = new RestRequest("/api/2/order", Method.POST);

            request.AddParameter("symbol", symbolName, ParameterType.UrlSegment);
            request.AddParameter("quantity", quantity, ParameterType.UrlSegment);
            request.AddParameter("side", side, ParameterType.UrlSegment);
            request.AddParameter("type", type, ParameterType.UrlSegment);
            request.AddParameter("timeInForce", timeInForce, ParameterType.UrlSegment);
            if (!string.IsNullOrEmpty(price))
            {
                request.AddParameter("price", price, ParameterType.UrlSegment);
            }
            if (!string.IsNullOrEmpty(stopPrice))
            {
                request.AddParameter("stopPrice", stopPrice, ParameterType.UrlSegment);
            }
            if (!string.IsNullOrEmpty(expireTime))
            {
                request.AddParameter("expireTime", expireTime, ParameterType.UrlSegment);
            }
            if (!string.IsNullOrEmpty(clientOrderId))
            {
                request.AddParameter("clientOrderId", clientOrderId, ParameterType.UrlSegment);
            }
            request.AddParameter("strictValidate", strictValidate, ParameterType.UrlSegment);
            return(await _hitBtcRestApi.Execute(request));
        }
Example #2
0
 public async void NotificationActiveOrders(string id, string clientOrderId, string symbol,
                                            PublicEnum.EnTradingSide side,
                                            PublicEnum.EnStatus status,
                                            PublicEnum.EnTradingType type, PublicEnum.EnTradingTimeInForce timeInForce, string quantity, string price,
                                            string cumQuantity, string createdAt,
                                            string updatedAt,
                                            PublicEnum.EnReportType reportType)
 {
     var request =
         string.Format(
             "{{\"jsonrpc\":\"2.0\",\"method\":\"activeOrders\",\"params\":[{{\"id\":\"{0}\",\"clientOrderId\":\"{1}\",\"symbol\":\"{2}\",\"side\":\"{3}\",\"status\":\"{4}\",\"type\":\"{5}\",\"timeInForce\":\"{6}\",\"quantity\":\"{7}\",\"price\":\"{8}\",\"cumQuantity\":\"{9}\",\"createdAt\":\"{10}\",\"updatedAt\":\"{11}\",\"reportType\":\"{12}\"}}]}}",
             id, clientOrderId, symbol, side, Utilities.FirstCharToLower(status.ToString()),
             Utilities.FirstCharToLower(type.ToString()), timeInForce, quantity, price, cumQuantity, createdAt,
             updatedAt, reportType);
     await _hitBtcSocketApi.Execute(request);
 }