TRD-0003 Fix insider transactions

This commit is contained in:
2024-02-23 15:25:04 -05:00
parent f650623fbc
commit 5a2d4c6a79
13 changed files with 408 additions and 19 deletions

View File

@@ -1,6 +1,5 @@
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using HtmlAgilityPack;
@@ -85,10 +84,18 @@ namespace MarketData.Helper
HtmlNodeCollection tables=htmlDocument.DocumentNode.SelectNodes("//table");
if(null==tables || tables.Count<5)continue;
HtmlNodeCollection nameAndAddressRows = tables[4].SelectNodes(".//tr");
if(nameAndAddressRows.Count<10)continue;
HtmlNode nameAndAddressTable=FindTable(tables,"1. Name and Address of Reporting Person");
if(null==nameAndAddressTable)continue;
HtmlNodeCollection nameAndAddressRows = nameAndAddressTable.SelectNodes(".//tr");
if(nameAndAddressRows.Count<2)continue;
insiderName=ApplyNameCase(nameAndAddressRows[1].InnerText);
relationshipOfReportingPerson=Utility.RemoveHtml(nameAndAddressRows[9].InnerText);
//HtmlNodeCollection nameAndAddressRows = tables[4].SelectNodes(".//tr");
//if(nameAndAddressRows.Count<10)continue;
//insiderName=ApplyNameCase(nameAndAddressRows[1].InnerText);
//relationshipOfReportingPerson=Utility.RemoveHtml(nameAndAddressRows[9].InnerText);
for(int index=0;index<tables.Count;index++)
{
@@ -143,6 +150,25 @@ namespace MarketData.Helper
}
}
}
private HtmlNode FindTable(HtmlNodeCollection tables,String startsWith)
{
if(null==tables)return null;
for(int index=0;index<tables.Count;index++)
{
HtmlNodeCollection nameAndAddressRows = tables[index].SelectNodes(".//tr");
for(int itemIndex=0;itemIndex<nameAndAddressRows.Count;itemIndex++)
{
String marker=nameAndAddressRows[itemIndex].InnerText;
if(marker.StartsWith(startsWith))
{
return tables[index];
}
}
}
return null;
}
private void BuildTransactionCodes()
{
transactionCodes.Add("P","Open market or private purchase of non-derivative or derivative security");

View File

@@ -1407,6 +1407,7 @@ namespace MarketData.Helper
String formName = secNodes[0].InnerText;
formName = formName.Replace("\n", "");
formName = formName.Trim();
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("GetSECFilingDocuments[Examining form {0}]",formName));
HtmlNodeCollection tables = htmlDocument.DocumentNode.SelectNodes("//*[@class=\"tableFile\"]");
if (null == tables || tables.Count < 1) return null;
HtmlNodeCollection rows = tables[0].SelectNodes(".//tr");