Downloading Bloomberg data with findatapy

If I say burger, you’ll probably think of several things, maybe McDonald’s or Burger King for starters. They are the ubiquitous purveyors of all things burger related wherever you are in the world. Sure, there are other burger joints, but they don’t have the same wide reach as the massive chains like Burger King. I might prefer other burgers in practice, but I know wherever I am in the world I can get a reasonable quality burger at Burger King for a good price.


The burger industry is not unique from this perspective! It’s also very true of finance. If I think of financial data, there’s likely a handful of firms that I’m likely to think of, notably Bloomberg and Refinitiv. They don’t necessarily have every single dataset under the sun, but they do a have a very wide selection. The most common way to interact with Bloomberg data is via the Bloomberg Terminal, and there are several hundred thousand terminals worldwide to plot and crunch this data. On many terminals, you also often have the Bloomberg Excel API, which makes it relatively straightforward to download data in spreadsheets.


If you’re using Python, to do some more involved number crunching, what are the choices to download Bloomberg data? There are quite a few different choices. I won’t go through all of them (eg. BPIPE, Bloomberg Data Licence etc.) and instead I’ll focus on a few I’ve tried. There are also different licensing models for different APIs and how the data is used. One choice is installing Bloomberg’s Python API blpapi, on a machine with a Bloomberg terminal (and indeed there are versions of several languages as well as Python like Java). Like the Excel API, this let’s you access reference data, historical data, intraday tick and bar data, via different calls. A newer product is BQuant, which is basically like a Jupyter notebook inside a Bloomberg Terminal, which let’s you make queries on Bloomberg data via Python through BQL (Bloomberg Query Language) similar in idea (but different syntax to) SQL, or you can make these queries in a more Pythonic way. The advantage is that in some cases, the calculations are don’t on the Bloomberg cloud, so data is not downloaded to your machine, instead you just get the results.


For many data scientists, however, you might wish to comingle Bloomberg data with other data sources from other vendors, for many reasons and also use your own tech stack for the analysis too. One example, can be to compare the the same data type (eg. EURUSD spot prices) between different vendors. Another can be that your data might only be available elsewhere. It can be tricky to combine the data, because each vendor has a different API, which is called in a different way. If you are not careful, your code will end up being a real mess, where the various vendor API calls are mixed in with your analysis. The solution is a higher level data API, which has a common way of interacting with the user, but underneath it calls each different data vendor API. Hence, you can concentrate on analysing data, rather than remembering how to call each vendor specific API, and you abstract away the vendor specific interaction.


Many financial firms have such common API libraries that are used internally. However, maintaining and developing such a higher level data API can be expensive and time consuming, even if it really doesn’t contain anything proprietary. It’s one of the reasons I open sourced my own findatapy library, which does exactly this. I wanted to make it easier to do market analysis and backtesting, and to separate out any vendor specific API calls (and hopefully only write once).


findatapy supports downloading data from many different data vendors, including Bloomberg. It also has support for ticker mapping. So you can define your own tickers, which map on to vendor specific tickers, which could be more difficult to remember. You can also define categories of tickers. It also comes built in with a few ticker mappings for FX. findatapy is used extensively in finmarketpy to construct total return indices and analysis for FX spot, FX forwards and FX options, in particular when working with Bloomberg data with only a few lines of code.


You can also construct your market data queries with findatapy using MarketDataRequest objects, as strings or even as JSON. Below we give an example where we download VIX index from Bloomberg, when we construct our query as a string. This Jupyter notebook goes into more detail about all the various ways to construct queries for downloading market data.


df = market.fetch_market(" Index", start_date='week')


For Bloomberg, I’ve written a layer of abstraction on top of blpapi, so you can download daily, intraday and tick data using the exact same findatapy API, rather than having to do the different underlying API calls in blpapi (which you would need to do if you called blpapi directly). So for our VIX index example, we just make the freq field as intraday. That’s all!


df = market.fetch_market(" Index.freq.intraday", start_date='week')


Another feature I’ve written specifically for Bloomberg in findatapy, is some functionality that makes it very easy to add Bloomberg override parameters. In this findatapy Python example, I show how you can download advance, preliminary and final US GDP, which typically requires the use of override parameters (for the same Bloomberg ticker), but these have been defined in the configuration file earlier, and we simply need to include the words “GDP” along with “Advance”, “Preliminary” and “Final” for findatapy to automatically apply these.


For anyone in financial markets, we know that Bloomberg has lots of data! The question is what are the best ways to interact with it if you want to do some heavy duty analysis, as opposed to purely using the terminal, which typically involve some element of coding. There are many ways of accessing it in Python, ranging from calling blpapi directly or using the BQuant tool. However, one choice I’d definitely suggest trying is also findatapy, my own open source data library which wraps nicely on top of blpapi. If you’re interested in me adding more functionality to findatapy, such as support for other data vendors and types, please do let me know! I’m always looking for contributors as well to my open source library.