Beispiel #1
0
        public IAvapiResponse_MAMA QueryPrimitive(
            string symbol,
            string interval,
            string series_type,
            float fastlimit = -1,
            float slowlimit = -1)
        {
            // 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>("series_type", series_type));
            getParameters.Add(new KeyValuePair <string, string>("fastlimit", fastlimit.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowlimit", slowlimit.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_MAMA ret = new AvapiResponse_MAMA
            {
                RawData         = response,
                Data            = ParseInternal(response),
                LastHttpRequest = queryString
            };

            return(ret);
        }
Beispiel #2
0
        public async Task <IAvapiResponse_MAMA> QueryPrimitiveAsync(
            string symbol,
            string interval,
            string series_type,
            float fastlimit = -1,
            float slowlimit = -1)
        {
            // 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>("series_type", series_type));
            getParameters.Add(new KeyValuePair <string, string>("fastlimit", fastlimit.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowlimit", slowlimit.ToString()));
            queryString += UrlUtility.AsQueryString(getParameters);

            string response;

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

            return(ret);
        }