Exemplo n.º 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));
        }
Exemplo n.º 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);
 }
Exemplo n.º 3
0
        public async Task <SocketOrder> NewOrder(string symbolName, string clientOrderId, string quantity, string price,
                                                 int id = 123, PublicEnum.EnTradingSide side = PublicEnum.EnTradingSide.buy)
        {
            string[] paramterArray = new string[5];
            if (!string.IsNullOrEmpty(symbolName))
            {
                paramterArray[0] = string.Format("\"symbol\": \"{0}\"", symbolName);
            }
            paramterArray[1] = string.Format("\"clientOrderId\": \"{0}\"", clientOrderId);
            if (!string.IsNullOrEmpty(quantity))
            {
                paramterArray[2] = string.Format("\"quantity\": \"{0}\"", quantity);
            }
            if (!string.IsNullOrEmpty(price))
            {
                paramterArray[3] = string.Format("\"price\": \"{0}\"", price);
            }
            paramterArray[4] = string.Format("\"side\": \"{0}\"", side.ToString());

            string parameters = string.Empty;

            for (var index = 0; index < paramterArray.Length - 1; index++)
            {
                if (!string.IsNullOrEmpty(paramterArray[index]))
                {
                    parameters += paramterArray[index] + " , ";
                }
            }

            if (!string.IsNullOrEmpty(paramterArray[4]))
            {
                parameters += paramterArray[4];
            }


            var request =
                string.Format("{{ \"method\": \"newOrder\", \"params\": {{ {0} }}, \"id\": {1} }}",
                              parameters, id);

            return(await _hitBtcSocketApi.Execute(request));
        }