### Commands to Record Source: https://docs.openbb.co/odp/cli/routines/routine-macro-recorder Example commands to be recorded after starting the macro recorder. These commands will be captured in the 'sample' routine. ```bash /equity/price/historical --symbol SPY --provider cboe --interval 1m /home/derivatives/options/chains --symbol SPY --provider cboe /home/stop/r ``` -------------------------------- ### Start All OpenBB Services Source: https://docs.openbb.co/snowflake Manually start all OpenBB services. This is typically not needed as services start automatically on installation or upgrade. ```sql -- Start all services (usually not needed - automatic on install/upgrade) CALL .core.start_openbb_service(); ``` -------------------------------- ### Install Altair Helper Source: https://docs.openbb.co/workspace/developers/widget-types/vega-lite Install the Altair Python package to get helper functions for creating Vega-Lite specifications. ```bash pip install altair ``` -------------------------------- ### Install All Toolkits and Data Providers from GitHub Source: https://docs.openbb.co/odp/python/faqs/data_providers Install all OpenBB toolkits and data providers by cloning the GitHub repo and running the dev_install script. ```bash python dev_install.py -e ``` -------------------------------- ### Install OpenBB MCP Server Source: https://docs.openbb.co/odp/python/quickstart/mcp Install the OpenBB MCP Server package using pip. This command is used to get started with the ODP Python Package as an MCP server. ```bash pip install openbb-mcp-server ``` -------------------------------- ### Execute an Example Routine Source: https://docs.openbb.co/odp/cli/quickstart Run a predefined example routine to demonstrate how multiple commands are sequenced as a script. ```bash /exe --example ``` -------------------------------- ### Install All Toolkits and Data Providers Source: https://docs.openbb.co/odp/python/faqs/data_providers Install all OpenBB toolkits and data providers using pip. ```bash pip install "openbb[all]" ``` -------------------------------- ### Controlled OpenBB Initialization with FastAPI Source: https://docs.openbb.co/odp/python/basic_usage This example demonstrates how to control the initialization of the OpenBB SDK within a FastAPI application using a Singleton pattern. It ensures that the OpenBB SDK is initialized only once and provides a dependency injection mechanism. ```python from typing import Annotated from fastapi import Depends, FastAPI from openbb_core.app.model.abstract.singleton import SingletonMeta app = FastAPI() class OpenBB(metaclass=SingletonMeta): def __init__(self): import openbb self._obb = openbb.sdk @property def obb(self): return self._obb def get_openbb(): return OpenBB().obb OpenBBApp = Annotated[OpenBB, Depends(get_openbb)] @app.get("stock_quote", response_model=list) async def quote( obb: OpenBBApp, some_parameter: int, symbol: str = "AAPL", ): """Widget description derived from the endpoint's docstring.""" return obb.equity.price.quote(symbol, provider="yfinance").model_dump()["results"] ``` -------------------------------- ### Start Workspace MCP Sidecar (Windows PowerShell) Source: https://docs.openbb.co/agents/workspace-mcp-quickstart Installs and runs the Workspace MCP sidecar using a PowerShell command. It installs uv if needed. ```powershell powershell -ExecutionPolicy Bypass -Command "Invoke-RestMethod https://raw.githubusercontent.com/OpenBB-finance/workspace-mcp/main/scripts/run.ps1 | Invoke-Expression" ``` -------------------------------- ### Basic GET Endpoint Source: https://docs.openbb.co/odp/python/developer/extension_types/router A simple GET endpoint that returns a string message. This is a basic example of a router command where the logic is self-contained within the function. ```APIDOC ## Basic GET Endpoint ### Description This is a straightforward GET endpoint that serves a static "Hello World" message. It demonstrates a basic router command where all the logic resides directly within the command function, returning a simple string response. ### Method GET ### Endpoint `/hello` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None (GET request) ### Response #### Success Response (200) - **OBBject[str]** - An OBBject containing a string result, typically "Hello from the Empty Router extension!" #### Response Example ```json { "results": "Hello from the Empty Router extension!" } ``` ``` -------------------------------- ### Install OpenBB Platform from Source Source: https://docs.openbb.co/odp/cli/installation Installs the OpenBB Platform from its source code after cloning the GitHub repository. Requires Poetry to be installed. ```bash python dev_install.py -e --cli ``` -------------------------------- ### Get Available Economic Indicators Source: https://docs.openbb.co/odp/python/reference/economy/available_indicators Use this function to get a list of all available economic indicators from a specified provider. Ensure the 'openbb' library is installed and imported. ```python from openbb import obb obb.economy.available_indicators() ``` -------------------------------- ### Provider Initialization in __init__.py Source: https://docs.openbb.co/odp/python/developer/extension_types/provider Initializes the Provider class with its name, website, description, and fetcher mappings. Credentials can be optionally specified. ```python from openbb_core.provider.abstract.provider import Provider from openbb_empty_provider.models.empty_model import EmptyFetcher empty_provider = Provider( name="empty", website="http://empty.io", description="""The empty provider is a supplier of promises.""", # credentials=["api_key"], # Credentials added here are mapped to `user_settings.json` in the `credentials` key. # Don't do "empty_api_key" here, the `name` will prefix whatever items are listed in the credentials field. fetcher_dict={ "EmptyModel": EmptyFetcher # The key is mapped to in @router.command(model="EmptyModel", methods=["GET"]) }, ) ``` -------------------------------- ### Get Economic Calendar Data Source: https://docs.openbb.co/odp/python/reference/economy/calendar Retrieve upcoming economic calendar events. By default, the calendar is forward-looking. Specify start and end dates to get historical data. ```python from openbb import obb # Get upcoming economic calendar events (forward-looking by default) obb.economy.calendar() # Get historical economic calendar events for a specific month obb.economy.calendar(start_date='2020-03-01', end_date='2020-03-31') ``` -------------------------------- ### Install openbb-core Source: https://docs.openbb.co/odp/python/extensions/openbb-core Install the openbb-core package as a standalone component from PyPI. ```bash pip install openbb-core ``` -------------------------------- ### Start Workspace MCP Sidecar (macOS, Linux, WSL, Git Bash) Source: https://docs.openbb.co/agents/workspace-mcp-quickstart Installs and runs the Workspace MCP sidecar using a curl command. It installs uv if needed. ```shell curl -LsSf https://raw.githubusercontent.com/OpenBB-finance/workspace-mcp/main/scripts/run.sh | sh ``` -------------------------------- ### Import OpenBB and Check Extensions (No Extensions Installed) Source: https://docs.openbb.co/odp/python/developer/architecture_overview Demonstrates importing the OpenBB object and the message displayed when no extensions are installed. ```python >>> from openbb import obb Failed to import extensions. Are any installed? >>> obb OpenBB Platform v1.5.1core Utilities: /user /system /coverage ``` -------------------------------- ### Parameter Definition Example (Date Type) Source: https://docs.openbb.co/workspace/developers/json-specs/widgets-json-reference Define a 'date' type parameter for a widget. This example sets the parameter name, default value, and UI label for a start date. ```json { "type": "date", "paramName": "startDate", "value": "2024-01-01", "label": "Start Date", "description": "The start date for the data" } ``` -------------------------------- ### Multiple Widget Grid Size Examples Source: https://docs.openbb.co/workspace/developers/widget-configuration/grid-size Demonstrates various widget configurations with different width and height values. ```python @register_widget({ "name": "Markdown Widget w-12 x h-20", "description": "A markdown widget", "type": "markdown", "endpoint": "markdown_widget2", "gridData": {"w": 12, "h": 20}, }) @app.get("/markdown_widget2") def markdown_widget2(): """Returns a markdown widget""" return "# Markdown Widget w-12 x h-20" ``` ```python @register_widget({ "name": "Markdown Widget w-40 x h-4", "description": "A markdown widget", "type": "markdown", "endpoint": "markdown_widget3", "gridData": {"w": 40, "h": 4}, }) @app.get("/markdown_widget3") def markdown_widget3(): """Returns a markdown widget""" return "# Markdown Widget w-40 x h-4" ``` ```python @register_widget({ "name": "Markdown Widget w-14 x h-12", "description": "A markdown widget", "type": "markdown", "endpoint": "markdown_widget4", "gridData": {"w": 14, "h": 12}, }) @app.get("/markdown_widget4") def markdown_widget4(): """Returns a markdown widget""" return "# Markdown Widget w-14 x h-12" ``` ```python @register_widget({ "name": "Markdown Widget w-28 x h-8", "description": "A markdown widget", "type": "markdown", "endpoint": "markdown_widget5", "gridData": {"w": 28, "h": 8}, }) @app.get("/markdown_widget5") def markdown_widget5(): """Returns a markdown widget""" return "# Markdown Widget w-28 x h-8" ``` ```python @register_widget({ "name": "Markdown Widget w-14 x h-6", "description": "A markdown widget", "type": "markdown", "endpoint": "markdown_widget6", "gridData": {"w": 14, "h": 6}, }) @app.get("/markdown_widget6") def markdown_widget6(): """Returns a markdown widget""" return "# Markdown Widget w-14 x h-6" ``` -------------------------------- ### Get Economic Calendar Data Source: https://docs.openbb.co/odp/python/reference/economy/calendar Retrieves economic calendar data. By default, it fetches forward-looking events. Users can specify start and end dates to get historical data. ```APIDOC ## Get Economic Calendar Data ### Description Retrieves upcoming or historical economic calendar events globally. By default, the calendar is forward-looking. Users can specify date ranges for historical data. ### Method `GET` (Implicit, as this is an SDK method call) ### Endpoint `/economy/calendar` (Conceptual endpoint for the SDK method) ### Parameters #### Query Parameters - **start_date** (`date | None | str`) - Optional - Start date of the data, in YYYY-MM-DD format. - **end_date** (`date | None | str`) - Optional - End date of the data, in YYYY-MM-DD format. - **release_id** (`int | None`) - Optional - Filter by release ID. - **country** (`str | None`) - Optional - Country of the event. Accepts country names, ISO 3166-1 alpha-2/alpha-3 codes. Multiple comma-separated values allowed. - **importance** (`Literal['low', 'medium', 'high'] | None`) - Optional - Importance of the event. - **group** (`Literal['interest_rate', 'inflation', 'bonds', 'consumer', 'gdp', 'government', 'housing', 'labour', 'markets', 'money', 'prices', 'trade', 'business'] | None`) - Optional - Grouping of events. - **calendar_id** (`None | int | str`) - Optional - Get events by TradingEconomics Calendar ID. ### Request Example ```python from openbb import obb # Get upcoming events obb.economy.calendar() # Get historical events for March 2020 obb.economy.calendar(start_date='2020-03-01', end_date='2020-03-31') ``` ### Response #### Success Response - **results** (`EconomicCalendar`) - Serializable results. - **provider** (`Optional[Literal['fmp', 'fred', 'nasdaq', 'tradingeconomics']]`) - Provider name. - **warnings** (`Optional[list[Warning_]]`) - List of warnings. - **chart** (`Optional[Chart]`) - Chart object. - **extra** (`dict[str, Any]`) - Extra information. ``` -------------------------------- ### Basic openbb-api Command Line Usage Source: https://docs.openbb.co/odp/python/extensions/interface/openbb-api Run the openbb-api command to start a backend. Defaults to using installed Open Data Platform extensions. Specify a custom app file with --app. ```bash openbb-api --app ./some_file.py --host 0.0.0.0 --port 8005 --reload ``` -------------------------------- ### Install OpenBB AI SDK Source: https://docs.openbb.co/workspace/developers/openbb-ai-sdk Install the openbb-ai package using pip. This is the first step to using the SDK in your agent backend. ```bash pip install openbb-ai ``` -------------------------------- ### Get SOFR Data Source: https://docs.openbb.co/odp/python/reference/fixedincome/rate/sofr Retrieve SOFR data using the OpenBB SDK. Ensure the 'openbb' library is installed. ```python from openbb import obb obb.fixedincome.rate.sofr() ``` -------------------------------- ### Get Corporate Bond Prices Source: https://docs.openbb.co/odp/python/reference/fixedincome/corporate/bond_prices Fetch corporate bond prices. This is a basic example demonstrating the function call. ```python from openbb import obb obb.fixedincome.corporate.bond_prices() ``` -------------------------------- ### Start Recording a Macro Source: https://docs.openbb.co/odp/cli/routines/routine-macro-recorder Initiates the macro recording process, naming the routine 'sample'. Any subsequent commands will be captured. ```bash record -n sample ``` -------------------------------- ### Get All Price Targets Source: https://docs.openbb.co/odp/python/reference/equity/estimates/price_target Retrieves all available analyst price targets. Ensure the OpenBB SDK is installed and configured. ```python from openbb import obb obb.equity.estimates.price_target() ``` -------------------------------- ### Install Dependencies Source: https://docs.openbb.co/workspace/developers/data-integration Install the necessary Python libraries for building the custom backend API. ```bash pip install fastapi uvicorn ``` -------------------------------- ### Install OpenBB Charting Source: https://docs.openbb.co/odp/python/extensions/infrastructure/openbb-charting Install the charting extension for OpenBB. Use the '[pywry]' extra for standalone window creation. ```bash pip install openbb-charting ``` ```bash pip install "openbb-charting[pywry]" ``` -------------------------------- ### Get Retail Prices Source: https://docs.openbb.co/odp/python/reference/economy/retail_prices Fetch default retail prices for common items. Requires the OpenBB SDK to be installed. ```python from openbb import obb obb.economy.retail_prices() ``` -------------------------------- ### Panel Fama-MacBeth Estimator Example Source: https://docs.openbb.co/odp/python/reference/econometrics/panel_fmac Demonstrates how to use the Fama-MacBeth estimator for panel data. Requires the 'openbb' library to be installed. ```python from openbb import obb obb.econometrics.panel_fmac(y_column='portfolio_value', x_columns='['risk_free_rate']', data='[{'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_1', 'time': 0, 'portfolio_value': 100000.0, 'risk_free_rate': 0.02}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_1', 'time': 1, 'portfolio_value': 150000.0, 'risk_free_rate': 0.03}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_2', 'time': 0, 'portfolio_value': 150000.0, 'risk_free_rate': 0.03}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_2', 'time': 1, 'portfolio_value': 133333.33, 'risk_free_rate': 0.03}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_3', 'time': 0, 'portfolio_value': 133333.33, 'risk_free_rate': 0.03}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_3', 'time': 1, 'portfolio_value': 125000.0, 'risk_free_rate': 0.03}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_4', 'time': 0, 'portfolio_value': 125000.0, 'risk_free_rate': 0.03}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_4', 'time': 1, 'portfolio_value': 120000.0, 'risk_free_rate': 0.02}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_5', 'time': 0, 'portfolio_value': 120000.0, 'risk_free_rate': 0.02}, {'is_multiindex': True, 'multiindex_names': "['asset_manager', 'time']", 'asset_manager': 'asset_manager_5', 'time': 1, 'portfolio_value': 116666.67, 'risk_free_rate': 0.02}]') ``` -------------------------------- ### Start MCP Server with Default Settings Source: https://docs.openbb.co/odp/python/extensions/interface/openbb-mcp Starts the MCP server using default transport and configuration. ```bash openbb-mcp ``` -------------------------------- ### Define API Key in .env File Source: https://docs.openbb.co/odp/python/settings/environment_variables This example shows how to add an API key for a provider (e.g., FMP) to the `.env` file. This method is recommended for persistent storage of credentials. ```bash FMP_API_KEY = "replaceWITHyourK3Y" ``` -------------------------------- ### Get SEC Litigation Releases Source: https://docs.openbb.co/odp/python/reference/regulators/sec/rss_litigation Fetches the RSS feed for SEC litigation releases. Ensure the OpenBB SDK is installed. ```python from openbb import obb obb.regulators.sec.rss_litigation() ``` -------------------------------- ### Get TCM EFFR Data Source: https://docs.openbb.co/odp/python/reference/fixedincome/spreads/tcm_effr Retrieve TCM EFFR data with default maturity. Requires the OpenBB SDK to be installed. ```python from openbb import obb obb.fixedincome.spreads.tcm_effr() ``` -------------------------------- ### Launch OpenBB CLI Source: https://docs.openbb.co/odp/cli/quickstart To launch the OpenBB CLI, ensure your data provider credentials are set up in `user_settings.json`. Then, activate your environment and run the `openbb` command in your terminal. ```bash openbb ``` -------------------------------- ### Installing an OBBject Extension Source: https://docs.openbb.co/odp/python/developer/extension_types/obbject Commands to install a local OBBject extension using pip and then build the OpenBB application. ```bash pip install -e . openbb-build ``` -------------------------------- ### Get Treasury Rates Source: https://docs.openbb.co/odp/python/reference/fixedincome/government/treasury_rates Fetch government treasury rates. Ensure the OpenBB SDK is installed and authenticated if required by the provider. ```python from openbb import obb obb.fixedincome.government.treasury_rates() ``` -------------------------------- ### Execute Calendar Command with Provider and Country Source: https://docs.openbb.co/odp/cli/quickstart This example shows how to execute the calendar command, specifying the provider as 'nasdaq' and the country as 'united_states'. Note that `--importance` and `--group` are ignored when using the Nasdaq provider. ```bash /economy/calendar --provider nasdaq --country united_states ``` -------------------------------- ### Get Income Growth for AAPL Source: https://docs.openbb.co/odp/python/reference/equity/fundamental/income_growth Retrieve the income statement growth for Apple (AAPL). This example shows the default parameters. ```python from openbb import obb obb.equity.fundamental.income_growth(symbol='AAPL') ``` -------------------------------- ### Get Stock Splits Calendar Source: https://docs.openbb.co/odp/python/reference/equity/calendar/splits Retrieve the stock splits calendar. Specify start and end dates for a custom range. ```python from openbb import obb obb.equity.calendar.splits() # Get stock splits calendar for specific dates. obb.equity.calendar.splits(start_date='2024-02-01', end_date='2024-02-07') ``` -------------------------------- ### Start Fast API Server Source: https://docs.openbb.co/odp/python/basic_usage/query_parameters Start the Fast API server for interacting with the OpenBB SDK via REST API. ```bash uvicorn openbb_core.api.rest_api:app ``` -------------------------------- ### Get Maritime Chokepoint Info Source: https://docs.openbb.co/odp/python/reference/economy/shipping/chokepoint_info Retrieve general metadata and statistics for maritime chokepoints. Ensure the OpenBB SDK is installed. ```python from openbb import obb obb.economy.shipping.chokepoint_info() ``` -------------------------------- ### Developer Installation Script Source: https://docs.openbb.co/odp/python/installation Run the developer installation script to build and install the OpenBB Python packages from source. ```bash python dev_install.py ``` -------------------------------- ### Get Discount Window Primary Credit Rate Source: https://docs.openbb.co/odp/python/reference/fixedincome/rate/dpcredit Fetch the Discount Window Primary Credit Rate data. This can be done without specifying a date range to get all available data, or by providing start and end dates for a specific period. ```python from openbb import obb obb.fixedincome.rate.dpcredit() ``` ```python from openbb import obb obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') ``` -------------------------------- ### Full pyproject.toml Example Source: https://docs.openbb.co/odp/python/developer/extension_types/provider A complete example of a pyproject.toml file for an OpenBB provider extension, including dependencies and plugin configuration. ```toml [tool.poetry] name = "openbb-empty-provider" version = "0.0.0" description = "Empty provider extension for OpenBB" authors = ["Hello "] readme = "README.md" packages = [{ include = "openbb_empty_provider" }] [tool.poetry.dependencies] python = "^3.10,<3.14" openbb-core = "*" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.poetry.plugins."openbb_provider_extension"] empty = "openbb_empty_provider:empty_provider" ``` -------------------------------- ### Get Treasury Prices Source: https://docs.openbb.co/odp/python/reference/fixedincome/government/treasury_prices Fetch treasury prices for the last business day or a specific date. Requires the `openbb` package to be installed. ```python from openbb import obb obb.fixedincome.government.treasury_prices() obb.fixedincome.government.treasury_prices(date='2019-02-05') ``` -------------------------------- ### Advanced MCP Configuration Example Source: https://docs.openbb.co/odp/python/extensions/interface/openbb-mcp Demonstrates fine-tuning a tool's behavior by explicitly exposing a route, setting its MCP type, specifying HTTP methods, and excluding arguments. ```python @app.get( "/some/route", openapi_extra={ "mcp_config": { "expose": True, "mcp_type": "tool", "methods": ["GET"], "exclude_args": ["internal_param"], "prompts": [ # ... prompt definitions ... ] } }, ) def some_route(param1: str, internal_param: str = "default"): """An example route with advanced MCP configuration.""" return {"param1": param1} ``` -------------------------------- ### Start API Server for Testing Source: https://docs.openbb.co/odp/python/developer/how-to/tests Start a local server before running API interface integration tests. Ensure the server is running to avoid test failures. ```bash uvicorn openbb_core.api.rest_api:app --host 0.0.0.0 --port 8000 --reload ```