public static OrderBook GetOrderBook(CEXIO.Commodity commodity) { if (!CEXIO.CanRequest()) { return(null); } String[] cS = Enum.GetName(typeof(CEXIO.Commodity), commodity).Split('_'); WebClient www = new WebClient(); byte[] res = www.UploadValues(OrderBookURL + cS[0] + "/" + cS[1], CEXIO.AuthHeader); String strRes = System.Text.Encoding.UTF8.GetString(res); String err = CEXIO.DetectError(strRes); if (!String.IsNullOrEmpty(err)) { return(null); } OrderBook oB = Deserialize(strRes); oB.commodity = commodity; return(oB); }
public static List <Order> GetOpenOrders(CEXIO.Commodity commodity) { if (!CEXIO.CanRequest()) { return(null); } String[] cS = Enum.GetName(typeof(CEXIO.Commodity), commodity).Split('_'); WebClient www = new WebClient(); byte[] res = www.UploadValues(OpenOrdersURL + cS[0] + "/" + cS[1], CEXIO.AuthHeader); String strRes = System.Text.Encoding.UTF8.GetString(res); String err = CEXIO.DetectError(strRes); if (!String.IsNullOrEmpty(err)) { return(null); } List <Order> orders = DeserializeList(strRes); foreach (Order o in orders) { o.commodity = commodity; } return(orders); }
public static Order PlaceNewOrder(CEXIO.Commodity commodity, Type type, Double amount, Double price) { if (!CEXIO.CanRequest()) { return(null); } NameValueCollection postData = CEXIO.AuthHeader; postData.Add("type", Enum.GetName(typeof(Type), type).ToLower()); postData.Add("amount", amount.ToString("F8", CultureInfo.InvariantCulture)); postData.Add("price", price.ToString("F8", CultureInfo.InvariantCulture)); String[] cS = Enum.GetName(typeof(CEXIO.Commodity), commodity).Split('_'); WebClient www = new WebClient(); byte[] res = www.UploadValues(PlaceOrderURL + cS[0] + "/" + cS[1], postData); String strRes = System.Text.Encoding.UTF8.GetString(res); String err = CEXIO.DetectError(strRes); if (!String.IsNullOrEmpty(err)) { return(null); } Order o = Deserialize(strRes); o.commodity = commodity; return(o); }
public Boolean Cancel() { if (!CEXIO.CanRequest()) { return(false); } NameValueCollection postData = CEXIO.AuthHeader; postData.Add("id", id.ToString()); WebClient www = new WebClient(); byte[] res = www.UploadValues(CancelOrderURL, postData); String strRes = System.Text.Encoding.UTF8.GetString(res); String err = CEXIO.DetectError(strRes); if (!String.IsNullOrEmpty(err)) { return(false); } return(strRes.ToLower() == "true"); }
public static Balance GetBalance() { if (!CEXIO.CanRequest()) { return(null); } WebClient www = new WebClient(); byte[] res = www.UploadValues(url, CEXIO.AuthHeader); String strRes = System.Text.Encoding.UTF8.GetString(res); String err = CEXIO.DetectError(strRes); if (!String.IsNullOrEmpty(err)) { return(null); } return(Deserialize(strRes)); }