Ejemplo n.º 1
0
        public static int GetDepth(string symbol)
        {
            //委单
            String JsonStr = Http.HttpGet(Define.Depth, "symbol=" + symbol + "&isClient=" + Define.channel_code);

            JsonData jsondata = GetJsonData(JsonStr);

            if (jsondata != null)
            {
                if (jsondata["asks"] != null)
                {
                    lock (Data.SellDepthList)
                    {
                        Data.SellDepthList.Clear();
                        int fdsaf = jsondata["asks"].Count;
                        for (int i = 0; i < jsondata["asks"].Count; i++)
                        {
                            Consign consign = new Consign();
                            //consign.c1 = c1.InnerText;
                            if (jsondata["asks"][i] != null)
                            {
                                consign.setprice(jsondata["asks"][i][0].ToString());
                            }
                            if (jsondata["asks"][i] != null)
                            {
                                consign.setnum(jsondata["asks"][i][1].ToString());
                            }
                            Data.SellDepthList.Add(consign);
                        }
                    }
                }

                if (jsondata["bids"] != null)
                {
                    Data.BuyDepthList.Clear();
                    int fdsaf = jsondata["bids"].Count;
                    for (int i = 0; i < jsondata["bids"].Count; i++)
                    {
                        Consign consign = new Consign();
                        //consign.c1 = c1.InnerText;
                        if (jsondata["bids"][i] != null)
                        {
                            consign.setprice(jsondata["bids"][i][0].ToString());
                        }
                        if (jsondata["bids"][i] != null)
                        {
                            consign.setnum(jsondata["bids"][i][1].ToString());
                        }
                        Data.BuyDepthList.Add(consign);
                    }
                }
            }
            return(Define.Login_Succeed);
        }
Ejemplo n.º 2
0
        public static int DoOrderHistory(String status, String symbol, String currentPage, String pageLength)
        {
            String JsonStr = Http.HttpPost(Define.OrderHistory, "symbol=" + symbol + "&status=" + status + "&currentPage=" + currentPage + "&pageLength=" + pageLength + "&isClient=" + Define.channel_code);

            JsonData jsondata = GetJsonData(JsonStr);
            if (jsondata != null)
            {
                if (jsondata["result"] != null)
                {
                    if (jsondata["result"].ToString() == "True")
                    {
                        if (jsondata["total"] != null)
                        {
                            int total = Convert.ToInt32(jsondata["total"].ToString());
                            if (total > 0)
                            {
                                int Count = jsondata["orders"].Count;
                                if (Count > 0)
                                {
                                    lock (Data.OrderList)
                                    {
                                        if (status == "0")
                                        {
                                            Data.OrderList.Clear();
                                            //Data.OrderMap.Clear();
                                        }
                                        else if (status == "2")
                                        {
                                            Data.OrderHistoryList.Clear();
                                            //Data.OrderHistoryMap.Clear();
                                        }
                                    }

                                }

                                for (int i = 0; i < jsondata["orders"].Count; i++)
                                {

                                    //consign.c1 = c1.InnerText;
                                    if (jsondata["orders"][i] != null)
                                    {
                                        String orders_id = jsondata["orders"][i]["orders_id"].ToString();

                                        lock (Data.OrderList)
                                        {
                                            if (status == "0")
                                            {
                                                //Data.OrderMap.TryGetValue(orders_id, out orders_id);
                                            }
                                            else if(status == "2")
                                            {
                                                //Data.OrderHistoryMap.TryGetValue(orders_id, out orders_id);
                                            }
                                        }

                                        if (orders_id != null && orders_id != "")
                                        {

                                            Consign consign = new Consign();
                                            //consign.setprice(jsondata["orders"][i][0].ToString());

                                            consign.amount = jsondata["orders"][i]["amount"].ToString();                            //委单币的数量
                                            consign.avg_rate = jsondata["orders"][i]["avg_rate"].ToString();                        //平均成交价
                                            consign.createDate = jsondata["orders"][i]["createDate"].ToString().Substring(0,10);    //时间
                                            consign.deal_amount = jsondata["orders"][i]["deal_amount"].ToString();                  //成交数量
                                            consign.orders_id = jsondata["orders"][i]["orders_id"].ToString();                      //交易单号
                                            consign.rate = jsondata["orders"][i]["rate"].ToString();                                //价格
                                            consign.status = jsondata["orders"][i]["status"].ToString();                            //挂单状态-1:已撤销 0/3:未成交 1:部分成交 2:完全成交
                                            consign.type = jsondata["orders"][i]["type"].ToString();                                //sell_market

                                            lock (Data.OrderList)
                                            {
                                                if (status == "0")
                                                {
                                                    Data.OrderList.Add(consign);
                                                    //Data.OrderMap.Add(consign.orders_id, "1");
                                                }
                                                else if (status == "2")
                                                {
                                                    Data.OrderHistoryList.Add(consign);
                                                    //Data.OrderHistoryMap.Add(consign.orders_id, "1");
                                                }
                                            }

                                        }
                                    }

                                    //{"orders":[{"amount":0.21,"avg_rate":0,"createDate":1391742319000,"deal_amount":0,"orders_id":66081,"rate":0,"status":0,"type":"sell_market"}],"result":true}

                                }
                            }

                        }
                    }
                    else
                    {
                        lock (Data.OrderList)
                        {
                            if (status == "0")
                            {
                                Data.OrderList.Clear();
                                //Data.OrderMap.Clear();
                            }
                            else if (status == "2")
                            {
                                Data.OrderHistoryList.Clear();
                                //Data.OrderHistoryMap.Clear();
                            }
                        }

                    }
                }
            }
            return Define.Login_Succeed;
        }
Ejemplo n.º 3
0
        public static int GetDepth(string symbol)
        {
            //委单
            String JsonStr = Http.HttpGet(Define.Depth, "symbol=" + symbol + "&isClient=" + Define.channel_code);

            JsonData jsondata = GetJsonData(JsonStr);
            if (jsondata != null)
            {

                if (jsondata["asks"] != null)
                {
                    lock(Data.SellDepthList)
                    {
                        Data.SellDepthList.Clear();
                        int fdsaf = jsondata["asks"].Count;
                        for (int i = 0; i < jsondata["asks"].Count; i++)
                        {
                            Consign consign = new Consign();
                            //consign.c1 = c1.InnerText;
                            if (jsondata["asks"][i] != null)
                            {
                                consign.setprice(jsondata["asks"][i][0].ToString());
                            }
                            if (jsondata["asks"][i] != null)
                            {
                                consign.setnum(jsondata["asks"][i][1].ToString());
                            }
                            Data.SellDepthList.Add(consign);
                        }
                    }

                }

                if (jsondata["bids"] != null)
                {
                    Data.BuyDepthList.Clear();
                    int fdsaf = jsondata["bids"].Count;
                    for (int i = 0; i < jsondata["bids"].Count; i++)
                    {
                        Consign consign = new Consign();
                        //consign.c1 = c1.InnerText;
                        if (jsondata["bids"][i] != null)
                        {
                            consign.setprice(jsondata["bids"][i][0].ToString());
                        }
                        if (jsondata["bids"][i] != null)
                        {
                            consign.setnum(jsondata["bids"][i][1].ToString());
                        }
                        Data.BuyDepthList.Add(consign);
                    }
                }

            }
            return Define.Login_Succeed;
        }
Ejemplo n.º 4
0
        public static int DoOrderHistory(String status, String symbol, String currentPage, String pageLength)
        {
            String JsonStr = Http.HttpPost(Define.OrderHistory, "symbol=" + symbol + "&status=" + status + "&currentPage=" + currentPage + "&pageLength=" + pageLength + "&isClient=" + Define.channel_code);

            JsonData jsondata = GetJsonData(JsonStr);

            if (jsondata != null)
            {
                if (jsondata["result"] != null)
                {
                    if (jsondata["result"].ToString() == "True")
                    {
                        if (jsondata["total"] != null)
                        {
                            int total = Convert.ToInt32(jsondata["total"].ToString());
                            if (total > 0)
                            {
                                int Count = jsondata["orders"].Count;
                                if (Count > 0)
                                {
                                    lock (Data.OrderList)
                                    {
                                        if (status == "0")
                                        {
                                            Data.OrderList.Clear();
                                            //Data.OrderMap.Clear();
                                        }
                                        else if (status == "2")
                                        {
                                            Data.OrderHistoryList.Clear();
                                            //Data.OrderHistoryMap.Clear();
                                        }
                                    }
                                }


                                for (int i = 0; i < jsondata["orders"].Count; i++)
                                {
                                    //consign.c1 = c1.InnerText;
                                    if (jsondata["orders"][i] != null)
                                    {
                                        String orders_id = jsondata["orders"][i]["orders_id"].ToString();

                                        lock (Data.OrderList)
                                        {
                                            if (status == "0")
                                            {
                                                //Data.OrderMap.TryGetValue(orders_id, out orders_id);
                                            }
                                            else if (status == "2")
                                            {
                                                //Data.OrderHistoryMap.TryGetValue(orders_id, out orders_id);
                                            }
                                        }



                                        if (orders_id != null && orders_id != "")
                                        {
                                            Consign consign = new Consign();
                                            //consign.setprice(jsondata["orders"][i][0].ToString());

                                            consign.amount      = jsondata["orders"][i]["amount"].ToString();                       //委单币的数量
                                            consign.avg_rate    = jsondata["orders"][i]["avg_rate"].ToString();                     //平均成交价
                                            consign.createDate  = jsondata["orders"][i]["createDate"].ToString().Substring(0, 10);  //时间
                                            consign.deal_amount = jsondata["orders"][i]["deal_amount"].ToString();                  //成交数量
                                            consign.orders_id   = jsondata["orders"][i]["orders_id"].ToString();                    //交易单号
                                            consign.rate        = jsondata["orders"][i]["rate"].ToString();                         //价格
                                            consign.status      = jsondata["orders"][i]["status"].ToString();                       //挂单状态-1:已撤销 0/3:未成交 1:部分成交 2:完全成交
                                            consign.type        = jsondata["orders"][i]["type"].ToString();                         //sell_market

                                            lock (Data.OrderList)
                                            {
                                                if (status == "0")
                                                {
                                                    Data.OrderList.Add(consign);
                                                    //Data.OrderMap.Add(consign.orders_id, "1");
                                                }
                                                else if (status == "2")
                                                {
                                                    Data.OrderHistoryList.Add(consign);
                                                    //Data.OrderHistoryMap.Add(consign.orders_id, "1");
                                                }
                                            }
                                        }
                                    }

                                    //{"orders":[{"amount":0.21,"avg_rate":0,"createDate":1391742319000,"deal_amount":0,"orders_id":66081,"rate":0,"status":0,"type":"sell_market"}],"result":true}
                                }
                            }
                        }
                    }
                    else
                    {
                        lock (Data.OrderList)
                        {
                            if (status == "0")
                            {
                                Data.OrderList.Clear();
                                //Data.OrderMap.Clear();
                            }
                            else if (status == "2")
                            {
                                Data.OrderHistoryList.Clear();
                                //Data.OrderHistoryMap.Clear();
                            }
                        }
                    }
                }
            }
            return(Define.Login_Succeed);
        }