### Install Datasets Packages Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Advanced_Usage.md Install the necessary packages for loading datasets from Hugging Face. Ensure `datasets`, `huggingface_hub`, and `pyarrow` are installed. ```bash pip install datasets huggingface_hub pyarrow ``` -------------------------------- ### Install Defeat Beta API MCP on macOS or Linux Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/mcp/README.md Run this one-line script to install the Defeat Beta API MCP server on macOS or Linux systems. This is an alternative to the uvx installation method. ```shell curl -sSL https://raw.githubusercontent.com/defeat-beta/defeatbeta-api/main/mcp/install | bash ``` -------------------------------- ### Install defeatbeta-api on Windows using Docker Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/README.md Install the defeatbeta-api package by running a Docker container with Python. This is an alternative for Windows users. ```bash docker run -it python:latest pip install defeatbeta-api ``` -------------------------------- ### Install defeatbeta-api Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Report_Examples.md Install the defeatbeta-api package using pip. This is a prerequisite for running the report generation locally. ```bash pip install defeatbeta-api ``` -------------------------------- ### Install defeatbeta-api on MacOS/Linux Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/README.md Use pip to install the defeatbeta-api package on MacOS or Linux systems. ```bash $ pip install defeatbeta-api ``` -------------------------------- ### Install httpx with SOCKS Support Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Advanced_Usage.md If using a SOCKS proxy, install `httpx` with SOCKS support to resolve potential `ImportError` issues. ```bash pip install "httpx[socks]" ``` -------------------------------- ### Industry Historical PB Ratio Data Example Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Value_Examples.md Example output of the industry PB ratio calculation, showing report date, industry, total BVE, and industry PB ratio. ```text report_date industry ... total_bve industry_pb_ratio 0 1994-11-30 Auto Manufacturers ... NaN NaN 1 1994-12-01 Auto Manufacturers ... NaN NaN 2 1994-12-02 Auto Manufacturers ... NaN NaN 3 1994-12-05 Auto Manufacturers ... NaN NaN 4 1994-12-06 Auto Manufacturers ... NaN NaN ... ... ... ... ... ... 7788 2025-11-10 Auto Manufacturers ... 6.133932e+11 3.45 7789 2025-11-11 Auto Manufacturers ... 6.133932e+11 3.44 7790 2025-11-12 Auto Manufacturers ... 6.133932e+11 3.39 7791 2025-11-13 Auto Manufacturers ... 6.133932e+11 3.22 7792 2025-11-14 Auto Manufacturers ... 6.133932e+11 3.22 [7793 rows x 5 columns] ``` -------------------------------- ### Industry Historical PS Ratio Data Example Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Value_Examples.md Example output of the industry PS ratio calculation, showing report date, industry, total TTM revenue, and industry PS ratio. ```text report_date industry ... total_ttm_revenue industry_ps_ratio 0 1994-11-30 Auto Manufacturers ... NaN NaN 1 1994-12-01 Auto Manufacturers ... NaN NaN 2 1994-12-02 Auto Manufacturers ... NaN NaN 3 1994-12-05 Auto Manufacturers ... NaN NaN 4 1994-12-06 Auto Manufacturers ... NaN NaN ... ... ... ... ... ... 7788 2025-11-10 Auto Manufacturers ... 1.026618e+12 2.06 7789 2025-11-11 Auto Manufacturers ... 1.026618e+12 2.05 7790 2025-11-12 Auto Manufacturers ... 1.026618e+12 2.02 7791 2025-11-13 Auto Manufacturers ... 1.026618e+12 1.92 7792 2025-11-14 Auto Manufacturers ... 1.026618e+12 1.92 [7793 rows x 5 columns] ``` -------------------------------- ### JSON Response Example with Date Formats Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Provides examples of date formats used in JSON responses, adhering to ISO 8601 (YYYY-MM-DD). ```json { "report_date": "2024-12-31", "period": "2024-12-31" } ``` -------------------------------- ### JSON Response Example with Currency Information Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Demonstrates the inclusion of currency information in financial data responses. ```json { "currency": "USD", # All amounts in US Dollars "statement": [] } ``` -------------------------------- ### Get Historical PB Ratio for All Tickers Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Retrieves historical Price-to-Book (PB) ratios for all tickers. ```python tickers.historical_pb_ratio() ``` -------------------------------- ### Example Output of get_transcript Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Info_Examples.md Displays the structure of the returned transcript data, which includes paragraph number, speaker, and content. This output is a pandas DataFrame. ```text >>> 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] ``` -------------------------------- ### Get Stock Information Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Info_Examples.md Retrieve detailed information about a specific stock. This includes company address, industry, business summary, and website. ```python ticker.info() ``` ```text >>> ticker.info() symbol address city country phone zip industry sector long_business_summary full_time_employees web_site report_date 0 TSLA 1 Tesla Road Austin United States 512 516 8177 78725 Auto Manufacturers Consumer Cyclical Tesla, Inc. designs, develops, manufactures, l... 125665 https://www.tesla.com 2025-04-12 ``` -------------------------------- ### Get Stock Officers Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Info_Examples.md Retrieves a list of stock officers for a given ticker symbol. The output includes their name, title, age, and compensation details. ```python ticker.officers() ``` ```text >>> ticker.officers() symbol name title age born pay exercised unexercised 0 TSLA Brian Scelfo Senior Director of Corporate Development 0 0 1 TSLA Mr. Elon R. Musk Co-Founder, Technoking of Tesla, CEO & Director 53 1971 0 0 2 TSLA Mr. Franz von Holzhausen Chief Designer 0 0 3 TSLA Mr. John Walker Vice President of Sales - North America 61 1963 121550 0 0 4 TSLA Mr. Peter Bannon Chip Architect 0 0 5 TSLA Mr. Rodney D. Westmoreland Jr. Director of Construction Management 0 0 6 TSLA Mr. Turner Caldwell Engineering Manager 0 0 7 TSLA Mr. Vaibhav Taneja Chief Financial Officer 46 1978 278000 8517957 202075632 8 TSLA Mr. Xiaotong Zhu Senior Vice President of Automotive 44 1980 926877 0 344144320 9 TSLA Travis Axelrod Head of Investor Relations 0 0 ``` -------------------------------- ### Instantiate Ticker Class Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/README.md Instantiate the Ticker class with a company's ticker symbol. For example, to get Tesla, Inc. data. ```python import defeatbeta_api from defeatbeta_api.data.ticker import Ticker ticker = Ticker('TSLA') ``` -------------------------------- ### Initialize DefeatBeta API with Configuration Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Advanced_Usage.md Import necessary classes and initialize a Ticker object with a default configuration. This is the starting point for using the API. ```python import defeatbeta_api from defeatbeta_api.client.duckdb_conf import Configuration from defeatbeta_api.data.ticker import Ticker ticker = Ticker("BABA", config=Configuration()) ``` -------------------------------- ### Get Quarterly Gross Margin Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves the quarterly gross margin for a stock. This is an example of the general structure for all margin APIs (gross, operating, net, EBITDA, FCF). ```jsonc { "symbol": "TSLA", "currency": "USD", "period_type": "quarterly", "periods": [...], "rows_returned": 20, "data": [ { "period": "2024-12-31", "gross_profit": 6531000000, "total_revenue": 25167000000, "gross_margin": 0.2595 # 25.95% } ] } ``` -------------------------------- ### Claude Desktop Project Instructions Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/README.md Configuration for a Claude Desktop project to integrate the defeatbeta-analyst skill and defeatbeta-api MCP tool. This allows for direct financial analysis queries without repeated setup. ```text Use the defeatbeta-analyst skill and the defeatbeta-api MCP tool for all financial analysis tasks. ``` -------------------------------- ### Batch Screening Example for DCF Valuations Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Screens multiple stocks for DCF valuations and prints their fair price, current price, and recommendation. ```python from defeatbeta_api import Ticker # Screen multiple stocks for DCF valuations symbols = ["AAPL", "MSFT", "GOOGL", "AMZN", "META"] for symbol in symbols: data = Ticker(symbol).dcf_data() dv = data["dcf_value"] print(f"{symbol}: Fair=${dv['fair_price']:.2f}, Current=${dv['current_price']:.2f}, {dv['recommendation']}") ``` -------------------------------- ### Pre-warm MCP Cache with uvx Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/mcp/README.md Run this command once to download and cache the MCP package locally. This is necessary to avoid initialization timeouts for MCP clients. ```shell uvx --refresh "git+https://github.com/defeat-beta/defeatbeta-api.git#subdirectory=mcp" ``` -------------------------------- ### Get Latest Data Update Date Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Call this function first to get the latest data update date. Use this date as 'today' for relative time queries. ```json { "latest_data_update_date": "2025-01-24" # YYYY-MM-DD format } ``` -------------------------------- ### Skill Packaging Structure Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/README.md Illustrates the required directory structure for packaging a DefeatBeta skill into a ZIP file for distribution. Ensure the skill folder is the root element within the ZIP archive. ```text defeatbeta-analyst.zip └── defeatbeta-analyst/ ├── SKILL.md # Main skill instructions └── references/ ├── analysis-templates.md # Workflow templates └── defeatbeta-api-reference.md # Complete API documentation ``` -------------------------------- ### GET /stock/valuation/enterprise-value Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves historical Enterprise Value (EV) for a stock. ```APIDOC ## GET /stock/valuation/enterprise-value ### Description Retrieves historical Enterprise Value (EV) for a stock. Returns a maximum of 1000 rows, with the most recent data if truncated. EV is calculated as Market Cap + Total Debt + Minority Interest + Preferred Stock Equity - Cash and Equivalents. ### Method GET ### Endpoint /stock/valuation/enterprise-value ### Parameters #### Query Parameters - **symbol** (str) - Required - The stock symbol (e.g., TSLA). - **start_date** (str) - Optional - The start date for the data range (YYYY-MM-DD). - **end_date** (str) - Optional - The end date for the data range (YYYY-MM-DD). ### Request Example ```json { "symbol": "TSLA", "start_date": "2020-01-01", "end_date": "2025-01-24" } ``` ### Response #### Success Response (200) - **symbol** (str) - The stock symbol. - **currency** (str) - The currency of the financial data. - **date_range** (str) - The date range for which the data is provided. - **rows_returned** (int) - Number of data rows returned. - **truncated** (bool) - Indicates if the results were truncated due to the row limit. - **data** (array) - Array of Enterprise Value data. - **report_date** (str) - The date of the report. - **fiscal_quarter** (str) - The fiscal quarter the data pertains to. - **market_capitalization** (float) - The market capitalization of the company. - **exchange_to_usd_rate** (float) - The exchange rate to USD. - **total_debt** (float) - Total debt of the company. - **total_debt_usd** (float) - Total debt in USD. - **minority_interest** (float) - Minority interest. - **minority_interest_usd** (float) - Minority interest in USD. - **preferred_stock_equity** (float) - Preferred stock equity. - **preferred_stock_equity_usd** (float) - Preferred stock equity in USD. - **cash_and_cash_equivalents** (float) - Cash and cash equivalents. - **cash_and_cash_equivalents_usd** (float) - Cash and cash equivalents in USD. - **enterprise_value** (float) - The calculated Enterprise Value. #### Response Example ```json { "symbol": "TSLA", "currency": "USD", "date_range": "2020-01-01 to 2025-01-24", "rows_returned": 1000, "truncated": true, "data": [ { "report_date": "2025-01-24", "fiscal_quarter": "2024-12-31", "market_capitalization": 750592000000, "exchange_to_usd_rate": 1.0, "total_debt": 12000000000, "total_debt_usd": 12000000000, "minority_interest": 0, "minority_interest_usd": 0, "preferred_stock_equity": 0, "preferred_stock_equity_usd": 0, "cash_and_cash_equivalents": 36600000000, "cash_and_cash_equivalents_usd": 36600000000, "enterprise_value": 725992000000 } ] } ``` ``` -------------------------------- ### GET /stock/valuation/pb-ratio Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves historical Price-to-Book (P/B) ratio for a stock. ```APIDOC ## GET /stock/valuation/pb-ratio ### Description Retrieves historical Price-to-Book (P/B) ratio for a stock. Returns a maximum of 1000 rows, with the most recent data if truncated. ### Method GET ### Endpoint /stock/valuation/pb-ratio ### Parameters #### Query Parameters - **symbol** (str) - Required - The stock symbol (e.g., TSLA). - **start_date** (str) - Optional - The start date for the data range (YYYY-MM-DD). - **end_date** (str) - Optional - The end date for the data range (YYYY-MM-DD). ### Request Example ```json { "symbol": "TSLA", "start_date": "2020-01-01", "end_date": "2025-01-24" } ``` ### Response #### Success Response (200) - **symbol** (str) - The stock symbol. - **currency** (str) - The currency of the financial data. - **date_range** (str) - The date range for which the data is provided. - **rows_returned** (int) - Number of data rows returned. - **truncated** (bool) - Indicates if the results were truncated due to the row limit. - **data** (array) - Array of P/B ratio data. - **report_date** (str) - The date of the report. - **fiscal_quarter** (str) - The fiscal quarter the data pertains to. - **market_capitalization** (float) - The market capitalization of the company. - **book_value_of_equity_usd** (float) - The book value of equity in USD. - **pb_ratio** (float) - The Price-to-Book ratio. #### Response Example ```json { "symbol": "TSLA", "currency": "USD", "date_range": "2020-01-01 to 2025-01-24", "rows_returned": 1000, "truncated": true, "data": [ { "report_date": "2025-01-24", "fiscal_quarter": "2024-12-31", "market_capitalization": 750592000000, "book_value_of_equity_usd": 55566666000, "pb_ratio": 13.51 } ] } ``` ``` -------------------------------- ### Quick Investment Screening Workflow Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/analysis-templates.md This workflow outlines the steps for a quick investment screening. It involves fetching data like latest update dates, stock profiles, price trends, income statements, and valuation metrics against industry peers. ```text 1. get_latest_data_update_date → Establish reference date 2. get_stock_profile → Understand business model → Check sector/industry → Note if financial institution (affects ROIC applicability) 3. get_stock_price (last 6 months) → Recent price trend → Volatility assessment 4. get_stock_quarterly_income_statement (last 4 quarters) → Revenue trend → Profitability check 5. get_stock_ttm_pe (last 3 years) → Current valuation vs historical → Identify extreme values 6. get_industry_ttm_pe (last 3 years) → Peer valuation comparison 7. get_stock_quarterly_revenue_yoy_growth → Growth momentum ``` -------------------------------- ### GET /stock/valuation/ps-ratio Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves historical Price-to-Sales (P/S) ratio for a stock. ```APIDOC ## GET /stock/valuation/ps-ratio ### Description Retrieves historical Price-to-Sales (P/S) ratio for a stock. Returns a maximum of 1000 rows, with the most recent data if truncated. ### Method GET ### Endpoint /stock/valuation/ps-ratio ### Parameters #### Query Parameters - **symbol** (str) - Required - The stock symbol (e.g., TSLA). - **start_date** (str) - Optional - The start date for the data range (YYYY-MM-DD). - **end_date** (str) - Optional - The end date for the data range (YYYY-MM-DD). ### Request Example ```json { "symbol": "TSLA", "start_date": "2020-01-01", "end_date": "2025-01-24" } ``` ### Response #### Success Response (200) - **symbol** (str) - The stock symbol. - **currency** (str) - The currency of the financial data. - **date_range** (str) - The date range for which the data is provided. - **rows_returned** (int) - Number of data rows returned. - **truncated** (bool) - Indicates if the results were truncated due to the row limit. - **data** (array) - Array of P/S ratio data. - **report_date** (str) - The date of the report. - **fiscal_quarter** (str) - The fiscal quarter the data pertains to. - **market_capitalization** (float) - The market capitalization of the company. - **ttm_revenue_usd** (float) - Trailing Twelve Months revenue in USD. - **ps_ratio** (float) - The Price-to-Sales ratio. #### Response Example ```json { "symbol": "TSLA", "currency": "USD", "date_range": "2020-01-01 to 2025-01-24", "rows_returned": 1000, "truncated": true, "data": [ { "report_date": "2025-01-24", "fiscal_quarter": "2024-12-31", "market_capitalization": 750592000000, "ttm_revenue_usd": 95000000000, "ps_ratio": 7.90 } ] } ``` ``` -------------------------------- ### Generate DCF Analysis with defeatbeta-api Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/DCF_Examples.md This Python snippet demonstrates how to initialize a Ticker object and generate a DCF analysis. It also shows how to retrieve supporting metrics like WACC and growth rates. The output file path for the DCF analysis is printed. ```python from defeatbeta_api import Ticker # Initialize ticker ticker = Ticker("AAPL") # Step 1: Generate DCF analysis dcf_result = ticker.dcf() print(f"DCF file saved to: {dcf_result['file_path']}") # Step 2: Review supporting metrics wacc = ticker.wacc() fcf_growth = ticker.annual_fcf_yoy_growth() revenue_growth = ticker.annual_revenue_yoy_growth() # Step 3: Open the Excel file and review assumptions # Step 4: Adjust assumptions if needed # Step 5: Make investment decision based on fair value vs. current price ``` -------------------------------- ### Initialize Ticker Class Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Import the Ticker class and initialize it with a stock symbol to begin analysis. ```python from defeatbeta_api import Ticker # Initialize with a stock symbol ticker = Ticker("AAPL") ``` -------------------------------- ### Get Dividend History Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Fetch the history of dividend payments made by a company. ```python # Get dividend history ticker.dividends() # Returns: DataFrame with date, dividend amount ``` -------------------------------- ### GET /stock/valuation/wacc Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves the historical Weighted Average Cost of Capital (WACC) for a stock. ```APIDOC ## GET /stock/valuation/wacc ### Description Retrieves the historical Weighted Average Cost of Capital (WACC) for a stock. Returns a maximum of 1000 rows, with the most recent data if truncated. ### Method GET ### Endpoint /stock/valuation/wacc ### Parameters #### Query Parameters - **symbol** (str) - Required - The stock symbol (e.g., TSLA). - **start_date** (str) - Optional - The start date for the data range (YYYY-MM-DD). - **end_date** (str) - Optional - The end date for the data range (YYYY-MM-DD). ### Request Example ```json { "symbol": "TSLA", "start_date": "2020-01-01", "end_date": "2025-01-24" } ``` ### Response #### Success Response (200) - **symbol** (str) - The stock symbol. - **date_range** (str) - The date range for which the data is provided. - **rows_returned** (int) - Number of data rows returned. - **truncated** (bool) - Indicates if the results were truncated due to the row limit. - **data** (array) - Array of WACC data. - **report_date** (str) - The date of the report. - **market_capitalization** (float) - The market capitalization of the company. - **total_debt** (float) - Total debt of the company. - **interest_expense** (float) - Total interest expense. - **tax_rate_for_calcs** (float) - Tax rate used for calculations. - **expected_market_return** (float) - Expected market return (e.g., 10-year S&P 500 CAGR). - **risk_free_rate** (float) - Risk-free rate (e.g., 10-year Treasury yield). - **beta_5y** (float) - 5-year beta of the stock. - **weight_of_debt** (float) - Weight of debt in the capital structure. - **weight_of_equity** (float) - Weight of equity in the capital structure. - **cost_of_debt** (float) - Cost of debt. - **cost_of_equity** (float) - Cost of equity (calculated using CAPM). - **wacc** (float) - Weighted Average Cost of Capital (percentage). #### Response Example ```json { "symbol": "TSLA", "date_range": "2020-01-01 to 2025-01-24", "rows_returned": 1000, "truncated": true, "data": [ { "report_date": "2025-01-24", "market_capitalization": 750592000000, "total_debt": 12000000000, "interest_expense": 180000000, "tax_rate_for_calcs": 0.15, "expected_market_return": 0.1107, "risk_free_rate": 0.0433, "beta_5y": 2.10, "weight_of_debt": 0.0157, "weight_of_equity": 0.9843, "cost_of_debt": 0.0150, "cost_of_equity": 0.1848, "wacc": 0.1820 } ] } ``` ``` -------------------------------- ### GET /stock/valuation/peg-ratio Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves the historical PEG ratio for a stock, based on EPS growth. ```APIDOC ## GET /stock/valuation/peg-ratio ### Description Retrieves the historical PEG ratio for a stock, based on Earnings Per Share (EPS) growth. Returns a maximum of 1000 rows, with the most recent data if truncated. ### Method GET ### Endpoint /stock/valuation/peg-ratio ### Parameters #### Query Parameters - **symbol** (str) - Required - The stock symbol (e.g., TSLA). - **start_date** (str) - Optional - The start date for the data range (YYYY-MM-DD). - **end_date** (str) - Optional - The end date for the data range (YYYY-MM-DD). ### Request Example ```json { "symbol": "TSLA", "start_date": "2020-01-01", "end_date": "2025-01-24" } ``` ### Response #### Success Response (200) - **symbol** (str) - The stock symbol. - **date_range** (str) - The date range for which the data is provided. - **rows_returned** (int) - Number of data rows returned. - **truncated** (bool) - Indicates if the results were truncated due to the row limit. - **data** (array) - Array of PEG ratio data. - **report_date** (str) - The date of the report. - **fiscal_quarter** (str) - The fiscal quarter the data pertains to. - **close_price** (float) - The closing price of the stock on the report date. - **ttm_eps** (float) - Trailing Twelve Months Earnings Per Share. - **ttm_pe** (float) - Trailing Twelve Months Price-to-Earnings ratio. - **eps_yoy_growth** (float) - Year-over-year EPS growth (e.g., 0.15 for 15%). - **peg_ratio** (float) - The PEG ratio (ttm_pe / (eps_yoy_growth * 100)). Null if EPS or growth is non-positive. #### Response Example ```json { "symbol": "TSLA", "date_range": "2020-01-01 to 2025-01-24", "rows_returned": 1000, "truncated": true, "data": [ { "report_date": "2025-01-24", "fiscal_quarter": "2024-12-31", "close_price": 403.84, "ttm_eps": 2.36, "ttm_pe": 64.43, "eps_yoy_growth": 0.15, "peg_ratio": 4.30 } ] } ``` ``` -------------------------------- ### Configure MCP Server in Client Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/mcp/README.md This JSON configuration adds the Defeat Beta API MCP server to your MCP client. It specifies the command to use and its arguments. ```json { "mcpServers": { "defeatbeta-api": { "command": "uvx", "args": [ "git+https://github.com/defeat-beta/defeatbeta-api.git#subdirectory=mcp" ] } } } ``` -------------------------------- ### Sample Enterprise Value Output Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Value_Examples.md Example output from the `ticker.enterprise_value()` method, showing historical data including market capitalization, debt, and calculated enterprise value. ```text >>> ticker.enterprise_value() symbol report_date market_capitalization fiscal_quarter exchange_to_usd_rate total_debt total_debt_usd minority_interest minority_interest_usd preferred_stock_equity preferred_stock_equity_usd cash_and_cash_equivalents cash_and_cash_equivalents_usd enterprise_value 7853 MSFT 2026-02-13 2.980053e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 3.013364e+12 7854 MSFT 2026-02-17 2.946935e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 2.980246e+12 7855 MSFT 2026-02-18 2.967281e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 3.000592e+12 7856 MSFT 2026-02-19 2.958816e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 2.992127e+12 7857 MSFT 2026-02-20 2.949683e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 2.982994e+12 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... 7858 MSFT 2026-02-23 2.854932e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 2.888243e+12 7859 MSFT 2026-02-24 2.888570e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 2.921881e+12 7860 MSFT 2026-02-25 2.974707e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 3.008018e+12 7861 MSFT 2026-02-26 2.983024e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 3.016335e+12 7862 MSFT 2026-02-27 2.916342e+12 2025-12-31 1.0 5.760700e+10 5.760700e+10 0.0 0.0 0.0 0.0 2.429600e+10 2.429600e+10 2.949653e+12 ``` -------------------------------- ### GET /api/stock/quarterly/roa Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves the quarterly Return on Assets (ROA) for a given stock symbol. ```APIDOC ## GET /api/stock/quarterly/roa ### Description Retrieves the quarterly Return on Assets (ROA) for a given stock symbol. ### Method GET ### Endpoint /api/stock/quarterly/roa ### Parameters #### Query Parameters - **symbol** (str) - Required - The stock symbol for which to retrieve ROA data. ### Response #### Success Response (200) - **symbol** (str) - The stock symbol. - **currency** (str) - The currency of the financial data (e.g., "USD"). - **period_type** (str) - The type of period (e.g., "quarterly"). - **periods** (list[str]) - A list of periods for which data is available. - **rows_returned** (int) - The number of rows returned in the data. - **data** (list[object]) - A list of ROA data objects for each period. - **period** (str) - The specific period (e.g., "2024-12-31"). - **net_income_common_stockholders** (float) - Net income attributable to common stockholders. - **beginning_total_assets** (float) - Total assets at the beginning of the period. - **ending_total_assets** (float) - Total assets at the end of the period. - **avg_assets** (float) - Average total assets for the period. - **roa** (float) - The calculated Return on Assets (e.g., 0.0191 for 1.91%). ### Response Example ```json { "symbol": "TSLA", "currency": "USD", "period_type": "quarterly", "periods": [...], "rows_returned": 20, "data": [ { "period": "2024-12-31", "net_income_common_stockholders": 2321000000, "beginning_total_assets": 120000000000, "ending_total_assets": 123456789000, "avg_assets": 121728394500, "roa": 0.0191 } ] } ``` ``` -------------------------------- ### GET /api/stock/quarterly/roe Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/skills/defeatbeta-analyst/references/defeatbeta-api-reference.md Retrieves the quarterly Return on Equity (ROE) for a given stock symbol. ```APIDOC ## GET /api/stock/quarterly/roe ### Description Retrieves the quarterly Return on Equity (ROE) for a given stock symbol. ### Method GET ### Endpoint /api/stock/quarterly/roe ### Parameters #### Query Parameters - **symbol** (str) - Required - The stock symbol for which to retrieve ROE data. ### Response #### Success Response (200) - **symbol** (str) - The stock symbol. - **currency** (str) - The currency of the financial data (e.g., "USD"). - **period_type** (str) - The type of period (e.g., "quarterly"). - **periods** (list[str]) - A list of periods for which data is available. - **rows_returned** (int) - The number of rows returned in the data. - **data** (list[object]) - A list of ROE data objects for each period. - **period** (str) - The specific period (e.g., "2024-12-31"). - **net_income_common_stockholders** (float) - Net income attributable to common stockholders. - **beginning_stockholders_equity** (float) - Stockholders' equity at the beginning of the period. - **ending_stockholders_equity** (float) - Stockholders' equity at the end of the period. - **avg_equity** (float) - Average stockholders' equity for the period. - **roe** (float) - The calculated Return on Equity (e.g., 0.0424 for 4.24%). ### Response Example ```json { "symbol": "TSLA", "currency": "USD", "period_type": "quarterly", "periods": [...], "rows_returned": 20, "data": [ { "period": "2024-12-31", "net_income_common_stockholders": 2321000000, "beginning_stockholders_equity": 54000000000, "ending_stockholders_equity": 55566666000, "avg_equity": 54783333000, "roe": 0.0424 } ] } ``` ``` -------------------------------- ### Import Ticker Class Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/notebooks/00_tutorial_info.ipynb Import the Ticker class from the defeatbeta_api.data.ticker module. This is the first step to initialize a stock ticker object. ```python from defeatbeta_api.data.ticker import Ticker ``` -------------------------------- ### Load Dataset from Hugging Face Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Advanced_Usage.md Load a dataset from Hugging Face, specifying the dataset name and data files. This example loads stock prices from a Parquet file. ```python from datasets import load_dataset import datasets datasets.utils.logging.set_verbosity_debug() dataset = load_dataset( "defeatbeta/yahoo-finance-data", data_files="data/stock_prices.parquet" ) # Inspect available splits print(dataset) # Access the 'train' split (or whichever split is available) ds = dataset["train"] # Split train and test 80% / 20% split_datasets = ds.train_test_split(test_size=0.2, seed=0xDEADBEAF) print(split_datasets) ``` -------------------------------- ### Get Annual Net Margin for All Tickers Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Retrieves annual net margin for all tickers. ```python tickers.annual_net_margin() ``` -------------------------------- ### Get Quarterly Gross Margin for All Tickers Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Retrieves quarterly gross margin for all tickers. ```python # Get profitability metrics tickers.quarterly_gross_margin() ``` -------------------------------- ### Get WACC for All Tickers Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Retrieves the Weighted Average Cost of Capital (WACC) for all tickers. ```python tickers.wacc() ``` -------------------------------- ### Initialize and Call Daily Treasure Yield Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/Economy_Examples.md Initializes the Treasure class and calls the daily_treasure_yield method to retrieve daily yield data. Ensure the defeatbeta_api library is installed. ```python from defeatbeta_api.data.treasure import Treasure treasure = Treasure() treasure.daily_treasure_yield() ``` -------------------------------- ### Set HTTP Proxy for MCP Server Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/mcp/README.md Configure an HTTP proxy for the MCP server if you are in a region with restricted access to financial data sources. This example sets a local proxy. ```json { "mcpServers": { "defeatbeta-api": { "command": "uvx", "args": [ "git+https://github.com/defeat-beta/defeatbeta-api.git#subdirectory=mcp" ], "env": { "DEFEATBETA_GATEWAY": "http://127.0.0.1:8118" } } } } ``` -------------------------------- ### Get Quarterly ROE for All Tickers Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Retrieves quarterly Return on Equity (ROE) for all tickers. ```python tickers.quarterly_roe() ``` -------------------------------- ### Get Info for All Tickers Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Retrieves combined information for all tickers initialized in the Tickers class. ```python # Get info for all tickers tickers.info() # Returns: Combined DataFrame with data for all symbols ``` -------------------------------- ### Summarize Financial Data for Q2 2025 Source: https://github.com/defeat-beta/defeatbeta-api/blob/main/doc/api/LLM_KeyData_Example.md Use this function to get a structured summary of key financial metrics for a given year and quarter. Requires an LLM instance and OpenAI configuration. ```python res = transcripts.summarize_key_financial_data_with_ai( 2025, 2, llm, OpenAIConfiguration(model='Qwen/Qwen3-8B')) print(res.to_string()) ``` -------------------------------- ### Get Stock Splits History Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Retrieve the history of stock splits for a given company. ```python # Get stock splits history ticker.splits() # Returns: DataFrame with date and split_ratio ``` -------------------------------- ### Extract Fair Value and Recommendation from DCF Data Source: https://context7.com/defeat-beta/defeatbeta-api/llms.txt Extracts and prints the fair price, current price, and recommendation from DCF data. ```python # Example: Extract fair value and recommendation dcf = ticker.dcf_data() print(f"Fair Price: ${dcf['dcf_value']['fair_price']:.2f}") print(f"Current Price: ${dcf['dcf_value']['current_price']:.2f}") print(f"Recommendation: {dcf['dcf_value']['recommendation']}") ```