Пример #1
0
        public Dictionary <string, TransformInfo> GetInfo()
        {
            string site = "https://api.livecoin.net/info/coinInfo";

            Dictionary <string, TransformInfo> temp;

            WebResponse resp = LiveCoinGetRequst.Requst(site);

            using (StreamReader stream = new StreamReader(
                       resp.GetResponseStream(), Encoding.UTF8))
            {
                string str = stream.ReadToEnd();
                if (!str.Contains("Error 502"))
                {
                    var res = JsonConvert.DeserializeObject <Fields>(str);
                    temp = res.info.ToDictionary(d => d.symbol, x => new TransformInfo(x));
                }
                else
                {
                    temp = new Dictionary <string, TransformInfo>();
                }
            }


            return(temp);
        }
Пример #2
0
        public TransformOrders GetOrder(string MainCoinName, string SecondCoinName)
        {
            if (MainCoinName == "USDT")
            {
                return(new TransformOrders());
            }
            string site = String.Format("https://api.livecoin.net/exchange/order_book?currencyPair={0}", SecondCoinName + "/" + MainCoinName);
            List <List <decimal> > asks = new List <List <decimal> >();
            List <List <decimal> > bids = new List <List <decimal> >();

            try
            {
                WebResponse resp = LiveCoinGetRequst.Requst(site);
                using (StreamReader stream = new StreamReader(
                           resp.GetResponseStream(), Encoding.UTF8))
                {
                    string  str = stream.ReadToEnd();
                    dynamic res = JsonConvert.DeserializeObject(str);
                    if (res.success == null)
                    {
                        foreach (var item in res.asks)
                        {
                            string  first  = item.First.Value;
                            decimal cost   = Decimal.Parse(first.Replace('.', ','), NumberStyles.Float);
                            long    second = item.Last.Value;
                            decimal weight = second;
                            var     temp   = new List <decimal>();
                            temp.Add(cost);
                            temp.Add(weight);
                            asks.Add(temp);
                        }
                        foreach (var item in res.bids)
                        {
                            string  first  = item.First.Value;
                            decimal cost   = Decimal.Parse(first.Replace('.', ','), NumberStyles.Float);
                            long    second = item.Last.Value;
                            decimal weight = second;
                            var     temp   = new List <decimal>();
                            temp.Add(cost);
                            temp.Add(weight);
                            bids.Add(temp);
                        }
                    }
                }

                return(new TransformOrders(asks, bids));
            }
            catch (WebException e)
            {
                string message = e.Message;
                //MessageBoxButtons buttons = MessageBoxButtons.OK;
                //MessageBox.Show(message, "LIVECOIN", buttons);
                return(new TransformOrders());
            }
        }
Пример #3
0
        public Dictionary <string, string> GetDepositAddresses()
        {
            WebResponse response = LiveCoinGetRequst.AuthRequst(Payment + "balances", "");
            Dictionary <string, string> temp;

            using (StreamReader stream = new StreamReader(
                       response.GetResponseStream(), Encoding.UTF8))
            {
                string str = stream.ReadToEnd();
                temp = JsonConvert.DeserializeObject <Dictionary <string, string> >(str);
            }
            return(temp);
        }
Пример #4
0
        public Dictionary <string, TransformBallans> GetBalances()
        {
            WebResponse response = LiveCoinGetRequst.AuthRequst(Payment + "balances", "");
            Dictionary <string, TransformBallans> temp = new Dictionary <string, TransformBallans>();

            using (StreamReader stream = new StreamReader(
                       response.GetResponseStream(), Encoding.UTF8))
            {
                string str    = stream.ReadToEnd();
                var    resalt = JsonConvert.DeserializeObject <List <Field> >(str);
                foreach (var item in resalt)
                {
                    if (temp.ContainsKey(item.currency))
                    {
                        if (item.type == "available")
                        {
                            temp[item.currency].Available = Convert.ToDecimal(item.price);
                        }
                        if (item.type == "trade")
                        {
                            temp[item.currency].OnOrders = Convert.ToDecimal(item.price);
                        }
                    }
                    else
                    {
                        if (item.type == "available")
                        {
                            var a = new TransformBallans();
                            a.Available = Convert.ToDecimal(item.price);
                            temp.Add(item.currency, a);
                        }
                        if (item.type == "trade")
                        {
                            var a = new TransformBallans();
                            a.OnOrders = Convert.ToDecimal(item.price);
                            temp.Add(item.currency, a);
                        }
                    }
                }
                return(temp);
            }
        }