Esempio n. 1
0
        /// <summary>/products/<product-id>/ticker
        /// <para>Snapshot information about the last trade (tick), best bid/ask and 24h volume.</para>
        /// <para>Required : product-id</para>
        /// <para>Optional : none</para>
        /// </summary>
        public static GDAXProductTicker GetProductTicker(string productID)
        {
            string responseString = string.Empty;

            try
            {
                var request  = new RestRequest("/products/" + productID + "/ticker", Method.GET);
                var response = client.Execute(request);
                //LogManager.AddLogMessage("GDAXControl", "GetProductTicker", "TICKER:" + tickresponse.Content);
                responseString = response.Content;
                var jsonObject           = JObject.Parse(responseString);
                GDAXProductTicker ticker = jsonObject.ToObject <GDAXProductTicker>();
                ticker.id = productID;
                string[] split = ticker.id.Split('-');
                ticker.symbol = split[0];
                ticker.market = split[1];
                //LogManager.AddLogMessage(Name, "GetProductTicker", ticker.id + " | " + ticker.price);
                UpdateStatus(true, "Updated Tickers");
                return(ticker);

                /*
                 * GDAXProductTicker ticker = new JavaScriptSerializer().Deserialize<GDAXProductTicker>(response.Content);
                 * ticker.id = productID;
                 * return ticker;
                 */
                // TO TEST
                //return null;
            }
            catch (Exception ex)
            {
                LogManager.AddLogMessage(Name, "GetProductTicker", "EXCEPTION!!! : " + ex.Message);
                UpdateStatus(false, responseString);
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>Ticker List
        /// <para>Get a list of all available currency pair tickers</para>
        /// </summary>
        public static List <GDAXProductTicker> getProductTickerList()
        {
            List <GDAXProductTicker> list = new List <GDAXProductTicker>();

            if (Products.Count > 0)
            {
                foreach (GDAXProduct product in Products)
                {
                    GDAXProductTicker ticker = GetProductTicker(product.id);
                    //LogManager.AddLogMessage(Name, "getProductTickerList", product.id, LogManager.LogMessageType.DEBUG);
                    list.Add(ticker);
                }
            }
            else
            {
                if (updateProductList())
                {
                    foreach (GDAXProduct product in Products)
                    {
                        GDAXProductTicker ticker = GetProductTicker(product.id);
                        //LogManager.AddLogMessage(Name, "getProductTickerList", product.id, LogManager.LogMessageType.DEBUG);
                        list.Add(ticker);
                    }
                }
            }

            return(list);
        }