关于xbbg库bdib()函数获取彭博10秒间隔日内数据及解决“Cannot find exchange info for tickername”报错的咨询
Hey Leo, let's work through your two problems step by step:
1. Fixing "Cannot find exchange info for tickername" Error
This error almost always stems from an incomplete ticker format. The xbbg package requires full Bloomberg ticker strings that include both the exchange code and security type suffix. Using a short ticker like just AAPL won't work—you need to specify something like AAPL US Equity (Apple stock on the US exchange) or EURUSD Curncy (EUR/USD currency pair).
Here's how to resolve this:
- Use the full ticker format: Replace
tickernamewith a valid Bloomberg ticker that includes exchange and type. For example:from xbbg import blp blp.bdib(ticker='AAPL US Equity', dt='2021-02-22') - Verify ticker validity: If you're unsure about the correct ticker, use Bloomberg Terminal's
FLDSfunction, or check withxbbgitself usingblp.ref():# Confirm a ticker's validity and get its name blp.ref('AAPL US Equity', 'NAME') - Check Bloomberg connection: Ensure your Bloomberg Terminal is logged in, and that
xbbgis properly configured (verify yourbbg.cfgfile has the correct path to Bloomberg's API installation).
2. Setting 10-Second Interval in bdib()
To pull intraday data at a 10-second frequency, use the interval parameter in bdib()—this accepts the interval length directly in seconds.
Here's the updated code:
from xbbg import blp # Fetch 10-second interval intraday data for 2021-02-22 df = blp.bdib(ticker='AAPL US Equity', dt='2021-02-22', interval=10)
If you need to filter data type (e.g., only trades or bid/ask quotes), add the typ parameter—like typ='TRADE' for trade data, or typ='BID'/typ='ASK' for quote data.
内容的提问来源于stack exchange,提问作者Leo Li

