public IOrderStatus GetOrderStatus(int order_id) { if (Username == null || Password == null) { LastErrorInfo = "Not Autorizated"; return(null); } WebConector wc = new WebConector(); string api_name = "private/QueryOrders"; Int64 nonce = DateTime.Now.Ticks; string data_transmit = string.Format("nonce={0}&txid={1}", nonce, order_id); var signature = SignatureFormat(api_name, data_transmit, nonce); List <Tuple <string, string> > heder = new List <Tuple <string, string> >(); heder.Add(new Tuple <string, string>("API-Key", Username)); heder.Add(new Tuple <string, string>("API-Sign", signature)); var jsonRezalt = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, data_transmit).Result; var jsonRezaltArray = JObject.Parse(jsonRezalt); if (jsonRezaltArray["error"] == null) { LastErrorInfo = ""; BaseOrderStatus bos = BaseOrderStatus.Exsist; bos.Value = jsonRezaltArray[order_id]["status"].ToString(); return(bos); } else { LastErrorInfo = jsonRezaltArray["error"].ToString(); return(null); } }
public List <KrakenOrder> GetOrdersHistory(BaseCurrencyPair currencyPair, int top_count = -1) { if (Username == null || Password == null) { LastErrorInfo = "Not Autorizated"; return(null); } List <KrakenOrder> rezalt = new List <KrakenOrder>(); WebConector wc = new WebConector(); string api_name = "private/OpenOrders"; Int64 nonce = DateTime.Now.Ticks; string data_transmit = string.Format("nonce={0}", nonce); var signature = SignatureFormat(api_name, data_transmit, nonce); List <Tuple <string, string> > heder = new List <Tuple <string, string> >(); heder.Add(new Tuple <string, string>("API-Key", Username)); heder.Add(new Tuple <string, string>("API-Sign", signature)); var jsonRezalt = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, data_transmit).Result; var jsonRezaltArray = JArray.Parse(jsonRezalt); if (jsonRezaltArray["error"] == null) { LastErrorInfo = ""; foreach (JObject record in jsonRezaltArray.Children <JObject>()) { KrakenOrder ko = new KrakenOrder(); BaseOrderStatus os = BaseOrderStatus.Exsist; os.Value = record["order_id"].ToString().FirstCharToUpper(); ko.Status = os; ko.Pair = new BaseCurrencyPair(record["descr"]["pair"].ToString()); ko.Type = KrakenOrderType.SetValue(record["descr"]["type"].ToString().FirstCharToUpper()); ko.Ordertype = KrakenOrderType.SetValue(record["descr"]["ordertype"].ToString().FirstCharToUpper()); ko.Price = double.Parse(record["descr"]["price"].ToString()); ko.Quantity = double.Parse(record["vol"].ToString()); ko.OpenTm = UnixTimestampToDateTime(double.Parse(record["opentm "].ToString())); rezalt.Add(ko); } } else { LastErrorInfo = jsonRezaltArray["error"].ToString(); } api_name = "private/OpenOrders"; nonce = DateTime.Now.Ticks; data_transmit = string.Format("nonce={0}", nonce); signature = SignatureFormat(api_name, data_transmit, nonce); heder = new List <Tuple <string, string> >(); heder.Add(new Tuple <string, string>("API-Key", Username)); heder.Add(new Tuple <string, string>("API-Sign", signature)); jsonRezalt = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, data_transmit).Result; jsonRezaltArray = JArray.Parse(jsonRezalt); if (jsonRezaltArray["error"] == null) { foreach (JObject record in jsonRezaltArray.Children <JObject>()) { KrakenOrder ko = new KrakenOrder(); BaseOrderStatus os = BaseOrderStatus.Exsist; os.Value = record["order_id"].ToString().FirstCharToUpper(); ko.Status = os; ko.Pair = new BaseCurrencyPair(record["descr"]["pair"].ToString()); ko.Type = KrakenOrderType.SetValue(record["descr"]["type"].ToString().FirstCharToUpper()); ko.Ordertype = KrakenOrderType.SetValue(record["descr"]["ordertype"].ToString().FirstCharToUpper()); ko.Price = double.Parse(record["descr"]["price"].ToString()); ko.Quantity = double.Parse(record["vol"].ToString()); ko.Amount = double.Parse(record["count"].ToString()); ko.OpenTm = UnixTimestampToDateTime(double.Parse(record["opentm "].ToString())); rezalt.Add(ko); } } else { LastErrorInfo += jsonRezaltArray["error"].ToString(); } rezalt = rezalt.Where(x => x.Pair.PairName == currencyPair.PairName).ToList(); rezalt.OrderBy(x => x.OpenTm); return((top_count > 0)?rezalt.Take(top_count).ToList():rezalt); }