Example #1
0
        public static void ExtractFromPropertiesFromTrs(EtfConverter etfConverter, IEnumerable<XElement> trs)
        {
            foreach (var tr in trs)
            {
                var tds = tr.Descendants("td");
                var xElements = tds as IList<XElement> ?? tds.ToList();
                if (xElements.Count < 2)
                    continue;

                var attributeName = xElements.First();
                var attributeValue = xElements.Skip(1).First();
                var name = EtfConverter.GetAttributeName(attributeName.Value);
                if (name != null)
                {
                    etfConverter.EtfFund[name] = attributeValue.Value.Trim();
                }
            }
        }
Example #2
0
        private static void ExtractFromTraidingDetailsRoot(EtfConverter etfConverter, XElement root)
        {
            //structure: exchange               | exchange code |  currency trading | Bloomberg code
            //           London Stock Exchange  |ISPY,          | GBP               | ISPY 
            //           Borsa Italiana         |ISPY,          | EUR               | LN
            //           Deutsche Börse         |USPLY          | EUR               | ISPY IM
            var exchange = new StringBuilder();
            var exchangeCode = new StringBuilder();
            var currencyTrading = new StringBuilder();
            var bloombergCode = new StringBuilder();

            foreach (var tr in root.Descendants("tr"))
            {
                var tds = tr.Descendants("td");
                var xElements = tds as IList<XElement> ?? tds.ToList();
                if (xElements.Count < 4)
                    continue;

                exchange.AppendFormat("{0}, ", xElements[0].Value);
                exchangeCode.AppendFormat("{0}, ", xElements[1].Value);
                currencyTrading.AppendFormat("{0}, ", xElements[2].Value);
                bloombergCode.AppendFormat("{0}, ", xElements[4].Value);

            }

            etfConverter.SetProperty("Exchange", exchange.ToString());
            etfConverter.SetProperty("Exchange Code", exchangeCode.ToString());
            etfConverter.SetProperty("Currency (trading)", currencyTrading.ToString());
            etfConverter.SetProperty("Bloomberg Code", bloombergCode.ToString());

        }
Example #3
0
        public EtfConverter GetSingleFundByLink(string fundUrl)
        {
            var etfConverter = new EtfConverter
            {
                FundUrl = fundUrl
            };

            var singleFund = this.GetSingleFundMainPageByLinkAsXElement(fundUrl);

            var fundName = ExtractFundName(singleFund);
            etfConverter.EtfFund["Product"] = fundName;

            var registeredCountries = ExtractRegisteredCountries(singleFund);

            if (registeredCountries != null)
                etfConverter.EtfFund["	Registered countries	"] = registeredCountries.Value.Trim();

            ExtractAndSetProductSection(singleFund, etfConverter);

            var parser = GetSectionParser.GetDetailsParser(singleFund);

            var indexPage = GetDetailsBySingleFundElement(parser, fundUrl, EtfSecurities.DetailsSection.Index);
            var detailsXElement = EtfSecurities.GetDetailsByPage(indexPage);
            EtfSecurities.ExtractFromPropertiesFromTrs(etfConverter, detailsXElement.Descendants("tr"));

            var tradingPage = GetDetailsBySingleFundElement(parser, fundUrl, EtfSecurities.DetailsSection.Trading);

            var tradingXElement = EtfSecurities.GetDetailsByPage(tradingPage);
            EtfSecurities.ExtractFromTraidingDetailsRoot(etfConverter, tradingXElement);

            File.WriteAllText("singleFund.xml", singleFund.ToString());

            return etfConverter;
        }
Example #4
0
        private static void ExtractAndSetProductSection(XElement singleFund, EtfConverter etfConverter)
        {
            var divProductSection = singleFund.GetXElementByAttribute("div", "id", "productSection");
            var trs = divProductSection.Descendants("tr");

            ExtractFromPropertiesFromTrs(etfConverter, trs);
        }
Example #5
0
        public void GetAllIndexesDetails()
        {
            var fundRepository = new FundRepository();
            var fundsLinks = this.etfsec.GetFundsLinks();
            foreach (var fundLink in fundsLinks.Take(5))
            {
                var singleFund = this.etfsec.GetSingleFundMainPageByLinkAsXElement(SingleFundUrl);
                var parser = GetSectionParser.GetDetailsParser(singleFund);
                var indexPage = EtfSecurities.GetDetailsBySingleFundElement(parser, SingleFundUrl, EtfSecurities.DetailsSection.Index);
                var detailsXElement = EtfSecurities.GetDetailsByPage(indexPage);
                var etfConverter = new EtfConverter();
                EtfSecurities.ExtractFromPropertiesFromTrs(etfConverter, detailsXElement.Descendants("tr"));
                var fund = etfConverter.Convert();
                fund.FundUrl = fundLink;

                fundRepository.AddOrUpdate(fund);
            }
        }