Esempio n. 1
0
        public async Task <IAvapiResponse_MINUS_DI> QueryPrimitiveAsync(
            string symbol,
            string interval,
            int time_period)
        {
            // Build Base Uri
            string queryString = AvapiUrl + "/query";

            // Build query parameters
            IDictionary <string, string> getParameters = new Dictionary <string, string>();

            getParameters.Add(new KeyValuePair <string, string>("function", s_function));
            getParameters.Add(new KeyValuePair <string, string>("apikey", ApiKey));
            getParameters.Add(new KeyValuePair <string, string>("symbol", symbol));
            getParameters.Add(new KeyValuePair <string, string>("interval", interval));
            getParameters.Add(new KeyValuePair <string, string>("time_period", time_period.ToString()));
            queryString += UrlUtility.AsQueryString(getParameters);

            string response;

            using (var result = await RestClient.GetAsync(queryString))
            {
                response = await result.Content.ReadAsStringAsync();
            }
            IAvapiResponse_MINUS_DI ret = new AvapiResponse_MINUS_DI
            {
                RawData         = response,
                Data            = ParseInternal(response),
                LastHttpRequest = queryString
            };

            return(ret);
        }
Esempio n. 2
0
        public IAvapiResponse_MINUS_DI QueryPrimitive(
            string symbol,
            string interval,
            int time_period)
        {
            // Build Base Uri
            string queryString = AvapiUrl + "/query";

            // Build query parameters
            IDictionary <string, string> getParameters = new Dictionary <string, string>();

            getParameters.Add(new KeyValuePair <string, string>("function", s_function));
            getParameters.Add(new KeyValuePair <string, string>("apikey", ApiKey));
            getParameters.Add(new KeyValuePair <string, string>("symbol", symbol));
            getParameters.Add(new KeyValuePair <string, string>("interval", interval));
            getParameters.Add(new KeyValuePair <string, string>("time_period", time_period.ToString()));
            queryString += UrlUtility.AsQueryString(getParameters);

            // Sent the Request and get the raw data from the Response
            string response = RestClient?.
                              GetAsync(queryString)?.
                              Result?.
                              Content?.
                              ReadAsStringAsync()?.
                              Result;

            IAvapiResponse_MINUS_DI ret = new AvapiResponse_MINUS_DI
            {
                RawData         = response,
                Data            = ParseInternal(response),
                LastHttpRequest = queryString
            };

            return(ret);
        }