Search code examples
pythonbloombergblpapi

How can I start Bloomberg API in python?


I managed to install blpapi in my python. However, there is error Exception: failed to start session My simple code is as follows.

import blpapi
import pandas as pd
import tia.bbg.datamgr as dm

mgr = dm.BbgDataManager()
sids = mgr['MSFT US EQUITY', 'IBM US EQUITY', 'CSCO US EQUITY']
df = sids.get_historical('PX_LAST', '1/1/2014', '11/12/2014')

What Can I do with this? Can you help?


Solution

  • Please clarify which IP and port you're attempting to connect to.

    If connecting to the local process 'bbcomm.exe' then the IP is 127.0.0.1 (localhost) and port 8194. Check if bbcomm.exe process is running (e.g. in Task Manager) if not then start it manually by typing bbcomm.exe in CMD, or by launching Excel with one or more BDP() functions. Make sure the Bloomberg Terminal is running.

    If you are connecting to a remote host (e.g. B-Pipe or ServerApi) then check if the port is reachable: telnet