public List <RicInfo> GetRicChineseInfo()
        {
            List <RicInfo> cbbcRicChineseList = new List <RicInfo>();

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

            for (int i = parent.CbbcStartPos - 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);
                cbbcRicChineseList.Add(ricInfo);
            }
            return(cbbcRicChineseList);
        }
Пример #2
0
        public string GetIDNLongNameForWarrant(RicInfo ricObj, bool isIndex, bool isStock, bool isCall, bool isHKD, HK_IssuerCodeMap issuerCodeMap)
        {
            string idnLongName = "";

            //For Index
            if (isIndex)
            {
                if (ricObj.Underlying == "HSI")
                {
                    idnLongName = "HANG SENG@";
                }
                if (ricObj.Underlying == "HSCEI")
                {
                    idnLongName = "HANG SENG C E I@";
                }
                if (ricObj.Underlying == "DJI")
                {
                    idnLongName = "DJ INDU AVERAGE@";
                }

                idnLongName += GetIssuerName(ricObj.Issuer, issuerCodeMap)[0];
                idnLongName += " ";
                DateTime maturittDateTime = DateTime.ParseExact(ricObj.MaturityDate, "dd-MM-yyyy", null);
                idnLongName += maturittDateTime.ToString("MMMyy", new CultureInfo("en-US")).ToUpper() + " ";



                //Attach Strike Price from Strike Level
                //For HKD
                if (isHKD)
                {
                    idnLongName += ricObj.StrikeLevel.Substring(4);
                }
                else
                {
                    idnLongName += ricObj.StrikeLevel;
                }

                idnLongName += " ";
                //For Call
                if (isCall)
                {
                    idnLongName += "C";
                }
                //For Put
                else
                {
                    idnLongName += "P";
                }

                if (isIndex)
                {
                    idnLongName += "IW";
                }
                else
                {
                    idnLongName += "WT";
                }
            }
            //For Stock
            if (isStock)
            {
                idnLongName  = ricObj.UnderlyingNameForStock + "@";
                idnLongName += GetIssuerName(ricObj.Issuer, issuerCodeMap)[0];
                DateTime maturittDateTime = DateTime.ParseExact(ricObj.MaturityDate, "dd-MM-yyyy", null);
                idnLongName += maturittDateTime.ToString("MMMyy", new CultureInfo("en-US")).ToUpper() + " ";
                //Attach Strike Price from Strike Level
                //For HKD
                if (isHKD)
                {
                    idnLongName += ricObj.StrikeLevel.Substring(4);
                }
                else
                {
                    idnLongName += ricObj.StrikeLevel;
                }

                idnLongName += " ";
                //For Call
                if (isCall)
                {
                    idnLongName += "C";
                }
                //For Put
                else
                {
                    idnLongName += "P";
                }

                if (isIndex)
                {
                    idnLongName += "IW";
                }
                else
                {
                    idnLongName += "WT";
                }
            }

            return(idnLongName);
        }
Пример #3
0
        public string GetIDNLongName(RicInfo ric)
        {
            bool isIndex = false;
            bool isBull  = false;
            bool isHKD   = false;

            if (Char.IsLetter(ric.Underlying, 0))
            {
                isIndex = true;
            }
            if (ric.BullBear.ToLower().Contains("bull"))
            {
                isBull = true;
            }

            if (Char.IsLetter(ric.StrikeLevel, 0))
            {
                isHKD = true;
            }
            string idnLongName = string.Empty;

            //For Index
            if (isIndex)
            {
                if (ric.Underlying == "HSI")
                {
                    idnLongName = "HANG SENG@";
                }
                if (ric.Underlying == "HSCEI")
                {
                    idnLongName = "HANG SENG C E I@";
                }

                if (ric.Underlying == "DJI")
                {
                    idnLongName = "DJ INDU AVERAGE@";
                }
            }

            //For stock
            else
            {
                idnLongName += ric.UnderlyingNameForStock + "@";
            }

            idnLongName += GetIssuerName(ric.Issuer, issuerCodeObj)[0];
            idnLongName += " ";
            DateTime maturittDateTime = DateTime.ParseExact(ric.MaturityDate, "dd-MM-yyyy", null);

            idnLongName += maturittDateTime.ToString("MMMyy", new CultureInfo("en-US")).ToUpper() + " ";

            //For HKD
            if (isHKD)
            {
                idnLongName += ric.StrikeLevel.Trim().Substring(4);
            }
            else
            {
                idnLongName += ric.StrikeLevel.Trim();
            }
            idnLongName += " ";

            if (isBull)
            {
                idnLongName += "C";
            }
            else
            {
                idnLongName += "P";
            }
            if (isIndex)
            {
                idnLongName += "IR";
            }
            else
            {
                idnLongName += "R";
            }
            return(idnLongName);
        }
Пример #4
0
        public HKRicTemplate(RicInfo ricInfo, FMType fmType)
        {
            bool isIndex     = false;
            bool isCall      = false;
            bool isHKD       = false;
            bool isStock     = false;
            bool isOil       = false;
            bool isCommodity = false;

            if (ricInfo.Underlying == "HSI" || ricInfo.Underlying == "HSCEI" || ricInfo.Underlying == "DJI")
            {
                isIndex = true;
            }

            if (Char.IsDigit(ricInfo.Underlying, 0))
            {
                isStock = true;
            }
            if (ricInfo.Name.Contains("OIL"))
            {
                isOil = true;
            }

            if (ricInfo.BullBear.ToLower().Contains("call"))
            {
                isCall = true;
            }
            if (ricInfo.Name.Contains("GOLD") || ricInfo.Name.Contains("SILVER"))
            {
                isCommodity = true;
            }
            if (Char.IsLetter(ricInfo.StrikeLevel, 0))
            {
                isHKD = true;
            }

            issuerCodeObj = ConfigUtil.ReadConfig(issuerCodeMapPath, typeof(HK_IssuerCodeMap)) as HK_IssuerCodeMap;
            DateTime effectiveDate = DateTime.ParseExact(ricInfo.ListingDate, "dd-MM-yyyy", null);

            EffectiveDate     = effectiveDate.ToString("dd-MMM-yy");
            UnderLyingRic     = ricInfo.Code + ".HK";
            CompositeChainRic = "0#" + ricInfo.Code + ".HK";
            BrokerPageRic     = ricInfo.Code + "bk.HK";
            MiscInfoPageRic   = ricInfo.Code + "MI.HK";
            DisplayName       = ricInfo.Name;
            OfficicalCode     = ricInfo.Code;
            ExchangeSymbol    = ricInfo.Code;
            Currency          = "HKD";
            RecordType        = "097";
            SpareUbytes8      = "WRNT";
            #region For CBBC only
            //For CBBC only
            if (fmType == FMType.Cbbc)
            {
                IdnLongName         = GetIDNLongName(ricInfo);
                UnderlyingChainRic1 = "0#CBBC.HK";
                UnderlyingChainRic2 = "0#WARRANTS.HK";
                GNTX20_10           = "CBBC/" + ricInfo.BullBear;
                GNTX20_10           = GNTX20_10.ToUpper();
                Row80_13            = "Callable " + ricInfo.BullBear + " Contracts";
                WarrantType         = "Callable " + ricInfo.BullBear + " Contracts";
                RdmCur = "344";
                if (ricInfo.BullBear.ToLower().Contains("bear"))
                {
                    GVFlag = "P";
                }
                if (ricInfo.BullBear.ToLower().Contains("bull"))
                {
                    GVFlag = "C";
                }
                if (Char.IsLetter(ricInfo.StrikeLevel, 0))
                {
                    CallLevel = ricInfo.CallLevel.Substring(4);
                }
                else
                {
                    CallLevel = ricInfo.CallLevel;
                }
                if (Char.IsLetter(ricInfo.Underlying, 0))
                {
                    GNTX20_12 = "IDX~~~~~~<" + ricInfo.Code + "MI.HK>";
                    IssTpFlg  = "I";
                    if (ricInfo.Underlying == "HSCEI")
                    {
                        GNTX20_6   = "<.HSCE";
                        LongLink14 = ".HSCE|HKD|1  <-- TQR INSERT DAILY";
                    }
                    else if (ricInfo.Underlying == "HSI")
                    {
                        LongLink14 = ".HSI|HKD|1  <-- TQR INSERT DAILY";
                        GNTX20_6   = "<." + ricInfo.Underlying + ">";
                    }

                    else if (ricInfo.Underlying == "DJI")
                    {
                        LongLink14 = ".DJI|USD|1  <-- TQR INSERT DAILY";
                        GNTX20_6   = "<." + ricInfo.Underlying + ">";
                    }
                    else
                    {
                        GNTX20_6   = "<." + ricInfo.Underlying + ">";
                        LongLink14 = "Index not equal HSI,HSCEI or DJI";
                    }
                }
                else
                {
                    GNTX20_12  = "HKD~~~~~~<" + ricInfo.Code + "MI.HK>";
                    IssTpFlg   = "S";
                    GNTX20_6   = "<" + ricInfo.Underlying + ".HK>";
                    LongLink14 = ricInfo.Underlying.Substring(1) + ".HK";
                }
            }
            #endregion

            #region For Warrant only
            else
            {
                GNTX20_10   = "EU/" + ricInfo.BullBear;
                GNTX20_10   = GNTX20_10.ToUpper();
                Row80_13    = "Equity Warrant";
                IdnLongName = GetIDNLongNameForWarrant(ricInfo, isIndex, isStock, isCall, isHKD, issuerCodeObj);
                if (isCall)
                {
                    GVFlag = "C";
                }
                else
                {
                    GVFlag = "P";
                }
                if (isStock)
                {
                    UnderlyingChainRic1 = "0#" + ricInfo.Underlying.Substring(1) + "W.HK";
                    ChainRic1           = "0#CWRTS.HK";
                    WarrantType         = "Equity Warrant";
                    GNTX20_6            = "<" + ricInfo.Underlying.Substring(1) + ".HK>";
                    GNTX20_12           = "HKD~~~~~~<" + ricInfo.Code + "MI.HK>";
                    IssTpFlg            = "S";
                    RdmCur     = "344";
                    LongLink14 = ricInfo.Underlying.Substring(1) + ".HK";
                }

                else if (isIndex)
                {
                    ChainRic1 = "";
                    Row80_13  = "Index Warrant";
                    GNTX20_12 = "IDX~~~~~~<" + ricInfo.Code + "MI.HK>";
                    RdmCur    = "344";
                    if (ricInfo.Underlying == "HSCEI")
                    {
                        UnderlyingChainRic1 = "0#.HSCEW.HK";
                        WarrantType         = "Hang Seng China Enterprises Index Warrant";
                        GNTX20_6            = "<.HSCE>";
                        LongLink14          = ".HSCE|HKD|1  <-- TQR INSERT DAILY";
                    }
                    else if (ricInfo.Underlying == "HSI")
                    {
                        WarrantType         = "Hang Seng Index Warrant";
                        UnderlyingChainRic1 = "0#." + ricInfo.Underlying + "W.HK";
                        GNTX20_6            = "<." + ricInfo.Underlying + ">";
                        LongLink14          = ".HSI|HKD|1  <-- TQR INSERT DAILY";
                    }
                    else
                    {
                        if (ricInfo.Underlying == "DJI")
                        {
                            LongLink14 = ".DJI|USD|1  <-- TQR INSERT DAILY";
                        }
                        else
                        {
                            LongLink14 = "Index not equal HSI,HSCEI or DJI";
                        }
                        UnderlyingChainRic1 = "0#." + ricInfo.Underlying + "W.HK";
                        WarrantType         = "DJ Industrial Average Index Warrant";
                    }
                    IssTpFlg = "I";
                }
                else if (isOil)
                {
                    ChainRic1   = "0#OWRTS.HK";
                    WarrantType = "Oil Warrant";
                    Row80_13    = "Future Warrant";
                    RdmCur      = "840";
                }
                else if (isCommodity)
                {
                    Row80_13            = "Commodity Warrant";
                    UnderlyingChainRic1 = string.Empty;
                    ChainRic1           = "0#OWRTS.HK";
                    WarrantType         = "Miscellaneous Warrant";
                    RdmCur = "840";
                }
                else
                {
                    //isCurrency = true;
                    if (ricInfo.Name.Contains("YEN"))
                    {
                        RdmCur = "392";
                    }
                    UnderlyingChainRic1 = string.Empty;
                    ChainRic1           = "0#OWRTS.HK";
                    WarrantType         = "Miscellaneous Warrant";
                    Row80_13            = "Currency Warrant";
                    IssTpFlg            = "F";
                    RdmCur     = string.Empty;
                    LongLink14 = string.Empty;
                }
            }
            #endregion

            ChainRic2 = "0#WARRANTS.HK";

            MiscInfoPageChainRic = "0#MI.HK";
            LotSize = ricInfo.BoardLot;
            //ColDsplyNmll
            ColDsplyNmll = GetColDsplyNmllInfo(ricInfo);
            BcastRef     = "n/a";
            WntRation    = (1.0 / Convert.ToDouble(ricInfo.EntitlementRatio)).ToString();

            if (Char.IsLetter(ricInfo.StrikeLevel, 0))
            {
                StrikPrc = ricInfo.StrikeLevel.Substring(4);
            }
            else
            {
                StrikPrc = ricInfo.StrikeLevel;
            }

            DateTime maturDate = DateTime.ParseExact(ricInfo.MaturityDate, "dd-MM-yyyy", null);
            MaturDate = maturDate.ToString("dd-MMM-yy");

            LongLink3   = "t" + ricInfo.Code + ".HK";
            SpareSnum13 = "1";
            GNTX20_3    = "[HK-\"WARRAN*\"]";
            GNTX20_7    = "********************";

            GNTX20_11  = ricInfo.TotalIssueSize;
            CouponRate = "n/a";
            IssuePrice = ricInfo.IssuerPrice;
            BondType   = "WARRANTS";
            Leg1Str    = string.Empty;
            Leg2Str    = string.Empty;
            GNTXT24_1  = string.Empty;
            GNTXT24_2  = string.Empty;

            NewOrgList          = string.Empty;
            PrimaryList         = string.Empty;
            OrgnizationName1    = string.Empty;
            GeographyEntity     = string.Empty;
            OrgnizationType     = string.Empty;
            AliasPre            = string.Empty;
            AliasGen            = string.Empty;
            IssueClassification = string.Empty;
            MSCICode            = string.Empty;
            BusinessActivity    = string.Empty;
            ExistingOrgList     = string.Empty;
            PrimaryList         = string.Empty;
            OrgnizationName2    = GetIssuerName(ricInfo.Issuer, issuerCodeObj)[1];
            IssueClassification = "WNT";
            //For WRT_CNR
            Gearing = ricInfo.Gear;
            Premium = ricInfo.Premium;
            DateTime announcementData = DateTime.ParseExact(ricInfo.LauntchDate, "dd-MM-yyyy", null);
            AnnouncementDate = announcementData.ToString("dd-MMM-yy");
            PaymentDate      = DateTime.ParseExact(ricInfo.ClearingCommencementDate, "dd-MM-yyyy", null).ToString("dd-MMM-yy");
        }
Пример #5
0
        public void PDFAnalysis(RicInfo ric, FMType fmType)
        {
            string ricCode  = ric.Code;
            int    position = 0;
            string txtPath  = GetPDFToTxtFilePath(ricCode, fmType);

            System.Threading.Thread.Sleep(3000);
            try
            {
                if (txtPath == null)
                {
                    throw new Exception();
                }

                String       gearStr    = "";
                String       premiumStr = "";
                String       lineText   = "";
                StreamReader sr         = new StreamReader(txtPath);
                lineText = sr.ReadToEnd();
                sr.Close();


                //Get position of stock
                int stockIndex  = lineText.IndexOf("Stock code");
                int stockLength = "Stock code".Length;
                if (stockIndex < 0)
                {
                    stockIndex = lineText.IndexOf("Stock Code");
                }


                string codeStr = SearchKeyValue(stockIndex, stockLength, lineText);

                position = codeStr.IndexOf(ricCode) / 5 + 1;

                //Get gearing value
                int gearingIndex = lineText.IndexOf("\n Gearing* ");
                int gearLength   = "\n Gearing* ".Length;
                if (gearingIndex < 0)
                {
                    gearingIndex = lineText.IndexOf("\nGearing*");
                    gearLength   = "\nGearing*".Length;
                }
                if (gearingIndex < 0)
                {
                    gearingIndex = lineText.IndexOf("\n Gearing *");
                    gearLength   = "\n Gearing *".Length;
                }
                if (gearingIndex < 0)
                {
                    gearingIndex = lineText.IndexOf("\nGearing     *");
                    gearLength   = "\n Gearing     *".Length;
                }
                if (gearingIndex < 0)
                {
                    gearingIndex = lineText.IndexOf("\nGearing *");
                    gearLength   = "\nGearing *".Length;
                }

                if (gearingIndex < 0)
                {
                    gearingIndex = lineText.IndexOf("Gearing*");
                    gearLength   = "Gearing*".Length;
                }
                gearStr = SearchKeyValue(gearingIndex, gearLength, lineText);

                //Get premium value
                int premiumIndex  = lineText.IndexOf("Premium*");
                int premiumLength = "Premium*".Length;
                if (premiumIndex < 0)
                {
                    premiumIndex  = lineText.IndexOf("Premium *");
                    premiumLength = "Premium *".Length;
                }

                premiumStr = SearchKeyValue(premiumIndex, premiumLength, lineText);

                String[] gearArr    = gearStr.Split('x');
                String[] premiumArr = premiumStr.Split('%');

                ric.Gear    = gearArr[position - 1];
                ric.Premium = premiumArr[position - 1];
            }//end try
            catch (Exception)
            {
                Logger.Log("PDF analysis failed for " + ricCode + "! Action: Need manually input gearing and premium ", Logger.LogType.Warning);
            }
        }
        public List <RicInfo> GetRicList()
        {
            List <RicInfo> cbbcRicList = new List <RicInfo>();

            RicChineseList = GetRicChineseInfo();
            HtmlAgilityPack.HtmlNodeCollection ricNodeList = GetNewlyCBBCRicNode(cbbcMainPageUri);

            try
            {
                int endPos = ricNodeList.Count < parent.CbbcEndPos ? ricNodeList.Count : parent.CbbcEndPos;
                for (int i = parent.CbbcStartPos - 1; i < endPos; i++)
                {
                    HtmlAgilityPack.HtmlNode ricNode = ricNodeList[i];
                    RicInfo ricInfo = new RicInfo();
                    ricInfo.Code = 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.CallLevel                = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 8 + 1].InnerText);
                    ricInfo.EntitlementRatio         = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 9 + 1].InnerText);
                    ricInfo.TotalIssueSize           = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 10 + 1].InnerText);
                    ricInfo.LauntchDate              = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 11 + 1].InnerText);
                    ricInfo.ClearingCommencementDate = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 12 + 1].InnerText);
                    ricInfo.ListingDate              = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 13 + 1].InnerText);
                    ricInfo.MaturityDate             = MiscUtil.GetCleanTextFromHtml(ricNode.ChildNodes[2 * 14 + 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.Cbbc);
                    cbbcRicList.Add(ricInfo);
                }
            }
            catch (Exception ex)
            {
                string errInfo = ex.ToString();
            }
            return(cbbcRicList);
        }