Exemple #1
0
        //id转带sh或sz
        public static NET_ERROR IdConvert(ref string stockid)
        {
            List <string> shid = new List <string>();
            List <string> szid = new List <string>();

            shid.Add("0" + stockid);
            szid.Add("1" + stockid);
            StockInfo si = new Netease();
            Dictionary <string, StockInfoEntity> ds;
            NET_ERROR NE = si.StockGetWithCheck(ref shid, out ds);

            if (NE == NET_ERROR.NET_REQ_OK && ds.Count > 0)
            {
                stockid = ds.First().Key;
            }
            else
            {
                return(NE);
            }
            NE = si.StockGetWithCheck(ref szid, out ds);
            if (NE == NET_ERROR.NET_REQ_OK && ds.Count > 0)
            {
                stockid = ds.First().Key;
            }
            return(NE);
        }
Exemple #2
0
 public static void Show(NET_ERROR e)
 {
     if (e == NET_ERROR.NET_CANT_CONNECT)
     {
         MessageBox.Show("网络无法连接");
     }
     else if (e == NET_ERROR.NET_JSON_NOT_EXISTS)
     {
         MessageBox.Show("数据不存在");
     }
     else if (e == NET_ERROR.NET_REQ_ERROR)
     {
         MessageBox.Show("请求错误");
     }
 }
Exemple #3
0
 public static void Show(NET_ERROR e)
 {
     if (e == NET_ERROR.NET_CANT_CONNECT)
     {
         MessageBox.Show("网络无法连接");
     }
     else if (e == NET_ERROR.NET_JSON_NOT_EXISTS)
     {
         MessageBox.Show("数据不存在");
     }
     else if (e == NET_ERROR.NET_REQ_ERROR)
     {
         MessageBox.Show("请求错误");
     }
 }
Exemple #4
0
        //批量获取名称
        public static NET_ERROR CheckName(List <string> stockid, out Dictionary <string, string> name)
        {
            StockInfo si = new Netease();
            Dictionary <string, StockInfoEntity> ds;
            NET_ERROR NE = si.StockGetWithCheck(ref stockid, out ds);

            name = new Dictionary <string, string>();
            if (NE == NET_ERROR.NET_REQ_OK)
            {
                foreach (var s in ds)
                {
                    name[s.Key] = s.Value.name;
                }
            }
            return(NE);
        }
Exemple #5
0
        //获取股票名称
        public static NET_ERROR CheckName(string stockid, out string name)
        {
            StockInfo     si = new Netease();
            List <string> id = new List <string>();

            id.Add(stockid);
            Dictionary <string, StockInfoEntity> ds;
            NET_ERROR NE = si.StockGetWithCheck(ref id, out ds);

            if (NE == NET_ERROR.NET_REQ_OK && ds.Count > 0)
            {
                name = ds.First().Value.name;
            }
            else
            {
                name = "";
            }
            return(NE);
        }
Exemple #6
0
 public abstract NET_ERROR HistoryMoney(string id, DateTime date, DateTime enddate, out Dictionary<DateTime, double> money);//返回股票历史收盘价
 protected void UpdateLog(string stockid, NET_ERROR e)//更新日志
 {
     DateTime dt = DateTime.Now;
     if (log.Count >= 100)//日志限制100条
     {
         log.RemoveRange(0, log.Count - 100);
     }
     if (e == NET_ERROR.NET_CANT_CONNECT)
     {
         log.Add(dt.ToLongTimeString().ToString() + ":" + stockid + " NET_CANT_CONNECT");
     }
     else if (e == NET_ERROR.NET_JSON_NOT_EXISTS)
     {
         log.Add(dt.ToLongTimeString().ToString() + ":" + stockid + " NET_JSON_NOT_EXISTS");
     }
     else if (e == NET_ERROR.NET_REQ_ERROR)
     {
         log.Add(dt.ToLongTimeString().ToString() + ":" + stockid + " NET_REQ_ERROR");
     }
 }
Exemple #7
0
        public abstract NET_ERROR HistoryMoney(string id, DateTime date, DateTime enddate, out Dictionary <DateTime, double> money); //返回股票历史收盘价

        protected void UpdateLog(string stockid, NET_ERROR e)                                                                        //更新日志
        {
            DateTime dt = DateTime.Now;

            if (log.Count >= 100)//日志限制100条
            {
                log.RemoveRange(0, log.Count - 100);
            }
            if (e == NET_ERROR.NET_CANT_CONNECT)
            {
                log.Add(dt.ToLongTimeString().ToString() + ":" + stockid + " NET_CANT_CONNECT");
            }
            else if (e == NET_ERROR.NET_JSON_NOT_EXISTS)
            {
                log.Add(dt.ToLongTimeString().ToString() + ":" + stockid + " NET_JSON_NOT_EXISTS");
            }
            else if (e == NET_ERROR.NET_REQ_ERROR)
            {
                log.Add(dt.ToLongTimeString().ToString() + ":" + stockid + " NET_REQ_ERROR");
            }
        }
Exemple #8
0
        //批量转id
        public static NET_ERROR IdConvert(ref List <string> stockid)
        {
            List <string> shid = new List <string>();
            List <string> szid = new List <string>();

            foreach (string id in stockid)
            {
                shid.Add("0" + id);
                szid.Add("1" + id);
            }
            stockid.Clear();
            StockInfo si = new Netease();
            Dictionary <string, StockInfoEntity> ds;
            NET_ERROR NE = si.StockGetWithCheck(ref shid, out ds);

            if (NE == NET_ERROR.NET_REQ_OK)
            {
                foreach (var s in ds)
                {
                    stockid.Add(s.Key);
                }
            }
            else
            {
                return(NE);
            }
            NE = si.StockGetWithCheck(ref szid, out ds);
            if (NE == NET_ERROR.NET_REQ_OK)
            {
                foreach (var s in ds)
                {
                    stockid.Add(s.Key);
                }
            }
            return(NE);
        }