Quick Start
This guide will help you make your first Bloomberg request.
Reference Data (BDP)
Section titled “Reference Data (BDP)”Get point-in-time data for securities:
import xbbg
# Single ticker, single fielddf = xbbg.bdp('AAPL US Equity', 'PX_LAST')
# Multiple tickers and fieldsdf = xbbg.bdp( ['AAPL US Equity', 'MSFT US Equity'], ['PX_LAST', 'VOLUME', 'NAME'])Output (long format):
| ticker | field | value |
|---|---|---|
| AAPL US Equity | PX_LAST | 185.50 |
| AAPL US Equity | VOLUME | 45234521 |
| AAPL US Equity | NAME | Apple Inc |
| MSFT US Equity | PX_LAST | 378.91 |
| … | … | … |
Historical Data (BDH)
Section titled “Historical Data (BDH)”Get time series data:
df = xbbg.bdh( 'AAPL US Equity', ['PX_LAST', 'VOLUME'], start_date='2024-01-01', end_date='2024-01-31')Output:
| ticker | date | field | value |
|---|---|---|---|
| AAPL US Equity | 2024-01-02 | PX_LAST | 185.50 |
| AAPL US Equity | 2024-01-02 | VOLUME | 45234521 |
| AAPL US Equity | 2024-01-03 | PX_LAST | 186.20 |
| … | … | … | … |
Bulk Data (BDS)
Section titled “Bulk Data (BDS)”Get multi-row data like dividends or index members:
# Dividend historydf = xbbg.bds('AAPL US Equity', 'DVD_Hist_All')
# Index membersdf = xbbg.bds('SPX Index', 'INDX_MEMBERS')Choose Your Backend
Section titled “Choose Your Backend”Return data in your preferred DataFrame format:
# Global settingxbbg.set_backend('polars')df = xbbg.bdp('AAPL US Equity', 'PX_LAST') # polars.DataFrame
# Per-call overridedf = xbbg.bdp('AAPL US Equity', 'PX_LAST', backend='pandas') # pandas.DataFrame
# Available backends: pandas, polars, pyarrow, duckdb, narwhalsAsync Support
Section titled “Async Support”For concurrent requests, use the async API:
import asyncioimport xbbg
async def main(): # Concurrent requests results = await asyncio.gather( xbbg.abdp('AAPL US Equity', 'PX_LAST'), xbbg.abdp('MSFT US Equity', 'PX_LAST'), xbbg.abdp('GOOGL US Equity', 'PX_LAST'), ) return results
dfs = asyncio.run(main())Next Steps
Section titled “Next Steps”- API Reference - Full function documentation
- DataFrame Backends - Learn about backend options
- Output Formats - Typed output formats