{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ๐Ÿ“ˆ DefeatBeta-API vs Yahoo Finance: Interactive Comparison\n", "\n", "Welcome to this interactive notebook where we'll explore the **DefeatBeta-API** - an open-source alternative to Yahoo Finance's market data APIs with higher reliability.\n", "\n", "## ๐ŸŽฏ What You'll Learn\n", "\n", "- How to use DefeatBeta-API for financial data analysis\n", "- Compare data structures and methods with Yahoo Finance\n", "- Explore unique features like earnings transcripts and DCF valuation\n", "- Test practical trading analysis scenarios\n", "\n", "## ๐Ÿ“ฆ Setup" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[nltk_data] Error loading punkt_tab: \n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[38;5;10m______ __ _ ______ _ \n", "| _ \\ / _| | | | ___ \\ | | \n", "| | | |___| |_ ___ __ _| |_ | |_/ / ___| |_ __ _ \n", "| | | / _ \\ _/ _ \\/ _` | __| | ___ \\/ _ \\ __/ _` |\n", "| |/ / __/ || __/ (_| | |_ | |_/ / __/ || (_| |\n", "|___/ \\___|_| \\___|\\__,_|\\__| \\____/ \\___|\\__\\__,_|\u001b[0m\n", "\u001b[1;38;5;10m๐Ÿ“ˆ:: Data Update Time ::\u001b[0m\t2026-04-17 \u001b[1;38;5;10m::\u001b[0m\n", "\u001b[1;38;5;10m๐Ÿ“ˆ:: Software Version ::\u001b[0m\t0.0.45 \u001b[1;38;5;10m::\u001b[0m\n", "โœ… yfinance is installed\n", "โœ… DefeatBeta-API imported successfully\n", "Python version: 3.12.12\n" ] } ], "source": [ "# Import required libraries\n", "import pandas as pd\n", "import numpy as np\n", "import time\n", "import sys\n", "\n", "# DefeatBeta-API\n", "from defeatbeta_api.data.ticker import Ticker\n", "\n", "# Yahoo Finance (for comparison)\n", "try:\n", " import yfinance as yf\n", " YFINANCE_AVAILABLE = True\n", " print(\"โœ… yfinance is installed\")\n", "except ImportError:\n", " YFINANCE_AVAILABLE = False\n", " print(\"โš ๏ธ yfinance not installed - install with: uv add yfinance\")\n", "\n", "print(\"โœ… DefeatBeta-API imported successfully\")\n", "print(f\"Python version: {sys.version.split()[0]}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿƒโ€โ™€๏ธ 1. QUICK PERFORMANCE TEST" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "PERFORMANCE COMPARISON: Fetching Price Data\n", "============================================================\n", "2026-04-25 17:43:11 INFO DuckDBClient MainThread - Cache is up-to-date. Update time: 2026-04-17\n", "\n", "โœ… DefeatBeta: 0.617s\n", " Data shape: (7897, 7)\n", "\n", "โœ… Yahoo Finance: 0.493s\n", " Data shape: (11433, 7)\n" ] } ], "source": [ "# Test query speed for both APIs\n", "symbol = 'AAPL'\n", "\n", "print(\"=\" * 60)\n", "print(\"PERFORMANCE COMPARISON: Fetching Price Data\")\n", "print(\"=\" * 60)\n", "\n", "# DefeatBeta\n", "start = time.time()\n", "db_ticker = Ticker(symbol)\n", "db_price = db_ticker.price()\n", "db_time = time.time() - start\n", "print(f\"\\nโœ… DefeatBeta: {db_time:.3f}s\")\n", "print(f\" Data shape: {db_price.shape}\")\n", "\n", "# Yahoo Finance\n", "if YFINANCE_AVAILABLE:\n", " start = time.time()\n", " yf_ticker = yf.Ticker(symbol)\n", " yf_price = yf_ticker.history(period='max')\n", " yf_time = time.time() - start\n", " print(f\"\\nโœ… Yahoo Finance: {yf_time:.3f}s\")\n", " print(f\" Data shape: {yf_price.shape}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ“Š 2. PRICE DATA COMPARISON" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "PRICE DATA STRUCTURE COMPARISON\n", "============================================================\n", "\n", "๐Ÿ“Œ DEFEATBETA API:\n", " Type: DataFrame\n", " Columns: ['symbol', 'report_date', 'open', 'close', 'high', 'low', 'volume']\n", "\n", " Latest 3 rows:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_dateopenclosehighlowvolume
7887AAPL2026-04-06256.51258.86262.16256.4629329900
7888AAPL2026-04-07256.16253.50256.20245.7062148000
7889AAPL2026-04-08258.45258.90259.75256.5341032800
7890AAPL2026-04-09259.00260.49261.12256.0728121600
7891AAPL2026-04-10259.98260.48262.19259.0231291500
7892AAPL2026-04-13259.73259.20260.18256.6636234700
7893AAPL2026-04-14259.25258.83261.93257.1948370700
7894AAPL2026-04-15258.16266.43266.56257.8149913500
7895AAPL2026-04-16266.80263.40267.16261.2743323100
7896AAPL2026-04-17266.96270.23272.30266.7261314800
\n", "
" ], "text/plain": [ " symbol report_date open close high low volume\n", "7887 AAPL 2026-04-06 256.51 258.86 262.16 256.46 29329900\n", "7888 AAPL 2026-04-07 256.16 253.50 256.20 245.70 62148000\n", "7889 AAPL 2026-04-08 258.45 258.90 259.75 256.53 41032800\n", "7890 AAPL 2026-04-09 259.00 260.49 261.12 256.07 28121600\n", "7891 AAPL 2026-04-10 259.98 260.48 262.19 259.02 31291500\n", "7892 AAPL 2026-04-13 259.73 259.20 260.18 256.66 36234700\n", "7893 AAPL 2026-04-14 259.25 258.83 261.93 257.19 48370700\n", "7894 AAPL 2026-04-15 258.16 266.43 266.56 257.81 49913500\n", "7895 AAPL 2026-04-16 266.80 263.40 267.16 261.27 43323100\n", "7896 AAPL 2026-04-17 266.96 270.23 272.30 266.72 61314800" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ YAHOO FINANCE:\n", " Type: DataFrame\n", " Columns: ['Open', 'High', 'Low', 'Close', 'Volume', 'Dividends', 'Stock Splits']\n", "\n", " Latest 3 rows:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
OpenHighLowCloseVolumeDividendsStock Splits
Date
2026-04-13 00:00:00-04:00259.730011260.179993256.660004259.200012362347000.00.0
2026-04-14 00:00:00-04:00259.250000261.929993257.190002258.829987483707000.00.0
2026-04-15 00:00:00-04:00258.160004266.559998257.809998266.429993499135000.00.0
2026-04-16 00:00:00-04:00266.799988267.160004261.269989263.399994433231000.00.0
2026-04-17 00:00:00-04:00266.959991272.299988266.720001270.230011614362000.00.0
2026-04-20 00:00:00-04:00270.329987274.279999270.290009273.049988365902000.00.0
2026-04-21 00:00:00-04:00271.500000272.799988265.399994266.170013502098000.00.0
2026-04-22 00:00:00-04:00267.820007273.739990266.869995273.170013432492000.00.0
2026-04-23 00:00:00-04:00275.049988275.769989271.649994273.429993333996000.00.0
2026-04-24 00:00:00-04:00272.760010273.059998269.649994271.059998381245000.00.0
\n", "
" ], "text/plain": [ " Open High Low Close \\\n", "Date \n", "2026-04-13 00:00:00-04:00 259.730011 260.179993 256.660004 259.200012 \n", "2026-04-14 00:00:00-04:00 259.250000 261.929993 257.190002 258.829987 \n", "2026-04-15 00:00:00-04:00 258.160004 266.559998 257.809998 266.429993 \n", "2026-04-16 00:00:00-04:00 266.799988 267.160004 261.269989 263.399994 \n", "2026-04-17 00:00:00-04:00 266.959991 272.299988 266.720001 270.230011 \n", "2026-04-20 00:00:00-04:00 270.329987 274.279999 270.290009 273.049988 \n", "2026-04-21 00:00:00-04:00 271.500000 272.799988 265.399994 266.170013 \n", "2026-04-22 00:00:00-04:00 267.820007 273.739990 266.869995 273.170013 \n", "2026-04-23 00:00:00-04:00 275.049988 275.769989 271.649994 273.429993 \n", "2026-04-24 00:00:00-04:00 272.760010 273.059998 269.649994 271.059998 \n", "\n", " Volume Dividends Stock Splits \n", "Date \n", "2026-04-13 00:00:00-04:00 36234700 0.0 0.0 \n", "2026-04-14 00:00:00-04:00 48370700 0.0 0.0 \n", "2026-04-15 00:00:00-04:00 49913500 0.0 0.0 \n", "2026-04-16 00:00:00-04:00 43323100 0.0 0.0 \n", "2026-04-17 00:00:00-04:00 61436200 0.0 0.0 \n", "2026-04-20 00:00:00-04:00 36590200 0.0 0.0 \n", "2026-04-21 00:00:00-04:00 50209800 0.0 0.0 \n", "2026-04-22 00:00:00-04:00 43249200 0.0 0.0 \n", "2026-04-23 00:00:00-04:00 33399600 0.0 0.0 \n", "2026-04-24 00:00:00-04:00 38124500 0.0 0.0 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Compare price data structures\n", "print(\"=\" * 60)\n", "print(\"PRICE DATA STRUCTURE COMPARISON\")\n", "print(\"=\" * 60)\n", "\n", "print(\"\\n๐Ÿ“Œ DEFEATBETA API:\")\n", "print(f\" Type: {type(db_price).__name__}\")\n", "print(f\" Columns: {list(db_price.columns)}\")\n", "print(f\"\\n Latest 3 rows:\")\n", "display(db_price.tail(10))\n", "\n", "if YFINANCE_AVAILABLE:\n", " print(\"\\n๐Ÿ“Œ YAHOO FINANCE:\")\n", " print(f\" Type: {type(yf_price).__name__}\")\n", " print(f\" Columns: {list(yf_price.columns)}\")\n", " print(f\"\\n Latest 3 rows:\")\n", " display(yf_price.tail(10))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ’ฐ 3. VALUATION METRICS" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "VALUATION METRICS (with historical data!)\n", "============================================================\n", "\n", "๐Ÿ“Œ TTM EPS History:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_datetailing_epsepsupdate_time
104NVDA2025-01-312.940.892026-04-18
105NVDA2025-04-303.100.762026-04-18
106NVDA2025-07-313.511.082026-04-18
107NVDA2025-10-314.041.302026-04-18
108NVDA2026-01-314.901.762026-04-18
\n", "
" ], "text/plain": [ " symbol report_date tailing_eps eps update_time\n", "104 NVDA 2025-01-31 2.94 0.89 2026-04-18\n", "105 NVDA 2025-04-30 3.10 0.76 2026-04-18\n", "106 NVDA 2025-07-31 3.51 1.08 2026-04-18\n", "107 NVDA 2025-10-31 4.04 1.30 2026-04-18\n", "108 NVDA 2026-01-31 4.90 1.76 2026-04-18" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ TTM P/E Ratio History:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_dateeps_report_dateclose_pricettm_epsttm_pe
6846NVDA2026-04-132026-01-31189.314.938.63
6847NVDA2026-04-142026-01-31196.514.940.10
6848NVDA2026-04-152026-01-31198.874.940.59
6849NVDA2026-04-162026-01-31198.354.940.48
6850NVDA2026-04-172026-01-31201.684.941.16
\n", "
" ], "text/plain": [ " symbol report_date eps_report_date close_price ttm_eps ttm_pe\n", "6846 NVDA 2026-04-13 2026-01-31 189.31 4.9 38.63\n", "6847 NVDA 2026-04-14 2026-01-31 196.51 4.9 40.10\n", "6848 NVDA 2026-04-15 2026-01-31 198.87 4.9 40.59\n", "6849 NVDA 2026-04-16 2026-01-31 198.35 4.9 40.48\n", "6850 NVDA 2026-04-17 2026-01-31 201.68 4.9 41.16" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ Market Capitalization History:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
report_dateclose_priceshares_outstandingmarket_capitalization
68462026-04-13189.312.430000e+104.600233e+12
68472026-04-14196.512.430000e+104.775193e+12
68482026-04-15198.872.430000e+104.832541e+12
68492026-04-16198.352.430000e+104.819905e+12
68502026-04-17201.682.430000e+104.900824e+12
\n", "
" ], "text/plain": [ " report_date close_price shares_outstanding market_capitalization\n", "6846 2026-04-13 189.31 2.430000e+10 4.600233e+12\n", "6847 2026-04-14 196.51 2.430000e+10 4.775193e+12\n", "6848 2026-04-15 198.87 2.430000e+10 4.832541e+12\n", "6849 2026-04-16 198.35 2.430000e+10 4.819905e+12\n", "6850 2026-04-17 201.68 2.430000e+10 4.900824e+12" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Explore valuation metrics - DefeatBeta provides HISTORICAL data\n", "symbol = 'NVDA' # NVIDIA for interesting metrics\n", "db_ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"VALUATION METRICS (with historical data!)\")\n", "print(\"=\" * 60)\n", "\n", "print(\"\\n๐Ÿ“Œ TTM EPS History:\")\n", "ttm_eps = db_ticker.ttm_eps()\n", "display(ttm_eps.tail(5))\n", "\n", "print(\"\\n๐Ÿ“Œ TTM P/E Ratio History:\")\n", "ttm_pe = db_ticker.ttm_pe()\n", "display(ttm_pe.tail(5))\n", "\n", "print(\"\\n๐Ÿ“Œ Market Capitalization History:\")\n", "market_cap = db_ticker.market_capitalization()\n", "display(market_cap[['report_date', 'close_price', 'shares_outstanding', 'market_capitalization']].tail(5))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "============================================================\n", "YAHOO FINANCE: Current Valuation (from .info)\n", "============================================================\n", " trailingPE: 42.591003\n", " forwardPE: 18.530712\n", " marketCap: 5062002737152\n", " trailingEps: 4.89\n", " forwardEps: 11.23918\n" ] } ], "source": [ "# Compare with Yahoo Finance current values\n", "if YFINANCE_AVAILABLE:\n", " print(\"\\n\" + \"=\" * 60)\n", " print(\"YAHOO FINANCE: Current Valuation (from .info)\")\n", " print(\"=\" * 60)\n", " \n", " yf_ticker = yf.Ticker(symbol)\n", " info = yf_ticker.info\n", " \n", " valuation_keys = ['trailingPE', 'forwardPE', 'marketCap', 'trailingEps', 'forwardEps']\n", " for key in valuation_keys:\n", " if key in info:\n", " print(f\" {key}: {info[key]}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ“‰ 4. FINANCIAL STATEMENTS" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "QUARTERLY INCOME STATEMENT\n", "============================================================\n", "\n", "๐Ÿ“Œ Type: Statement\n", " Methods: .df(), .data(), .print_pretty_table()\n", "\n", "๐Ÿ“Œ DataFrame Shape: (47, 17)\n", " Columns: TTM + 16 quarters\n", "\n", "๐Ÿ“Œ KEY METRICS (TTM values):\n", " Total Revenue: $281.72B\n", " Gross Profit: $193.89B\n", " Operating Income: $128.53B\n", " Net Income Common Stockholders: $101.83B\n", " Diluted EPS: $10.32\n" ] } ], "source": [ "# Explore quarterly income statement\n", "symbol = 'MSFT'\n", "db_ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"QUARTERLY INCOME STATEMENT\")\n", "print(\"=\" * 60)\n", "\n", "# Get the Statement object\n", "income_stmt = db_ticker.quarterly_income_statement()\n", "print(f\"\\n๐Ÿ“Œ Type: {type(income_stmt).__name__}\")\n", "print(f\" Methods: .df(), .data(), .print_pretty_table()\")\n", "\n", "# Get as DataFrame\n", "stmt_df = income_stmt.df()\n", "print(f\"\\n๐Ÿ“Œ DataFrame Shape: {stmt_df.shape}\")\n", "print(f\" Columns: TTM + 16 quarters\")\n", "\n", "# Show key metrics\n", "key_metrics = [\n", " 'Total Revenue',\n", " 'Gross Profit',\n", " 'Operating Income',\n", " 'Net Income Common Stockholders',\n", " 'Diluted EPS'\n", "]\n", "\n", "print(\"\\n๐Ÿ“Œ KEY METRICS (TTM values):\")\n", "for metric in key_metrics:\n", " if metric in stmt_df['Breakdown'].values:\n", " row = stmt_df[stmt_df['Breakdown'] == metric].iloc[0]\n", " value = float(row['TTM']) # Convert Decimal to float\n", " if abs(value) >= 1e9:\n", " print(f\" {metric}: ${value/1e9:.2f}B\")\n", " elif abs(value) >= 1e6:\n", " print(f\" {metric}: ${value/1e6:.2f}M\")\n", " else:\n", " print(f\" {metric}: ${value:.2f}\")\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ FORMATTED TABLE (first 10 line items):\n", "------------------------------------------------------------\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
MetricTTM Value
0Total Revenue281724000000.0
1Operating Revenue281724000000.0
2Cost of Revenue87831000000.0
3Gross Profit193893000000.0
4Operating Expense65365000000.0
5Selling General and Administrative32877000000.0
6General & Administrative Expense7223000000.0
7Other G and A7223000000.0
8Selling & Marketing Expense25654000000.0
9Research & Development32488000000.0
\n", "
" ], "text/plain": [ " Metric TTM Value\n", "0 Total Revenue 281724000000.0\n", "1 Operating Revenue 281724000000.0\n", "2 Cost of Revenue 87831000000.0\n", "3 Gross Profit 193893000000.0\n", "4 Operating Expense 65365000000.0\n", "5 Selling General and Administrative 32877000000.0\n", "6 General & Administrative Expense 7223000000.0\n", "7 Other G and A 7223000000.0\n", "8 Selling & Marketing Expense 25654000000.0\n", "9 Research & Development 32488000000.0" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Try the pretty print version\n", "print(\"\\n๐Ÿ“Œ FORMATTED TABLE (first 10 line items):\")\n", "print(\"-\" * 60)\n", "# Note: print_pretty_table() might be very wide, so let's show a subset\n", "subset = stmt_df.head(10)[['Breakdown', 'TTM']]\n", "subset.columns = ['Metric', 'TTM Value']\n", "display(subset)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ“ˆ 5. FINANCIAL RATIOS" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "FINANCIAL RATIOS (Historical Time Series)\n", "============================================================\n", "\n", "๐Ÿ“Œ RETURN ON EQUITY (ROE):\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_datenet_income_common_stockholdersbeginning_stockholders_equityending_stockholders_equityavg_equityroe
0TSLA2023-09-301.851000e+095.113000e+105.346600e+105.229800e+100.0354
1TSLA2023-12-317.927000e+095.346600e+106.263400e+105.805000e+100.1366
2TSLA2024-03-311.432000e+096.263400e+106.437800e+106.350600e+100.0225
3TSLA2024-06-301.400000e+096.437800e+106.646800e+106.542300e+100.0214
4TSLA2024-09-302.173000e+096.646800e+106.993100e+106.819950e+100.0319
5TSLA2024-12-312.314000e+096.993100e+107.291300e+107.142200e+100.0324
6TSLA2025-03-314.090000e+087.291300e+107.465300e+107.378300e+100.0055
7TSLA2025-06-301.172000e+097.465300e+107.731400e+107.598350e+100.0154
8TSLA2025-09-301.373000e+097.731400e+107.997000e+107.864200e+100.0175
9TSLA2025-12-318.400000e+087.997000e+108.213700e+108.105350e+100.0104
\n", "
" ], "text/plain": [ " symbol report_date net_income_common_stockholders \\\n", "0 TSLA 2023-09-30 1.851000e+09 \n", "1 TSLA 2023-12-31 7.927000e+09 \n", "2 TSLA 2024-03-31 1.432000e+09 \n", "3 TSLA 2024-06-30 1.400000e+09 \n", "4 TSLA 2024-09-30 2.173000e+09 \n", "5 TSLA 2024-12-31 2.314000e+09 \n", "6 TSLA 2025-03-31 4.090000e+08 \n", "7 TSLA 2025-06-30 1.172000e+09 \n", "8 TSLA 2025-09-30 1.373000e+09 \n", "9 TSLA 2025-12-31 8.400000e+08 \n", "\n", " beginning_stockholders_equity ending_stockholders_equity avg_equity \\\n", "0 5.113000e+10 5.346600e+10 5.229800e+10 \n", "1 5.346600e+10 6.263400e+10 5.805000e+10 \n", "2 6.263400e+10 6.437800e+10 6.350600e+10 \n", "3 6.437800e+10 6.646800e+10 6.542300e+10 \n", "4 6.646800e+10 6.993100e+10 6.819950e+10 \n", "5 6.993100e+10 7.291300e+10 7.142200e+10 \n", "6 7.291300e+10 7.465300e+10 7.378300e+10 \n", "7 7.465300e+10 7.731400e+10 7.598350e+10 \n", "8 7.731400e+10 7.997000e+10 7.864200e+10 \n", "9 7.997000e+10 8.213700e+10 8.105350e+10 \n", "\n", " roe \n", "0 0.0354 \n", "1 0.1366 \n", "2 0.0225 \n", "3 0.0214 \n", "4 0.0319 \n", "5 0.0324 \n", "6 0.0055 \n", "7 0.0154 \n", "8 0.0175 \n", "9 0.0104 " ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ RETURN ON INVESTED CAPITAL (ROIC):\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_dateebittax_rate_for_calcsnopatbeginning_invested_capitalending_invested_capitalavg_invested_capitalroic
0TSLA2022-09-30NaNNaNNaN3.952800e+10NaNNaNNaN
1TSLA2023-09-302.083000e+090.081.916360e+095.264900e+105.717000e+105.490950e+100.0349
2TSLA2023-12-312.252000e+090.211.779080e+095.717000e+106.729100e+106.223050e+100.0286
3TSLA2024-03-311.964000e+090.261.453360e+096.729100e+106.925200e+106.827150e+100.0213
4TSLA2024-06-301.873000e+090.211.479670e+096.925200e+107.383000e+107.154100e+100.0207
5TSLA2024-09-302.883000e+090.222.248740e+097.383000e+107.732100e+107.557550e+100.0298
6TSLA2024-12-312.862000e+090.162.404080e+097.732100e+108.079100e+107.905600e+100.0304
7TSLA2025-03-316.800000e+080.294.828000e+088.079100e+108.189700e+108.134400e+100.0059
8TSLA2025-06-301.635000e+090.231.258950e+098.189700e+108.427000e+108.308350e+100.0152
9TSLA2025-09-302.035000e+090.291.444850e+098.427000e+108.743100e+108.585050e+100.0168
10TSLA2025-12-311.266000e+090.289.115200e+088.743100e+109.029000e+108.886050e+100.0103
\n", "
" ], "text/plain": [ " symbol report_date ebit tax_rate_for_calcs nopat \\\n", "0 TSLA 2022-09-30 NaN NaN NaN \n", "1 TSLA 2023-09-30 2.083000e+09 0.08 1.916360e+09 \n", "2 TSLA 2023-12-31 2.252000e+09 0.21 1.779080e+09 \n", "3 TSLA 2024-03-31 1.964000e+09 0.26 1.453360e+09 \n", "4 TSLA 2024-06-30 1.873000e+09 0.21 1.479670e+09 \n", "5 TSLA 2024-09-30 2.883000e+09 0.22 2.248740e+09 \n", "6 TSLA 2024-12-31 2.862000e+09 0.16 2.404080e+09 \n", "7 TSLA 2025-03-31 6.800000e+08 0.29 4.828000e+08 \n", "8 TSLA 2025-06-30 1.635000e+09 0.23 1.258950e+09 \n", "9 TSLA 2025-09-30 2.035000e+09 0.29 1.444850e+09 \n", "10 TSLA 2025-12-31 1.266000e+09 0.28 9.115200e+08 \n", "\n", " beginning_invested_capital ending_invested_capital avg_invested_capital \\\n", "0 3.952800e+10 NaN NaN \n", "1 5.264900e+10 5.717000e+10 5.490950e+10 \n", "2 5.717000e+10 6.729100e+10 6.223050e+10 \n", "3 6.729100e+10 6.925200e+10 6.827150e+10 \n", "4 6.925200e+10 7.383000e+10 7.154100e+10 \n", "5 7.383000e+10 7.732100e+10 7.557550e+10 \n", "6 7.732100e+10 8.079100e+10 7.905600e+10 \n", "7 8.079100e+10 8.189700e+10 8.134400e+10 \n", "8 8.189700e+10 8.427000e+10 8.308350e+10 \n", "9 8.427000e+10 8.743100e+10 8.585050e+10 \n", "10 8.743100e+10 9.029000e+10 8.886050e+10 \n", "\n", " roic \n", "0 NaN \n", "1 0.0349 \n", "2 0.0286 \n", "3 0.0213 \n", "4 0.0207 \n", "5 0.0298 \n", "6 0.0304 \n", "7 0.0059 \n", "8 0.0152 \n", "9 0.0168 \n", "10 0.0103 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Explore financial ratios with historical data\n", "symbol = 'TSLA' # Tesla for interesting ratios\n", "db_ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"FINANCIAL RATIOS (Historical Time Series)\")\n", "print(\"=\" * 60)\n", "\n", "print(\"\\n๐Ÿ“Œ RETURN ON EQUITY (ROE):\")\n", "roe = db_ticker.roe()\n", "display(roe)\n", "\n", "print(\"\\n๐Ÿ“Œ RETURN ON INVESTED CAPITAL (ROIC):\")\n", "roic = db_ticker.roic()\n", "display(roic)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ WEIGHTED AVERAGE COST OF CAPITAL (WACC):\n", " Columns: ['symbol', 'report_date', 'market_capitalization', 'exchange_rate', 'total_debt', 'total_debt_usd', 'interest_expense', 'interest_expense_usd', 'pretax_income', 'pretax_income_usd', 'tax_provision', 'tax_provision_usd', 'tax_rate_for_calcs', 'sp500_cagr_end', 'sp500_10y_cagr', 'treasure_10y_yield', 'beta_5y', 'weight_of_debt', 'weight_of_equity', 'cost_of_debt', 'cost_of_equity', 'wacc']\n", "\n", " Latest calculation components:\n", " Market Cap: $3967.28B\n", " Beta (5Y): 1.0636\n", " S&P 500 10Y CAGR: 12.87%\n", " Treasury 10Y Yield: 4.26%\n", " Weight of Debt: 0.0272\n", " Weight of Equity: 0.9728\n", " Cost of Debt: 0.0090\n", " Cost of Equity: 0.1342\n", "\n", " โญ WACC: 0.1308 (13.08%\n" ] } ], "source": [ "# WACC - Weighted Average Cost of Capital\n", "print(\"\\n๐Ÿ“Œ WEIGHTED AVERAGE COST OF CAPITAL (WACC):\")\n", "wacc = db_ticker.wacc()\n", "print(f\" Columns: {list(wacc.columns)}\")\n", "print(f\"\\n Latest calculation components:\")\n", "latest_wacc = wacc.iloc[-1]\n", "print(f\" Market Cap: ${float(latest_wacc['market_capitalization'])/1e9:.2f}B\")\n", "print(f\" Beta (5Y): {float(latest_wacc['beta_5y']):.4f}\")\n", "print(f\" S&P 500 10Y CAGR: {float(latest_wacc['sp500_10y_cagr']):.2%}\")\n", "print(f\" Treasury 10Y Yield: {float(latest_wacc['treasure_10y_yield']):.2%}\")\n", "print(f\" Weight of Debt: {float(latest_wacc['weight_of_debt']):.4f}\")\n", "print(f\" Weight of Equity: {float(latest_wacc['weight_of_equity']):.4f}\")\n", "print(f\" Cost of Debt: {float(latest_wacc['cost_of_debt']):.4f}\")\n", "print(f\" Cost of Equity: {float(latest_wacc['cost_of_equity']):.4f}\")\n", "print(f\"\\n โญ WACC: {float(latest_wacc['wacc']):.4f} ({float(latest_wacc['wacc']):.2%}\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ“Š 6. GROWTH & MARGIN METRICS" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "GROWTH & MARGIN METRICS\n", "============================================================\n", "\n", "๐Ÿ“Œ QUARTERLY REVENUE YoY GROWTH:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_daterevenueprev_year_revenueyoy_growth
5NVDA2024-04-302.604400e+10NaNNaN
6NVDA2024-07-313.004000e+101.350700e+101.2240
7NVDA2024-10-313.508200e+101.812000e+100.9361
8NVDA2025-01-313.933100e+102.210300e+100.7794
9NVDA2025-04-304.406200e+102.604400e+100.6918
10NVDA2025-07-314.674300e+103.004000e+100.5560
11NVDA2025-10-315.700600e+103.508200e+100.6249
12NVDA2026-01-316.812700e+103.933100e+100.7321
\n", "
" ], "text/plain": [ " symbol report_date revenue prev_year_revenue yoy_growth\n", "5 NVDA 2024-04-30 2.604400e+10 NaN NaN\n", "6 NVDA 2024-07-31 3.004000e+10 1.350700e+10 1.2240\n", "7 NVDA 2024-10-31 3.508200e+10 1.812000e+10 0.9361\n", "8 NVDA 2025-01-31 3.933100e+10 2.210300e+10 0.7794\n", "9 NVDA 2025-04-30 4.406200e+10 2.604400e+10 0.6918\n", "10 NVDA 2025-07-31 4.674300e+10 3.004000e+10 0.5560\n", "11 NVDA 2025-10-31 5.700600e+10 3.508200e+10 0.6249\n", "12 NVDA 2026-01-31 6.812700e+10 3.933100e+10 0.7321" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ QUARTERLY EPS YoY GROWTH:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_dateepsprev_year_epsyoy_growth
101NVDA2024-04-300.600.086.5000
102NVDA2024-07-310.670.251.6800
103NVDA2024-10-310.780.371.1081
104NVDA2025-01-310.890.490.8163
105NVDA2025-04-300.760.600.2667
106NVDA2025-07-311.080.670.6119
107NVDA2025-10-311.300.780.6667
108NVDA2026-01-311.760.890.9775
\n", "
" ], "text/plain": [ " symbol report_date eps prev_year_eps yoy_growth\n", "101 NVDA 2024-04-30 0.60 0.08 6.5000\n", "102 NVDA 2024-07-31 0.67 0.25 1.6800\n", "103 NVDA 2024-10-31 0.78 0.37 1.1081\n", "104 NVDA 2025-01-31 0.89 0.49 0.8163\n", "105 NVDA 2025-04-30 0.76 0.60 0.2667\n", "106 NVDA 2025-07-31 1.08 0.67 0.6119\n", "107 NVDA 2025-10-31 1.30 0.78 0.6667\n", "108 NVDA 2026-01-31 1.76 0.89 0.9775" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Explore growth metrics\n", "symbol = 'NVDA'\n", "db_ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"GROWTH & MARGIN METRICS\")\n", "print(\"=\" * 60)\n", "\n", "print(\"\\n๐Ÿ“Œ QUARTERLY REVENUE YoY GROWTH:\")\n", "rev_growth = db_ticker.quarterly_revenue_yoy_growth()\n", "display(rev_growth.tail(8))\n", "\n", "print(\"\\n๐Ÿ“Œ QUARTERLY EPS YoY GROWTH:\")\n", "eps_growth = db_ticker.quarterly_eps_yoy_growth()\n", "display(eps_growth.tail(8))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ QUARTERLY GROSS MARGIN:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_dategross_profittotal_revenuegross_margin
11NVDA2025-01-312.872300e+103.933100e+100.7303
12NVDA2025-04-302.666800e+104.406200e+100.6052
13NVDA2025-07-313.385300e+104.674300e+100.7242
14NVDA2025-10-314.184900e+105.700600e+100.7341
15NVDA2026-01-315.109300e+106.812700e+100.7500
\n", "
" ], "text/plain": [ " symbol report_date gross_profit total_revenue gross_margin\n", "11 NVDA 2025-01-31 2.872300e+10 3.933100e+10 0.7303\n", "12 NVDA 2025-04-30 2.666800e+10 4.406200e+10 0.6052\n", "13 NVDA 2025-07-31 3.385300e+10 4.674300e+10 0.7242\n", "14 NVDA 2025-10-31 4.184900e+10 5.700600e+10 0.7341\n", "15 NVDA 2026-01-31 5.109300e+10 6.812700e+10 0.7500" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ QUARTERLY NET MARGIN:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_datenet_income_common_stockholderstotal_revenuenet_margin
11NVDA2025-01-312.209100e+103.933100e+100.5617
12NVDA2025-04-301.877500e+104.406200e+100.4261
13NVDA2025-07-312.642200e+104.674300e+100.5653
14NVDA2025-10-313.191000e+105.700600e+100.5598
15NVDA2026-01-314.296000e+106.812700e+100.6306
\n", "
" ], "text/plain": [ " symbol report_date net_income_common_stockholders total_revenue \\\n", "11 NVDA 2025-01-31 2.209100e+10 3.933100e+10 \n", "12 NVDA 2025-04-30 1.877500e+10 4.406200e+10 \n", "13 NVDA 2025-07-31 2.642200e+10 4.674300e+10 \n", "14 NVDA 2025-10-31 3.191000e+10 5.700600e+10 \n", "15 NVDA 2026-01-31 4.296000e+10 6.812700e+10 \n", "\n", " net_margin \n", "11 0.5617 \n", "12 0.4261 \n", "13 0.5653 \n", "14 0.5598 \n", "15 0.6306 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Margin metrics\n", "print(\"\\n๐Ÿ“Œ QUARTERLY GROSS MARGIN:\")\n", "gross_margin = db_ticker.quarterly_gross_margin()\n", "display(gross_margin.tail(5))\n", "\n", "print(\"\\n๐Ÿ“Œ QUARTERLY NET MARGIN:\")\n", "net_margin = db_ticker.quarterly_net_margin()\n", "display(net_margin.tail(5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐ŸŽฏ 7. UNIQUE FEATURES: EARNINGS TRANSCRIPTS" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "EARNINGS CALL TRANSCRIPTS (Unique to DefeatBeta!)\n", "============================================================\n", "\n", "๐Ÿ“Œ Available transcripts: 82 quarters\n", " From FY2005 Q4 to FY2026 Q1\n", "\n", "๐Ÿ“Œ MOST RECENT TRANSCRIPTS:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fiscal_yearfiscal_quarterreport_date
77202512025-01-30
78202522025-05-01
79202532025-07-31
80202542025-10-30
81202612026-01-29
\n", "
" ], "text/plain": [ " fiscal_year fiscal_quarter report_date\n", "77 2025 1 2025-01-30\n", "78 2025 2 2025-05-01\n", "79 2025 3 2025-07-31\n", "80 2025 4 2025-10-30\n", "81 2026 1 2026-01-29" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Access earnings call transcripts\n", "symbol = 'AAPL'\n", "db_ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"EARNINGS CALL TRANSCRIPTS (Unique to DefeatBeta!)\")\n", "print(\"=\" * 60)\n", "\n", "transcripts = db_ticker.earning_call_transcripts()\n", "transcript_list = transcripts.get_transcripts_list()\n", "\n", "print(f\"\\n๐Ÿ“Œ Available transcripts: {len(transcript_list)} quarters\")\n", "print(f\" From FY{transcript_list.iloc[0]['fiscal_year']} Q{transcript_list.iloc[0]['fiscal_quarter']} to FY{transcript_list.iloc[-1]['fiscal_year']} Q{transcript_list.iloc[-1]['fiscal_quarter']}\")\n", "\n", "print(\"\\n๐Ÿ“Œ MOST RECENT TRANSCRIPTS:\")\n", "display(transcript_list[['fiscal_year', 'fiscal_quarter', 'report_date']].tail(5))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ SAMPLE: Q4 2025 EARNINGS CALL\n", " Type: DataFrame\n", " Total paragraphs: 77\n", " Speakers: 15\n", "\n", " ๐Ÿ“ FIRST 3 PARAGRAPHS:\n", "\n", " [Suhasini Chandramouli]:\n", " Good afternoon, and welcome to the Apple Q4 Fiscal Year 2025 Earnings Conference Call. My name is Suhasini Chandramouli, Director of Investor Relation...\n", "\n", " [Timothy Cook]:\n", " Thank you, Suhasini. Good afternoon, everyone, and thanks for joining the call. Today, Apple is proud to report $102.5 billion in revenue, up 8% from ...\n", "\n", " [Kevan Parekh]:\n", " Thanks, Tim, and good afternoon, everyone. Our revenue of $102.5 billion was up 8% year-over-year and is a new September quarter record. We set some t...\n" ] } ], "source": [ "# Get a specific transcript\n", "print(\"\\n๐Ÿ“Œ SAMPLE: Q4 2025 EARNINGS CALL\")\n", "q4_2025 = transcripts.get_transcript(2025, 4)\n", "\n", "if q4_2025 is not None and len(q4_2025) > 0:\n", " print(f\" Type: {type(q4_2025).__name__}\")\n", " print(f\" Total paragraphs: {len(q4_2025)}\")\n", " print(f\" Speakers: {q4_2025['speaker'].nunique()}\")\n", " \n", " print(\"\\n ๐Ÿ“ FIRST 3 PARAGRAPHS:\")\n", " for idx, row in q4_2025.head(3).iterrows():\n", " speaker = row['speaker']\n", " content = row['content'][:150] + \"...\" if len(row['content']) > 150 else row['content']\n", " print(f\"\\n [{speaker}]:\")\n", " print(f\" {content}\")" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ AVAILABLE AI METHODS:\n", " โ€ข transcripts.analyze_financial_metrics_change_for_this_quarter_with_ai()\n", " โ€ข transcripts.analyze_financial_metrics_forecast_for_future_with_ai()\n", " โ€ข transcripts.summarize_key_financial_data_with_ai()\n", "\n", "โš ๏ธ NOTE: AI methods require OPENAI_API_KEY to be set in environment\n", " Set with: export OPENAI_API_KEY=your_key_here\n" ] } ], "source": [ "# AI-powered analysis (requires OpenAI API key)\n", "print(\"\\n๐Ÿ“Œ AVAILABLE AI METHODS:\")\n", "ai_methods = [m for m in dir(transcripts) if 'ai' in m.lower() or 'analyze' in m.lower()]\n", "for method in ai_methods:\n", " print(f\" โ€ข transcripts.{method}()\")\n", "\n", "print(\"\\nโš ๏ธ NOTE: AI methods require OPENAI_API_KEY to be set in environment\")\n", "print(\" Set with: export OPENAI_API_KEY=your_key_here\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐ŸŒ 8. REVENUE BREAKDOWN (Unique Feature!)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "REVENUE BREAKDOWN BY SEGMENT\n", "============================================================\n", "\n", "๐Ÿ“Œ Columns: ['symbol', 'report_date', 'Mac', 'Services', 'Wearables, Home and Accessories', 'iPad', 'iPhone']\n", "\n", "๐Ÿ“Œ Latest Quarter (2025-12-31):\n", " Mac: $8.39B\n", " Services: $30.01B\n", " Wearables, Home and Accessories: $11.49B\n", " iPad: $8.60B\n", " iPhone: $85.27B\n", "\n", " TOTAL: $143.76B\n" ] } ], "source": [ "# Revenue by segment - unique to DefeatBeta!\n", "symbol = 'AAPL'\n", "db_ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"REVENUE BREAKDOWN BY SEGMENT\")\n", "print(\"=\" * 60)\n", "\n", "revenue_segment = db_ticker.revenue_by_segment()\n", "print(f\"\\n๐Ÿ“Œ Columns: {list(revenue_segment.columns)}\")\n", "print(f\"\\n๐Ÿ“Œ Latest Quarter ({revenue_segment.iloc[-1]['report_date']}):\")\n", "\n", "latest = revenue_segment.iloc[-1]\n", "total = 0\n", "for col in revenue_segment.columns[2:]: # Skip symbol and report_date\n", " value = latest[col]\n", " if pd.notna(value):\n", " value = float(value) # Convert Decimal to float\n", " print(f\" {col}: ${value/1e9:.2f}B\")\n", " total += value\n", "print(f\"\\n TOTAL: ${total/1e9:.2f}B\")\n" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "๐Ÿ“Œ REVENUE BY GEOGRAPHY:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolreport_dateAmericasEuropeGreater ChinaJapanRest of Asia Pacific
20AAPL2025-06-304.119800e+102.401400e+101.536900e+105.782000e+097.673000e+09
21AAPL2025-09-304.419200e+102.870300e+101.449300e+106.636000e+098.442000e+09
22AAPL2025-12-315.852900e+103.814600e+102.552600e+109.413000e+091.214200e+10
\n", "
" ], "text/plain": [ " symbol report_date Americas Europe Greater China \\\n", "20 AAPL 2025-06-30 4.119800e+10 2.401400e+10 1.536900e+10 \n", "21 AAPL 2025-09-30 4.419200e+10 2.870300e+10 1.449300e+10 \n", "22 AAPL 2025-12-31 5.852900e+10 3.814600e+10 2.552600e+10 \n", "\n", " Japan Rest of Asia Pacific \n", "20 5.782000e+09 7.673000e+09 \n", "21 6.636000e+09 8.442000e+09 \n", "22 9.413000e+09 1.214200e+10 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Revenue by geography\n", "print(\"\\n๐Ÿ“Œ REVENUE BY GEOGRAPHY:\")\n", "revenue_geo = db_ticker.revenue_by_geography()\n", "display(revenue_geo.tail(3))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ“‹ 9. DCF VALUATION (Automated!)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "AUTOMATED DCF VALUATION\n", "============================================================\n", "\n", "๐Ÿ“Œ Running DCF analysis...\n" ] }, { "data": { "text/html": [ "\n", " \n", "
\n", " \n", " โฌ‡๏ธ Download AAPL DCF.xlsx\n", " \n", "
\n", "
\n", "
\n", "
\n", "
\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " Return type: dict\n", " Keys: ['file_path', 'description']\n", " Description: DCF Valuation Analysis for AAPL\n", " Excel file: AAPL.xlsx\n", "\n", "โš ๏ธ NOTE: DCF generates a professional Excel spreadsheet with:\n", " โ€ข WACC calculations\n", " โ€ข 10-year cash flow projections\n", " โ€ข Enterprise value and fair price\n", " โ€ข Buy/Sell recommendations\n" ] } ], "source": [ "# Automated DCF Valuation\n", "symbol = 'AAPL'\n", "db_ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"AUTOMATED DCF VALUATION\")\n", "print(\"=\" * 60)\n", "\n", "print(\"\\n๐Ÿ“Œ Running DCF analysis...\")\n", "dcf_result = db_ticker.dcf()\n", "\n", "print(f\"\\n Return type: {type(dcf_result).__name__}\")\n", "if isinstance(dcf_result, dict):\n", " print(f\" Keys: {list(dcf_result.keys())}\")\n", " print(f\" Description: {dcf_result.get('description', 'N/A')}\")\n", " if 'file_path' in dcf_result:\n", " print(f\" Excel file: {dcf_result['file_path']}\")\n", "\n", "print(\"\\nโš ๏ธ NOTE: DCF generates a professional Excel spreadsheet with:\")\n", "print(\" โ€ข WACC calculations\")\n", "print(\" โ€ข 10-year cash flow projections\")\n", "print(\" โ€ข Enterprise value and fair price\")\n", "print(\" โ€ข Buy/Sell recommendations\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ” 10. EXPLORE YOUR OWN STOCK" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "EXPLORING: GOOGL\n", "============================================================\n", "\n", "๐Ÿ“Œ CURRENT PRICE DATA:\n", " Latest Close: $341.68\n", " Date: 2026-04-17\n", " Volume: 25,519,000\n", "\n", "๐Ÿ“Œ VALUATION:\n", " TTM P/E: 31.61\n", " Market Cap: $4133.30B\n", "\n", "๐Ÿ“Œ PROFITABILITY:\n", " ROE: 8.59%\n", " WACC: 13.93%\n", "\n", "๐Ÿ“Œ GROWTH:\n", " Revenue YoY Growth: 18.00%\n" ] } ], "source": [ "# Interactive stock analysis - change the symbol!\n", "SYMBOL = 'GOOGL' # โฌ…๏ธ CHANGE THIS TO ANY STOCK SYMBOL\n", "\n", "print(\"=\" * 60)\n", "print(f\"EXPLORING: {SYMBOL}\")\n", "print(\"=\" * 60)\n", "\n", "ticker = Ticker(SYMBOL)\n", "\n", "# Basic stats\n", "price_data = ticker.price()\n", "latest = price_data.iloc[-1]\n", "\n", "print(f\"\\n๐Ÿ“Œ CURRENT PRICE DATA:\")\n", "print(f\" Latest Close: ${float(latest['close']):.2f}\")\n", "print(f\" Date: {latest['report_date']}\")\n", "print(f\" Volume: {int(latest['volume']):,}\")\n", "\n", "# Valuation\n", "ttm_pe = ticker.ttm_pe()\n", "if not ttm_pe.empty:\n", " print(f\"\\n๐Ÿ“Œ VALUATION:\")\n", " print(f\" TTM P/E: {float(ttm_pe.iloc[-1]['ttm_pe']):.2f}\")\n", "\n", "market_cap = ticker.market_capitalization()\n", "if not market_cap.empty:\n", " mcap = float(market_cap.iloc[-1]['market_capitalization'])\n", " print(f\" Market Cap: ${mcap/1e9:.2f}B\")\n", "\n", "# Ratios\n", "roe = ticker.roe()\n", "if not roe.empty:\n", " print(f\"\\n๐Ÿ“Œ PROFITABILITY:\")\n", " print(f\" ROE: {float(roe.iloc[-1]['roe']):.2%}\")\n", "\n", "wacc = ticker.wacc()\n", "if not wacc.empty:\n", " print(f\" WACC: {float(wacc.iloc[-1]['wacc']):.2%}\")\n", "\n", "# Growth\n", "growth = ticker.quarterly_revenue_yoy_growth()\n", "if not growth.empty:\n", " print(f\"\\n๐Ÿ“Œ GROWTH:\")\n", " print(f\" Revenue YoY Growth: {float(growth.iloc[-1]['yoy_growth']):.2%}\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿงช 11. STOCK COMPARISON" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "STOCK COMPARISON\n", "============================================================\n", "\n", "๐Ÿ“Œ COMPARISON TABLE:\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PriceP/EMarket CapROERev GrowthGross Margin
Symbol
AAPL270.2334.21$3967.3B52.0%15.7%48.2%
MSFT422.7926.46$3139.5B10.2%16.7%68.0%
GOOGL341.6831.61$4133.3B8.6%18.0%59.8%
NVDA201.6841.16$4900.8B31.1%73.2%75.0%
\n", "
" ], "text/plain": [ " Price P/E Market Cap ROE Rev Growth Gross Margin\n", "Symbol \n", "AAPL 270.23 34.21 $3967.3B 52.0% 15.7% 48.2%\n", "MSFT 422.79 26.46 $3139.5B 10.2% 16.7% 68.0%\n", "GOOGL 341.68 31.61 $4133.3B 8.6% 18.0% 59.8%\n", "NVDA 201.68 41.16 $4900.8B 31.1% 73.2% 75.0%" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Compare multiple stocks\n", "stocks = ['AAPL', 'MSFT', 'GOOGL', 'NVDA'] # โฌ…๏ธ CHANGE THESE\n", "\n", "print(\"=\" * 60)\n", "print(\"STOCK COMPARISON\")\n", "print(\"=\" * 60)\n", "\n", "comparison_data = []\n", "\n", "for symbol in stocks:\n", " try:\n", " ticker = Ticker(symbol)\n", " \n", " metrics = {'Symbol': symbol}\n", " \n", " # Price\n", " price = ticker.price()\n", " if not price.empty:\n", " metrics['Price'] = float(price.iloc[-1]['close'])\n", " \n", " # Valuation\n", " ttm_pe = ticker.ttm_pe()\n", " if not ttm_pe.empty:\n", " metrics['P/E'] = float(ttm_pe.iloc[-1]['ttm_pe'])\n", " \n", " market_cap = ticker.market_capitalization()\n", " if not market_cap.empty:\n", " metrics['Market Cap'] = float(market_cap.iloc[-1]['market_capitalization'])\n", " \n", " # Profitability\n", " roe = ticker.roe()\n", " if not roe.empty:\n", " metrics['ROE'] = float(roe.iloc[-1]['roe'])\n", " \n", " # Growth\n", " growth = ticker.quarterly_revenue_yoy_growth()\n", " if not growth.empty:\n", " metrics['Rev Growth'] = float(growth.iloc[-1]['yoy_growth'])\n", " \n", " # Margins\n", " gross_margin = ticker.quarterly_gross_margin()\n", " if not gross_margin.empty:\n", " metrics['Gross Margin'] = float(gross_margin.iloc[-1]['gross_margin'])\n", " \n", " comparison_data.append(metrics)\n", " \n", " except Exception as e:\n", " print(f\"โš ๏ธ Error loading {symbol}: {e}\")\n", "\n", "df = pd.DataFrame(comparison_data)\n", "df.set_index('Symbol', inplace=True)\n", "\n", "# Format Market Cap in billions\n", "df['Market Cap'] = df['Market Cap'].apply(lambda x: f\"${x/1e9:.1f}B\" if pd.notna(x) else 'N/A')\n", "df['Rev Growth'] = df['Rev Growth'].apply(lambda x: f\"{x:.1%}\" if pd.notna(x) else 'N/A')\n", "df['Gross Margin'] = df['Gross Margin'].apply(lambda x: f\"{x:.1%}\" if pd.notna(x) else 'N/A')\n", "df['ROE'] = df['ROE'].apply(lambda x: f\"{x:.1%}\" if pd.notna(x) else 'N/A')\n", "\n", "print(\"\\n๐Ÿ“Œ COMPARISON TABLE:\")\n", "display(df)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ“š 12. COMPLETE METHOD REFERENCE" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "============================================================\n", "COMPLETE API METHOD REFERENCE\n", "============================================================\n", "\n", "๐Ÿ’น Price & Volume:\n", " โ€ข ticker.price()\n", "\n", "๐Ÿ“Š Valuation:\n", " โ€ข ticker.market_capitalization()\n", " โ€ข ticker.pb_ratio()\n", " โ€ข ticker.peg_ratio()\n", " โ€ข ticker.ps_ratio()\n", " โ€ข ticker.ttm_eps()\n", " โ€ข ticker.ttm_pe()\n", "\n", "๐Ÿ“ˆ Financial Ratios:\n", " โ€ข ticker.asset_turnover()\n", " โ€ข ticker.beta()\n", " โ€ข ticker.equity_multiplier()\n", " โ€ข ticker.roa()\n", " โ€ข ticker.roe()\n", " โ€ข ticker.roic()\n", " โ€ข ticker.wacc()\n", "\n", "๐Ÿ“‹ Income Statement:\n", " โ€ข ticker.annual_income_statement()\n", " โ€ข ticker.quarterly_income_statement()\n", "\n", "โš–๏ธ Balance Sheet:\n", " โ€ข ticker.annual_balance_sheet()\n", " โ€ข ticker.quarterly_balance_sheet()\n", "\n", "๐Ÿ’ต Cash Flow:\n", " โ€ข ticker.annual_cash_flow()\n", " โ€ข ticker.quarterly_cash_flow()\n", "\n", "๐Ÿ“‰ Growth Metrics:\n", " โ€ข ticker.annual_ebitda_yoy_growth()\n", " โ€ข ticker.annual_fcf_yoy_growth()\n", " โ€ข ticker.annual_net_income_yoy_growth()\n", " โ€ข ticker.annual_operating_income_yoy_growth()\n", " โ€ข ticker.annual_revenue_yoy_growth()\n", " โ€ข ticker.quarterly_ebitda_yoy_growth()\n", " โ€ข ticker.quarterly_eps_yoy_growth()\n", " โ€ข ticker.quarterly_fcf_yoy_growth()\n", " โ€ข ticker.quarterly_net_income_yoy_growth()\n", " โ€ข ticker.quarterly_operating_income_yoy_growth()\n", " โ€ข ticker.quarterly_revenue_yoy_growth()\n", " โ€ข ticker.quarterly_ttm_eps_yoy_growth()\n", "\n", "๐Ÿ“Š Margin Metrics:\n", " โ€ข ticker.annual_ebitda_margin()\n", " โ€ข ticker.annual_fcf_margin()\n", " โ€ข ticker.annual_gross_margin()\n", " โ€ข ticker.annual_net_margin()\n", " โ€ข ticker.annual_operating_margin()\n", " โ€ข ticker.quarterly_ebitda_margin()\n", " โ€ข ticker.quarterly_fcf_margin()\n", " โ€ข ticker.quarterly_gross_margin()\n", " โ€ข ticker.quarterly_net_margin()\n", " โ€ข ticker.quarterly_operating_margin()\n", "\n", "๐ŸŽ™๏ธ Special Data:\n", " โ€ข ticker.dividends()\n", " โ€ข ticker.earning_call_transcripts()\n", " โ€ข ticker.news()\n", " โ€ข ticker.sec_filing()\n", " โ€ข ticker.splits()\n", "\n", "๐ŸŒ Revenue Breakdown:\n", " โ€ข ticker.revenue_by_geography()\n", " โ€ข ticker.revenue_by_product()\n", " โ€ข ticker.revenue_by_segment()\n", "\n", "๐Ÿญ Industry Metrics:\n", " โ€ข ticker.industry_asset_turnover()\n", " โ€ข ticker.industry_equity_multiplier()\n", " โ€ข ticker.industry_pb_ratio()\n", " โ€ข ticker.industry_ps_ratio()\n", " โ€ข ticker.industry_quarterly_ebitda_margin()\n", " โ€ข ticker.industry_quarterly_gross_margin()\n", " โ€ข ticker.industry_quarterly_net_margin()\n", " โ€ข ticker.industry_roa()\n", " โ€ข ticker.industry_roe()\n", " โ€ข ticker.industry_ttm_pe()\n", "\n", "โ„น๏ธ Info & Calendar:\n", " โ€ข ticker.calendar()\n", " โ€ข ticker.currency()\n", " โ€ข ticker.info()\n", " โ€ข ticker.officers()\n", " โ€ข ticker.shares()\n" ] } ], "source": [ "# List all available methods\n", "symbol = 'AAPL'\n", "ticker = Ticker(symbol)\n", "\n", "print(\"=\" * 60)\n", "print(\"COMPLETE API METHOD REFERENCE\")\n", "print(\"=\" * 60)\n", "\n", "all_methods = [m for m in dir(ticker) if not m.startswith('_')]\n", "\n", "categories = {\n", " '๐Ÿ’น Price & Volume': ['price'],\n", " '๐Ÿ“Š Valuation': ['ttm_eps', 'ttm_pe', 'market_capitalization', 'ps_ratio', 'pb_ratio', 'peg_ratio'],\n", " '๐Ÿ“ˆ Financial Ratios': ['roe', 'roic', 'roa', 'wacc', 'beta', 'equity_multiplier', 'asset_turnover'],\n", " '๐Ÿ“‹ Income Statement': ['quarterly_income_statement', 'annual_income_statement'],\n", " 'โš–๏ธ Balance Sheet': ['quarterly_balance_sheet', 'annual_balance_sheet'],\n", " '๐Ÿ’ต Cash Flow': ['quarterly_cash_flow', 'annual_cash_flow'],\n", " '๐Ÿ“‰ Growth Metrics': [m for m in all_methods if 'yoy_growth' in m.lower()],\n", " '๐Ÿ“Š Margin Metrics': [m for m in all_methods if 'margin' in m.lower() and 'industry' not in m.lower()],\n", " '๐ŸŽ™๏ธ Special Data': ['earning_call_transcripts', 'news', 'sec_filing', 'dividends', 'splits'],\n", " '๐ŸŒ Revenue Breakdown': ['revenue_by_segment', 'revenue_by_product', 'revenue_by_geography'],\n", " '๐Ÿญ Industry Metrics': [m for m in all_methods if 'industry' in m.lower()],\n", " 'โ„น๏ธ Info & Calendar': ['info', 'calendar', 'currency', 'shares', 'officers']\n", "}\n", "\n", "for category, methods in categories.items():\n", " matching = [m for m in methods if m in all_methods]\n", " if matching:\n", " print(f\"\\n{category}:\")\n", " for method in sorted(matching):\n", " print(f\" โ€ข ticker.{method}()\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐ŸŽ“ EXERCISES TO TRY" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 1: Find Undervalued Stocks\n", "Screen for stocks with P/E < 20 but ROE > 15%\n", "\n", "### Exercise 2: Growth Stock Analysis\n", "Compare NVDA vs AMD on revenue growth, margins, and profitability\n", "\n", "### Exercise 3: DCF Valuation\n", "Run DCF on 3 different stocks and compare their fair value estimates\n", "\n", "### Exercise 4: Revenue Mix Analysis\n", "Analyze how Apple's revenue mix has shifted from hardware to services\n", "\n", "### Exercise 5: Earnings Transcript Mining\n", "Extract key topics and sentiment from recent earnings calls" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## ๐Ÿ“– SUMMARY" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### DefeatBeta-API vs Yahoo Finance\n", "\n", "| Feature | DefeatBeta | Yahoo Finance |\n", "|---------|------------|---------------|\n", "| **Rate Limits** | โœ… None | โŒ Yes |\n", "| **Historical Data** | โœ… Full | โœ… Full |\n", "| **Financial Ratios** | โœ… Time series | โš ๏ธ Current only |\n", "| **Earnings Transcripts** | โœ… Yes | โŒ No |\n", "| **Revenue Segmentation** | โœ… Yes | โŒ No |\n", "| **DCF Valuation** | โœ… Automated | โŒ No |\n", "| **Real-time Data** | โŒ Daily batch | โœ… 15min delayed |\n", "| **Query Speed** | โšก Fast (DuckDB) | ๐Ÿข Variable |\n", "\n", "### When to Use Each\n", "- **DefeatBeta**: Historical analysis, financial modeling, backtesting, DCF\n", "- **Yahoo Finance**: Real-time data, analyst consensus, quick lookups" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "sym = \"AAPL\"\n", "dbt = Ticker(sym)" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['__class__',\n", " '__delattr__',\n", " '__dict__',\n", " '__dir__',\n", " '__doc__',\n", " '__eq__',\n", " '__format__',\n", " '__ge__',\n", " '__getattribute__',\n", " '__getstate__',\n", " '__gt__',\n", " '__hash__',\n", " '__init__',\n", " '__init_subclass__',\n", " '__le__',\n", " '__lt__',\n", " '__module__',\n", " '__ne__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__setattr__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " '__weakref__',\n", " '_add_dcf_template_section',\n", " '_add_dcf_value_section',\n", " '_add_discount_rate_section',\n", " '_add_growth_estimates_section',\n", " '_add_key_metrics_display',\n", " '_calculate_yoy_growth',\n", " '_dataframe_to_stock_statements',\n", " '_generate_margin',\n", " '_get_finance_values_map',\n", " '_quarterly_book_value_of_equity',\n", " '_quarterly_eps_yoy_growth',\n", " '_query_data',\n", " '_query_data2',\n", " '_revenue_by_breakdown',\n", " '_statement',\n", " 'annual_balance_sheet',\n", " 'annual_cash_flow',\n", " 'annual_ebitda_margin',\n", " 'annual_ebitda_yoy_growth',\n", " 'annual_fcf_margin',\n", " 'annual_fcf_yoy_growth',\n", " 'annual_gross_margin',\n", " 'annual_income_statement',\n", " 'annual_net_income_yoy_growth',\n", " 'annual_net_margin',\n", " 'annual_operating_income_yoy_growth',\n", " 'annual_operating_margin',\n", " 'annual_revenue_yoy_growth',\n", " 'asset_turnover',\n", " 'beta',\n", " 'calendar',\n", " 'company_meta',\n", " 'config',\n", " 'currency',\n", " 'dcf',\n", " 'dividends',\n", " 'download_data_performance',\n", " 'duckdb_client',\n", " 'earning_call_transcripts',\n", " 'equity_multiplier',\n", " 'http_proxy',\n", " 'huggingface_client',\n", " 'industry_asset_turnover',\n", " 'industry_equity_multiplier',\n", " 'industry_pb_ratio',\n", " 'industry_ps_ratio',\n", " 'industry_quarterly_ebitda_margin',\n", " 'industry_quarterly_gross_margin',\n", " 'industry_quarterly_net_margin',\n", " 'industry_roa',\n", " 'industry_roe',\n", " 'industry_ttm_pe',\n", " 'info',\n", " 'log_level',\n", " 'market_capitalization',\n", " 'news',\n", " 'officers',\n", " 'pb_ratio',\n", " 'peg_ratio',\n", " 'price',\n", " 'ps_ratio',\n", " 'quarterly_balance_sheet',\n", " 'quarterly_cash_flow',\n", " 'quarterly_ebitda_margin',\n", " 'quarterly_ebitda_yoy_growth',\n", " 'quarterly_eps_yoy_growth',\n", " 'quarterly_fcf_margin',\n", " 'quarterly_fcf_yoy_growth',\n", " 'quarterly_gross_margin',\n", " 'quarterly_income_statement',\n", " 'quarterly_net_income_yoy_growth',\n", " 'quarterly_net_margin',\n", " 'quarterly_operating_income_yoy_growth',\n", " 'quarterly_operating_margin',\n", " 'quarterly_revenue_yoy_growth',\n", " 'quarterly_ttm_eps_yoy_growth',\n", " 'revenue_by_geography',\n", " 'revenue_by_product',\n", " 'revenue_by_segment',\n", " 'roa',\n", " 'roe',\n", " 'roic',\n", " 'sec_filing',\n", " 'shares',\n", " 'splits',\n", " 'ticker',\n", " 'treasure',\n", " 'ttm_eps',\n", " 'ttm_fcf',\n", " 'ttm_net_income_common_stockholders',\n", " 'ttm_pe',\n", " 'ttm_revenue',\n", " 'wacc']" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir(dbt)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symboladdresscitycountryphonezipindustrysectorlong_business_summaryfull_time_employeesweb_sitereport_date
0AAPLOne Apple Park WayCupertinoUnited States(408) 996-101095014Consumer ElectronicsTechnologyApple Inc. designs, manufactures, and markets ...150000https://www.apple.com2026-04-18
\n", "
" ], "text/plain": [ " symbol address city country phone zip \\\n", "0 AAPL One Apple Park Way Cupertino United States (408) 996-1010 95014 \n", "\n", " industry sector \\\n", "0 Consumer Electronics Technology \n", "\n", " long_business_summary full_time_employees \\\n", "0 Apple Inc. designs, manufactures, and markets ... 150000 \n", "\n", " web_site report_date \n", "0 https://www.apple.com 2026-04-18 " ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dbt.info()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dbt" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "yft = yf.ticker.Ticker(sym)" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['__class__',\n", " '__delattr__',\n", " '__dict__',\n", " '__dir__',\n", " '__doc__',\n", " '__eq__',\n", " '__format__',\n", " '__ge__',\n", " '__getattribute__',\n", " '__getstate__',\n", " '__gt__',\n", " '__hash__',\n", " '__init__',\n", " '__init_subclass__',\n", " '__le__',\n", " '__lt__',\n", " '__module__',\n", " '__ne__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__setattr__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " '__weakref__',\n", " '_analysis',\n", " '_data',\n", " '_download_options',\n", " '_earnings',\n", " '_earnings_dates',\n", " '_expirations',\n", " '_fast_info',\n", " '_fetch_ticker_tz',\n", " '_financials',\n", " '_fundamentals',\n", " '_funds_data',\n", " '_get_earnings_dates_using_scrape',\n", " '_get_earnings_dates_using_screener',\n", " '_get_ticker_tz',\n", " '_holders',\n", " '_isin',\n", " '_lazy_load_price_history',\n", " '_message_handler',\n", " '_news',\n", " '_options2df',\n", " '_price_history',\n", " '_quote',\n", " '_shares',\n", " '_tz',\n", " '_underlying',\n", " 'actions',\n", " 'analyst_price_targets',\n", " 'balance_sheet',\n", " 'balancesheet',\n", " 'calendar',\n", " 'capital_gains',\n", " 'cash_flow',\n", " 'cashflow',\n", " 'dividends',\n", " 'earnings',\n", " 'earnings_dates',\n", " 'earnings_estimate',\n", " 'earnings_history',\n", " 'eps_revisions',\n", " 'eps_trend',\n", " 'fast_info',\n", " 'financials',\n", " 'funds_data',\n", " 'get_actions',\n", " 'get_analyst_price_targets',\n", " 'get_balance_sheet',\n", " 'get_balancesheet',\n", " 'get_calendar',\n", " 'get_capital_gains',\n", " 'get_cash_flow',\n", " 'get_cashflow',\n", " 'get_dividends',\n", " 'get_earnings',\n", " 'get_earnings_dates',\n", " 'get_earnings_estimate',\n", " 'get_earnings_history',\n", " 'get_eps_revisions',\n", " 'get_eps_trend',\n", " 'get_fast_info',\n", " 'get_financials',\n", " 'get_funds_data',\n", " 'get_growth_estimates',\n", " 'get_history_metadata',\n", " 'get_income_stmt',\n", " 'get_incomestmt',\n", " 'get_info',\n", " 'get_insider_purchases',\n", " 'get_insider_roster_holders',\n", " 'get_insider_transactions',\n", " 'get_institutional_holders',\n", " 'get_isin',\n", " 'get_major_holders',\n", " 'get_mutualfund_holders',\n", " 'get_news',\n", " 'get_recommendations',\n", " 'get_recommendations_summary',\n", " 'get_revenue_estimate',\n", " 'get_sec_filings',\n", " 'get_shares',\n", " 'get_shares_full',\n", " 'get_splits',\n", " 'get_sustainability',\n", " 'get_upgrades_downgrades',\n", " 'get_valuation_measures',\n", " 'growth_estimates',\n", " 'history',\n", " 'history_metadata',\n", " 'income_stmt',\n", " 'incomestmt',\n", " 'info',\n", " 'insider_purchases',\n", " 'insider_roster_holders',\n", " 'insider_transactions',\n", " 'institutional_holders',\n", " 'isin',\n", " 'live',\n", " 'major_holders',\n", " 'mutualfund_holders',\n", " 'news',\n", " 'option_chain',\n", " 'options',\n", " 'quarterly_balance_sheet',\n", " 'quarterly_balancesheet',\n", " 'quarterly_cash_flow',\n", " 'quarterly_cashflow',\n", " 'quarterly_earnings',\n", " 'quarterly_financials',\n", " 'quarterly_income_stmt',\n", " 'quarterly_incomestmt',\n", " 'recommendations',\n", " 'recommendations_summary',\n", " 'revenue_estimate',\n", " 'sec_filings',\n", " 'session',\n", " 'shares',\n", " 'splits',\n", " 'sustainability',\n", " 'ticker',\n", " 'ttm_cash_flow',\n", " 'ttm_cashflow',\n", " 'ttm_financials',\n", " 'ttm_income_stmt',\n", " 'ttm_incomestmt',\n", " 'upgrades_downgrades',\n", " 'valuation',\n", " 'ws']" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir(yft)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.12" } }, "nbformat": 4, "nbformat_minor": 4 }