Esempio n. 1
0
        public async Task <OpenOrdersResponse> GetOpenOrdersAsync(OpenOrdersRequest request)
        {
            if (String.IsNullOrEmpty(request.Pair))
            {
                throw new ArgumentNullException(nameof(request.Pair));
            }

            string queryString = HttpHelper.QueryString(new Dictionary <string, string> {
                { "symbol", request.Pair }
            }, true);
            dynamic content = await MakePrivateCallAsync(HttpMethod.Get, $"order?{queryString}&filter=%7B%22open%22%3A%20true%7D", String.Empty);

            var orders = new List <OrderResult>();

            foreach (dynamic item in content)
            {
                var order = new OrderResult((string)item.orderID)
                {
                    Pair      = item.symbol,
                    TradeType = Enums.Parse <TradeType>((string)item.side, true),
                    Rate      = item.price,
                    Amount    = item.orderQty,
                    CreatedAt = DateTimeOffset.Parse((string)item.timestamp)
                };
                orders.Add(order);
            }

            return(new OpenOrdersResponse(orders));
        }
Esempio n. 2
0
        public async Task <OpenOrdersResponse> GetOpenOrdersAsync(OpenOrdersRequest request)
        {
            var queryString = HttpHelper.QueryString(new Dictionary <string, string>
            {
                { "symbol", request.Pair },
                { "timestamp", DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString() }
            }, true);
            dynamic content = await MakePrivateCallAsync(HttpMethod.Get, "openOrders", queryString);

            var orders = new List <OrderResult>();

            foreach (dynamic item in content)
            {
                var order = new OrderResult((long)item.orderId)
                {
                    Pair      = item.symbol,
                    TradeType = Enums.Parse <TradeType>((string)item.side, true),
                    OrderType = Enums.Parse <OrderType>((string)item.type, true),
                    Rate      = item.price,
                    Amount    = item.origQty,
                    CreatedAt = DateTimeOffset.FromUnixTimeSeconds((long)double.Parse((string)item.time))
                };
                orders.Add(order);
            }

            return(new OpenOrdersResponse(orders));
        }
Esempio n. 3
0
        public override OpenOrdersModel RequestOpenOrders()
        {
            var o     = new OpenOrdersRequest(this);
            var model = o.Request <OpenOrdersResponse>().Transform();

            return(model);
        }
Esempio n. 4
0
        public async Task <OpenOrdersResponse> GetOpenOrdersAsync(OpenOrdersRequest request)
        {
            if (String.IsNullOrEmpty(request.Pair))
            {
                throw new ArgumentNullException(nameof(request.Pair));
            }

            string queryString = HttpHelper.QueryString(new Dictionary <string, string> {
                { "method", "ActiveOrders" }, { "pair", request.Pair }, { "nonce", GenerateNonce(_settings.CreatedAt) }
            }, true);
            dynamic content = await MakePrivateCallAsync(queryString);

            var orders = new List <OrderResult>();

            if (content.@return != null)
            {
                foreach (dynamic key in content.@return)
                {
                    dynamic data  = content.@return[key];
                    var     order = new OrderResult((long)key)
                    {
                        Pair      = data.pair,
                        TradeType = Enums.Parse <TradeType>((string)data.type, true),
                        Rate      = data.rate,
                        Amount    = data.amount,
                        CreatedAt = DateTimeOffset.FromUnixTimeSeconds((long)double.Parse((string)data.timestamp_created))
                    };
                    orders.Add(order);
                }
            }

            return(new OpenOrdersResponse(orders));
        }
Esempio n. 5
0
        public async Task <OpenOrdersResponse> GetOpenOrdersAsync(OpenOrdersRequest request)
        {
            //var queryString = HttpHelper.QueryString(new Dictionary<string, string>
            //{
            //	{ "symbol", request.Pair },
            //	{ "timestamp", DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString() }
            //}, true);
            //dynamic content = await MakePrivateCallAsync(HttpMethod.Get, "openOrders", queryString);
            var orders = new List <OrderResult>();

            //foreach (dynamic item in content)
            //{

            //}

            return(new OpenOrdersResponse(orders));
        }
Esempio n. 6
0
        public async Task <OpenOrdersResponse> GetOpenOrdersAsync(OpenOrdersRequest request)
        {
            dynamic content = await MakePrivateCallAsync(request, "orders");

            var orders = new List <OrderResult>();

            foreach (dynamic item in content)
            {
                var order = new OrderResult((long)item.id)
                {
                    Pair      = item.symbol,
                    TradeType = Enums.Parse <TradeType>((string)item.side, true),
                    Rate      = item.price,
                    Amount    = item.original_amount,
                    CreatedAt = DateTimeOffset.FromUnixTimeSeconds((long)double.Parse((string)item.timestamp))
                };
                orders.Add(order);
            }

            return(new OpenOrdersResponse(orders));
        }
Esempio n. 7
0
        public async Task <OpenOrdersResponse> GetOpenOrdersAsync(OpenOrdersRequest request)
        {
            dynamic content = await MakePrivateCallAsync(BuildUrl(_settings.PrivateUrl, "GetOpenOrders"), request);

            var orders = new List <OrderResult>();

            foreach (dynamic item in content.Data)
            {
                var order = new OrderResult((long)item.OrderId)
                {
                    Pair      = item.Market,
                    TradeType = Enums.Parse <TradeType>((string)item.Type, true),
                    Rate      = item.Rate,
                    Amount    = item.Amount,
                    CreatedAt = DateTimeOffset.Parse((string)item.TimeStamp)
                };
                orders.Add(order);
            }

            return(new OpenOrdersResponse(orders));
        }
Esempio n. 8
0
        public async Task <OpenOrdersResponse> GetOpenOrdersAsync(OpenOrdersRequest request)
        {
            dynamic content = await MakePrivateCallAsync("user_open_orders", String.Empty);

            var orders = new List <OrderResult>();

            foreach (dynamic key in content)
            {
                foreach (dynamic item in content[key])
                {
                    var order = new OrderResult((long)item.order_id)
                    {
                        Pair      = item.pair,
                        TradeType = Enums.Parse <TradeType>((string)item.type, true),
                        Rate      = item.price,
                        Amount    = item.quantity,
                        CreatedAt = DateTimeOffset.FromUnixTimeSeconds((long)item.created)
                    };
                    orders.Add(order);
                }
            }

            return(new OpenOrdersResponse(orders));
        }
 public async Task <OrderList> GetOpenOrdersAsync(OpenOrdersRequest request)
 {
     return(await this.httpClient.GetAsync <OrderList>($"{baseUrl}/api/v1/orders/open{Query(request)}"));
 }
 public OrderList GetOpenOrders(OpenOrdersRequest request) => GetOpenOrdersAsync(request).GetAwaiter().GetResult();
Esempio n. 11
0
 public async Task <OpenOrdersResponse> GetOpenOrders(OpenOrdersRequest request)
 {
     return(await GetResult <OpenOrdersResponse, OpenOrdersRequest>(PrivateApiCall.GetOpenOrders, request));
 }