Open kikepech opened 6 days ago
You can get that value from the XBRL instance
company = Company("AAPL")
financials = company.financials
inancials.xbrl_data.instance.dei_facts.get("dei:EntityCommonStockSharesOutstanding").get('value')
Thank you so much for the support.
I would like to ask you something else. How do you manage to handle multiple income statements, each with its own title? In my case, I started reading them in loops with titles like 'CONSOLIDATEDSTATEMENTSOFOPERATIONS', 'ConsolidatedStatementofIncome', 'ConsolidatedStatementsofIncome', 'ConsolidatedStatementsofEarnings', and 'CONSOLIDATEDSTATEMENTSOFINCOME', taken from MNLZ, KO, PEP, and others.
Every income statement has a row with a concept named "us-gaap_StatementOfCashFlowsAbstract".
The function def get_income_statement(self, standard: bool = False) -> Optional[Statement]
looks for the role name that contains that concept
https://github.com/dgunning/edgartools/blob/main/edgar/financials.py#L260
Does this answer your question?
Thanks again for the support. Im sorry but im to noob to understand, I don't know how to use this piece of code, however I sense that that is the panacea of I was looking, I want to show you a piece of the code code I make, could you teach me how to match both part?:
from edgar import *
from edgar.documents import HtmlDocument
from edgar.xbrl import *
import pandas as pd
from edgar.financials import Financials
from edgar import get_filings
set_identity("mail@mail.com")
def get_latest_statement(company_symbol, form_type, statement_type):
try:
filing = Company(company_symbol).get_filings(form=form_type).latest(1)
xbrl_data = filing.xbrl()
statements = xbrl_data.statements
def extract_and_save_data(company_symbol, form_type, statement_types, output_file):
try:
data = {}
for statement_type in statement_types:
statement_df = get_latest_statement(company_symbol, form_type, statement_type)
if statement_df is not None:
data[statement_type] = statement_df
metrics = {}
if 'CONSOLIDATEDSTATEMENTSOFOPERATIONS' in data:
operations_df = data['CONSOLIDATEDSTATEMENTSOFOPERATIONS']
metrics['Net Sales 2023'] = float(operations_df.loc['Net sales', '2023'])
if 'CONSOLIDATEDBALANCESHEETS' in data:
balance_df = data['CONSOLIDATEDBALANCESHEETS']
metrics['Cash'] = float(balance_df.loc['Cash and cash equivalents', '2023'])
metrics_df = pd.DataFrame(list(metrics.items()), columns=['Metric', 'Value'])
if __name__ == "__main__":
company_symbol = "HRL"
form_type = "10-K"
statement_types = ['CONSOLIDATEDSTATEMENTSOFOPERATIONS', CONSOLIDATEDBALANCESHEETS]
extract_and_save_data(company_symbol,` form_type, statement_types, output_file)
I guess I make a mess there, thanks in advance for any feedback!.
Use
financials = Financials.extract(filings)
income_statement = financials.get_income_statement()
income_statement.get_concept("us-gaap_RevenueFromContractWithCustomerIncludingAssessedTax").value['2023']
# Or get by label
income_statement.get_concept(label="Net Sales").value['2023']
balance_sheet = financials.get_balance_sheet()
balance_sheet.get_concept("us-gaap_CashAndCashEquivalentsAtCarryingValue").value.get('2023')
# Get by label
balance_sheet.get_concept(label="Cash and Cash Equivalents").value.get('2023')
Got it now!, I guess I'll add the "concepts" now and then, Because are not always the same (Ex: AAPL: "us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax"
and PEP: "us-gaap_Revenues"
).
Thank you so much for the tips!.
hi all,
can someone help me to understand how I can get dei:EntityCommonStockSharesOutstanding? is normally in the first page of the CIK, in my case I was looking for Pepsico (Tag dei:EntityCommonStockSharesOutstanding, Fact 1,374,429,271)