Main Content

Connect to Bloomberg

This example shows how to create a connection to Bloomberg® using these Bloomberg services: Bloomberg Desktop, Bloomberg Server, and B-PIPE®. For details about Bloomberg connection requirements, see Data Server Connection Requirements. To ensure a successful Bloomberg connection, perform the required steps before executing a connection function. For details, see Installing Bloomberg and Configuring Connections.

Create the Bloomberg Desktop Connection

c = blp
c = 
  blp with properties:
      session: [1x1 com.bloomberglp.blpapi.Session]
    ipaddress: 'localhost'
         port: 8194
      timeout: 0

blp creates a Bloomberg connection object c and returns its properties.

Validate the connection c.

v = isconnection(c)
v =

     1

v returns true showing that the Bloomberg connection is valid.

Retrieve the Bloomberg Desktop connection properties.

v = get(c)
v = 

      session: [1x1 com.bloomberglp.blpapi.Session]
    ipaddress: 'localhost'
         port: 8194
      timeout: 0

v is a structure containing the Bloomberg session object, IP address, port number, and timeout value.

Close the Bloomberg Desktop connection.

close(c)

Create the Bloomberg Server Connection

Connect to the Bloomberg Server using the IP addresses of the machine running the Bloomberg Server. This code assumes the following:

  • The Bloomberg UUID is 12345678.

  • The IP address serverip for the machine running the Bloomberg Server is '111.11.11.111'.

uuid = 12345678;
serverip = '111.11.11.111';

c = blpsrv(uuid,serverip)
c = 

  blpsrv with properties:

         uuid: 12345678
         user: [1x1 com.bloomberglp.blpapi.impl.aT]
      session: [1x1 com.bloomberglp.blpapi.Session]
    ipaddress: '111.11.11.111'
         port: 8195
      timeout: 0

blpsrv connects to the machine running the Bloomberg Server on the default port number 8195. blpsrv creates the Bloomberg Server connection object c.

Close the Bloomberg Server connection.

close(c)

Create the B-PIPE Connection

Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This code assumes the following:

  • The authentication is Windows® Authentication by setting authorizationtype to 'OS_LOGON'.

  • The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.

  • The IP address serverip for the machine running the Bloomberg B-PIPE process is '111.11.11.112'.

  • The port number is 8194.

authorizationtype = 'OS_LOGON';
applicationname = '';
serverip = {'111.11.11.112'};
portnumber = 8194;

c = bpipe(authorizationtype,applicationname,serverip,portnumber)
c = 

  bpipe with properties:

    appauthtype: ''
       authtype: 'OS_LOGON'
        appname: []
           user: [1x1 com.bloomberglp.blpapi.impl.aT]
        session: [1x1 com.bloomberglp.blpapi.Session]
      ipaddress: {'111.11.11.112'}
           port: 8194.00
        timeout: 0

bpipe connects to Bloomberg B-PIPE at the port number 8194. bpipe creates the Bloomberg B-PIPE connection object c.

Close the B-PIPE connection.

close(c)

See Also

| | | | |

Related Examples

More About