Exemple #1
0
        public Hashtable Exchange_Rate_ccy_pair(int currency1, int currency2)
        {
            Hashtable hstemp = new Hashtable();
            Site sitetemp = new Site();
            string strcurrencycodes = sitetemp.getcurrencycode(currency1) + sitetemp.getcurrencycode(currency2);
            if (currency1 != currency2)
            {
                string url = "/prices/market/" + strcurrencycodes+ "?accept_stale=true";

                /*
                RestClient client = new RestClient(url);
                var request = new RestRequest(Method.GET);
                request.AddParameter("accept_stale", "true");
                // execute the request
                RestResponse response = (RestResponse)client.Execute(request);
                string responseString = response.Content; // raw content as string
                if (responseString.ToLower().Contains("error"))
                {
                    token = update_info_currencycloud_token();

                    client.BaseUrl = geturl() + "/api/en/v1.0/" + token + "/prices/market/" + strcurrencycodes;
                    response = (RestResponse)client.Execute(request);
                    responseString = response.Content; // raw content as string
                }*/
                string responseString = CallWeb_Request(url, hstemp);

                hstemp = JsonConvert.DeserializeObject<Hashtable>(responseString);
                hstemp = JsonConvert.DeserializeObject<Hashtable>(hstemp["data"].ToString());
            }
            else
            {
                //yyyyMMdd-HH:mm:ss
                hstemp.Add("bid_price_timestamp", DateTime.Now.ToString("yyyyMMdd-HH:mm:ss"));
                hstemp.Add("bid_price",0.9998);
                hstemp.Add("broker_bid",0.9958);
                hstemp.Add("offer_price_timestamp",DateTime.Now.ToString("yyyyMMdd-HH:mm:ss"));
                hstemp.Add("offer_price",1.0002);
                hstemp.Add("broker_offer",1.0052);
                hstemp.Add("market_price",1);
                hstemp.Add("value_date",DateTime.Now.ToString("yyyyMMdd"));
                hstemp.Add("quote_condition","open");
                hstemp.Add("real_market",strcurrencycodes);
                hstemp.Add("ccy_pair",strcurrencycodes);
            }

            return hstemp;
        }