-
Notifications
You must be signed in to change notification settings - Fork 2
Company Details
This API returns the company information, financial ratios, and other key metrics for the equity specified. Data is generally refreshed on the same day a company reports its latest earnings and financials.
from alphavantage_api_client import AlphavantageClient, CompanyOverview
def sample_company_overview():
client = AlphavantageClient()
event = {
"symbol" : "TSLA"
}
company_overview = client.get_company_overview(event)
print(f"description: {company_overview.description}")
print(f"name: {company_overview.name}")
print(f" pe_ratio: {company_overview.pe_ratio}")
print(f"shares_outstanding: {company_overview.shares_outstanding}")
print(f"dividend_ratio: {company_overview.dividend_date}")
print(f"dividend_yield: {company_overview.dividend_yield}")
print(f"price_to_book_ratio: {company_overview.price_to_book_ratio}")
# and more!
if __name__ == "__main__":
sample_company_overview()
Event Params
❚ Required: symbol
The symbol of the ticker of your choice. For example: symbol=IBM.
A financial statement that provides a snapshot of a company's financial position at a specific point in time. It shows the company's assets, liabilities, and shareholders' equity.
This API returns the annual and quarterly balance sheets for the company of interest, with normalized fields mapped to GAAP and IFRS taxonomies of the SEC. Data is generally refreshed on the same day a company reports its latest earnings and financials.
from alphavantage_api_client import AlphavantageClient, AccountingReport
def sample_balance_sheet():
client = AlphavantageClient()
event = {
"symbol" : "TSLA"
}
balance_sheet = client.get_balance_sheet(event)
print(balance_sheet.get_most_recent_quarterly_report()) # get the newest quarterly statement
print(balance_sheet.get_most_recent_annual_report()) # get the most recent annual report
print(balance_sheet.quarterlyReports) # get [] quarterly reports
print(balance_sheet.annualReports) # get [] annual reports
if __name__ == "__main__":
sample_balance_sheet()
Event Params
❚ Required: symbol
The symbol of the ticker of your choice. For example: symbol=IBM.
Also known as a profit and loss statement or P&L statement, is a financial statement that provides an overview of a company's revenues, expenses, and net income or loss over a specific period of time. It is one of the key financial statements used by investors to assess a company's profitability and financial performance.
This API returns the annual and quarterly income statements for the company of interest, with normalized fields mapped to GAAP and IFRS taxonomies of the SEC. Data is generally refreshed on the same day a company reports its latest earnings and financials.
from alphavantage_api_client import AlphavantageClient, AccountingReport
def sample_income_statement():
client = AlphavantageClient()
event = {
"symbol" : "TSLA"
}
income_statement = client.get_income_statement(event)
print(income_statement.get_most_recent_quarterly_report()) # get the newest quarterly statement
print(income_statement.get_most_recent_annual_report()) # get the most recent annual report
print(income_statement.quarterlyReports) # get [] quarterly reports
print(income_statement.annualReports) # get [] annual reports
if __name__ == "__main__":
sample_income_statement()
Event Params
❚ Required: symbol
The symbol of the ticker of your choice. For example: symbol=IBM.
An earnings statement, also known as an earnings report or earnings statement, is a financial statement that provides an overview of a company's revenue, expenses, and profit or loss for a specific period of time. It is commonly used by investors to evaluate a company's financial performance.
This API returns the annual and quarterly earnings (EPS) for the company of interest. Quarterly data also includes analyst estimates and surprise metrics.
from alphavantage_api_client import AlphavantageClient, AccountingReport
def sample_earnings_statement():
client = AlphavantageClient()
event = {
"symbol" : "TSLA"
}
earnings = client.get_earnings(event)
print(earnings.get_most_recent_quarterly_report()) # get the newest quarterly statement
print(earnings.get_most_recent_annual_report()) # get the most recent annual report
print(earnings.quarterlyReports) # get [] quarterly reports
print(earnings.annualReports) # get [] annual reports
Event Params
❚ Required: symbol
The symbol of the ticker of your choice. For example: symbol=IBM.
A cash flow statement is a financial statement that provides information about the cash inflows and outflows of a company during a specific period of time. It helps investors understand how a company generates and uses cash.
This API returns the annual and quarterly cash flow for the company of interest, with normalized fields mapped to GAAP and IFRS taxonomies of the SEC. Data is generally refreshed on the same day a company reports its latest earnings and financials.
from alphavantage_api_client import AlphavantageClient, AccountingReport
def sample_cash_flow():
client = AlphavantageClient()
event = {
"symbol" : "TSLA"
}
cash_flow = client.get_cash_flow(event)
print(cash_flow.get_most_recent_quarterly_report()) # get the newest quarterly statement
print(cash_flow.get_most_recent_annual_report()) # get the most recent annual report
print(cash_flow.quarterlyReports) # get [] quarterly reports
print(cash_flow.annualReports) # get [] annual reports
if __name__ == "__main__":
sample_cash_flow()
Event Params
❚ Required: symbol
The symbol of the ticker of your choice. For example: symbol=IBM.
There might be times where you want to combine all 4 financial statements (income, cash flow, earnings and balance sheet) into one object. The Ticker
abstraction makes that easy. This will produce a dictionary where the key is the fiscal date ending and the value is a dictionary with all values from each financial statement.
from alphavantage_api_client import AlphavantageClient, Ticker
def sample_ticker_usage():
"""
combine all financial statements (income, cash flow, earnings and balance sheet) for both
quarterly and annual reports. There migth be times you want to store/visualize them together
thus providing another dimensionality of the data
Returns:
"""
aapl = (Ticker()
.create_client()
.should_retry_once() # auto retry when limit reached
.from_symbol("AAPL") # define the company of interest
.fetch_accounting_reports() # make the call to alpha vantage api
.correlate_accounting_reports() # combines all 4 financial statements
)
# get the individual financial statements if needed
earnings = aapl.get_earnings()
income_statement = aapl.get_income_statement()
balance_sheet = aapl.get_balance_sheet()
cash_flow = aapl.get_cash_flow()
# get the combined financial statements and iterate easy
correlated_financial_statements = aapl.get_correlated_reports() # both quarterly and annually
for fiscal_date_ending in correlated_financial_statements:
combined_financial_statements = correlated_financial_statements[fiscal_date_ending]
print(f"{fiscal_date_ending} = {combined_financial_statements}")
if __name__ == "__main__":
sample_ticker_usage()
Simple python wrapper around alpha vantage api, provide consistency across end points, debug easily and get the most out of your free account!