コード例 #1
0
ファイル: Impl_ULTOSC.cs プロジェクト: DJKampouris/Avapi
        public IAvapiResponse_ULTOSC QueryPrimitive(
            string symbol,
            string interval,
            int timeperiod1 = -1,
            int timeperiod2 = -1,
            int timeperiod3 = -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>("timeperiod1", timeperiod1.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("timeperiod2", timeperiod2.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("timeperiod3", timeperiod3.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_ULTOSC ret = new AvapiResponse_ULTOSC
            {
                RawData         = response,
                Data            = ParseInternal(response),
                LastHttpRequest = queryString
            };

            return(ret);
        }
コード例 #2
0
ファイル: Impl_ULTOSC.cs プロジェクト: DJKampouris/Avapi
        public async Task <IAvapiResponse_ULTOSC> QueryPrimitiveAsync(
            string symbol,
            string interval,
            int timeperiod1 = -1,
            int timeperiod2 = -1,
            int timeperiod3 = -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>("timeperiod1", timeperiod1.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("timeperiod2", timeperiod2.ToString()));
            getParameters.Add(new KeyValuePair <string, string>("timeperiod3", timeperiod3.ToString()));
            queryString += UrlUtility.AsQueryString(getParameters);

            string response;

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

            return(ret);
        }