public void PlaceBuyLimitOrder(string securityCode, decimal buyingPrice, DateTime validUntil)
 {
     using (HttpClient client = HttpHelpers.CreateNewClient <IOrdersService>())
     {
         string path = HttpHelpers.GetServicePath <IOrdersService>("PlaceBuyLimitOrder");
         string uri  = $"{path}?securityCode={securityCode}&buyingPrice={buyingPrice}&validUntil={validUntil}";
         HttpResponseMessage response = client.PostAsync(uri, new StringContent(string.Empty)).Result;
         if (!response.IsSuccessStatusCode)
         {
             throw new HttpException((int)response.StatusCode, response.Content.ReadAsStringAsync().Result);
         }
     }
 }
        public decimal GetPortfolioValue()
        {
            using (HttpClient client = HttpHelpers.CreateNewClient <IPortfolioService>())
            {
                string path = HttpHelpers.GetServicePath <IPortfolioService>("GetValue");
                HttpResponseMessage response = client.GetAsync(path).Result;
                if (response.IsSuccessStatusCode)
                {
                    decimal value = response.Content.ReadAsAsync <decimal>().Result;
                    return(value);
                }

                throw new HttpException((int)response.StatusCode, response.ReasonPhrase);
            }
        }
        public LimitOrder[] GetLimitOrders()
        {
            using (HttpClient client = HttpHelpers.CreateNewClient <IOrdersService>())
            {
                string path = HttpHelpers.GetServicePath <IOrdersService>("GetLimitOrders");
                HttpResponseMessage response = client.GetAsync(path).Result;
                if (response.IsSuccessStatusCode)
                {
                    LimitOrder[] value = response.Content.ReadAsAsync <LimitOrder[]>().Result;
                    return(value);
                }

                throw new HttpException((int)response.StatusCode, response.Content.ReadAsStringAsync().Result);
            }
        }
        public Quotation[] GetQuotations(string securityCode, DateTime @from, DateTime to)
        {
            using (HttpClient client = HttpHelpers.CreateNewClient <IQuotationService>())
            {
                string path = HttpHelpers.GetServicePath <IQuotationService>("GetBySecurity");
                string uri  = $"{path}?securityCode={securityCode}&from={from}&to={to}";
                HttpResponseMessage response = client.GetAsync(uri).Result;
                if (response.IsSuccessStatusCode)
                {
                    Quotation[] value = response.Content.ReadAsAsync <Quotation[]>().Result;
                    return(value);
                }

                throw new HttpException((int)response.StatusCode, response.Content.ReadAsStringAsync().Result);
            }
        }
        public Quotation[] GetQuotations(string[] securities, DateTime @from, DateTime to)
        {
            using (HttpClient client = HttpHelpers.CreateNewClient <IQuotationService>())
            {
                string path        = HttpHelpers.GetServicePath <IQuotationService>("GetBySecurities");
                var    queryString = HttpUtility.ParseQueryString(string.Empty);
                for (int i = 0; i < securities.Length; i++)
                {
                    queryString.Add("securities", securities[i]);
                }
                queryString["from"] = @from.ToString("yyyy-MM-dd");
                queryString["to"]   = to.ToString("yyyy-MM-dd");


                HttpResponseMessage response = client.GetAsync($"{path}?{queryString}").Result;
                if (response.IsSuccessStatusCode)
                {
                    Quotation[] value = response.Content.ReadAsAsync <Quotation[]>().Result;
                    return(value);
                }

                throw new HttpException((int)response.StatusCode, response.Content.ReadAsStringAsync().Result);
            }
        }