Ejemplo n.º 1
0
        public IAvapiResponse_STOCH QueryPrimitive(
            string symbol,
            string interval,
            int fastkperiod = -1,
            int slowkperiod = -1,
            int slowdperiod = -1,
            int slowkmatype = -1,
            int slowdmatype = -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>("fastkperiod", fastkperiod.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowkperiod", slowkperiod.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowdperiod", slowdperiod.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowkmatype", slowkmatype.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowdmatype", slowdmatype.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_STOCH ret = new AvapiResponse_STOCH
            {
                RawData         = response,
                Data            = ParseInternal(response),
                LastHttpRequest = queryString
            };

            return(ret);
        }
Ejemplo n.º 2
0
        public async Task <IAvapiResponse_STOCH> QueryPrimitiveAsync(
            string symbol,
            string interval,
            int fastkperiod = -1,
            int slowkperiod = -1,
            int slowdperiod = -1,
            int slowkmatype = -1,
            int slowdmatype = -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>("fastkperiod", fastkperiod.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowkperiod", slowkperiod.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowdperiod", slowdperiod.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowkmatype", slowkmatype.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("slowdmatype", slowdmatype.ToString()));
            queryString += UrlUtility.AsQueryString(getParameters);

            string response;

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

            return(ret);
        }