Example #1
0
        public double[] getTickerData(string coinName)
        {
            JArray retData = apiData.getTicker(coinName);

            if (retData == null)
            {
                return(null);
            }
            if (retData.Count < 1)
            {
                return(null);
            }

            double[] retTickerData = new double[11];
            retTickerData[0]  = (double)retData[0]["opening_price"];
            retTickerData[1]  = (double)retData[0]["trade_price"];
            retTickerData[2]  = (double)retData[0]["low_price"];
            retTickerData[3]  = (double)retData[0]["high_price"];
            retTickerData[4]  = (double)retData[0]["trade_volume"];
            retTickerData[5]  = (double)retData[0]["acc_trade_price"];
            retTickerData[6]  = (double)retData[0]["prev_closing_price"];
            retTickerData[7]  = (double)retData[0]["acc_trade_volume_24h"];
            retTickerData[8]  = (double)retData[0]["acc_trade_price_24h"];
            retTickerData[9]  = (double)retData[0]["signed_change_price"];
            retTickerData[10] = (double)retData[0]["signed_change_rate"];

            return(retTickerData);
        }
Example #2
0
        // update 'btmiIndex_swap' and 'btaiIndex_swap' swap buffer using API
        private int updateBtmi()
        {
            JArray retData = apiData.getTicker(new List <string> {
                "BTC", "ETH"
            });

            if (retData == null)
            {
                return(-1);
            }

            btcIndex_swap = new Index((JObject)retData[0]);
            ethIndex_swap = new Index((JObject)retData[1]);

            return(0);
        }
Example #3
0
        public int updateHoldList()
        {
            List <string> tickerList = new List <string>();
            JArray        retData    = apiData.getAsset();

            if (retData == null)
            {
                return(-1);
            }

            holdList.Rows.Clear();
            for (int i = 0; i < retData.Count; i++)
            {
                DataRow dataRow = holdList.NewRow();
                dataRow["name"]    = retData[i]["currency"];
                dataRow["locked"]  = retData[i]["locked"];
                dataRow["balance"] = (double)retData[i]["locked"] + (double)retData[i]["balance"];
                if (retData[i]["currency"].ToString() == "KRW")
                {
                    dataRow["last"]  = 1d;
                    dataRow["total"] = dataRow["balance"];
                }
                else
                {
                    tickerList.Add(retData[i]["currency"].ToString());
                }
                holdList.Rows.Add(dataRow);
            }

            if (tickerList.Count < 1)
            {
                return(0);
            }
            retData = apiData.getTicker(tickerList);
            if (retData == null)
            {
                return(-2);
            }

            for (int i = 0; i < retData.Count; i++)
            {
                string[] temp = retData[i]["market"].ToString().Split('-');
                if (temp.Length < 2)
                {
                    continue;
                }
                for (int j = 0; j < holdList.Rows.Count; j++)
                {
                    if (holdList.Rows[j]["name"].ToString() == temp[1])
                    {
                        holdList.Rows[j]["last"]  = retData[i]["trade_price"];
                        holdList.Rows[j]["total"] = (double)holdList.Rows[j]["last"] * ((double)holdList.Rows[j]["locked"] + (double)holdList.Rows[j]["balance"]);
                        break;
                    }
                }
            }

            return(0);
        }
Example #4
0
        private int updateTicker()
        {
            JArray jArray = apiData.getTicker(coinList);

            if (jArray == null)
            {
                return(-1);
            }

            coinList.Clear();
            for (int i = 0; i < jArray.Count; i++)
            {
                string[] coinName = jArray[i]["market"].ToString().Split('-');
                coinList.Add(coinName[1]);
                ticker[coinName[1]].coinName   = coinName[1];
                ticker[coinName[1]].open       = (double)jArray[i]["opening_price"];
                ticker[coinName[1]].close      = (double)jArray[i]["trade_price"];
                ticker[coinName[1]].max        = (double)jArray[i]["high_price"];
                ticker[coinName[1]].min        = (double)jArray[i]["low_price"];
                ticker[coinName[1]].volume     = (double)jArray[i]["trade_volume"];
                ticker[coinName[1]].prePrice   = (double)jArray[i]["prev_closing_price"];
                ticker[coinName[1]].accTotal   = (double)jArray[i]["acc_trade_price"];
                ticker[coinName[1]].accVolume  = (double)jArray[i]["acc_trade_volume"];
                ticker[coinName[1]].change     = (double)jArray[i]["signed_change_price"];
                ticker[coinName[1]].changeRate = (double)jArray[i]["signed_change_rate"];

                if (ticker[coinName[1]].changeRate > 0.1)
                {
                    if (!hotList.Contains(coinName[1]))
                    {
                        hotList.Add(coinName[1]);
                    }
                    if (dangerList.Contains(coinName[1]))
                    {
                        dangerList.Remove(coinName[1]);
                    }
                }
                else if (ticker[coinName[1]].changeRate < -0.1)
                {
                    if (hotList.Contains(coinName[1]))
                    {
                        hotList.Remove(coinName[1]);
                    }
                    if (!dangerList.Contains(coinName[1]))
                    {
                        dangerList.Add(coinName[1]);
                    }
                }
            }

            return(0);
        }
Example #5
0
        public int setLastPrice()
        {
            JArray retData = apiData.getTicker(coinList);

            if (retData == null)
            {
                return(-1);
            }

            for (int i = 0; i < retData.Count; i++)
            {
                string[] temp = retData[i]["market"].ToString().Split('-');
                lastPrice[temp[1]] = (double)retData[i]["trade_price"];
            }

            return(0);
        }
Example #6
0
        // set last trade price using API
        public int setLastPrice()
        {
            List <string> coinList = new List <string>();

            for (int i = 0; i < setting.Count; i++)
            {
                coinList.Add(setting[i].coinName);
            }
            JArray retData = apiData.getTicker(coinList);

            if (retData == null)
            {
                return(-1);
            }

            for (int i = 0; i < retData.Count; i++)
            {
                string[] temp = retData[i]["market"].ToString().Split('-');
                lastPrice[temp[1]] = (double)retData[i]["trade_price"];
            }

            return(0);
        }