3
$\begingroup$

I am very new with python, and I am used to work with bloomberg formulas for excel. I am starting to use a lot more python in my analysis, is there any library that performs same functions as bdp, bdh or bcurve? Thanks! Juan

$\endgroup$
2
  • 1
    $\begingroup$ You can't use BCurve or any other DLIB functions in python. Not even in Bloomberg BQNT environment. A good alternative would be to use QuantLib. You can build curves and value instruments just like DLIB. $\endgroup$ Jun 2 '20 at 9:59
  • $\begingroup$ Bcurve is actually part of the curves toolkit (CTK) which is not related to DLIB. That said, the above comment is still correct. CTK, the swaps toolkit (STK) and the derivatives toolkit (DTK), cannot be used with blpapi (only premium data offerings would allow you to do this). $\endgroup$
    – AKdemy
    May 29 at 12:31
5
$\begingroup$

I have experimented with various choices quite a bit.

My advice is to use vanilla blpapi . There are many good examples in the git repository. Some helpful installation notes are also here .

There are packages built on top, such as pdblp that, in my opinion, are very good but not required by most people.

$\endgroup$
2
$\begingroup$

blpapi as mentioned it worth learning for sure. In addition to it, if you are looking to work with Pandas I would suggest using TIA: https://github.com/bpsmith/tia

At the moment, TIA is only compatible with Python 2, but here https://github.com/bpsmith/tia/issues/11 has a Python 3 conversion. I've been using this recently and it's pretty good. An example:

from tia.bbg import LocalTerminal
import tia.bbg.datamgr as dm
import datetime

sid = 'IBM US EQUITY'
event = 'TRADE'
dt = pd.datetools.BDay(-1).apply(pd.datetime.now())
start = pd.datetime.combine(dt, datetime.time(13, 30))
end = pd.datetime.combine(dt, datetime.time(21, 30))
f = LocalTerminal.get_intraday_bar(sid, event, start, end, 
interval=60).as_frame()
f.head(1)

      close     high    low   numEvents   open      time                value   volume
0   162.2500    162.70  161.51  4005    162.4900    2015-02-24 14:30:00  110345672  680888

The github link above has loads of examples, too.

$\endgroup$
2
$\begingroup$

I normally use pybbg which is also a wrapper for blpapi.

With a logged in Bloomberg session, just import it and start a connection

import pybbg as pybbg
bbg = pybbg.Pybbg()

Then you can use bdp, bdh, bds and bdih.

bdp

bbg.bdp('PGB 1.95 06/15/2029 Govt', ['MATURITY', 'COUPON', 'ISSUE_DT', 'YLD_YTM_MID'])

enter image description here

You can even query deals from SWPM...

pd.options.display.float_format = '{:,.2f}'.format
flds = ['SW_CURVE_DT', 'SW_MARKET_VAL', 'SW_CNV_BPV', 'VALUE_1_BP_CHANGE_IN_FIXED_CPN']
bbg.bdp('SLPA2EZJ Corp', flds)

enter image description here

...and provide overrides

flds = ['SW_CURVE_DT', 'SW_MARKET_VAL', 'SW_CNV_BPV', 'VALUE_1_BP_CHANGE_IN_FIXED_CPN']
overrides = {'SW_CURVE_DT': '20190507'}
bbg.bdp('SLPA2EZJ Corp', flds, overrides)

enter image description here

bdh

bbg.bdh('EUR Curncy', 'PX_LAST', '20200525')

enter image description here

bds

bbg.bds('YCSW0045 Index', 'CURVE_TENOR_RATES')

enter image description here

bdib

from datetime import  datetime
flds = ['close', 'high', 'low', 'open']
ticker = 'PGB 1.95 06/15/2029 Govt'
bbg.bdib(ticker, flds, datetime(2020,6,1,15,0), datetime(2020,6,1,15,30), eventType='ASK', interval = 5)

enter image description here

$\endgroup$
2
$\begingroup$

Ask your Bloomberg rep to enable you for BQNT access. They will push a Python instance to your machine and you can go to the terminal and run BQNT

You will get a Jupyter environment that can use Bloomberg data

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.