Example #1
0
        public static void Main(string[] args)
        {
            List <InfoData> iflist = BizApi.QueryInfoAll();

            foreach (InfoData id in iflist)
            {
                InfoExtData ifd = QueryInfoExtFromEastMoney(id.sid);
                BizApi.InsertInfoExt(ifd);
                //Console.WriteLine(ifd.sid + " infoext inserted.");
            }

            //InfoExtData ifd = QueryInfoExtFromEastMoney("sh600339");
        }
        public static string Generate(string level, string tag, string old, string daybefore, string industry, string location, string type)
        {
            DateTime now        = BizCommon.ParseToDate(tag);
            DateTime end_date   = now.AddDays((double)(-Int32.Parse(daybefore)));
            DateTime start_date = end_date.AddMonths(-Int32.Parse(old));

            List <AnalyzeData> data = BizApi.QueryAnalyzeData(tag, start_date, end_date, Int32.Parse(level), industry, location, type);

            var newRow = "";

            newRow += "Start:" + BizCommon.ParseToString(start_date) + "  End:" + BizCommon.ParseToString(end_date);

            for (int i = 0; i < data.Count; i++)
            {
                newRow += "<tr>";
                var big = data[i].big;
                var sid = data[i].sid;


                var link = "<a target='_parent' href='/web/single_dynamic.html?sid=" + sid + "&big=" + big + "'>" + sid + "</a>";
                newRow += "<td>" + link + "</td>";
                newRow += "<td>" + data[i].name + "</td>";

                var ind1 = data[i].firstlevel;
                var ind2 = data[i].secondlevel;

                var ind_link1 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "'>" + ind1 + "</a>";
                newRow += "<td>" + ind_link1 + "</td>";
                var ind_link2 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "&industry2=" + ind2 + "'>" + ind2 + "</a>";
                newRow += "<td>" + ind_link2 + "</td>";

                var enddate   = data[i].enddate;
                var startdate = data[i].startdate;



                //newRow += "<td>" + start_date + "</td>";
                //newRow += "<td>" + end_date + "</td>";

                //排名情况
                var y = "/rest/rest/analyzevalue?level=" + level + "&tag=" + tag + "&sid=" + sid + "&daybefore=" + daybefore;

                newRow += "<td>" + QueryAnalyze1(sid, level, tag, old, daybefore) + "</td>";
                //newRow += "<td>" + data[i].rank + "</td>";
                newRow += "<td>" + data[i].value + "</td>";

                //财务信息

                InfoExtData data1 = BizApi.QueryInfoExtById(sid);

                newRow += "<td>" + data1.shiyinglv + "</td>";
                newRow += "<td>" + data1.shijinglv + "</td>";
                newRow += "<td>" + data1.jingzichan + "</td>";
                newRow += "<td>" + data1.shourutongbi + "</td>";
                newRow += "<td>" + data1.jingliruntongbi + "</td>";
                newRow += "<td>" + data1.meiguweifenpeilirun + "</td>";
                newRow += "<td>" + data1.zongguben + "</td>";
                newRow += "<td>" + data1.liutonggu + "</td>";

                //最新价格
                newRow += "<td>" + BizApi.QueryLatestPrice(sid, tag) + "</td>";

                //价格范围
                newRow += "<td>" + BizApi.QueryMaxMinPriceByRange(sid, 12) + "</td>";
            }

            return(newRow);
        }
Example #3
0
        public static InfoExtData QueryInfoExtFromEastMoney(string sid)
        {
            InfoExtData ifd = new InfoExtData();

            ifd.sid = sid;
            //Console.WriteLine("start");
            try
            {
                string       url      = string.Format("http://quote.eastmoney.com/{0}.html", sid);
                WebClient    client   = new WebClient();
                byte[]       gg       = client.DownloadData(url);
                string       haha     = System.Text.Encoding.GetEncoding("gb2312").GetString(gg);
                TextReader   stream   = new StringReader(haha);
                HtmlDocument document = new HtmlDocument();
                document.Load(stream);

                HtmlNode           rootNode = document.DocumentNode;
                HtmlNodeCollection c        = rootNode.SelectNodes("//table[@id='rtp2']");

                //处理html
                string innerString = c[0].InnerText;
                innerString = innerString.Replace(System.Environment.NewLine, "");
                innerString = innerString.Replace(":", ":");
                innerString = System.Text.RegularExpressions.Regex.Replace(innerString, @"\s{1,}", " ", RegexOptions.IgnoreCase);
                //innerString = innerString.Replace(": ", ":");

                bool     shourutongbi    = false;
                bool     jingliruntongbi = false;
                string[] array           = innerString.Trim().Split(' ');
                foreach (string item in array)
                {
                    if (item.Trim().Length > -1 && item.IndexOf(":") > -1)
                    {
                        string[] bb = item.Split(':');

                        if (bb[0].IndexOf("收益") > -1)
                        {
                            ifd.shouyi = decimal.Parse(bb[1]);
                        }
                        if (bb[0].IndexOf("PE") > -1)
                        {
                            ifd.shiyinglv = decimal.Parse(bb[1].Trim().Equals("-") ? "0" : bb[1].Trim());
                        }
                        if (bb[0].IndexOf("净资产") > -1)
                        {
                            ifd.jingzichan = decimal.Parse(bb[1]);
                        }
                        if (bb[0].IndexOf("市净率") > -1)
                        {
                            ifd.shijinglv = decimal.Parse(bb[1]);
                        }
                        if (bb[0].IndexOf("收入") > -1)
                        {
                            ifd.shouru   = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            shourutongbi = true;
                        }
                        if (bb[0].IndexOf("净利润") > -1)
                        {
                            ifd.jinglirun   = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            jingliruntongbi = true;
                        }
                        if (bb[0].IndexOf("同比") > -1)
                        {
                            if (shourutongbi)
                            {
                                ifd.shourutongbi = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                                shourutongbi     = false;
                            }
                            if (jingliruntongbi)
                            {
                                ifd.jingliruntongbi = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                                jingliruntongbi     = false;
                            }
                        }
                        if (bb[0].IndexOf("毛利率") > -1)
                        {
                            ifd.maolilv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("净利率") > -1)
                        {
                            ifd.jinglilv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("ROE") > -1)
                        {
                            ifd.ROE = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("负债率") > -1)
                        {
                            ifd.fuzhailv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("总股本") > -1)
                        {
                            ifd.zongguben = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("总值") > -1)
                        {
                            ifd.zongzhi = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("流通股") > -1)
                        {
                            ifd.liutonggu = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("流值") > -1)
                        {
                            ifd.liuzhi = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("每股未分配利润") > -1)
                        {
                            ifd.meiguweifenpeilirun = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                        }
                        if (bb[0].IndexOf("上市时间") > -1)
                        {
                            ifd.shangshishijian = bb[1];
                        }
                    }
                }
            }
            catch
            {
                StockLog.Log.Error(sid + " infoext parse fail");
            }

            return(ifd);
        }