public void TestParseContent() { var testUri = new Uri( "https://www.sec.gov/Archives/edgar/data/1593936/000155837016004206/0001558370-16-004206-index.htm"); var testContent = System.IO.File.ReadAllText( TestAssembly.TestDataDir + @"\ExampleSecIndexHtm.html"); var testSubject = new NoFuture.Rand.Com.PublicCompany { CIK = new CentralIndexKey { Value = "0000768899" } }; testSubject.AddName(KindsOfNames.Legal, "TrueBlue, Inc."); testSubject.AddSecReport(new Form10K { HtmlFormLink = testUri }); var testResult = Copula.TryGetXmlLink(testContent, testUri, ref testSubject); Assert.IsTrue(testResult); var testResultItem = testSubject.SecReports.FirstOrDefault(x => x is Form10K && ((Form10K)x).HtmlFormLink == testUri); Assert.IsNotNull(testResultItem); Assert.IsInstanceOf(typeof(Form10K), testResultItem); Assert.IsNotNull(((Form10K)testResultItem).XmlLink); Assert.IsNotNull(testSubject.EIN); Assert.AreEqual("371737959", testSubject.EIN.Value); }
public void TestParseCompanyFullTextSearch() { var xmlContent = System.IO.File.ReadAllText(SEC_BY_FULLTEXT_XML_PATH); var testResult = Copula.ParseSecEdgarFullTextSearch(xmlContent, new Uri("http://www.sec.gov/cgi-bin/srch-edgar")); Assert.IsNotNull(testResult); Assert.AreNotEqual(0, testResult.Length); foreach (var r in testResult) { System.Console.WriteLine($"Name: {r.Name}; CIK: {r.CIK.Value}"); foreach (var a in r.SecReports) { var ar = a as Form10K; if (ar == null) { continue; } System.Console.WriteLine("IsLate: {2}; Accession Number: {0}; Link: {1}", ar.AccessionNumber, ar.InteractiveFormLink, ar.IsLate); System.Console.WriteLine($"HtmlLink: {ar.HtmlFormLink}"); } System.Console.WriteLine("----------"); } }
public void TestTryGetCorpData() { var xmlContent = System.IO.File.ReadAllText(SEC_BY_CIK_XML_PATH); var testResultOut = new PublicCompany(); var testResult = Copula.TryParseSecEdgarCikSearch(xmlContent, new Uri( "http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=041215216456&type=10-K&dateb=&owner=exclude&count=100&output=atom"), ref testResultOut); Assert.IsTrue(testResult); Assert.IsNotNull(testResultOut); Assert.AreEqual("0000717538", testResultOut.CIK.Value); Assert.AreEqual("6021", testResultOut.SIC.Value); Assert.AreEqual("ARROW FINANCIAL CORP", testResultOut.Name); Assert.IsNotNull(testResultOut.MailingAddress); Assert.IsNotNull(testResultOut.BusinessAddress); Assert.IsInstanceOf(typeof(UsStreetPo), testResultOut.MailingAddress.Street); Assert.IsInstanceOf(typeof(UsCityStateZip), testResultOut.MailingAddress.CityArea); var mailingAddrStreet = (UsStreetPo)testResultOut.MailingAddress.Street; var mailingAddrCity = (UsCityStateZip)testResultOut.MailingAddress.CityArea; Assert.IsInstanceOf(typeof(UsStreetPo), testResultOut.BusinessAddress.Street); Assert.IsInstanceOf(typeof(UsCityStateZip), testResultOut.BusinessAddress.CityArea); var bizAddrStreet = (UsStreetPo)testResultOut.BusinessAddress.Street; var bizAddrCity = (UsCityStateZip)testResultOut.BusinessAddress.CityArea; Assert.AreEqual("250", mailingAddrStreet.PostBox); Assert.AreEqual("250", bizAddrStreet.PostBox); Assert.AreEqual("GLEN", bizAddrStreet.StreetName); Assert.AreEqual("ST", bizAddrStreet.StreetKind); Assert.AreEqual("GLENS FALLS", bizAddrCity.City); Assert.AreEqual("NY", bizAddrCity.StateAbbrev); Assert.AreEqual("12801", bizAddrCity.ZipCode); Assert.AreEqual("GLENS FALLS", mailingAddrCity.City); Assert.AreEqual("NY", mailingAddrCity.StateAbbrev); Assert.AreEqual("12801", mailingAddrCity.ZipCode); Assert.IsNotNull(testResultOut.PhoneNumbers); var testResultPhones = testResultOut.PhoneNumbers.ToList(); var testResultPhone = testResultPhones[0]; Assert.IsNotNull(testResultPhone); Assert.IsInstanceOf <NorthAmericanPhone>(testResultPhone); var testResultNAmerPhone = (NorthAmericanPhone)testResultPhone; Assert.AreEqual("518", testResultNAmerPhone.AreaCode); Assert.AreEqual("415", testResultNAmerPhone.CentralOfficeCode); Assert.AreEqual("4299", testResultNAmerPhone.SubscriberNumber); }
public void TestTryGetDayOfYearFiscalEnd() { int testResultOut; var testResult = Copula.TryGetDayOfYearFiscalEnd("--12-25", out testResultOut); System.Console.WriteLine(testResultOut); Assert.IsTrue(testResult); }
public void TestParseAccessionNumFromSummary() { var testResult = Copula.ParseAccessionNumFromSummary( "<b>Filed Date:</b> 04/15/2015 <b>Accession Number:</b> 0001549727-15-000033 <b>Size:</b> 3 MB"); Assert.IsNotNull(testResult); Assert.AreEqual("0001549727-15-000033", testResult); System.Console.WriteLine(testResult); }
public void TestTryParseFfiecInstitutionProfileAspxHtml() { var testContent = System.IO.File.ReadAllText(TestAssembly.TestDataDir + @"\ffiecHtml.html"); Bank firmOut = new Bank(); var testResult = Copula.TryParseFfiecInstitutionProfileAspxHtml(testContent, new Uri(UsGov.Links.Ffiec.SEARCH_URL_BASE), ref firmOut); System.Console.WriteLine(firmOut.RoutingNumber); Assert.IsTrue(testResult); }
public void TestParseNameFromTitle() { var testResult = Copula.ParseNameFromTitle("10-K - 1347 Property Insurance Holdings, Inc."); System.Console.WriteLine(testResult.Item2); Assert.IsInstanceOf(typeof(Form10K), testResult.Item1); Assert.AreEqual("1347 Property Insurance Holdings, Inc.", testResult.Item2); testResult = Copula.ParseNameFromTitle("13F-HR - 10-15 ASSOCIATES, INC."); Assert.IsInstanceOf(typeof(Form13Fhr), testResult.Item1); Assert.AreEqual("10-15 ASSOCIATES, INC.", testResult.Item2); System.Console.WriteLine(testResult.Item2); }
public void TestTryMergeXbrl() { var testUri = new Uri("https://www.sec.gov/Archives/edgar/data/1593936/000155837016004206/mik-20160130.xml"); var testSubject = new NoFuture.Rand.Com.PublicCompany { CIK = new CentralIndexKey { Value = "0000768899" } }; testSubject.AddName(KindsOfNames.Legal, "TrueBlue, Inc."); testSubject.AddSecReport(new Form10K { XmlLink = testUri }); var testContent = System.IO.File.ReadAllText(TestAssembly.TestDataDir + @"\ExampleSecXbrl.xml"); var testResult = Copula.TryMergeXbrlInto10K(testContent, testUri, ref testSubject); Assert.IsTrue(testResult); Assert.IsTrue(testSubject.TickerSymbols.Any(x => x.Symbol == "TBI")); var tenK2015 = testSubject.SecReports.FirstOrDefault(x => x is Form10K && ((Form10K)x).XmlLink == testUri) as Form10K; Assert.IsNotNull(tenK2015); Assert.AreEqual(42029009, tenK2015.NumOfShares); Assert.AreEqual(1266835M, tenK2015.TotalAssets); Assert.AreEqual(731262M, tenK2015.TotalLiabilities); Assert.AreEqual(71247M, tenK2015.NetIncome); Assert.AreEqual(97842M, tenK2015.OperatingIncome); Assert.AreEqual(2695680M, tenK2015.Revenue); Assert.IsNotNull(tenK2015.GetTextBlocks()); Assert.AreNotEqual(0, tenK2015.GetTextBlocks().Count); var lastTb = tenK2015.GetTextBlocks().Last(); var firstTb = tenK2015.GetTextBlocks().First(); Assert.IsTrue(lastTb.Item2.Length > firstTb.Item2.Length); Assert.IsFalse(string.IsNullOrWhiteSpace(testSubject.GetForm10KDescriptionOfBiz())); }
public void TestTryParseIexKeyStatsJson() { var testContent = System.IO.File.ReadAllText(TestAssembly.TestDataDir + @"\IexKeyStatsResponse.json"); var corp = new PublicCompany(); var testResult = Copula.TryParseIexKeyStatsJson(testContent, IexKeyStats.GetUri("AAPL"), ref corp); Assert.IsTrue(testResult); Assert.IsTrue(corp.NetUris.Any()); foreach (var uri in corp.NetUris) { Console.WriteLine(uri.ToString()); } }
public void TestTryParseIexCompanyJson() { var testContent = System.IO.File.ReadAllText(TestAssembly.TestDataDir + @"\IexCompanyResponse.json"); var corp = new PublicCompany(); var testResult = Copula.TryParseIexCompanyJson(testContent, IexCompany.GetUri("AAPL"), ref corp); Assert.IsTrue(testResult); Assert.IsFalse(string.IsNullOrWhiteSpace(corp.Description)); var ticker = corp.TickerSymbols.FirstOrDefault(); Assert.IsNotNull(ticker); Assert.AreEqual("AAPL", ticker.Symbol); Assert.IsTrue(ticker.Exchange.Contains("Nasdaq")); var uri = corp.NetUris.FirstOrDefault(); Assert.IsNotNull(uri); Assert.AreEqual("http://www.apple.com/", uri.ToString()); Assert.IsFalse(string.IsNullOrWhiteSpace(corp.Description)); Assert.IsFalse(string.IsNullOrWhiteSpace(corp.Name)); }
public override IEnumerable <dynamic> ParseContent(object content) { var xmlContent = content as string; if (string.IsNullOrWhiteSpace(xmlContent)) { return(null); } var xmlNsMgr = GetXmlAndNsMgr(xmlContent); if (xmlNsMgr?.Item1 == null || xmlNsMgr.Item2 == null) { return(null); } _xml = xmlNsMgr.Item1; _nsMgr = xmlNsMgr.Item2; bool.TryParse(_xml.SelectSingleNode($"//{XmlNs.DEI}:AmendmentFlag", _nsMgr)?.InnerText ?? bool.FalseString, out var amendmentFlag); var endOfYearStr = _xml.SelectSingleNode($"//{XmlNs.DEI}:CurrentFiscalYearEndDate", _nsMgr)?.InnerText ?? string.Empty; Copula.TryGetDayOfYearFiscalEnd(endOfYearStr, out var endOfYear); var cik = _xml.SelectSingleNode($"//{XmlNs.DEI}:EntityCentralIndexKey", _nsMgr)?.InnerText; int.TryParse( _xml.SelectSingleNode($"//{XmlNs.DEI}:EntityCommonStockSharesOutstanding", _nsMgr)?.InnerText ?? String.Empty, out var numOfShares); var name = _xml.SelectSingleNode($"//{XmlNs.DEI}:EntityRegistrantName", _nsMgr)?.InnerText; var ticker = _xml.SelectSingleNode($"//{XmlNs.DEI}:TradingSymbol", _nsMgr)?.InnerText; var assets = GetNodeDollarYear(_xml, $"//{XmlNs.US_GAAP}:Assets", _nsMgr); var liabilities = GetNodeDollarYear(_xml, $"//{XmlNs.US_GAAP}:Liabilities", _nsMgr); var netIncome = GetNodeDollarYear(_xml, $"//{XmlNs.US_GAAP}:NetIncomeLoss", _nsMgr); List <Tuple <int, decimal> > operateIncome = new List <Tuple <int, decimal> >(); foreach (var anotherName in new[] { "OperatingIncomeLoss", "BenefitsLossesAndExpenses" }) { operateIncome = GetNodeDollarYear(_xml, $"//{XmlNs.US_GAAP}:{anotherName}", _nsMgr); if (operateIncome.Any()) { break; } } List <Tuple <int, decimal> > salesRev = new List <Tuple <int, decimal> >(); foreach ( var anotherName in new[] { "Revenues", "RetailRevenue", "SalesRevenueNet", "SalesRevenueServicesNet", "SalesRevenueGoodsNet" }) { salesRev = GetNodeDollarYear(_xml, $"//{XmlNs.US_GAAP}:{anotherName}", _nsMgr); if (salesRev.Any()) { break; } } var textBlocks = GetTextBlocks(); return(new List <dynamic> { new { IsAmended = amendmentFlag, EndOfYear = endOfYear, Cik = cik, NumOfShares = numOfShares, Name = name, Ticker = ticker, Assets = assets, Liabilities = liabilities, NetIncome = netIncome, OperatingIncome = operateIncome, Revenue = salesRev, TextBlocks = textBlocks } }); }