1
votes

from xbbg import blp works for equity but does not work for bonds.

I use this pip library: https://pypi.org/project/xbbg/

I do the following imports.

import blpapi
from xbbg import blp

I then run the following test for an equity:

# this works
eqData = blp.bdh(
    tickers='SPX Index', flds=['high', 'low', 'last_price'],
    start_date='2018-10-10', end_date='2018-10-20',
    )

print(eqData)

This works and produces the expected dataframe.

I do exactly the same for a corporate bond:

# this returns empty
bondData = blp.bdh(
    tickers='XS1152338072 Corp', flds=['px_bid', 'px_ask'],
    start_date='2019-10-10', end_date='2018-10-20',
    )

print(bondData)

This fails (produces an empty dataFrame), even though the data exists.

Here is the result (an empty DataFrame):

getting bond data...
Empty DataFrame
Columns: []
Index: []

Also note that i can get the BDP function to work for bonds. why can i not get the BDH function to work ?

1

1 Answers

1
votes

it appears as though the start date (year) was after the end date. ie. change 2019 to 2018.

start_date='2019-10-10', end_date='2018-10-20'

corrects to

start_date='2012-10-10', end_date='2018-10-20',

This produces the expected dataFrame.