public void RefetchAllCompanies()
        {
            CompanyCollection companies = CompanyBL.Instance.GetCompanies();

            XbrlNodeBL xbrlMngr = new XbrlNodeBL();
            Dictionary <string, List <string> > xbrlTaxonomyTree = new Dictionary <string, List <string> >();
            //xbrlTaxonomyTree = xbrlMngr.PopulateXbrlTaxonomyTree();

            bool start = true;

            foreach (Company comp in companies)
            {
                //if (comp.Symbol.Equals("twc"))
                //{
                //    start = true;
                //}

                if (start)
                {
                    try
                    {
                        string xmlUrl = GetXbrlDocument(comp.Symbol);
                        xbrlMngr.ProcessXbrlInstanceDocument(xmlUrl, xbrlTaxonomyTree);
                        Console.WriteLine("loaded {0}", comp.Symbol);
                    }
                    catch (Exception ex)
                    { Console.WriteLine(string.Format("ERROR: DID NOT LOAD symbol: {0} {1}", comp.Symbol, ex.Message)); }
                }
            }
        }
        public void RefetchAllCompanies()
        {
            CompanyCollection companies = CompanyBL.Instance.GetCompanies();

            XbrlNodeBL xbrlMngr = new XbrlNodeBL();
            Dictionary<string, List<string>> xbrlTaxonomyTree = new Dictionary<string, List<string>>();
            //xbrlTaxonomyTree = xbrlMngr.PopulateXbrlTaxonomyTree();

            bool start = true;

            foreach (Company comp in companies)
            {
                //if (comp.Symbol.Equals("twc"))
                //{
                //    start = true;
                //}

                if (start)
                {
                    try
                    {
                        string xmlUrl = GetXbrlDocument(comp.Symbol);
                        xbrlMngr.ProcessXbrlInstanceDocument(xmlUrl, xbrlTaxonomyTree);
                        Console.WriteLine("loaded {0}", comp.Symbol);
                    }
                    catch (Exception ex)
                    { Console.WriteLine(string.Format("ERROR: DID NOT LOAD symbol: {0} {1}", comp.Symbol, ex.Message)); }
                }

            }
        }
        public void GetSP500Components()
        {
            string        url       = "http://en.wikipedia.org/wiki/List_of_S%26P_500_companies";
            HtmlDocument  doc       = new HtmlWeb().Load(url);
            List <string> companies = new List <string>();

            foreach (HtmlNode div in doc.DocumentNode.SelectNodes("//a[@href and @rel='nofollow' and @class='external text']"))
            {
                if (div.Attributes["href"].Value.Contains("ticker"))
                {
                    companies.Add(div.InnerHtml);
                }
            }

            XbrlNodeBL xbrlMngr = new XbrlNodeBL();

            foreach (string symbol in companies)
            {
                try
                {
                    string xmlUrl = GetXbrlDocument(symbol);
                    //xbrlMngr.ProcessXbrlInstanceDocument(xmlUrl);
                    Console.WriteLine("loaded {0}", symbol);
                }
                catch (Exception ex)
                { Console.WriteLine(string.Format("ERROR: DID NOT LOAD symbol: {0} {1}", symbol, ex.Message)); }
            }
        }
        public void GetSP500Components()
        {
            string url = "http://en.wikipedia.org/wiki/List_of_S%26P_500_companies";
            HtmlDocument doc = new HtmlWeb().Load(url);
            List<string> companies = new List<string>();

            foreach (HtmlNode div in doc.DocumentNode.SelectNodes("//a[@href and @rel='nofollow' and @class='external text']"))
            {
                if (div.Attributes["href"].Value.Contains("ticker"))
                {
                    companies.Add(div.InnerHtml);
                }
            }

            XbrlNodeBL xbrlMngr = new XbrlNodeBL();

            foreach (string symbol in companies)
            {
                try
                {
                    string xmlUrl = GetXbrlDocument(symbol);
                    //xbrlMngr.ProcessXbrlInstanceDocument(xmlUrl);
                    Console.WriteLine("loaded {0}", symbol);
                }
                catch(Exception ex)
                { Console.WriteLine(string.Format("ERROR: DID NOT LOAD symbol: {0} {1}", symbol, ex.Message)); }
            }
        }
 public XbrlDocumentScheduler(string[] compsList1, string[] compsList2)
 {
     this.xbrlLoader = new XbrlDocumentLoaderBL();
     this.xbrlMngr = new XbrlNodeBL();
     syms1 = compsList1;
     syms2 = compsList2;
 }
Example #6
0
 public XbrlDocumentScheduler(string[] compsList1, string[] compsList2)
 {
     this.xbrlLoader = new XbrlDocumentLoaderBL();
     this.xbrlMngr   = new XbrlNodeBL();
     syms1           = compsList1;
     syms2           = compsList2;
 }
        public void GetNyseComponents()
        {
            for (char c = 'A'; c <= 'Z'; c++)
            {
                string        url       = "http://en.wikipedia.org/wiki/Companies_listed_on_the_New_York_Stock_Exchange_(" + c + ")";
                HtmlDocument  doc       = new HtmlWeb().Load(url);
                List <string> companies = new List <string>();

                foreach (HtmlNode div in doc.DocumentNode.SelectNodes("//a[@href and @rel='nofollow' and @class='external text']"))
                {
                    if (div.Attributes["href"].Value.Contains("ticker=") && div.ParentNode.NextSibling.NextSibling.LastChild.InnerHtml.Equals("USA"))
                    {
                        if (div.InnerHtml.Length < 5)
                        {
                            companies.Add(div.InnerHtml);
                        }
                    }
                }

                XbrlNodeBL xbrlMngr = new XbrlNodeBL();
                Dictionary <string, List <string> > xbrlTaxonomyTree = new Dictionary <string, List <string> >();
                xbrlTaxonomyTree = xbrlMngr.PopulateXbrlTaxonomyTree();
                //bool start = false;
                bool start = true;

                foreach (string symbol in companies)
                {
                    //if (symbol.Equals("XPO"))
                    //{
                    //    start = true;
                    //}
                    if (start)
                    {
                        try
                        {
                            string xmlUrl = GetXbrlDocument(symbol);
                            xbrlMngr.ProcessXbrlInstanceDocument(xmlUrl, xbrlTaxonomyTree);
                            Console.WriteLine("loaded {0}", symbol);
                        }
                        catch (Exception ex)
                        { Console.WriteLine(string.Format("ERROR: DID NOT LOAD symbol: {0} {1}", symbol, ex.Message)); }
                    }
                }
            }
        }
        public IncomeStatement Populate(XbrlNodeBL nodeMngr, XbrlDocument xbrlDoc, string symbol, int year, Dictionary<string, List<string>> xbrlTaxonomyTree)
        {    
            IncomeStatement inc = new IncomeStatement();
            inc.Symbol = symbol;
            inc.Year = year;

            IncomeStatementFilterItem item = new IncomeStatementFilterItem();

            foreach (XbrlFragment frag in xbrlDoc.XbrlFragments)
            {
                foreach (Item xbrlItem in frag.Facts)
                {
                    if (nodeMngr.IsAnnualItem(xbrlItem) && xbrlItem.Type.Name.Equals("monetaryItemType"))
                    {
                        if (xbrlItem.ContextRef.PeriodEndDate.Year == inc.Year)
                        {
                            item = CheckItem(xbrlItem, item, xbrlTaxonomyTree);
                        }
                    } 
                }
            }
            return PopulateFinancialStatement(item, inc);
        }
        public IncomeStatement Populate(XbrlNodeBL nodeMngr, XbrlDocument xbrlDoc, string symbol, int year, Dictionary <string, List <string> > xbrlTaxonomyTree)
        {
            IncomeStatement inc = new IncomeStatement();

            inc.Symbol = symbol;
            inc.Year   = year;

            IncomeStatementFilterItem item = new IncomeStatementFilterItem();

            foreach (XbrlFragment frag in xbrlDoc.XbrlFragments)
            {
                foreach (Item xbrlItem in frag.Facts)
                {
                    if (nodeMngr.IsAnnualItem(xbrlItem) && xbrlItem.Type.Name.Equals("monetaryItemType"))
                    {
                        if (xbrlItem.ContextRef.PeriodEndDate.Year == inc.Year)
                        {
                            item = CheckItem(xbrlItem, item, xbrlTaxonomyTree);
                        }
                    }
                }
            }
            return(PopulateFinancialStatement(item, inc));
        }
        public void GetNyseComponents()
        {
            for (char c = 'A'; c <= 'Z'; c++)
            {
                string url = "http://en.wikipedia.org/wiki/Companies_listed_on_the_New_York_Stock_Exchange_("+ c +")";
                HtmlDocument doc = new HtmlWeb().Load(url);
                List<string> companies = new List<string>();

                foreach (HtmlNode div in doc.DocumentNode.SelectNodes("//a[@href and @rel='nofollow' and @class='external text']"))
                {
                    if (div.Attributes["href"].Value.Contains("ticker=") && div.ParentNode.NextSibling.NextSibling.LastChild.InnerHtml.Equals("USA"))
                    {
                        if (div.InnerHtml.Length < 5)
                        {
                            companies.Add(div.InnerHtml);
                        }
                    }
                }

                XbrlNodeBL xbrlMngr = new XbrlNodeBL();
                Dictionary<string, List<string>> xbrlTaxonomyTree = new Dictionary<string, List<string>>();
                xbrlTaxonomyTree = xbrlMngr.PopulateXbrlTaxonomyTree();
                //bool start = false;
                bool start = true;

                foreach (string symbol in companies)
                {
                    //if (symbol.Equals("XPO"))
                    //{
                    //    start = true;
                    //}
                    if (start)
                    {
                        try
                        {
                            string xmlUrl = GetXbrlDocument(symbol);
                            xbrlMngr.ProcessXbrlInstanceDocument(xmlUrl, xbrlTaxonomyTree);
                            Console.WriteLine("loaded {0}", symbol);
                        }
                        catch (Exception ex)
                        { Console.WriteLine(string.Format("ERROR: DID NOT LOAD symbol: {0} {1}", symbol, ex.Message)); }
                    }
                }
            }
        }