public bool CanselOrder(int order_id)
        {
            if (Username == null || Password == null)
            {
                return(false);
            }
            WebConector wc       = new WebConector();
            string      api_name = "order_cancel";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            string nonce = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();

            heder.Add(new Tuple <string, string>("Key", Username));
            string data_for_encript = "order_id=" + order_id + "&" + "nonce=" + nonce;

            heder.Add(new Tuple <string, string>("Sign", SignatureHelper.Sign(Password, data_for_encript)));

            var body = new NameValueCollection();

            body.Add("order_id", order_id.ToString());
            body.Add("nonce", nonce);
            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, body).Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray["result"].ToString() == "true")
            {
                LastErrorInfo = "";
                return(true);
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(false);
            }
        }
Example #2
0
        public bool CanselOrder(int order_id)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(false);
            }
            WebConector wc       = new WebConector();
            string      api_name = "auth/w/order/cancel";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            string nonce            = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();
            string body_jsonstr     = "{id:" + order_id + "}";
            string data_for_encript = "/api/" + api_name + nonce.ToString() + body_jsonstr;

            heder.Add(new Tuple <string, string>("bfx-apikey", Username));
            heder.Add(new Tuple <string, string>("bfx-signature", SignatureHelper.Sign(Password, data_for_encript, 384)));
            heder.Add(new Tuple <string, string>("bfx-nonce", nonce));

            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(abase_url, api_name), heder, body_jsonstr).Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray["error"] != null)
            {
                LastErrorInfo = "";
                //return Int32.Parse(jsonRezaltArray["order_id"].ToString());
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                //return -1;
            }
            throw new NotImplementedException();
        }
        public int PostOrder(IOrder order)
        {
            if (Username == null || Password == null)
            {
                return(-1);
            }
            WebConector wc       = new WebConector();
            string      api_name = "order_create";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            string nonce = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();

            heder.Add(new Tuple <string, string>("Key", Username));
            string data_for_encript = "pair=" + order.Pair.PairName + "&" + "quantity=" + order.Quantity + "&" + "price=" + order.Price + "&" + "type=" + order.Type.Value + "&" + "nonce=" + nonce;

            heder.Add(new Tuple <string, string>("Sign", SignatureHelper.Sign(Password, data_for_encript)));

            var body = this.ToNameValue(order);

            body.Add("nonce", nonce);
            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, body).Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray["result"].ToString() == "true")
            {
                LastErrorInfo = "";
                return(Int32.Parse(jsonRezaltArray["order_id"].ToString()));
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(-1);
            }
        }
        public bool CanselOrder(int order_id)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(false);
            }

            WebConector wc                       = new WebConector();
            string      api_name                 = "private/CancelOrder";
            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 = "";
                return(true);
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(false);
            }
        }
Example #5
0
//        let signature = `/api/${apiPath}${nonce}${JSON.stringify(body)}`
//const sig = CryptoJS.HmacSHA384(signature, apiSecret).toString()

        public int PostOrder(IOrder order)
        {
            if (Username == null || Password == null)
            {
                return(-1);
            }
            WebConector wc       = new WebConector();
            string      api_name = "auth/w/order/submit";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            string nonce        = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();
            string body_jsonstr = "{\"type\":\"" + order.Type.Value + "\",\"symbol\":\"" + order.Pair + "\",\"price\":\"" + order.Price + "\",\"amount\":\"" + order.Amount + "\",\"flags\":\"0\"}";
            //string body_jsonstr = "type=" + order.Type.Value + "&symbol=" + order.Pair + "&price=" + order.Price + "&amount=" + order.Amount + "&flags=0";
            string data_for_encript = "/api/" + api_name + nonce + body_jsonstr;

            heder.Add(new Tuple <string, string>("bfx-apikey", Encoding.UTF8.GetString(Encoding.Default.GetBytes(Username))));
            heder.Add(new Tuple <string, string>("bfx-signature", Encoding.UTF8.GetString(Encoding.Default.GetBytes(SignatureHelper.Sign(Password, data_for_encript, 384)))));
            heder.Add(new Tuple <string, string>("bfx-nonce", Encoding.UTF8.GetString(Encoding.Default.GetBytes(nonce))));
            var    _url_url        = string.Format(abase_url, api_name);
            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(abase_url, api_name), heder, body_jsonstr, "application/x-www-form-urlencoded").Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray["error"] != null)
            {
                LastErrorInfo = "";
                return(Int32.Parse(jsonRezaltArray["order_id"].ToString()));
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(-1);
            }
        }
        public List <BaseHistoryRecord> GetHistoryRecords(DateTime dateTime)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Authenticated";
                return(new List <BaseHistoryRecord>());
            }
            WebConector wc       = new WebConector();
            string      api_name = "wallet_history";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            string nonce = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();

            heder.Add(new Tuple <string, string>("Key", Username));
            string data_for_encript = "nonce=" + nonce;

            heder.Add(new Tuple <string, string>("Sign", SignatureHelper.Sign(Password, data_for_encript)));

            var body = new NameValueCollection();

            body.Add("nonce", nonce);
            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, body).Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray.Count != 0)
            {
                List <BaseHistoryRecord> rezaltlist = new List <BaseHistoryRecord>();
                foreach (var accountvalue in jsonRezaltArray["history"])
                {
                    BaseHistoryRecord bhr = new BaseHistoryRecord();
                    //bhr.Id = accountvalue[""];
                    bhr.Type      = accountvalue["type"].ToString();
                    bhr.Time      = Convert.ToDateTime(accountvalue["dt"].ToString());
                    bhr.Currency  = accountvalue["curr"].ToString();
                    bhr.Status    = accountvalue["status"].ToString();
                    bhr.Provaider = accountvalue["provider"].ToString();
                    bhr.Amount    = accountvalue["amount"].ToString();
                    bhr.Account   = accountvalue["account"].ToString();
                    bhr.Txit      = accountvalue["txid"].ToString();
                    rezaltlist.Add(bhr);
                }

                LastErrorInfo = "";
                return(rezaltlist);
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(new List <BaseHistoryRecord>());
            }
        }
        public List <BaseOrder> GetOrdersHistory(BaseCurrencyPair currencyPair, int top_count = 100)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(new List <BaseOrder>());
            }
            if (top_count > 1000)
            {
                top_count = 1000;
            }
            WebConector wc       = new WebConector();
            string      api_name = "/api/v3/allOrders";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            var    jsontimestamp = wc.ReqwestGetAsync(string.Format("{0}/api/v3/time", base_url), new List <Tuple <string, string> >(), "").Result;
            string timestamp     = (JObject.Parse(jsontimestamp))["serverTime"].ToString();

            heder.Add(new Tuple <string, string>("X-MBX-APIKEY", Username));
            string data_for_encript = "symbol=" + currencyPair.PairName + "&limit=" + top_count + "&recvWindow=" + "50000" + "&timestamp=" + timestamp;

            heder.Add(new Tuple <string, string>("signature", SignatureHelper.Sign(Password, data_for_encript, 256)));
            data_for_encript += "&signature=" + SignatureHelper.Sign(Password, data_for_encript, 256);
            string jsonRezalt = wc.ReqwestPostAsync(string.Format("{0}{1}", base_url, api_name), heder, data_for_encript).Result;

            try
            {
                var jsonRezaltArray = JArray.Parse(jsonRezalt);
                LastErrorInfo = "";
                var rezalt = new List <BaseOrder>();
                foreach (var order in jsonRezaltArray)
                {
                    BaseOrder bo = new BaseOrder();
                    bo.Id       = order["orderId"].ToObject <int>();
                    bo.Pair     = new BaseCurrencyPair(order["symbol"].ToString());
                    bo.Quantity = order["origQty"].ToObject <double>();
                    bo.Price    = order["price"].ToObject <double>();
                    bo.Type     = BinanceOrderType.SetValue(order["type"].ToString());
                    bo.Amount   = order["executedQty"].ToObject <int>();
                    rezalt.Add(bo);
                }
                return(rezalt);
            }
            catch (Exception ex)
            {
                LastErrorInfo = jsonRezalt;
                return(new List <BaseOrder>());
            }
        }
        public List <BaseOrder> GetOrdersHistory(BaseCurrencyPair currencyPair, int top_count = 100)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Authenticated";
                return(new List <BaseOrder>());
            }
            WebConector wc       = new WebConector();
            string      api_name = "user_cancelled_orders";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            string nonce = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();

            heder.Add(new Tuple <string, string>("Key", Username));
            string data_for_encript = "limit=" + top_count + "&" + "nonce=" + nonce;

            heder.Add(new Tuple <string, string>("Sign", SignatureHelper.Sign(Password, data_for_encript)));

            var body = new NameValueCollection();

            body.Add("limit", top_count.ToString());
            body.Add("nonce", nonce);
            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, body).Result;
            var    jsonRezaltArray = JArray.Parse(jsonRezalt);

            if (jsonRezaltArray.Count != 0)
            {
                List <BaseOrder> rezaltlist = new List <BaseOrder>();
                foreach (JObject record in jsonRezaltArray.Children <JObject>())
                {
                    BaseOrder bhr = new BaseOrder();
                    bhr.Id       = int.Parse(record["order_id"].ToString());
                    bhr.Type     = BaseOrderType.SetValue(record["order_type"].ToString());
                    bhr.Pair     = new BaseCurrencyPair(record["pair"].ToString());
                    bhr.Price    = double.Parse(record["price"].ToString());
                    bhr.Quantity = double.Parse(record["quantity"].ToString());
                    bhr.Amount   = double.Parse(record["amount"].ToString());
                    rezaltlist.Add(bhr);
                }

                LastErrorInfo = "";
                return(rezaltlist);
            }
            else
            {
                return(new List <BaseOrder>());
            }
        }
        public List <BaseAccount> GetAccountsList()
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Authenticated";
                return(new List <BaseAccount>());
            }
            WebConector wc       = new WebConector();
            string      api_name = "user_info";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            string nonce = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();

            heder.Add(new Tuple <string, string>("Key", Username));
            string data_for_encript = "nonce=" + nonce;

            heder.Add(new Tuple <string, string>("Sign", SignatureHelper.Sign(Password, data_for_encript)));

            var body = new NameValueCollection();

            body.Add("nonce", nonce);
            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, body).Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray.Count != 0)
            {
                List <BaseAccount> rezaltlist = new List <BaseAccount>();
                foreach (var accountvalue in JObject.Parse(jsonRezaltArray["balances"].ToString()))
                {
                    rezaltlist.Add(new BaseAccount(accountvalue.Key, double.Parse(accountvalue.Value.ToString())));
                }

                LastErrorInfo = "";
                return(rezaltlist);
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(new List <BaseAccount>());
            }
        }
        public int PostOrder(IOrder order)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(-1);
            }
            if (!(order is KrakenOrder))
            {
                LastErrorInfo = "Use KrakenOrder type";
                return(-1);
            }
            WebConector wc            = new WebConector();
            string      api_name      = "private/AddOrder";
            Int64       nonce         = DateTime.Now.Ticks;
            string      data_transmit = "nonce=" + nonce + "&pair=" + order.Pair.PairName + "&" + "type=" + order.Type.Value + "&"
                                        + "ordertype=" + ((KrakenOrder)order).Ordertype.Value + "&" + "volume=" + order.Quantity + "&"
                                        + "price=" + order.Price;
            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));

            string jsonRezalt      = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, data_transmit).Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray["error"] == null)
            {
                LastErrorInfo = "";
                return(Int32.Parse(jsonRezaltArray["txid"].ToString()));
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(-1);
            }
        }
        public int PostOrder(IOrder order)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(-1);
            }
            if (!(order is BinanceOrder))
            {
                LastErrorInfo = "Use BinanceOrder type";
                return(-1);
            }
            WebConector wc       = new WebConector();
            string      api_name = "/api/v3/order";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            var    jsontimestamp = wc.ReqwestGetAsync(string.Format("{0}/api/v3/time", base_url), new List <Tuple <string, string> >(), "").Result;
            string timestamp     = (JObject.Parse(jsontimestamp))["serverTime"].ToString();

            heder.Add(new Tuple <string, string>("X-MBX-APIKEY", Username));
            string data_for_encript = "symbol=" + order.Pair.PairName + "&side=" + ((BinanceOrder)order).Side.Value + "&type=" + order.Type.Value + "&timeInForce=" + ((BinanceOrder)order).TimeInForce.ToString("G") + "&quantity=" + order.Quantity + "&price=" + order.Price + "&timestamp=" + timestamp;

            heder.Add(new Tuple <string, string>("signature", SignatureHelper.Sign(Password, data_for_encript, 256)));
            data_for_encript += "&signature=" + SignatureHelper.Sign(Password, data_for_encript, 256);
            string jsonRezalt      = wc.ReqwestPostAsync(string.Format("{0}{1}", base_url, api_name), heder, data_for_encript).Result;
            var    jsonRezaltArray = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray["orderId"] != null)
            {
                LastErrorInfo = "";
                return(Int32.Parse(jsonRezaltArray["orderId"].ToString()));
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["msg"].ToString();
                return(-1);
            }
        }
        //Kraken not suport get input info
        public List <BaseAccount> GetAccountsList()
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(null);
            }
            WebConector wc                       = new WebConector();
            string      api_name                 = "private/Balance";
            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 = JObject.Parse(jsonRezalt);

            if (jsonRezaltArray["error"] == null)
            {
                LastErrorInfo = "";
                List <BaseAccount> rezalt = new List <BaseAccount>();
                foreach (var record in jsonRezaltArray)
                {
                    rezalt.Add(new BaseAccount(record.Key, double.Parse(record.Value.ToString())));
                }
                return(rezalt);
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(null);
            }
        }
        public List <BaseHistoryRecord> GetHistoryRecords(DateTime dateTime)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(new List <BaseHistoryRecord>());
            }
            WebConector wc       = new WebConector();
            string      api_name = "wapi/v3/depositHistory.html";
            List <Tuple <string, string> > heder = new List <Tuple <string, string> >();
            var    jsontimestamp = wc.ReqwestGetAsync(string.Format("{0}/api/v3/time", base_url), new List <Tuple <string, string> >(), "").Result;
            string timestamp     = (JObject.Parse(jsontimestamp))["serverTime"].ToString();

            heder.Add(new Tuple <string, string>("X-MBX-APIKEY", Username));
            string data_for_encript = "&startTime=" + dateTime.ToUnixTimestamp() + "&recvWindow=" + "50000" + "&timestamp=" + timestamp;

            heder.Add(new Tuple <string, string>("signature", SignatureHelper.Sign(Password, data_for_encript, 256)));
            data_for_encript += "&signature=" + SignatureHelper.Sign(Password, data_for_encript, 256);
            string jsonRezalt   = wc.ReqwestPostAsync(string.Format("{0}{1}", base_url, api_name), heder, data_for_encript).Result;
            var    jarrayRezalt = JObject.Parse(jsonRezalt);
            var    rezalt       = new List <BaseHistoryRecord>();

            if (jarrayRezalt["msg"] == null)
            {
                var jsonArrayRecords = JArray.Parse(jarrayRezalt["depositList"].ToString());
                foreach (var record in jsonArrayRecords)
                {
                    BaseHistoryRecord bhr = new BaseHistoryRecord();
                    bhr.Id        = 0;
                    bhr.Provaider = record["txId"].ToString();
                    bhr.Status    = record["status"].ToString();
                    bhr.Time      = (new DateTime()).FromUnixTimestamp(record["insertTime"].ToObject <Int64>());
                    bhr.Txit      = record["txId"].ToString();
                    bhr.Type      = "deposit";
                    bhr.Account   = record["address"].ToString();;
                    bhr.Amount    = record["amount"].ToString();;
                    bhr.Currency  = record["asset"].ToString();;
                    rezalt.Add(bhr);
                }
            }
            else
            {
                LastErrorInfo = jarrayRezalt["msg"].ToString();
                return(new List <BaseHistoryRecord>());
            }
            api_name      = "/wapi/v3/withdrawHistory.html";
            heder         = new List <Tuple <string, string> >();
            jsontimestamp = wc.ReqwestGetAsync(string.Format("{0}/api/v3/time", base_url), new List <Tuple <string, string> >(), "").Result;
            timestamp     = (JObject.Parse(jsontimestamp))["serverTime"].ToString();
            heder.Add(new Tuple <string, string>("X-MBX-APIKEY", Username));
            data_for_encript = "&startTime=" + dateTime.ToUnixTimestamp() + "&recvWindow=" + "50000" + "&timestamp=" + timestamp;
            heder.Add(new Tuple <string, string>("signature", SignatureHelper.Sign(Password, data_for_encript, 256)));
            data_for_encript += "&signature=" + SignatureHelper.Sign(Password, data_for_encript, 256);
            jsonRezalt        = wc.ReqwestPostAsync(string.Format("{0}{1}", base_url, api_name), heder, data_for_encript).Result;
            jarrayRezalt      = JObject.Parse(jsonRezalt);
            if (jarrayRezalt["msg"] == null)
            {
                var jsonArrayRecords = JArray.Parse(jarrayRezalt["withdrawList"].ToString());
                foreach (var record in jsonArrayRecords)
                {
                    BaseHistoryRecord bhr = new BaseHistoryRecord();
                    bhr.Id        = 0;
                    bhr.Provaider = record["txId"].ToString();
                    bhr.Status    = record["status"].ToString();
                    bhr.Time      = (new DateTime()).FromUnixTimestamp(record["insertTime"].ToObject <Int64>());
                    bhr.Txit      = record["txId"].ToString();
                    bhr.Type      = "withdraw";
                    bhr.Account   = record["address"].ToString();;
                    bhr.Amount    = record["amount"].ToString();;
                    bhr.Currency  = record["asset"].ToString();;
                    rezalt.Add(bhr);
                }
            }
            else
            {
                LastErrorInfo += jarrayRezalt["msg"].ToString();
                return(new List <BaseHistoryRecord>());
            }
            throw new NotImplementedException();
        }
        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);
        }
        public List <BaseHistoryRecord> GetHistoryRecords(DateTime dateTime)
        {
            if (Username == null || Password == null)
            {
                LastErrorInfo = "Not Autorizated";
                return(null);
            }
            List <BaseHistoryRecord> rezalt = new List <BaseHistoryRecord>();
            WebConector wc                       = new WebConector();
            string      api_name                 = "private/WithdrawStatus";
            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 (var record in jsonRezaltArray.Children <JObject>())
                {
                    BaseHistoryRecord bhr = new BaseHistoryRecord();
                    bhr.Time      = UnixTimestampToDateTime(double.Parse(record["time"].ToString()));
                    bhr.Type      = "Withdraw";
                    bhr.Id        = int.Parse(record["refid"].ToString());
                    bhr.Currency  = "";
                    bhr.Status    = record["status"].ToString();
                    bhr.Provaider = record["info "].ToString();
                    bhr.Amount    = record["amount"].ToString();
                    bhr.Account   = "";
                    bhr.Txit      = record["txid"].ToString();
                }
            }
            else
            {
                LastErrorInfo = jsonRezaltArray["error"].ToString();
                return(null);
            }
            api_name      = "private/DepositStatus";
            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 (var record in jsonRezaltArray.Children <JObject>())
                {
                    BaseHistoryRecord bhr = new BaseHistoryRecord();
                    bhr.Time      = UnixTimestampToDateTime(double.Parse(record["time"].ToString()));
                    bhr.Type      = "Deposit";
                    bhr.Id        = int.Parse(record["refid"].ToString());
                    bhr.Currency  = "";
                    bhr.Status    = record["status"].ToString();
                    bhr.Provaider = record["info "].ToString();
                    bhr.Amount    = record["amount"].ToString();
                    bhr.Account   = "";
                    bhr.Txit      = record["txid"].ToString();
                }
            }
            else
            {
                LastErrorInfo += jsonRezaltArray["error"].ToString();
                return(null);
            }
            return(rezalt);
        }