API Reference¶
-
class
pdblp.pdblp.
BCon
(host='localhost', port=8194, debug=False, timeout=500)¶ -
bdh
(tickers, flds, start_date, end_date, elms=[], ovrds=[], longdata=False)¶ Get tickers and fields, return pandas Dataframe with columns as MultiIndex with levels “ticker” and “field” and indexed by “date”. If long data is requested return DataFrame with columns [“date”, “ticker”, “field”, “value”].
- tickers: {list, string}
- String or list of strings corresponding to tickers
- flds: {list, string}
- String or list of strings corresponding to FLDS
- start_date: string
- String in format YYYYmmdd
- end_date: string
- String in format YYYYmmdd
- elms: list of tuples
- List of tuples where each tuple corresponds to the other elements to be set, e.g. [(“periodicityAdjustment”, “ACTUAL”)]. Refer to the HistoricalDataRequest section in the ‘Services & schemas reference guide’ for more info on these values
- ovrds: list of tuples
- List of tuples where each tuple corresponds to the override field and value
- longdata: boolean
- Whether data should be returned in long data format or pivoted
-
bdib
(ticker, start_datetime, end_datetime, event_type, interval, elms=[])¶ Get Open, High, Low, Close, Volume, and numEvents for a ticker. Return pandas dataframe
- ticker: string
- String corresponding to ticker
- start_datetime: string
- UTC datetime in format YYYY-mm-ddTHH:MM:SS
- end_datetime: string
- UTC datetime in format YYYY-mm-ddTHH:MM:SS
- event_type: string {TRADE, BID, ASK, BID_BEST, ASK_BEST, BEST_BID,
- BEST_ASK}
Requested data event type
- interval: int {1… 1440}
- Length of time bars
- elms: list of tuples
- List of tuples where each tuple corresponds to the other elements to be set. Refer to the IntradayBarRequest section in the ‘Services & schemas reference guide’ for more info on these values
-
bsrch
(domain)¶ This function uses the Bloomberg API to retrieve ‘bsrch’ (Bloomberg SRCH Data) queries. Returns list of tickers.
domain: string A character string with the name of the domain to execute. It can be a user defined SRCH screen, commodity screen or one of the variety of Bloomberg examples. All domains are in the format <domain>:<search_name>. Example “COMDTY:NGFLOW” Returns ——- data: pandas.DataFrame List of bloomberg tickers from the BSRCH
-
bulkref
(tickers, flds, ovrds=[])¶ Make a bulk reference data request, get tickers and fields, return long pandas Dataframe with columns [ticker, field, name, value, position]. Name refers to the element name and position is the position in the corresponding array returned.
- tickers: {list, string}
- String or list of strings corresponding to tickers
- flds: {list, string}
- String or list of strings corresponding to FLDS
- ovrds: list of tuples
- List of tuples where each tuple corresponds to the override field and value
>>> import pdblp >>> con = pdblp.BCon() >>> con.start() >>> con.bulkref('BCOM Index', 'INDX_MWEIGHT')
This returns bulk reference data which has array values. In raw format the messages passed back contain data of the form
- fieldData = {
- INDX_MWEIGHT[] = {
- INDX_MWEIGHT = {
- Member Ticker and Exchange Code = “BON8” Percentage Weight = 2.410000
} INDX_MWEIGHT = {
Member Ticker and Exchange Code = “C N8” Percentage Weight = 6.560000} INDX_MWEIGHT = {
Member Ticker and Exchange Code = “CLN8” Percentage Weight = 7.620000}
}
}
-
bulkref_hist
(tickers, flds, dates, ovrds=[], date_field='REFERENCE_DATE')¶ Make iterative calls to bulkref() and create a long dataframe with columns [date, ticker, field, name, value, position] where each date corresponds to overriding a historical data override field.
- tickers: {list, string}
- String or list of strings corresponding to tickers
- flds: {list, string}
- String or list of strings corresponding to FLDS
- dates: list
- list of date strings in the format YYYYmmdd
- ovrds: list of tuples
- List of tuples where each tuple corresponds to the override field and value. This should not include the date_field which will be iteratively overridden
- date_field: str
- Field to iteratively override for requesting historical data, e.g. REFERENCE_DATE, CURVE_DATE, etc.
>>> import pdblp >>> con = pdblp.BCon() >>> con.start() >>> dates = ["20160625", "20160626"] >>> con.bulkref_hist("BVIS0587 Index", "CURVE_TENOR_RATES", dates, ... date_field="CURVE_DATE")
-
debug
¶ When True, print all Bloomberg Open API request and response messages to stdout
-
ref
(tickers, flds, ovrds=[])¶ Make a reference data request, get tickers and fields, return long pandas Dataframe with columns [ticker, field, value]
- tickers: {list, string}
- String or list of strings corresponding to tickers
- flds: {list, string}
- String or list of strings corresponding to FLDS
- ovrds: list of tuples
- List of tuples where each tuple corresponds to the override field and value
>>> import pdblp >>> con = pdblp.BCon() >>> con.start() >>> con.ref("CL1 Comdty", ["FUT_GEN_MONTH"])
This returns reference data which has singleton values. In raw format the messages passed back contain data of the form
- fieldData = {
- FUT_GEN_MONTH = “FGHJKMNQUVXZ”
}
-
ref_hist
(tickers, flds, dates, ovrds=[], date_field='REFERENCE_DATE')¶ Make iterative calls to ref() and create a long dataframe with columns [date, ticker, field, value] where each date corresponds to overriding a historical data override field.
- tickers: {list, string}
- String or list of strings corresponding to tickers
- flds: {list, string}
- String or list of strings corresponding to FLDS
- dates: list
- list of date strings in the format YYYYmmdd
- ovrds: list of tuples
- List of tuples where each tuple corresponds to the override field and value. This should not include the date_field which will be iteratively overridden
- date_field: str
- Field to iteratively override for requesting historical data, e.g. REFERENCE_DATE, CURVE_DATE, etc.
>>> import pdblp >>> con = pdblp.BCon() >>> con.start() >>> dates = ["20160625", "20160626"] >>> con.ref_hist("AUD1M CMPN Curncy", "SETTLE_DT", dates)
-
restart
()¶ Restart the blp session
-
start
()¶ start connection and init service for refData
-
stop
()¶ Close the blp session
-