Ejemplo n.º 1
0
 public override bool GetTicker()
 {
     try
     {
         var client  = new RestClient("http://data.mtgox.com/api/1/BTCUSD/ticker_fast");
         var request = new RestRequest
         {
             Method = Method.GET
         };
         var response = client.Execute <JsonGetTickerFastMtGox>(request);
         //if (response == null) return false;
         var ask = [email protected];
         var bid = [email protected];
         var now = [email protected];
         this.Ask  = decimal.Parse(ask, CultureInfo.InvariantCulture);
         this.Bid  = decimal.Parse(bid, CultureInfo.InvariantCulture);
         this.Date = CUtility.UnixTimeStampToDateTime((double)now / 1000000).AddHours(1);
         return(true);
     }
     catch (Exception)
     {
         throw;
         return(false);
     }
 }
Ejemplo n.º 2
0
        public bool Next()
        {
            try
            {
                CUtility.Log("mtgox...");
                var client  = new RestClient("http://data.mtgox.com/api/1/BTCUSD/ticker_fast");
                var request = new RestRequest
                {
                    Method = Method.GET
                };
                var response = client.Execute <JsonGetTickerFastMtGox>(request);
                //if (response == null) return false;
                var ask = [email protected];
                var bid = [email protected];
                var now = [email protected];
                this.Ask  = decimal.Parse(ask, CultureInfo.InvariantCulture);
                this.Bid  = decimal.Parse(bid, CultureInfo.InvariantCulture);
                this.Date = CUtility.UnixTimeStampToDateTime((double)now / 1000000).AddHours(1);
                //CUtility.UnixTime.ConvertToDateTime((uint) now/1000000).AddHours(1); //DateTime.Now;
                CUtility.Log(string.Format("{0} {1}", this.Date.ToString(CultureInfo.InvariantCulture), this.Bid));
            }
            catch (Exception ex)
            {
                //throw;
                CUtility.Log(ex.Message + " " + ex.StackTrace);
                return(true); // non puo' mai essere false se capita un errore su mtgox
            }

            return(true);
        }