Ejemplo n.º 1
0
        public static async Task <StatementOfBeneficialOwnership> ParseXmlFromWebUrlAsync(string url)
        {
            string content = await SecRequestManager.Instance.SecGetAsync(url);

            StatementOfBeneficialOwnership ToReturn = StatementOfBeneficialOwnership.ParseXml(content);

            return(ToReturn);
        }
        public virtual void LoadFromNode(XmlNode node)
        {
            //Security title
            XmlNode node_securityTitle = node.SelectSingleNode("securityTitle");

            if (node_securityTitle != null)
            {
                XmlNode node_value = node_securityTitle.SelectSingleNode("value");
                SecurityTitle = node_value.InnerText;
            }

            //Shares Owned following transaction
            XmlNode node_postTransactionAmounts = node.SelectSingleNode("postTransactionAmounts");

            if (node_postTransactionAmounts != null)
            {
                //Shares owned following transaction
                XmlNode node_sharesOwnedFollowingTransaction = node_postTransactionAmounts.SelectSingleNode("sharesOwnedFollowingTransaction");
                if (node_sharesOwnedFollowingTransaction != null)
                {
                    XmlNode node_value = node_sharesOwnedFollowingTransaction.SelectSingleNode("value");
                    if (node_value != null)
                    {
                        string node_val_str = node_value.InnerText;
                        SecuritiesOwnedFollowingTransaction = Convert.ToSingle(node_val_str);
                    }
                }

                //Direct or indirect ownership
                XmlNode node_ownershipNature = node.SelectSingleNode("ownershipNature");
                if (node_ownershipNature != null)
                {
                    XmlNode node_directOrIndirectOwnership = node_ownershipNature.SelectSingleNode("directOrIndirectOwnership");
                    if (node_directOrIndirectOwnership != null)
                    {
                        XmlNode node_value = node_directOrIndirectOwnership.SelectSingleNode("value");
                        if (node_value != null)
                        {
                            string val = node_value.InnerText;
                            if (val.ToLower() == "d")
                            {
                                DirectOrIndirectOwnership = OwnershipNature.Direct;
                            }
                            else if (val.ToLower() == "i")
                            {
                                DirectOrIndirectOwnership = OwnershipNature.Indirect;
                            }
                        }
                    }
                }
            }

            //Transaction date
            XmlNode node_transactionDate = node.SelectSingleNode("transactionDate");

            if (node_transactionDate != null)
            {
                XmlNode node_value = node_transactionDate.SelectSingleNode("value");
                if (node_value != null)
                {
                    TransactionDate = DateTime.Parse(node_value.InnerText);
                }
            }

            //Transaction code
            XmlNode node_transactionCoding = node.SelectSingleNode("transactionCoding");

            if (node_transactionCoding != null)
            {
                XmlNode node_transactionCode = node_transactionCoding.SelectSingleNode("transactionCode");
                if (node_transactionCode != null)
                {
                    string tc = node_transactionCode.InnerText.ToLower();
                    TransactionCode = StatementOfBeneficialOwnership.TransactionTypeFromCode(tc);
                }
            }

            //Transaction Amounts section (# of shares, price per share, acquired or disposed)
            XmlNode node_transactionAmounts = node.SelectSingleNode("transactionAmounts");

            if (node_transactionAmounts != null)
            {
                //Transaction Shares Quanity
                XmlNode node_transactionShares = node_transactionAmounts.SelectSingleNode("transactionShares");
                if (node_transactionShares != null)
                {
                    XmlNode node_value = node_transactionShares.SelectSingleNode("value");
                    if (node_value != null)
                    {
                        TransactionQuantity = Convert.ToSingle(node_value.InnerText);
                    }
                }

                //Transaction price per share
                XmlNode node_transactionPricePerShare = node_transactionAmounts.SelectSingleNode("transactionPricePerShare");
                if (node_transactionPricePerShare != null)
                {
                    XmlNode node_value = node_transactionPricePerShare.SelectSingleNode("value");
                    if (node_value != null)
                    {
                        TransactionPricePerSecurity = Convert.ToSingle(node_value.InnerText);
                    }
                }

                //Acquired or disposed?
                XmlNode node_transactionAcquiredDisposedCode = node_transactionAmounts.SelectSingleNode("transactionAcquiredDisposedCode");
                if (node_transactionAcquiredDisposedCode != null)
                {
                    XmlNode node_value = node_transactionAcquiredDisposedCode.SelectSingleNode("value");
                    if (node_value != null)
                    {
                        string ad_code = node_value.InnerText.ToLower();
                        if (ad_code == "a")
                        {
                            AcquiredOrDisposed = AcquiredDisposed.Acquired;
                        }
                        else if (ad_code == "d")
                        {
                            AcquiredOrDisposed = AcquiredDisposed.Disposed;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static StatementOfBeneficialOwnership ParseXml(string xml)
        {
            StatementOfBeneficialOwnership ToReturn = new StatementOfBeneficialOwnership();

            //Load the xml
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            //Get the ownership document node that contains all data
            XmlNode doc_data = doc.SelectSingleNode("ownershipDocument");

            //Get schema version
            if (doc_data.SelectSingleNode("schemaVersion") != null)
            {
                ToReturn.SchemaVersion = doc_data.SelectSingleNode("schemaVersion").InnerText;
            }
            else
            {
                ToReturn.SchemaVersion = null;
            }

            //Get period of report
            ToReturn.PeriodOfReport = DateTime.Parse(doc_data.SelectSingleNode("periodOfReport").InnerText);

            //documentType
            XmlNode node_documentType = doc_data.SelectSingleNode("documentType");

            if (node_documentType != null)
            {
                ToReturn.DocumentType = node_documentType.InnerText.Trim();
            }
            else
            {
                ToReturn.DocumentType = null;
            }

            #region "Issuer"

            XmlNode issuer = doc_data.SelectSingleNode("issuer");

            //CIK
            ToReturn.IssuerCik = issuer.SelectSingleNode("issuerCik").InnerText;

            //Issuer name
            ToReturn.IssuerName = issuer.SelectSingleNode("issuerName").InnerText;

            //Issuer trading symbol
            ToReturn.IssuerTradingSymbol = issuer.SelectSingleNode("issuerTradingSymbol").InnerText;

            #endregion

            #region "Owner"

            //Get the reporting owner node
            XmlNode node_reportingowner = doc_data.SelectSingleNode("reportingOwner");

            //Reporting owner id data
            XmlNode node_reportingOwnerId = node_reportingowner.SelectSingleNode("reportingOwnerId");
            ToReturn.OwnerCik  = node_reportingOwnerId.SelectSingleNode("rptOwnerCik").InnerText;
            ToReturn.OwnerName = node_reportingOwnerId.SelectSingleNode("rptOwnerName").InnerText;

            //Reporting owner address data
            XmlNode node_reportingOwnerAddress = node_reportingowner.SelectSingleNode("reportingOwnerAddress");
            ToReturn.OwnerStreet1   = node_reportingOwnerAddress.SelectSingleNode("rptOwnerStreet1").InnerText;
            ToReturn.OwnerStreet2   = node_reportingOwnerAddress.SelectSingleNode("rptOwnerStreet2").InnerText;
            ToReturn.OwnerCity      = node_reportingOwnerAddress.SelectSingleNode("rptOwnerCity").InnerText;
            ToReturn.OwnerStateCode = node_reportingOwnerAddress.SelectSingleNode("rptOwnerState").InnerText;
            ToReturn.OwnerZipCode   = node_reportingOwnerAddress.SelectSingleNode("rptOwnerZipCode").InnerText;

            //Owner relationship
            XmlNode node_reportingOwnerRelationship = node_reportingowner.SelectSingleNode("reportingOwnerRelationship");

            //Owner is officer (this is sometimes called "Director")
            XmlNode node_isOfficer  = node_reportingOwnerRelationship.SelectSingleNode("isOfficer");
            XmlNode node_isDirector = node_reportingOwnerRelationship.SelectSingleNode("isDirector");
            if (node_isOfficer != null)
            {
                string owner_is_officer_val = node_reportingOwnerRelationship.SelectSingleNode("isOfficer").InnerText;
                if (owner_is_officer_val == "0")
                {
                    ToReturn.OwnerIsOfficer = false;
                }
                else if (owner_is_officer_val == "1")
                {
                    ToReturn.OwnerIsOfficer = true;
                }
            }
            else if (node_isDirector != null) //If the isOfficer node was null, check for the isDirector node instead.
            {
                string owner_is_officer_val = node_reportingOwnerRelationship.SelectSingleNode("isDirector").InnerText;
                if (owner_is_officer_val == "0")
                {
                    ToReturn.OwnerIsOfficer = false;
                }
                else if (owner_is_officer_val == "1")
                {
                    ToReturn.OwnerIsOfficer = true;
                }
            }
            else //If we couldn't find a relevant tag, just say they are not an officer
            {
                ToReturn.OwnerIsOfficer = false;
            }



            //Get the officer title (this will only be there if this person is an officer)
            if (ToReturn.OwnerIsOfficer)
            {
                XmlNode node_officerTitle = node_reportingOwnerRelationship.SelectSingleNode("officerTitle");
                if (node_officerTitle != null)
                {
                    ToReturn.OwnerOfficerTitle = node_reportingOwnerRelationship.SelectSingleNode("officerTitle").InnerText;
                }
                else
                {
                    ToReturn.OwnerOfficerTitle = null;
                }
            }
            else
            {
                ToReturn.OwnerOfficerTitle = null;
            }


            #endregion

            #region "Non Derivative table"

            XmlNode node_nonDerivativeTable = doc_data.SelectSingleNode("nonDerivativeTable");
            if (node_nonDerivativeTable != null)
            {
                List <NonDerivativeTransaction> transactions = new List <NonDerivativeTransaction>();
                foreach (XmlNode node_nonDerivativeEntry in node_nonDerivativeTable.ChildNodes)
                {
                    NonDerivativeTransaction ndt = new NonDerivativeTransaction();
                    ndt.LoadFromNode(node_nonDerivativeEntry);
                    transactions.Add(ndt);
                }
                ToReturn.NonDerivativeTransactions = transactions.ToArray();
            }

            #endregion

            #region "Derivative table"

            XmlNode node_derivativeTable = doc_data.SelectSingleNode("derivativeTable");
            if (node_derivativeTable != null)
            {
                List <DerivativeTransaction> DTs = new List <DerivativeTransaction>();
                foreach (XmlNode node_derivativeTransaction in node_derivativeTable.ChildNodes)
                {
                    DerivativeTransaction dt = new DerivativeTransaction();
                    dt.LoadFromNode(node_derivativeTransaction);
                    DTs.Add(dt);
                }
                ToReturn.DerivativeTransactions = DTs.ToArray();
            }

            #endregion

            return(ToReturn);
        }