/// <summary> /// Transactions /// </summary> /// <returns>Transactions</returns> public List <Transact> GetTransaction(int delta = 3600) { String URI = @"https://www.bitstamp.net/api/transactions/?timedelta=" + delta; try { CookieCollection cookies = new CookieCollection(); var client = new MyHttpClient(URI); var result = client.MakeRequest(out cookies); var trans = JsonConvert.DeserializeObject <List <Transact> >(result); return(trans); } catch (Exception exception) { SingleInstance.Log.Debug(exception.Message); return(new List <Transact>()); } }
/// <summary> /// Conversion /// </summary> /// <returns>Conversion</returns> public Conversion GetConversion() { CookieCollection cookies = new CookieCollection(); String URI = @"https://www.bitstamp.net/api/eur_usd/"; try { var client = new MyHttpClient(URI); var result = client.MakeRequest(out cookies); var conv = JsonConvert.DeserializeObject <Conversion>(result); return(conv); } catch (Exception exception) { SingleInstance.Log.Debug(exception.Message); return(new Conversion()); } }
/// <summary> /// Reserve /// </summary> /// <returns>Reserve</returns> public Reserve GetReserve() { CookieCollection cookies = new CookieCollection(); String URI = @"https://www.bitstamp.net/api/bitinstant/"; try { var client = new MyHttpClient(URI); var result = client.MakeRequest(out cookies); var reserve = JsonConvert.DeserializeObject <Reserve>(result); return(reserve); } catch (Exception exception) { SingleInstance.Log.Debug(exception.Message); return(new Reserve()); } }
/// <summary> /// OrderBook /// </summary> /// <returns>OrderBook</returns> public OrderBook GetOrderBook() { String URI = @"https://www.bitstamp.net/api/order_book/?group=1"; try { CookieCollection cookies = new CookieCollection(); var client = new MyHttpClient(URI); var result = client.MakeRequest(out cookies); var orderBook = JsonConvert.DeserializeObject <OrderBook>(result); return(orderBook); #region WEBCLIENT // Create web client simulating IE6. //using (WebClient client = new WebClient()) //{ // //client.Headers["User-Agent"] = // //"Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) " + // //"(compatible; MSIE 6.0; Windows NT 5.1; " + // //".NET CLR 1.1.4322; .NET CLR 2.0.50727)"; // // Download data. // client.Proxy = WebRequest.DefaultWebProxy; // byte[] arr = client.DownloadData(URI); // // Write values. // var result = Convert.ToString(arr); // var orderBook = JsonConvert.DeserializeObject<OrderBook>(result); // return orderBook; //} #endregion } catch (Exception exception) { SingleInstance.Log.Debug(exception.Message); return(new OrderBook()); } }
/// <summary> /// Ticker /// </summary> /// <returns>Tick</returns> public Tick GetTick() { CookieCollection cookies = new CookieCollection(); String URI = @"https://www.bitstamp.net/api/ticker"; try { var client = new MyHttpClient(URI); var result = client.MakeRequest(out cookies); JavaScriptSerializer js = new JavaScriptSerializer(); var tick = js.Deserialize(result, typeof(Tick)) as Tick; return(tick); } catch (Exception exception) { SingleInstance.Log.Debug(exception.Message); return(new Tick()); } }