BloombergFetch
Python functionality for getting different data from Bloomberg: prices, implied vols, fundamentals
Install / Use
/learn @ArturSepp/BloombergFetchREADME
bbg-fetch
Bloomberg data in DataFrames. No boilerplate. No bloat.
bbg-fetch gives you clean, production-ready functions for the Bloomberg data you actually need — prices, fundamentals, vol surfaces, futures curves, bond analytics, index constituents — without writing event loops or managing sessions.
from bbg_fetch import fetch_field_timeseries_per_tickers
prices = fetch_field_timeseries_per_tickers(
tickers={'ES1 Index': 'SPX', 'TY1 Comdty': '10yUST'},
field='PX_LAST',
start_date=pd.Timestamp('2020-01-01')
)
# Returns a clean DataFrame with renamed columns, sorted index, split/div adjusted
Why bbg-fetch?
vs. raw blpapi
Writing Bloomberg queries with blpapi directly means 40–60 lines of session management, request construction, event-loop iteration, and response parsing — for every single query. You end up writing the same boilerplate wrapper in every project.
With blpapi:
import blpapi
opts = blpapi.SessionOptions()
opts.setServerHost('localhost')
opts.setServerPort(8194)
session = blpapi.Session(opts)
session.start()
session.openService('//blp/refdata')
service = session.getService('//blp/refdata')
request = service.createRequest('HistoricalDataRequest')
request.getElement('securities').appendValue('AAPL US Equity')
request.getElement('fields').appendValue('PX_LAST')
request.set('startDate', '20200101')
request.set('endDate', '20241231')
request.set('adjustmentNormal', True)
request.set('adjustmentAbnormal', True)
request.set('adjustmentSplit', True)
session.sendRequest(request)
# ... then 30 more lines to parse the event loop into a DataFrame
With bbg-fetch:
from bbg_fetch import fetch_field_timeseries_per_tickers
prices = fetch_field_timeseries_per_tickers(
tickers=['AAPL US Equity'],
field='PX_LAST',
start_date=pd.Timestamp('2020-01-01')
)
Same result. One line.
vs. xbbg
xbbg is a capable library, but its v1 rewrite introduced a Rust core, narwhals, and pyarrow>=22 as hard dependencies — over 30MB of transitive installs for what most quant teams use: bdp, bdh, and bds.
| | bbg-fetch | xbbg v1 |
|---|---|---|
| Dependencies | numpy + pandas | narwhals + pyarrow + Rust binary |
| Install size | ~50KB (plus blpapi) | ~30MB+ transitive |
| Python support | 3.9–3.12 | 3.10–3.14 |
| Intraday bars / streaming | No | Yes |
| Exchange-aware market hours | No | Yes |
| Session management | Automatic singleton | Configurable pool |
| Debug Bloomberg errors | Your code, 400 lines | Third-party internals |
bbg-fetch is for teams that need historical, reference, and bulk data — reliably, with minimal dependencies. If you need intraday bars or real-time streaming, use xbbg.
The sweet spot
bbg-fetch sits between raw blpapi (too low-level) and xbbg (too many dependencies). It wraps the three Bloomberg services that cover 95% of quant workflows — BDP, BDH, BDS — into high-level functions that return clean DataFrames with proper column naming, corporate action adjustments, and index alignment.
What you get
Multi-asset coverage
- Equities: Historical prices with split/dividend adjustments, fundamentals, dividend history
- Futures: Contract tables with carry analysis, active contract series, roll handling
- Options: Implied volatility surfaces (moneyness and delta), option chains
- Fixed Income: Bond pricing and analytics by ISIN, yield curves, CDS spreads
- FX: Currency rates and volatility
- Indices: Constituent weights, ISIN-to-ticker resolution
Production-ready details
- Dict-based ticker renaming:
{'ES1 Index': 'SPX'}→ DataFrame columns namedSPX - Automatic retry on Bloomberg connection flakes
- Corporate action adjustments on by default (normal, abnormal, splits)
- Predefined field mappings for vol surfaces (30d/60d/3m/6m/12m moneyness, delta)
- Carry computation built into futures contract tables
Installation
1. Install blpapi
pip install --index-url=https://blpapi.bloomberg.com/repository/releases/python/simple blpapi
Pre-built wheels for Python 3.8–3.12 on Windows/macOS/Linux bundle the C++ SDK automatically.
Corporate proxy? Download the .whl from https://blpapi.bloomberg.com/repository/releases/python/simple/blpapi/ via browser, then:
pip install /path/to/blpapi-3.24.6-cp312-cp312-win_amd64.whl
2. Install bbg-fetch
pip install bbg-fetch
Or from source:
git clone https://github.com/ArturSepp/BloombergFetch.git
pip install .
Requirements: Python 3.9+, Bloomberg Terminal running on the same machine.
Examples
Prices across tickers (with renaming)
import pandas as pd
from bbg_fetch import fetch_field_timeseries_per_tickers
# Pass a dict to auto-rename columns: Bloomberg ticker → your label
prices = fetch_field_timeseries_per_tickers(
tickers={'ES1 Index': 'SPX', 'TY1 Comdty': '10yUST', 'GC1 Comdty': 'Gold'},
field='PX_LAST',
start_date=pd.Timestamp('2015-01-01')
)
# DataFrame with columns ['SPX', '10yUST', 'Gold'], DatetimeIndex, sorted, adjusted
# Or pass a list — column names stay as Bloomberg tickers
prices = fetch_field_timeseries_per_tickers(
tickers=['AAPL US Equity', 'MSFT US Equity'],
field='PX_LAST',
start_date=pd.Timestamp('2020-01-01')
)
# Unadjusted prices (for futures, rates, etc.)
raw = fetch_field_timeseries_per_tickers(
tickers=['TY1 Comdty'], field='PX_LAST',
CshAdjNormal=False, CshAdjAbnormal=False, CapChg=False
)
Multiple fields for a single ticker
from bbg_fetch import fetch_fields_timeseries_per_ticker
# OHLC data
ohlc = fetch_fields_timeseries_per_ticker(
ticker='AAPL US Equity',
fields=['PX_OPEN', 'PX_HIGH', 'PX_LOW', 'PX_LAST'],
start_date=pd.Timestamp('2023-01-01')
)
# Futures-specific fields
fut_data = fetch_fields_timeseries_per_ticker(
ticker='ES1 Index',
fields=['PX_LAST', 'FUT_DAYS_EXP'],
CshAdjNormal=False, CshAdjAbnormal=False, CapChg=False
)
Company fundamentals
from bbg_fetch import fetch_fundamentals
# Basic security info
info = fetch_fundamentals(
tickers=['AAPL US Equity', 'GOOGL US Equity'],
fields=['security_name', 'gics_sector_name', 'crncy', 'market_cap']
)
# Fund-level data
fund_info = fetch_fundamentals(
tickers=['HAHYIM2 HK Equity'],
fields=['name', 'front_load', 'back_load', 'fund_mgr_stated_fee', 'fund_min_invest']
)
# Dict-based renaming works for both tickers and fields
info = fetch_fundamentals(
tickers={'AAPL US Equity': 'Apple', 'MSFT US Equity': 'Microsoft'},
fields={'security_name': 'Name', 'gics_sector_name': 'Sector'}
)
Balance sheet and credit metrics
from bbg_fetch import fetch_balance_data
credit = fetch_balance_data(
tickers=['ABI BB Equity', 'T US Equity', 'JPM US Equity'],
fields=('GICS_SECTOR_NAME', 'TOT_COMMON_EQY', 'BS_LT_BORROW',
'NET_DEBT_TO_EBITDA', 'INTEREST_COVERAGE_RATIO',
'FREE_CASH_FLOW_MARGIN', 'EARN_YLD')
)
Current market prices
from bbg_fetch import fetch_last_prices
from bbg_fetch.core import FX_DICT
# FX rates (uses built-in FX_DICT by default: 19 major pairs)
fx = fetch_last_prices()
# Custom tickers
prices = fetch_last_prices(tickers=['AAPL US Equity', 'SPX Index', 'USGG10YR Index'])
# With renaming
prices = fetch_last_prices(
tickers={'ES1 Index': 'SPX Fut', 'TY1 Comdty': '10y Fut', 'GC1 Comdty': 'Gold Fut'}
)
Implied volatility surface
from bbg_fetch import fetch_vol_timeseries, IMPVOL_FIELDS_DELTA
from bbg_fetch.core import (IMPVOL_FIELDS_MNY_30DAY, IMPVOL_FIELDS_MNY_60DAY,
IMPVOL_FIELDS_MNY_3MTH, IMPVOL_FIELDS_MNY_6MTH,
IMPVOL_FIELDS_MNY_12M)
# Delta-based vol for FX (1M and 2M, 10Δ to 50Δ puts and calls)
fx_vol = fetch_vol_timeseries(
ticker='EURUSD Curncy',
vol_fields=IMPVOL_FIELDS_DELTA,
start_date=pd.Timestamp('2023-01-01')
)
# Returns: spot_price, div_yield, rf_rate + all vol columns
# Full moneyness surface across 5 tenors (30d, 60d, 3m, 6m, 12m × 9 strikes)
eq_vol = fetch_vol_timeseries(
ticker='SPX Index',
vol_fields=[IMPVOL_FIELDS_MNY_30DAY, IMPVOL_FIELDS_MNY_60DAY,
IMPVOL_FIELDS_MNY_3MTH, IMPVOL_FIELDS_MNY_6MTH,
IMPVOL_FIELDS_MNY_12M],
start_date=pd.Timestamp('2010-01-01')
)
# Single tenor with raw field names (no renaming)
vol_30d = fetch_vol_timeseries(
ticker='SPX Index',
vol_fields=['30DAY_IMPVOL_100.0%MNY_DF', '30DAY_IMPVOL_90.0%MNY_DF'],
start_date=pd.Timestamp('2020-01-01')
)
Futures contract table with carry
from bbg_fetch import fetch_futures_contract_table
# Full contract table: prices, bid/ask, volume, OI, days to expiry, annualized carry
curve = fetch_futures_contract_table(ticker="ES1 Index")
# Nikkei futures
nk_curve = fetch_futures_contract_table(ticker="NK1 Index")
Active futures price series
from bbg_fetch import fetch_active_futures
# Front and second month continuous series
front, second = fetch_active_futures(generic_ticker='ES1 Index')
# Start from second generic (e.g., for roll analysis)
gen2, gen3 = fetch_active_futures(generic_ticker='ES1 Index', first_gen=2)
Futures ticker utilities
from bbg_fetch import instrument_to_active_ticker, contract_to_instrument
# ES1 Index → ES
instrument_to_active_ticker('ES1 Index', num=3) # → 'ES3 Index'
contract_to_instrument(
