Defeat Beta API


An open-source alternative to Yahoo Finance’s market data APIs with higher reliability.
See the example guide for detailed usage instructions, and try it out directly in an interactive environment using
.
The list of changes can be found in the Changelog
Introduction
✅ High-Performance & Reliable Data Engine: Provides a stable, reproducible market data source fully hosted on Hugging Face’s yahoo-finance-data dataset—eliminating scraping issues and rate limits. DuckDB runs the queries, while DefeatBeta’s local file cache fetches only the Parquet and JSON ranges needed by each query.
✅ Extended Financial Data: Includes TTM EPS, TTM PE, Market Cap, PS Ratio, PB Ratio, PEG Ratio, ROE, ROIC, WACC, ROA, Equity Multiplier, Assert Turnover, SEC Filings, Earnings call transcripts, Stock News, Revenue by segment and Revenue by geography etc. (continuously expanding).
✅ Automated DCF Valuation: Generate comprehensive Discounted Cash Flow (DCF) analysis with professional Excel output. Automatically calculates WACC, projects 10-year cash flows, estimates enterprise value and fair price, and provides buy/sell recommendations—all in a ready-to-use, fully editable spreadsheet.
✅ LLM-Powered Analysis: Use Large Language Models (LLMs) to analyze earnings call transcripts, quarterly financial changes, and quarterly forecasts to extract key data, understand metric changes, and interpret forecast drivers.
✅ MCP Server implementation: A MCP server implementation for defeatbeta-api, provides AI access analysis through MCP. Click here to discover more ways to use MCP.
✅ Skills implementation: A Skills implementation for defeatbeta-api, enhances AI financial analysis capabilities with professional workflows. Compatible with Claude.ai, Manus, and other AI platforms that support skills.
Quickstart
Installation
Install defeatbeta-api from PYPI using pip:
MacOS / Linux / Windows
$ pip install defeatbeta-api
💡 Windows is supported natively since v0.0.60. The current dataset cache uses the same Python filesystem interface on Windows, macOS, and Linux.
Usage
Instantiate the Ticker class with a company’s ticker symbol. For example, to get Tesla, Inc. data:
import defeatbeta_api
from defeatbeta_api.data.ticker import Ticker
ticker = Ticker('TSLA')
The following examples demonstrate common API usage patterns (see more examples in this documentation):
Example: Fetching Stock Price Data
ticker.price()
>>> ticker.price()
symbol report_date open close high low volume
0 TSLA 2010-06-29 1.27 1.59 1.67 1.17 281494500
1 TSLA 2010-06-30 1.72 1.59 2.03 1.55 257806500
2 TSLA 2010-07-01 1.67 1.46 1.73 1.35 123282000
3 TSLA 2010-07-02 1.53 1.28 1.54 1.25 77097000
4 TSLA 2010-07-06 1.33 1.07 1.33 1.06 103003500
... ... ... ... ... ... ... ...
3716 TSLA 2025-04-07 223.78 233.29 252.00 214.25 183453800
3717 TSLA 2025-04-08 245.00 221.86 250.44 217.80 171603500
3718 TSLA 2025-04-09 224.69 272.20 274.69 223.88 219433400
3719 TSLA 2025-04-10 260.00 252.40 262.49 239.33 181722600
3720 TSLA 2025-04-11 251.84 252.31 257.74 241.36 128656900
[3721 rows x 7 columns]
Hong Kong daily prices use the same API and DataFrame columns. Symbols ending in
.HK read data/HK/stock_prices.parquet; existing US symbols read
data/US/stock_prices.parquet. Keep the leading zeros in Yahoo Finance symbols.
Ticker("0700.HK").price()
Ticker("2800.HK").price() # Hong Kong ETFs use the same price API.
from defeatbeta_api.data.tickers import Tickers
Tickers(["AAPL", "0700.HK", "2800.HK"]).price()
Price queries read the published price file directly, including instruments
outside the company metadata catalog. The MCP get_stock_price tool also accepts
.HK symbols with its existing date filters and row limit. This support covers
daily prices; cross-market beta and HK financial ratios require separate work.
Example: Accessing Financial Statements
statement = ticker.quarterly_income_statement()
print(statement.print_pretty_table())
>>> statement=ticker.quarterly_income_statement()
>>> statement.print_pretty_table()
|------------------------------------------------------------+------------+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------|
| Breakdown | TTM | 2024-12-31 | 2024-09-30 | 2024-06-30 | 2024-03-31 | 2023-12-31 | 2023-09-30 | 2023-06-30 | 2023-03-31 | 2022-12-31 | 2022-09-30 | 2022-06-30 |
|------------------------------------------------------------+------------+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------|
| +Total Revenue | 97,690,000 | 25,707,000 | 25,182,000 | 25,500,000 | 21,301,000 | 25,167,000 | 23,350,000 | 24,927,000 | * | * | * | 16,934,000 |
| Operating Revenue | 97,690,000 | 25,707,000 | 25,182,000 | 25,500,000 | 21,301,000 | 25,167,000 | 23,350,000 | 24,927,000 | * | * | * | 16,934,000 |
| Cost of Revenue | 80,240,000 | 21,528,000 | 20,185,000 | 20,922,000 | 17,605,000 | 20,729,000 | 19,172,000 | 20,394,000 | * | * | * | 12,700,000 |
| Gross Profit | 17,450,000 | 4,179,000 | 4,997,000 | 4,578,000 | 3,696,000 | 4,438,000 | 4,178,000 | 4,533,000 | * | * | * | 4,234,000 |
| +Operating Expense | 9,690,000 | 2,589,000 | 2,225,000 | 2,351,000 | 2,525,000 | 2,374,000 | 2,414,000 | 2,134,000 | * | * | * | 1,628,000 |
| Selling General and Administrative | 5,150,000 | 1,313,000 | 1,186,000 | 1,277,000 | 1,374,000 | 1,280,000 | 1,253,000 | 1,191,000 | * | * | * | 961,000 |
| Research & Development | 4,540,000 | 1,276,000 | 1,039,000 | 1,074,000 | 1,151,000 | 1,094,000 | 1,161,000 | 943,000 | * | * | * | 667,000 |
| Operating Income | 7,760,000 | 1,590,000 | 2,772,000 | 2,227,000 | 1,171,000 | 2,064,000 | 1,764,000 | 2,399,000 | * | * | * | 2,606,000 |
| +Net Non-Operating Interest Income Expense | 1,219,000 | 346,000 | 337,000 | 262,000 | 274,000 | 272,000 | 244,000 | 210,000 | * | * | * | -18,000 |
| Non-Operating Interest Income | 1,569,000 | 442,000 | 429,000 | 348,000 | 350,000 | 333,000 | 282,000 | 238,000 | * | * | * | 26,000 |
| Non-Operating Interest Expense | 350,000 | 96,000 | 92,000 | 86,000 | 76,000 | 61,000 | 38,000 | 28,000 | * | * | * | 44,000 |
| +Other Income Expense | 11,000 | 830,000 | -325,000 | -602,000 | 108,000 | -145,000 | 37,000 | 328,000 | * | * | * | -114,000 |
| +Special Income Charges | -684,000 | -7,000 | -55,000 | -622,000 | * | 0 | 0 | 0 | * | -34,000 | 0 | -142,000 |
| Restructuring & Mergers Acquisition | 684,000 | 7,000 | 55,000 | 622,000 | * | 0 | 0 | 0 | * | 34,000 | 0 | 142,000 |
| Other Non Operating Income Expenses | 695,000 | 837,000 | -270,000 | 20,000 | 108,000 | -145,000 | 37,000 | 328,000 | * | * | * | 28,000 |
| Pretax Income | 8,990,000 | 2,766,000 | 2,784,000 | 1,887,000 | 1,553,000 | 2,191,000 | 2,045,000 | 2,937,000 | * | * | * | 2,474,000 |
| Tax Provision | 1,837,000 | 434,000 | 601,000 | 393,000 | 409,000 | -5,752,000 | 167,000 | 323,000 | * | * | * | 205,000 |
| +Net Income Common Stockholders | 7,130,000 | 2,314,000 | 2,167,000 | 1,478,000 | 1,171,000 | 7,927,000 | 1,851,000 | 2,703,000 | * | * | * | 2,256,000 |
| +Net Income(Attributable to Parent Company Shareholders) | 7,130,000 | 2,356,000 | 2,167,000 | 1,478,000 | 1,129,000 | 7,930,000 | 1,853,000 | 2,703,000 | * | * | * | 2,259,000 |
| +Net Income Including Non-C
提示:代码过长已自动截断
Example: Accessing Earnings Call Transcripts
Fetching transcripts list
transcripts = ticker.earning_call_transcripts()
transcripts.get_transcripts_list()
>>> transcripts = ticker.earning_call_transcripts()
>>> transcripts.get_transcripts_list()
symbol fiscal_year fiscal_quarter report_date
0 TSLA 2011 2 2011-08-03
1 TSLA 2011 3 2011-11-03
2 TSLA 2011 4 2012-02-16
3 TSLA 2012 1 2012-05-09
4 TSLA 2012 2 2012-07-25
.. ... ... ... ...
55 TSLA 2025 1 2025-04-22
56 TSLA 2025 2 2025-07-23
57 TSLA 2025 3 2025-10-22
58 TSLA 2025 4 2026-01-28
59 TSLA 2026 1 2026-04-22
[60 rows x 4 columns]
Note: This call returns metadata only. Transcript paragraphs are fetched on demand via
get_transcript(fiscal_year, fiscal_quarter), which issues a server-side filtered query
(column-pruned + period-filtered) so listing the catalog is cheap regardless of how many
quarters are available.
Fetching the Q4 2024 Earnings Call Transcript
transcripts = ticker.earning_call_transcripts()
transcripts.get_transcript(2024, 4)
>>> transcripts.get_transcript(2024, 4)
paragraph_number speaker content
0 1 Operator Good afternoon, everyone and welcome to Tesla'...
1 2 Elon Musk Thank you. So, in summary, in Q4, we set a rec...
2 3 Travis Axelrod Great. Thank you very much, Elon. And, Vaibhav...
3 4 Vaibhav Taneja Yeah, I'll talk about things on Earth. As Elon...
4 5 Travis Axelrod Great. Thank you very much, Vaibhav. Now, we w...
.. ... ... ...
74 75 Vaibhav Taneja So, is your question, Dan, that how do we marr...
75 76 Travis Axelrod Go ahead and unmute yourself, Dan.
76 77 Dan Levy Yeah. More so just how much more aggressively ...
77 78 Elon Musk Well, right now, the constraint we're trying t...
78 79 Travis Axelrod Great. Alrighty. And with that, I think we are...
[79 rows x 3 columns]
transcripts = ticker.earning_call_transcripts()
transcripts.print_pretty_table(2024, 4)
>>> transcripts.print_pretty_table(2024, 4)
Earnings Call Transcripts FY2024 Q4 (Reported on 2025-01-29)
+--------------------+-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
提示:代码过长已自动截断
评论