private static List <ISINTemp> getISINListFromSinglePage(string pageSource)
        {
            List <ISINTemp> isinList = new List <ISINTemp>();
            HtmlDocument    htc      = new HtmlDocument();

            if (!String.IsNullOrEmpty(pageSource))
            {
                htc.LoadHtml(pageSource);
            }
            if (htc != null)
            {
                var nodeList = htc.DocumentNode.SelectNodes("//table/tr/td/table/tr");
                if (nodeList != null)
                {
                    for (int x = 1; x < nodeList.Count - 1; x++)
                    {
                        ISINTemp temp = new ISINTemp();
                        temp.ISIN   = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectSingleNode(".//td/a").InnerText);
                        temp.Issuer = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectNodes(".//td")[0].InnerText);
                        String attribute = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectSingleNode(".//td/a").Attributes["href"].Value);
                        String param1    = attribute.Split('(')[1].Split(',')[0].Trim(new Char[] { ' ', '\'' }).ToString();
                        String param2    = attribute.Split('(')[1].Split(',')[1].Trim(new Char[] { ' ', '\'' }).ToString();
                        temp.ISINLink       = String.Format("http://isin.krx.co.kr/jsp/BA_VW021.jsp?isu_cd={0}&modi=t&req_no={1}", param2, param1);
                        temp.ItemName       = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectNodes(".//td")[2].InnerText);
                        temp.Category       = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectNodes(".//td")[3].InnerText);
                        temp.Status         = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectNodes(".//td")[4].InnerText);
                        temp.IssueDate      = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectNodes(".//td")[5].InnerText);
                        temp.ListingDate    = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectNodes(".//td")[6].InnerText);
                        temp.ISINCreateDate = MiscUtil.GetCleanTextFromHtml(nodeList[x].SelectNodes(".//td")[7].InnerText);
                        isinList.Add(temp);
                    }
                }
            }
            return(isinList);
        }
        private List <TWISINOffclCode> GetISINList(HtmlNode rootNode)
        {
            var offclCodeISINList           = new List <TWISINOffclCode>();
            HtmlNodeCollection collection   = rootNode.SelectNodes("//tr");
            string             kindOfOption = "";

            foreach (var node in collection.Skip(1))
            {
                if (node.SelectSingleNode("./td").Attributes["colspan"] != null)
                {
                    kindOfOption = MiscUtil.GetCleanTextFromHtml(node.InnerText);
                    continue;
                }
                var ISINOffclCode = new TWISINOffclCode();
                HtmlNodeCollection tempCollection = node.SelectNodes("./td");
                int index = tempCollection[0].InnerText.IndexOf(" ");
                if (index < 0)
                {
                    index = tempCollection[0].InnerText.IndexOf(" ");
                }
                ISINOffclCode.OffclCode = tempCollection[0].InnerText.Substring(0, index);
                ISINOffclCode.ISIN      = tempCollection[1].InnerText;

                ISINOffclCode.FutureOptionType = kindOfOption;
                offclCodeISINList.Add(ISINOffclCode);
            }
            return(offclCodeISINList);
        }
Exemple #3
0
        private List <string> GetSourceFileLinks(string baseUrl)
        {
            holidayList = HolidayManager.SelectHoliday(5);
            List <string> linkList   = new List <string>();
            string        pageSource = WebClientUtil.GetPageSource(baseUrl, 1800000);
            HtmlDocument  htmlDoc    = new HtmlDocument();

            htmlDoc.LoadHtml(pageSource);
            var    tableList      = htmlDoc.DocumentNode.SelectNodes("//table[@class = 'styleShiryo']");
            var    nodeDailyList  = tableList[1].SelectNodes("tr/td");
            string dailyExcelLink = "http://www.tse.or.jp" + MiscUtil.GetCleanTextFromHtml(nodeDailyList[2].SelectSingleNode("a").Attributes["href"].Value);

            linkList.Add(dailyExcelLink);
            if (DateTime.Today == MiscUtil.GetNextWeeklyTradingDay(DateTime.Today, holidayList, 2) || specialCase.Equals("yes"))
            {
                var    nodeWeeklyList = tableList[2].SelectNodes("tr/td");
                string titleWeekly    = MiscUtil.GetCleanTextFromHtml(nodeWeeklyList[0].InnerText);
                if (IsLastWeekInfo(titleWeekly) || specialCase.Equals("yes"))
                {
                    string weeklyExcelLink = "http://www.tse.or.jp" + MiscUtil.GetCleanTextFromHtml(nodeWeeklyList[2].SelectSingleNode("a").Attributes["href"].Value);
                    linkList.Add(weeklyExcelLink);
                }
            }
            return(linkList);
        }
        public List <RicInfo> GetRicList()
        {
            List <RicInfo> warrantRicList = new List <RicInfo>();

            RicChineseList = GetRicChineseInfo();
            HtmlAgilityPack.HtmlNodeCollection ricNodeList = GetNewlyWarrantRicNode(warrantMainPageUri);
            int endPos = ricNodeList.Count < parent.WarrantEndPos ? ricNodeList.Count : parent.WarrantEndPos;

            for (int i = parent.WarrantStartPos - 1; i < endPos; i++)
            {
                HtmlAgilityPack.HtmlNode ricNode = ricNodeList[i];
                RicInfo ricInfo = new RicInfo();
                ricInfo.Code       = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 1 + 1].InnerText);
                ricInfo.Underlying = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 4 + 1].InnerText);

                string id = ricNode.ChildNodes[2 * 1 + 1].ChildNodes[0].Attributes["href"].Value;
                id = id.Substring(id.IndexOf('=') + 1);
                id = id.Substring(0, id.IndexOf("'"));

                //id = id.Substring(id.IndexOf('=') + 1, 5);
                string[] arr = GetUnderlyingForStockAndIssuePrice(id);
                if (Char.IsDigit(ricInfo.Underlying, 0))
                {
                    ricInfo.UnderlyingNameForStock = arr[0];
                }
                ricInfo.IssuerPrice = arr[1];

                ricInfo.Name                     = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 2 + 1].InnerText);
                ricInfo.Issuer                   = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 3 + 1].InnerText);
                ricInfo.BullBear                 = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 5 + 1].InnerText);
                ricInfo.BoardLot                 = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 6 + 1].InnerText);
                ricInfo.StrikeLevel              = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 7 + 1].InnerText);
                ricInfo.EntitlementRatio         = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 8 + 1].InnerText);
                ricInfo.TotalIssueSize           = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 9 + 1].InnerText);
                ricInfo.LauntchDate              = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 10 + 1].InnerText);
                ricInfo.ClearingCommencementDate = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 11 + 1].InnerText);
                ricInfo.ListingDate              = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 12 + 1].InnerText);
                ricInfo.MaturityDate             = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 13 + 1].InnerText);

                //Get Chinese name information
                foreach (RicInfo ric in RicChineseList)
                {
                    if (ric.Code == ricInfo.Code)
                    {
                        ricInfo.ChineseName = ric.ChineseName;
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }

                //Get Gear and Premium from PDF
                parent.PDFAnalysis(ricInfo, FMType.Warrant);
                warrantRicList.Add(ricInfo);
            }
            return(warrantRicList);
        }
        private void getSZSEIndexList()
        {
            string pageSource             = WebClientUtil.GetPageSource(configObj.SzseBaseUri, 180000, "");
            var    doc                    = WebClientUtil.GetHtmlDocument(string.Format("{0}/main/marketdata/hqcx/zsybg/", configObj.SzseBaseUri), 180000, "", Encoding.GetEncoding("gb2312"));
            string szseIndexSourceFileUrl = MiscUtil.GetCleanTextFromHtml(doc.DocumentNode.SelectNodes("//td[@align='right']/a")[0].Attributes["href"].Value);

            downloadAndParseIndexFile(string.Format("{0}{1}", configObj.SzseBaseUri, szseIndexSourceFileUrl));
            updateSZSEIndexListWithRic();
        }
 private void updateSSEIndexListWithRic()
 {
     foreach (ChinaIndex index in sseIndexList)
     {
         var htmlDoc  = WebClientUtil.GetHtmlDocument(index.SourceUrl, 180000, "", Encoding.GetEncoding("gb2312"));
         var nodeList = htmlDoc.DocumentNode.SelectNodes("//td[@class='table3']//a");
         foreach (HtmlNode node in nodeList)
         {
             string officialCode = MiscUtil.GetCleanTextFromHtml(node.InnerText);
             officialCode = officialCode.Substring(officialCode.IndexOf("(") + 1, (officialCode.IndexOf(")") - officialCode.IndexOf("(") - 1));
             index.RicList.Add(generateRic(officialCode));
         }
     }
 }
        //http://www.chinaclear.cn/isin/isinbiz/queryCommon.do?m=querycommon
        //http://www.chinaclear.cn/isin/isinbiz/queryCommon.do
        public string GetISINFromCode(string officialCode)
        {
            string isin     = string.Empty;
            string postData = string.Format("m=querycommon&currentPage=0&securitiesCode={0}&isin=&securitiesNameCL=&query=%B2%E9%D1%AF", officialCode);
            var    htmlDoc  = WebClientUtil.GetHtmlDocument(configObj.QueryUrl, 18000, postData);

            htmlDoc.DocumentNode.SelectNodes("//body//table//tr//td//table//tr//td//form//table//tr//td[@class='isnr']");
            var htmlDocumentNodes = htmlDoc.DocumentNode.SelectNodes("//body//table//tr//td//table//tr//td//table//tr//td[@class='isnr']");

            //TODO: To Find a Better Way to Get the ISIN
            if (htmlDocumentNodes.Count == 11)
            {
                isin = MiscUtil.GetCleanTextFromHtml(htmlDocumentNodes[8].InnerText);
            }
            return(isin);
        }
        //Get all the newly generated ISIN for goverment bond
        //http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=enter
        //http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=queryFast
        public List <RicISINInfo> GetAllISINForGoverBond()
        {
            AdvancedWebClient wc         = new AdvancedWebClient();
            string            postData   = "loginName=&password=&securitiesName=%BC%C7%D5%CB%CA%BD%B8%BD%CF%A2&securitiesCode=";
            string            url        = "http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=enter";
            string            pageSource = WebClientUtil.GetPageSource(wc, url, 18000, postData);

            pageSource = WebClientUtil.GetPageSource(wc, "http://www.chinaclear.cn/isin/user/userApplyLogin.do?m=queryFast", 18000, "", Encoding.GetEncoding("gb2312"));
            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
            htmlDoc.LoadHtml(pageSource);
            var nodeList = htmlDoc.DocumentNode.SelectNodes("//tr[@class='td5']");

            return(nodeList.Select(node => new RicISINInfo
            {
                ISIN = MiscUtil.GetCleanTextFromHtml(node.ChildNodes[1 * 2 + 1].InnerText), Name = MiscUtil.GetCleanTextFromHtml(node.ChildNodes[2 * 2 + 1].InnerText)
            }).ToList());
        }
Exemple #9
0
        public List <RicInfo> GetRicChineseInfo()
        {
            List <RicInfo> WarrantRicChineseList = new List <RicInfo>();

            HtmlAgilityPack.HtmlNodeCollection ricNodeList = GetNewlyWarrantRicNode("http://www.hkex.com.hk/chi/dwrc/newissue/newlaunch_c.htm");
            int endPos = ricNodeList.Count < parent.WarrantEndPos ? ricNodeList.Count : parent.WarrantEndPos;

            for (int i = parent.WarrantStartPos - 1; i < endPos; i++)
            {
                HtmlAgilityPack.HtmlNode ricNode = ricNodeList[i];
                RicInfo ricInfo = new RicInfo();
                ricInfo.Code        = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 1 + 1].InnerText);
                ricInfo.ChineseName = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 2 + 1].InnerText);
                WarrantRicChineseList.Add(ricInfo);
            }
            return(WarrantRicChineseList);
        }
Exemple #10
0
        //Get information from http://www.hkex.com.hk/eng/Warrant/Warrantsummary.asp?id={0}"
        private string[] GetUnderlyingForStockAndIssuePrice(string id)
        {
            string[] arr = { "", "" };
            string   uri = string.Format("http://www.hkex.com.hk/eng/dwrc/dwsummary.asp?id={0}", id);

            HtmlAgilityPack.HtmlDocument htmlDoc = WebClientUtil.GetHtmlDocument(uri, 180000);
            var nodes = htmlDoc.DocumentNode.SelectNodes("//body/font/table/tbody/tr/td//table/tbody/tr/td/table/tbody/tr");

            foreach (HtmlAgilityPack.HtmlNode node in nodes)
            {
                if (node.ChildNodes[2 * 0 + 1].InnerText == "Issue Price (Initial Issue):")
                {
                    arr[1] = MiscUtil.GetCleanTextFromHtml(node.ChildNodes[2 * 1 + 1].InnerText).Substring(4);
                }

                else if (node.ChildNodes[2 * 0 + 1].InnerText == "Underlying:")
                {
                    arr[0] = MiscUtil.GetCleanTextFromHtml(node.ChildNodes[2 * 1 + 1].InnerText).Substring(8);
                }
            }
            return(arr);
        }
        private void getSSEIndexList()
        {
            var doc      = WebClientUtil.GetHtmlDocument(string.Format("{0}/sseportal/index/cn/common/index_list_new.shtml", configObj.SseBaseUri), 180000, "", Encoding.GetEncoding("gb2312"));
            var nodeList = doc.DocumentNode.SelectNodes("//td[@class='table2']//a");

            foreach (HtmlNode node in nodeList)
            {
                //http://www.sse.com.cn/sseportal/index/cn/i000010/intro.
                if (node.ParentNode.Attributes["align"] == null)
                {
                    ChinaIndex index = new ChinaIndex();
                    index.ChineseName = MiscUtil.GetCleanTextFromHtml(node.InnerText);
                    index.SourceUrl   = string.Format("{0}{1}", configObj.SseBaseUri, node.Attributes["href"].Value);
                    //http://www.sse.com.cn/sseportal/index/cn/i000010/intro.shtml
                    //http://www.sse.com.cn/sseportal/index/cn/i000010/const_list.shtml
                    index.SourceUrl = index.SourceUrl.Replace("intro.shtml", "const_list.shtml");
                    sseIndexList.Add(index);
                }
            }

            updateSSEIndexListWithRic();
        }
        private void getCSIIndexList()
        {
            //string pageSource = WebClientUtil.GetPageSource(null, string.Format("{0}/sseportal/csiportal/xzzx/queryindexdownloadlist.do?type=1", configObj.CSI_BASE_URI), 180000, "", Encoding.GetEncoding("gb2312"));
            var doc       = WebClientUtil.GetHtmlDocument(string.Format("{0}/sseportal/csiportal/xzzx/queryindexdownloadlist.do?type=1", configObj.CsiBaseUri), 180000, "", Encoding.GetEncoding("gb2312"));
            var nodeList  = doc.DocumentNode.SelectNodes("//tr[@align='center']");
            var nodeList2 = doc.DocumentNode.SelectNodes("//tr[@class='list-div-table-header']");

            foreach (HtmlNode node in nodeList2)
            {
                nodeList.Append(node);
            }

            for (int i = 0; i < nodeList.Count; i++)
            {
                ChinaIndex index = new ChinaIndex();
                index.ChineseName = MiscUtil.GetCleanTextFromHtml(nodeList[i].ChildNodes[2 * 0 + 1].ChildNodes[2].InnerText);
                try
                {
                    if (nodeList[i].ChildNodes[2 * 5 + 1].ChildNodes.Count == 3)
                    {
                        index.SourceUrl  = configObj.CsiBaseUri + MiscUtil.GetCleanTextFromHtml(nodeList[i].ChildNodes[2 * 5 + 1].ChildNodes[1].Attributes["href"].Value);
                        index.OfficeCode = getOfficialCodeForCSI(index.SourceUrl);
                        index.RicList    = getRicsForCSI(index.SourceUrl);
                        csiIndexList.Add(index);
                    }
                    else
                    {
                        Logger.Log(string.Format("There's no '成分股列表'in the exchange web site for {0}", index.ChineseName));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(string.Format("There's error when parsing information for {0}. Exception message: {1} ", index.ChineseName, ex.Message));
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// Grab drop anouncement from kind webpage.
        /// </summary>
        private void GrabDataFromKindWebpage()
        {
            string startDate = configObj.StartDate;
            string endDate   = configObj.EndDate;

            if (string.IsNullOrEmpty(startDate))
            {
                startDate = DateTime.Today.ToString("yyyy-MM-dd");
            }
            if (string.IsNullOrEmpty(endDate))
            {
                endDate = DateTime.Today.ToString("yyyy-MM-dd");
            }
            string dataStartDate = (DateTime.Parse(endDate).AddMonths(-2)).ToString("yyyy-MM-dd");
            string postData      = string.Format("method=searchTotalInfoSub&forward=searchtotalinfo_detail&searchCodeType=&searchCorpName=%EC%83%81%EC%9E%A5%ED%8F%90%EC%A7%80&repIsuSrtCd=&isurCd=&fdName=all_mktact_idx&pageIndex=1&currentPageSize=300&scn=mktact&srchFd=2&kwd=%EC%83%81%EC%9E%A5%ED%8F%90%EC%A7%80&fromData={0}&toData={1}", dataStartDate, endDate);
            string searchUri     = "http://kind.krx.co.kr/disclosure/searchtotalinfo.do";

            try
            {
                HtmlDocument htc        = new HtmlDocument();
                var          pageSource = WebClientUtil.GetDynamicPageSource(searchUri, 300000, postData);
                if (!string.IsNullOrEmpty(pageSource))
                {
                    htc.LoadHtml(pageSource);
                }
                HtmlNodeCollection nodeCollections = htc.DocumentNode.SelectNodes("//dt");
                HtmlNodeCollection ddCollections   = htc.DocumentNode.SelectNodes("//dl/dd");

                if (nodeCollections.Count > 0)
                {
                    for (int i = nodeCollections.Count - 1; i >= 0; i--)
                    {
                        HtmlNode ddNode = ddCollections[i].SelectSingleNode(".//span");

                        HtmlNode dtNode    = nodeCollections[i];
                        HtmlNode node      = nodeCollections[i].SelectSingleNode(".//span/a");
                        string   titleNode = string.Empty;
                        if (node != null)
                        {
                            titleNode = node.InnerText.ToString();
                        }
                        titleNode = titleNode.Contains("[") ? titleNode.Replace("[", "").Replace("]", "").Trim().ToString() : titleNode;

                        if (titleNode.Contains("신주인수권증권 상장폐지"))
                        {
                            HtmlNode nodeDate = dtNode.SelectSingleNode("./em");
                            if (nodeDate != null)
                            {
                                DateTime anouncementDate = new DateTime();
                                anouncementDate = DateTime.Parse(nodeDate.InnerText.Trim(), new CultureInfo("en-US"));
                                if (anouncementDate < DateTime.Parse(startDate))
                                {
                                    continue;
                                }
                            }
                            string title = titleNode.Substring(0, "신주인수권증권 상장폐지".Length).Trim().ToString();
                            if (title.Equals("신주인수권증권 상장폐지"))
                            {
                                CompanyWarrantDropTemplate item = new CompanyWarrantDropTemplate();
                                HtmlNode header    = nodeCollections[i].SelectSingleNode(".//strong/a");
                                string   attribute = string.Empty;
                                if (header != null)
                                {
                                    attribute = header.Attributes["onclick"].Value.ToString().Trim();
                                }
                                if (!string.IsNullOrEmpty(attribute))
                                {
                                    attribute = attribute.Split('(')[1].Split(')')[0].Trim(new Char[] { ' ', '\'', ';' }).ToString();
                                }

                                string judge = ddNode.InnerText.Split(':')[1].Trim();

                                //string attrituteUri = string.Format("http://kind.krx.co.kr/common/companysummary.do?method=searchCompanySummary&strIsurCd={0}&lstCd=undefined", attribute);
                                //string judge = string.Empty;
                                //HtmlDocument doc = WebClientUtil.GetHtmlDocument(attrituteUri, 120000, null);
                                //if (doc != null)
                                //{
                                //    HtmlNode docnode = doc.DocumentNode.SelectSingleNode("//div[@id='pContents']/table/tbody/tr[2]/td[2]");
                                //    if (docnode != null)
                                //    {
                                //        judge = docnode.InnerText;
                                //    }
                                //}


                                string parameters = node.Attributes["onclick"].Value.ToString().Trim();
                                parameters = parameters.Split('(')[1].Split(')')[0].ToString().Trim(new char[] { ' ', '\'', ';' });
                                string param1 = parameters.Split(',')[0].Trim(new char[] { ' ', '\'', ',' }).ToString();
                                string param2 = parameters.Split(',')[1].Trim(new char[] { ' ', '\'', ',' }).ToString();
                                string uri    = string.Format("http://kind.krx.co.kr/common/disclsviewer.do?method=search&acptno={0}&docno={1}&viewerhost=&viewerport=", param1, param2);

                                HtmlDocument doc    = WebClientUtil.GetHtmlDocument(uri, 300000, null);
                                string       ticker = string.Empty;
                                if (doc != null)
                                {
                                    ticker = doc.DocumentNode.SelectSingleNode("//header/h1").InnerText;
                                }

                                if (!string.IsNullOrEmpty(ticker))
                                {
                                    Match m = Regex.Match(ticker, @"\(([0-9a-zA-Z]{6})\)");
                                    if (m == null)
                                    {
                                        string msg = "Cannot get ticker numbers in ." + ticker;
                                        Logger.Log(msg, Logger.LogType.Error);
                                        continue;
                                    }
                                    ticker = m.Groups[1].Value;
                                }

                                //if (!string.IsNullOrEmpty(ticker))
                                //    ticker = ticker.Split('(')[1].Trim(new char[] { ' ', ')', '(' }).ToString();

                                string param3 = judge.Contains("유가증권") ? "68913" : (judge.Contains("코스닥") ? "70925" : null);
                                if (string.IsNullOrEmpty(param3))
                                {
                                    return;
                                }
                                param1 = param1.Insert(4, "/").Insert(7, "/").Insert(10, "/").ToString();
                                uri    = string.Format("http://kind.krx.co.kr/external/{0}/{1}/{2}.htm", param1, param2, param3);

                                doc = WebClientUtil.GetHtmlDocument(uri, 300000, null);
                                if (doc == null)
                                {
                                    return;
                                }
                                // For KQ
                                if (judge.Contains("코스닥"))
                                {
                                    HtmlNode koreaName = doc.DocumentNode.SelectSingleNode("//tr[1]/td[2]");
                                    HtmlNode effective = doc.DocumentNode.SelectSingleNode("//tr[5]/td[2]");
                                    string   kname     = string.Empty;
                                    string   edate     = string.Empty;
                                    if (koreaName != null)
                                    {
                                        kname = koreaName.InnerText.Trim().ToString();
                                    }
                                    if (effective != null)
                                    {
                                        edate = effective.InnerText.Trim().ToString();
                                    }
                                    kname = kname.Trim().ToString();
                                    if (!string.IsNullOrEmpty(kname))
                                    {
                                        kname = kname.Contains("(주)") ? kname.Replace("(주)", "").Trim() : kname;
                                    }
                                    edate = edate.Trim().ToString();
                                    if (!string.IsNullOrEmpty(edate))
                                    {
                                        edate = Convert.ToDateTime(edate).ToString("yyyy-MMM-dd", new CultureInfo("en-US"));
                                    }
                                    item.KoreanName    = kname;
                                    item.EffectiveDate = edate;
                                    item.RIC           = ticker + ".KQ";
                                    waDrop.Add(item);
                                }
                                //For KS
                                else if (judge.Contains("유가증권"))
                                {
                                    string skName = MiscUtil.GetCleanTextFromHtml(doc.DocumentNode.SelectSingleNode("//tr[1]/td[2]").InnerText);
                                    skName = Regex.Split(skName, "   ", RegexOptions.IgnoreCase)[0].Trim(new char[] { ' ', ':' }).ToString();
                                    string seDate = MiscUtil.GetCleanTextFromHtml(doc.DocumentNode.SelectSingleNode("//tr[8]/td[2]").InnerText);
                                    seDate             = Convert.ToDateTime(seDate).ToString("yyyy-MMM-dd", new CultureInfo("en-US"));
                                    item.KoreanName    = skName;
                                    item.EffectiveDate = seDate;
                                    item.RIC           = ticker + ".KS";
                                    waDrop.Add(item);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                String msg = "Error found in SearchTheWebpageToGrabData()      : \r\n" + ex.InnerException + "  :  \r\n" + ex.ToString();
                Logger.Log(msg, Logger.LogType.Error);
                return;
            }
        }
        public static KoreaCompany GetCompanyInfo(string attribute)
        {
            KoreaCompany company = null;

            try
            {
                string uri             = "http://kind.krx.co.kr/common/companysummary.do";
                string companyPostData = string.Format("method=searchCompanySummaryOvrvwDetail&menuIndex=0&strIsurCd={0}&lstCd=undefined&taskDd=&spotIsuTrdMktTpCd=&methodType=0", attribute);

                string companyPageSource = null;
                int    retry             = 3;

                while (string.IsNullOrEmpty(companyPageSource) && retry-- > 0)
                {
                    try
                    {
                        companyPageSource = WebClientUtil.GetDynamicPageSource(uri, 300000, companyPostData);
                    }
                    catch
                    {
                        System.Threading.Thread.Sleep(3000);
                    }
                }

                if (string.IsNullOrEmpty(companyPageSource))
                {
                    return(null);
                }

                companyPageSource = MiscUtil.GetCleanTextFromHtml(companyPageSource);
                HtmlDocument companyDoc = new HtmlDocument();
                if (!string.IsNullOrEmpty(companyPageSource))
                {
                    companyDoc.LoadHtml(companyPageSource);
                }


                if (companyDoc != null)
                {
                    company = new KoreaCompany();
                    HtmlNode table     = companyDoc.DocumentNode.SelectNodes("//table")[0];
                    string   koreaName = table.SelectSingleNode(".//tr[1]/td[1]").InnerText.Trim();
                    string   legalName = table.SelectSingleNode(".//tr[1]/td[2]").InnerText.Trim();
                    string   isin      = table.SelectSingleNode(".//tr[2]/td[1]").InnerText.Trim();;
                    string   market    = table.SelectSingleNode(".//tr[3]/td[2]").InnerText.Trim();
                    market = GetMarketCode(market);
                    string listingDate = table.SelectSingleNode(".//tr[3]/td[1]").InnerText.Trim();

                    if (!string.IsNullOrEmpty(market))
                    {
                        company.Market = market;
                    }
                    if (!string.IsNullOrEmpty(isin))
                    {
                        company.ISIN = isin;
                    }
                    if (!string.IsNullOrEmpty(legalName))
                    {
                        company.LegalName = legalName;
                    }
                    if (!string.IsNullOrEmpty(koreaName))
                    {
                        company.KoreaName = koreaName;
                    }
                    if (!string.IsNullOrEmpty(listingDate))
                    {
                        company.ListingDate = listingDate;
                    }
                }
            }
            catch
            {
                return(null);
            }
            return(company);
        }