MCPcopy Index your code
hub / github.com/defeat-beta/defeatbeta-api

github.com/defeat-beta/defeatbeta-api @release-0.0.60

Chat with this repo
repository ↗ · DeepWiki ↗ · release release-0.0.60 ↗ · + Follow
622 symbols 2,477 edges 83 files 176 documented · 28%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Defeat Beta API

Python version PyPi version PyPi downloads Star this repo

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 JupyterLab.

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. Powered by DuckDB’s OLAP engine and the cache_httpfs extension, the system delivers sub-second analytical queries with full SQL compatibility, giving you a unified, high-performance workflow for large-scale financial data.

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

$ pip install defeatbeta-api

Windows

⚠️ Requires WSL/Docker Due to dependencies on cache_httpfs (unsupported on Windows):

Option 1: WSL (Recommended) 1. Install WSL 2. In WSL terminal:

$ pip install defeatbeta-api

Option 2: Docker 1. Install Docker Desktop 2. Run in Linux container:

docker run -it python:latest pip install defeatbeta-api

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]

Example: Accessing Financial Statements

statement = ticker.quarterly_income_statement()
print(statement.print_pretty_table())

```text

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-Controlling Interests | 7,153,000 | 2,332,000 | 2,183,000 | 1,494,000 | 1,144,000 | 7,943,000 | 1,878,000 | 2,614,000 | * | * | * | 2,269,000 | | Net Income Continuous Operations | 7,153,000 | 2,332,000 | 2,183,000 | 1,494,000 | 1,144,000 | 7,943,000 | 1,878,000 | 2,614,000 | * | * | * | 2,269,000 | | Minority Interests | -23,000 | 24,000 | -16,000 | -16,000 | -15,000 | -13,000 | -25,000 | 89,000 | * | * | * | -10,000 | | Otherunder Preferred Stock Dividend | * | * | 0 | * | -42,000 | * | 2,000 | 0 | -5,000 | * | 0 | 3,000 | | Adjustments for Dilutive Securities | 0 | * | * | * | * | 0 | 0 | 0 | * | 0 | 0 | 0 | | Diluted NI Available to Com 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 | | Basic EPS | 3.41 | * | 0.68 | 0.46 | 0.37 | 2.49 | 0.58 | 0.85 | * | * | * | 0.73 | | Diluted EPS | 3.1 | * | 0.62 | 0.42 | 0.34 | 2.27 | 0.53 | 0.78 | * | * | * | 0.65 | | Basic Average Shares | 3,168,250 | * | 3,198,000 | 3,191,000 | 3,186,000 | 3,181,000 | 3,176,000 | 3,171,000 | * | * | * | 3,111,000 | | Diluted Average Shares | 3,480,250 | * | 3,497,000 | 3,481,000 | 3,484,000 | 3,492,000 | 3,493,000 | 3,478,000 | * | * | * | 3,464,000 | | Total Operating Income as Reported | 7,076,000 | 1,583,000 | 2,717,000 | 1,605,000 | 1,171,000 | 2,064,000 | 1,764,000 | 2,399,000 | * | * | * | 2,464,000 | | Rent Expense Supplemental | 1,003,000 | 242,000 | 247,000 | 245,000 | 269,000 | 296,000 | 301,000 | 338,000 | * |

Core symbols most depended-on inside this repo

get
called by 193
skills/defeatbeta-dcf/scripts/build_dcf_excel.py
query
called by 64
defeatbeta_api/client/duckdb_client.py
create_ticker
called by 63
mcp/src/defeatbeta_mcp/tools/util.py
advance
called by 53
skills/defeatbeta-dcf/scripts/build_dcf_excel.py
get_url_path
called by 52
defeatbeta_api/client/hugging_face_client.py
load_sql
called by 49
defeatbeta_api/data/sql/sql_loader.py
_run_parallel_concat
called by 48
defeatbeta_api/data/tickers.py
get
called by 46
defeatbeta_api/utils/case_insensitive_dict.py

Shape

Method 443
Function 144
Class 35

Languages

Python100%

Modules by API surface

defeatbeta_api/data/ticker.py100 symbols
test/test_ticker.py73 symbols
defeatbeta_api/data/tickers.py73 symbols
test/test_tickers.py70 symbols
defeatbeta_api/utils/util.py31 symbols
skills/defeatbeta-dcf/scripts/build_dcf_excel.py21 symbols
test/test_industry.py14 symbols
mcp/src/defeatbeta_mcp/tools/margin.py13 symbols
defeatbeta_api/reports/tearsheet.py13 symbols
mcp/src/defeatbeta_mcp/tools/growth.py12 symbols
defeatbeta_api/client/duckdb_client.py12 symbols
defeatbeta_api/data/transcripts.py10 symbols

For agents

$ claude mcp add defeatbeta-api \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page