コード例 #1
0
            public void ComoLista_Colones_DosISIN()
            {
                elResultadoEsperado = DosValoracionesEnColones();

                listaDeISINEnColones = new List <ISIN>();

                ISIN unISINEnColones = new ISIN();

                unISINEnColones.NumeroISIN = "HDA000000000001";
                unISINEnColones.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
                unISINEnColones.diasMinimosAlVencimientoDelEmisor = 7;
                unISINEnColones.porcentajeCobertura            = 0.8M;
                unISINEnColones.precioLimpioDelVectorDePrecios = 80;
                unISINEnColones.montoNominalDelSaldo           = 3578000;
                listaDeISINEnColones.Add(unISINEnColones);

                ISIN otroISINEnColones = new ISIN();

                otroISINEnColones.NumeroISIN = "HDA000000000001";
                otroISINEnColones.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
                otroISINEnColones.diasMinimosAlVencimientoDelEmisor = 7;
                otroISINEnColones.porcentajeCobertura            = 0.8M;
                otroISINEnColones.precioLimpioDelVectorDePrecios = 80;
                otroISINEnColones.montoNominalDelSaldo           = 3578000;
                listaDeISINEnColones.Add(otroISINEnColones);

                fechaActual = new DateTime(2016, 1, 1);

                elResultadoObtenido = new ValoracionISINColones(listaDeISINEnColones, fechaActual).ComoLista();

                Verificacion.LasListasSonIguales(elResultadoEsperado, elResultadoObtenido);
            }
コード例 #2
0
        public void ComoLista_UDESAnotados_DosISIN()
        {
            elResultadoEsperado = DosValoracionesEnUDESAnotadosEnCuenta();

            losDatos = Substitute.For <DatosDeLaValoracionPorEntidad>();
            losDatos.listaDeISINEnUDESAnotadosEnCuenta = new List <ISIN>();
            ISIN unISINEnUDESAnotadosEnCuenta = new ISIN();

            unISINEnUDESAnotadosEnCuenta.NumeroISIN = "HDA000000000001";
            unISINEnUDESAnotadosEnCuenta.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINEnUDESAnotadosEnCuenta.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnUDESAnotadosEnCuenta.porcentajeCobertura            = 0.8M;
            unISINEnUDESAnotadosEnCuenta.precioLimpioDelVectorDePrecios = 80;
            unISINEnUDESAnotadosEnCuenta.montoNominalDelSaldo           = 1000;
            losDatos.listaDeISINEnUDESAnotadosEnCuenta.Add(unISINEnUDESAnotadosEnCuenta);

            ISIN otroISINEnUDESAnotadosEnCuenta = new ISIN();

            otroISINEnUDESAnotadosEnCuenta.NumeroISIN = "HDA000000000001";
            otroISINEnUDESAnotadosEnCuenta.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            otroISINEnUDESAnotadosEnCuenta.diasMinimosAlVencimientoDelEmisor = 7;
            otroISINEnUDESAnotadosEnCuenta.porcentajeCobertura            = 0.8M;
            otroISINEnUDESAnotadosEnCuenta.precioLimpioDelVectorDePrecios = 80;
            otroISINEnUDESAnotadosEnCuenta.montoNominalDelSaldo           = 1000;
            losDatos.listaDeISINEnUDESAnotadosEnCuenta.Add(otroISINEnUDESAnotadosEnCuenta);
            losDatos.listaDeISINEnUDESNoAnotadosEnCuenta = new List <ISIN>();
            losDatos.fechaActual.Returns(new DateTime(2016, 1, 1));
            losDatos.tipoDeCambioDeUDESDeAyer.Returns(745);
            losDatos.tipoDeCambioDeUDESDeHoy.Returns(750);


            elResultadoObtenido = new ValoracionISINAnotadoEnCuenta(losDatos).ComoLista();

            Verificacion.LasListasSonIguales(elResultadoEsperado, elResultadoObtenido);
        }
コード例 #3
0
        protected ValoracionDeLosISINDeUnaEntidad UnaValoracionConUnISINEnDolares()
        {
            List <ISIN> listaDeISINEnColones = new List <ISIN>();
            List <ISIN> listaDeISINEnDolares = new List <ISIN>();

            ISIN unISINEnDolares = new ISIN();

            unISINEnDolares.NumeroISIN = "HDA000000000001";
            unISINEnDolares.fechaDeVencimientoDelValorOficial = new DateTime(2016, 1, 7);
            unISINEnDolares.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnDolares.porcentajeCobertura            = 0.8M;
            unISINEnDolares.precioLimpioDelVectorDePrecios = 80;
            unISINEnDolares.montoNominalDelSaldo           = 1000;
            listaDeISINEnDolares.Add(unISINEnDolares);

            List <ISIN> listaDeISINEnUDESAnotadosEnCuenta   = new List <ISIN>();
            List <ISIN> listaDeISINEnUDESNoAnotadosEnCuenta = new List <ISIN>();
            DateTime    fechaActual = new DateTime(2016, 1, 1);
            decimal     tipoDeCambioDeUDESDeAyer = 745;
            decimal     tipoDeCambioDeUDESDeHoy  = 750;

            return(new ValoracionPorEntidad(
                       listaDeISINEnColones,
                       listaDeISINEnDolares,
                       listaDeISINEnUDESAnotadosEnCuenta,
                       listaDeISINEnUDESNoAnotadosEnCuenta,
                       fechaActual,
                       tipoDeCambioDeUDESDeAyer,
                       tipoDeCambioDeUDESDeHoy).GenereLaValoracion());
        }
コード例 #4
0
        public void ComoLista_UDESAnotados_DosISIN()
        {
            elResultadoEsperado = DosValoracionesEnUDESAnotadosEnCuenta();

            listaDeISINEnUDESAnotadosEnCuenta = new List <ISIN>();
            ISIN unISINEnUDESAnotadosEnCuenta = new ISIN();

            unISINEnUDESAnotadosEnCuenta.NumeroISIN = "HDA000000000001";
            unISINEnUDESAnotadosEnCuenta.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINEnUDESAnotadosEnCuenta.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnUDESAnotadosEnCuenta.porcentajeCobertura            = 0.8M;
            unISINEnUDESAnotadosEnCuenta.precioLimpioDelVectorDePrecios = 80;
            unISINEnUDESAnotadosEnCuenta.montoNominalDelSaldo           = 1000;
            listaDeISINEnUDESAnotadosEnCuenta.Add(unISINEnUDESAnotadosEnCuenta);

            ISIN otroISINEnUDESAnotadosEnCuenta = new ISIN();

            otroISINEnUDESAnotadosEnCuenta.NumeroISIN = "HDA000000000001";
            otroISINEnUDESAnotadosEnCuenta.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            otroISINEnUDESAnotadosEnCuenta.diasMinimosAlVencimientoDelEmisor = 7;
            otroISINEnUDESAnotadosEnCuenta.porcentajeCobertura            = 0.8M;
            otroISINEnUDESAnotadosEnCuenta.precioLimpioDelVectorDePrecios = 80;
            otroISINEnUDESAnotadosEnCuenta.montoNominalDelSaldo           = 1000;
            listaDeISINEnUDESAnotadosEnCuenta.Add(otroISINEnUDESAnotadosEnCuenta);
            List <ISIN> listaDeISINEnUDESNoAnotadosEnCuenta = new List <ISIN>();
            DateTime    fechaActual = new DateTime(2016, 1, 1);
            decimal     tipoDeCambioDeUDESDeAyer = 745;
            decimal     tipoDeCambioDeUDESDeHoy  = 750;


            elResultadoObtenido = new ValoracionISINAnotadoEnCuenta(listaDeISINEnUDESAnotadosEnCuenta, fechaActual, tipoDeCambioDeUDESDeAyer, tipoDeCambioDeUDESDeHoy).ComoLista();

            Verificacion.LasListasSonIguales(elResultadoEsperado, elResultadoObtenido);
        }
コード例 #5
0
        protected ValoracionDeLosISINDeUnaEntidad UnaValoracionConDosISINEnDolares()
        {
            losDatos = Substitute.For <DatosDeLaValoracionPorEntidad>();
            losDatos.listaDeISINEnColones = new List <ISIN>();
            losDatos.listaDeISINEnDolares = new List <ISIN>();

            ISIN unISINEnDolares = new ISIN();

            unISINEnDolares.NumeroISIN = "HDA000000000001";
            unISINEnDolares.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINEnDolares.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnDolares.porcentajeCobertura            = 0.8M;
            unISINEnDolares.precioLimpioDelVectorDePrecios = 80;
            unISINEnDolares.montoNominalDelSaldo           = 1000;
            losDatos.listaDeISINEnDolares.Add(unISINEnDolares);

            ISIN otroISINEnDolares = new ISIN();

            otroISINEnDolares.NumeroISIN = "HDA000000000001";
            otroISINEnDolares.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            otroISINEnDolares.diasMinimosAlVencimientoDelEmisor = 7;
            otroISINEnDolares.porcentajeCobertura            = 0.8M;
            otroISINEnDolares.precioLimpioDelVectorDePrecios = 80;
            otroISINEnDolares.montoNominalDelSaldo           = 1000;
            losDatos.listaDeISINEnDolares.Add(otroISINEnDolares);

            losDatos.listaDeISINEnUDESAnotadosEnCuenta   = new List <ISIN>();
            losDatos.listaDeISINEnUDESNoAnotadosEnCuenta = new List <ISIN>();
            losDatos.fechaActual.Returns(new DateTime(2016, 1, 1));
            losDatos.tipoDeCambioDeUDESDeAyer.Returns(745);
            losDatos.tipoDeCambioDeUDESDeHoy.Returns(750);

            return(new ValoracionPorEntidad().GenereLaValoracion(losDatos));
        }
コード例 #6
0
 // ustalenie typu instrumentu
 private BosInstrumentType GetInstrumentType()
 {
     // TODO: Na pewno są gdzieś jakieś oficjalne zasady podziału tych numerów!?
     // Na razie to czysta zgadywanka z mojej strony, więc jeśli źle działa - daj znać!
     if (ISIN != null)
     {
         if (ISIN.StartsWith("PL99"))
         {
             return(BosInstrumentType.Index);
         }
         if (ISIN.StartsWith("PL0G"))
         {
             return(BosInstrumentType.Futures);
         }
         return(BosInstrumentType.Default);
     }
     if (Symbol != null)
     {
         // szczególnie to poniżej to już kompletny HACK ;-)
         if (Symbol.StartsWith("FW"))
         {
             return(BosInstrumentType.Futures);
         }
         if (Symbol.StartsWith("OW"))
         {
             return(BosInstrumentType.Futures);
         }
         if (Symbol.Contains("WIG"))
         {
             return(BosInstrumentType.Index);
         }
     }
     return(BosInstrumentType.Default);
 }
コード例 #7
0
        static void Main(string[] args)
        {
            DatosDeLaValoracionPorEntidad losDatos = new DatosDeISINPorEntidadDependencia();

            losDatos.listaDeISINEnColones = new List <ISIN>();
            losDatos.listaDeISINEnDolares = new List <ISIN>();
            losDatos.listaDeISINEnUDESAnotadosEnCuenta   = new List <ISIN>();
            losDatos.listaDeISINEnUDESNoAnotadosEnCuenta = new List <ISIN>();

            ISIN unISINEnDolares = new ISIN();

            unISINEnDolares.NumeroISIN = "HDA000000000001";
            unISINEnDolares.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINEnDolares.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnDolares.porcentajeCobertura            = 0.8M;
            unISINEnDolares.precioLimpioDelVectorDePrecios = 80;
            unISINEnDolares.montoNominalDelSaldo           = 3578000;
            losDatos.listaDeISINEnColones.Add(unISINEnDolares);

            ISIN unISINEnColones = new ISIN();

            unISINEnColones.NumeroISIN = "HDA000000000001";
            unISINEnColones.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINEnColones.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnColones.porcentajeCobertura            = 0.8M;
            unISINEnColones.precioLimpioDelVectorDePrecios = 80;
            unISINEnColones.montoNominalDelSaldo           = 3578000;
            losDatos.listaDeISINEnColones.Add(unISINEnColones);

            ISIN unISINUDESAnotados = new ISIN();

            unISINUDESAnotados.NumeroISIN = "HDA000000000001";
            unISINUDESAnotados.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINUDESAnotados.diasMinimosAlVencimientoDelEmisor = 7;
            unISINUDESAnotados.porcentajeCobertura            = 0.8M;
            unISINUDESAnotados.precioLimpioDelVectorDePrecios = 80;
            unISINUDESAnotados.montoNominalDelSaldo           = 3578000;
            losDatos.listaDeISINEnUDESAnotadosEnCuenta.Add(unISINUDESAnotados);

            ISIN unISINUDESNoAnotados = new ISIN();

            unISINUDESNoAnotados.NumeroISIN = "HDA000000000001";
            unISINUDESNoAnotados.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINUDESNoAnotados.diasMinimosAlVencimientoDelEmisor = 7;
            unISINUDESNoAnotados.porcentajeCobertura            = 0.8M;
            unISINUDESNoAnotados.precioLimpioDelVectorDePrecios = 80;
            unISINUDESNoAnotados.montoNominalDelSaldo           = 3578000;
            losDatos.listaDeISINEnUDESNoAnotadosEnCuenta.Add(unISINUDESNoAnotados);

            Console.ReadLine();
        }
コード例 #8
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + ISIN.GetHashCode();
                hash = hash * 23 + Name.GetHashCode();
                hash = hash * 23 + Symbol.GetHashCode();
                hash = hash * 23 + Currency?.GetHashCode() ?? 0;
                hash = hash * 23 + Segment.GetHashCode();
                hash = hash * 23 + Sector?.GetHashCode() ?? 0;
                hash = hash * 23 + SectorCode?.GetHashCode() ?? 0;
                hash = hash * 23 + FactSheetUrl?.GetHashCode() ?? 0;
                hash = hash * 23 + NasdaqInstrumentId.GetHashCode();

                return(hash);
            }
        }
コード例 #9
0
        public void ComoLista_UDESNoAnotados_UnISIN()
        {
            elResultadoEsperado = UnaValoracionEnUDESNoAnotadosEnCuenta();

            listaEnUDESNoAnotados = new List <ISIN>();

            ISIN unISINEnUDESNoAnotadosEnCuenta = new ISIN();

            unISINEnUDESNoAnotadosEnCuenta.NumeroISIN = "HDA000000000001";
            unISINEnUDESNoAnotadosEnCuenta.fechaDeVencimientoDelValorOficial = new DateTime(2016, 6, 6);
            unISINEnUDESNoAnotadosEnCuenta.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnUDESNoAnotadosEnCuenta.porcentajeCobertura            = 0.8M;
            unISINEnUDESNoAnotadosEnCuenta.precioLimpioDelVectorDePrecios = 80;
            unISINEnUDESNoAnotadosEnCuenta.montoNominalDelSaldo           = 1000;
            listaEnUDESNoAnotados.Add(unISINEnUDESNoAnotadosEnCuenta);
            DateTime fechaActual = new DateTime(2016, 1, 1);

            elResultadoObtenido = new ValoracionISINNoAnotadoEnCuenta(listaEnUDESNoAnotados, fechaActual).ComoLista();

            Verificacion.LasListasSonIguales(elResultadoEsperado, elResultadoObtenido);
        }
コード例 #10
0
        public void ComoLista_Dolares_UnISIN()
        {
            elResultadoEsperado = UnaValoracionEnDolares();

            losDatos = Substitute.For <DatosDeLaValoracionPorEntidad>();
            losDatos.listaDeISINEnDolares = new List <ISIN>();

            ISIN unISINEnDolares = new ISIN();

            unISINEnDolares.NumeroISIN = "HDA000000000001";
            unISINEnDolares.fechaDeVencimientoDelValorOficial = new DateTime(2016, 1, 7);
            unISINEnDolares.diasMinimosAlVencimientoDelEmisor = 7;
            unISINEnDolares.porcentajeCobertura            = 0.8M;
            unISINEnDolares.precioLimpioDelVectorDePrecios = 80;
            unISINEnDolares.montoNominalDelSaldo           = 1000;
            losDatos.listaDeISINEnDolares.Add(unISINEnDolares);

            losDatos.fechaActual.Returns(new DateTime(2016, 1, 1));

            elResultadoObtenido = new ValoracionISINDolares(losDatos).ComoLista();

            Verificacion.LasListasSonIguales(elResultadoEsperado, elResultadoObtenido);
        }
コード例 #11
0
        protected override IDSearchResult ConvertResult(YahooManaged.Base.ConnectionInfo connInfo, System.IO.Stream stream, YahooManaged.Base.SettingsBase settings)
        {
            IDSearchResult      result = null;
            List <IDSearchData> lst    = new List <IDSearchData>();

            if (stream != null)
            {
                if (settings is IDInstantSearchDownloadSettings)
                {
                    #region Instant
                    string          resultStr = MyHelper.StreamToString(stream, ((IDInstantSearchDownloadSettings)settings).TextEncoding);
                    MatchCollection results   = Regex.Matches(resultStr, "{\"symbol\":.*?}");
                    foreach (Match res in results)
                    {
                        string[] prp = res.Value.Replace("{", "").Replace("}", "").Split(',');
                        if (prp.Length > 0)
                        {
                            string name     = string.Empty;
                            string id       = string.Empty;
                            string category = string.Empty;
                            string exchange = string.Empty;
                            string type     = string.Empty;
                            foreach (string p in prp)
                            {
                                string[] kvp = p.Replace("\"", "").Split(':');
                                if (kvp.Length == 2)
                                {
                                    switch (kvp[0])
                                    {
                                    case "symbol":
                                        id = kvp[1].Trim();
                                        break;

                                    case "name":
                                        name = kvp[1].Trim();
                                        break;

                                    case "exch":
                                        exchange = kvp[1].Trim();
                                        break;

                                    case "type":
                                        switch (kvp[1].Trim())
                                        {
                                        case "S":
                                            type = "Stock";
                                            break;

                                        case "I":
                                            type = "Index";
                                            break;

                                        case "F":
                                            type = "Future";
                                            break;

                                        case "E":
                                            type = "ETF";
                                            break;

                                        case "M":
                                            type = "Fund";
                                            break;
                                        }
                                        break;
                                    }
                                }
                            }
                            lst.Add(new IDSearchData(name, id, type, exchange, string.Empty, null));
                        }
                    }
                    Dictionary <SecurityType, int> dict = new Dictionary <SecurityType, int>();
                    dict.Add(SecurityType.Any, lst.Count);
                    return(new IDSearchResult(lst.ToArray(), 0, lst.Count, lst.Count, dict));

                    #endregion
                }
                else if (settings is IDQuerySearchDownloadSettings)
                {
                    #region Query
                    IDQuerySearchDownloadSettings sett = (IDQuerySearchDownloadSettings)settings;

                    int pageingFrom = sett.ResultsIndex, pagingTo = sett.ResultsIndex + 20, overall = 0;
                    Dictionary <SecurityType, int> resultsCount  = new Dictionary <SecurityType, int>();

                    System.Globalization.CultureInfo convCulture = new System.Globalization.CultureInfo("en-US");
                    XDocument doc = MyHelper.ParseXmlDocument(stream);

                    XElement resultNode = XPath.GetElement("//div[@id=\"yfi_sym_lookup\"]", doc);
                    if (resultNode != null)
                    {
                        XElement navigationNode = XPath.GetElement("ul[1]", resultNode);
                        if (navigationNode != null)
                        {
                            string s;
                            int    t;


                            s = XPath.GetElement("li[1]/a/em", navigationNode).Value;
                            if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                            {
                                resultsCount.Add(SecurityType.Any, t);
                            }
                            s = XPath.GetElement("li[2]/a/em", navigationNode).Value;
                            if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                            {
                                resultsCount.Add(SecurityType.Stock, t);
                            }
                            s = XPath.GetElement("li[3]/a/em", navigationNode).Value;
                            if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                            {
                                resultsCount.Add(SecurityType.Fund, t);
                            }
                            s = XPath.GetElement("li[4]/a/em", navigationNode).Value;
                            if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                            {
                                resultsCount.Add(SecurityType.ETF, t);
                            }
                            s = XPath.GetElement("li[5]/a/em", navigationNode).Value;
                            if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                            {
                                resultsCount.Add(SecurityType.Index, t);
                            }
                            s = XPath.GetElement("li[6]/a/em", navigationNode).Value;
                            if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                            {
                                resultsCount.Add(SecurityType.Future, t);
                            }


                            if (MyHelper.EnumToArray(navigationNode.Elements()).Length == 7)
                            {
                                resultsCount.Add(SecurityType.Warrant, 0);
                                s = XPath.GetElement("li[7]/a/em", navigationNode).Value;
                                if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                                {
                                    resultsCount.Add(SecurityType.Currency, t);
                                }
                            }
                            else if (MyHelper.EnumToArray(navigationNode.Elements()).Length == 8)
                            {
                                s = XPath.GetElement("li[7]/a/em", navigationNode).Value;
                                if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                                {
                                    resultsCount.Add(SecurityType.Warrant, t);
                                }
                                s = XPath.GetElement("li[8]/a/em", navigationNode).Value;
                                if (int.TryParse(s.Substring(s.LastIndexOf("(") + 1).Replace(")", "").Trim(), out t))
                                {
                                    resultsCount.Add(SecurityType.Currency, t);
                                }
                            }
                        }

                        XElement contentNode = XPath.GetElement("div[1]", resultNode);
                        if (contentNode != null)
                        {
                            XElement tableNode     = XPath.GetElement("/div[1]/table", contentNode);
                            XElement tableHeadNode = XPath.GetElement("/thead/tr", tableNode);
                            XElement tableBodyNode = XPath.GetElement("/tbody", tableNode);

                            List <string> tableColumnNames = new List <string>();
                            tableColumnNames.Add("symbol");
                            tableColumnNames.Add("name");
                            bool hasISIN = XPath.GetElement("/th[3]", tableHeadNode).Value.ToLower().Contains("isin");
                            if (hasISIN)
                            {
                                tableColumnNames.Add("isin");
                            }
                            else
                            {
                                tableColumnNames.Add("lasttrade");
                            }
                            int l = MyHelper.EnumToArray(tableHeadNode.Elements()).Length;
                            for (int i = 3; i < l; i++)
                            {
                                if (hasISIN)
                                {
                                    switch (i)
                                    {
                                    case 3:
                                        tableColumnNames.Add("lasttrade");
                                        break;

                                    case 4:
                                        tableColumnNames.Add("type");
                                        break;

                                    case 5:
                                        tableColumnNames.Add("exchange");
                                        break;
                                    }
                                }
                                else
                                {
                                    string name = MyHelper.GetEnumItemAt(tableHeadNode.Elements(), i).Value.ToLower();
                                    if (name.Contains("type"))
                                    {
                                        tableColumnNames.Add("type");
                                    }
                                    else if (name.Contains("industry"))
                                    {
                                        tableColumnNames.Add("industry");
                                    }
                                    else if (name.Contains("exchange"))
                                    {
                                        tableColumnNames.Add("exchange");
                                    }
                                }
                            }


                            foreach (XElement rowNode in tableBodyNode.Elements())
                            {
                                IEnumerable <XElement> enm = rowNode.Elements();
                                if (MyHelper.EnumToArray(enm).Length >= tableColumnNames.Count)
                                {
                                    string name = string.Empty, id = string.Empty, type = string.Empty, industry = string.Empty, exchange = string.Empty;
                                    ISIN   isin = null;

                                    for (int i = 0; i < tableColumnNames.Count; i++)
                                    {
                                        switch (tableColumnNames[i])
                                        {
                                        case "symbol":
                                            id = MyHelper.GetEnumItemAt(enm, i).Value.Trim();
                                            break;

                                        case "name":
                                            name = MyHelper.GetEnumItemAt(enm, i).Value.Trim();
                                            break;

                                        case "isin":
                                            if (MyHelper.GetEnumItemAt(enm, i).Value.Trim() != string.Empty)
                                            {
                                                try
                                                {
                                                    isin = new ISIN(MyHelper.GetEnumItemAt(enm, i).Value.Trim());
                                                }
                                                catch { }
                                            }
                                            break;

                                        case "lasttrade":
                                            break;

                                        case "type":
                                            type = MyHelper.GetEnumItemAt(enm, i).Value.Trim();
                                            break;

                                        case "industry":
                                            industry = MyHelper.GetEnumItemAt(enm, i).Value.Trim();
                                            break;

                                        case "exchange":
                                            exchange = MyHelper.GetEnumItemAt(enm, i).Value.Trim();
                                            break;
                                        }
                                    }
                                    lst.Add(new IDSearchData(name, id, type, exchange, industry, isin));
                                }
                            }

                            overall = lst.Count;
                            XElement paginationNode = XPath.GetElement("//div[@id=\"pagination\"]", doc);
                            if (paginationNode != null)
                            {
                                PaginationScanner scn = new PaginationScanner();
                                scn.SetPagination(paginationNode.Value, out pageingFrom, out pagingTo, out overall);
                            }
                        }
                    }

                    result = new IDSearchResult(lst.ToArray(), pageingFrom, pagingTo, overall, resultsCount);
                    #endregion
                }
                else if (settings is IDAlphabeticSearchDownloadSettings)
                {
                    #region Alphabet
                    XDocument  doc          = MyHelper.ParseXmlDocument(stream);
                    XElement[] resultsNodes = XPath.GetElements("//results", doc);

                    if (resultsNodes.Length > 0)
                    {
                        XElement resultNode = resultsNodes[0];

                        foreach (XElement trNode in resultNode.Elements())
                        {
                            XElement[] enm = MyHelper.EnumToArray(trNode.Elements());
                            if (trNode.Name.LocalName == "tr" && enm.Length >= 2)
                            {
                                string name = string.Empty;
                                foreach (XElement subNode in enm[0].Elements())
                                {
                                    name += subNode.Value.Trim() + " ";
                                }
                                name = name.TrimEnd();
                                string id = enm[1].Value.Trim();
                                lst.Add(new IDSearchData(name, id, "stock", "", null, null));
                            }
                        }
                    }

                    result = new IDSearchResult(lst.ToArray(), -1, -1, -1, new Dictionary <SecurityType, int>());
                    #endregion
                }
            }
            if (result == null)
            {
                result = new IDSearchResult(lst.ToArray(), -1, -1, -1, new Dictionary <SecurityType, int>());
            }
            return(result);
        }
コード例 #12
0
        internal IDSearchData(string name, string id, string type, string exchange, string industry, ISIN isin)
            : base(id)
        {
            mName     = name;
            mIndustry = industry;
            mExchange = exchange;
            mISIN     = isin;
            switch (type.ToLower())
            {
            case "stock":
            case "aktien":
            case "titre":
            case "acción":
                mType = SecurityType.Stock;
                break;

            case "mutual fund":
            case "fund":
            case "fonds":
            case "Fonds commun de placement":
            case "fondo mutuo":
                mType = SecurityType.Fund;
                break;

            case "etf":
            case "trackers":
            case "fondos cotizados en bolsa":
                mType = SecurityType.ETF;
                break;

            case "index":
            case "indice":
            case "índice":
                mType = SecurityType.Index;
                break;

            case "futures":
            case "future":
            case "futuro":
                mType = SecurityType.Future;
                break;

            case "warrant":
            case "zertifikate & os":
            case "warrants":
                mType = SecurityType.Warrant;
                break;

            case "currency":
            case "währungen":
            case "devises":
            case "divisas":
                mType = SecurityType.Currency;
                break;

            default:
                mType = SecurityType.Any;
                if (type != string.Empty)
                {
                    System.Diagnostics.Debug.WriteLine(type);
                }
                break;
            }
        }
コード例 #13
0
        public int CompareTo(object obj)
        {
            var etf = (ETFItem)obj;

            return(ISIN.CompareTo(etf.ISIN));
        }