Retrieve Data Using Bloomberg Data License

This example shows how to retrieve Bloomberg® Data License data with a request file using a Bloomberg Data License connection. To create a successful Bloomberg connection, see Connect to Bloomberg. To access the code for this example, enter edit BloombergDataLicenseWorkflow.m.

Connect to Bloomberg Data License

Create the Bloomberg Data License connection c. This code assumes the following:

  • The Bloomberg Data License SFTP server login name is 'xxxxx'.

  • The Bloomberg Data License SFTP server password is 'xxxxxxxx'.

  • The Bloomberg Data License SFTP server name is 'dlsftp.bloomberg.com'.

  • The Bloomberg Data License SFTP port number is 30206.

  • The decryption code is 'nAcLeZ'.

username = 'xxxxx';
password = 'xxxxxxxx';
hostname = 'dlsftp.bloomberg.com';
portnumber = 30206;
decrypt = 'nAcLeZ';

c = bdl(username,password,hostname,portnumber,decrypt);

bdl connects to Bloomberg Data License at port number 30206 with password authentication.

Request Bloomberg Data File

Create a Bloomberg Data License request file getdatarequest.req using the Bloomberg Data License Request Builder. Submit the request file to Bloomberg Data License using c.

c.Connection.put('getdatarequest.req')

Retrieve the folder listing to see if the output file exists using c.

s = dir(c)
s = 

     'd--x--x--x    2 root     root         4096 Sep  5 11:25 bin'
     'dr--r--r--    2 root     root         4096 Sep  5 11:25 etc'
     '-rw-rw-rw-    2 op       general      1194 Sep 24 10:14 getdataoutput.out'
     ...

The output file getdataoutput.out is available.

Save the output file to the current folder. The first argument is the name of the generated output file from the Bloomberg Data License server. The second argument is the name of the saved file on the local machine.

c.Connection.get('getdataoutput.out','getdataoutput.out')

The current folder contains the output file getdataoutput.out.

If the file is encrypted, run the Bloomberg Data License decryption software. You can download the decryption software from Bloomberg. For questions, contact Bloomberg.

!des -D -u -k "pDyJaV" getdataoutput.out  getdataoutput.dat

Import Bloomberg Data into MATLAB

Convert the contents of the output file to a MATLAB® structure using the sample function bdlloader.

d = bdlloader('getdataoutput.out')
d = 
 
          Header: [1x1 struct]
      Identifier: {4x1 cell}
           Rcode: {4x1 cell}
         Nfields: {4x1 cell}
         PX_OPEN: {4x1 cell}
         PX_LAST: {4x1 cell}
         PX_HIGH: {4x1 cell}
          PX_LOW: {4x1 cell}
     PX_CLOSE_DT: {4x1 cell}

d is a structure with these fields:

  • Output file header information

  • Security identifier

  • Return code

  • Number of fields requested and received

  • Open price

  • Last price

  • High price

  • Low price

  • Date of last close

To access the code for bdlloader, see bdlloader.m.

Display the output file header information.

d.Header
ans = 
 
            RUNDATE: '20140924'
        PROGRAMFLAG: 'oneshot'
           FIRMNAME: 'xxxxx'
           FILETYPE: 'pc'
      REPLYFILENAME: 'getdataoutput.out'
     PRICING_SOURCE: 'BVAL'
      CLOSINGVALUES: 'yes'
              SECID: 'TICKER'
          YELLOWKEY: 'Equity'
        PROGRAMNAME: 'getdata'
        TIMESTARTED: 'Wed Sep 24 10:19:59 EDT 2014'
       TIMEFINISHED: 'Wed Sep 24 10:20:17 EDT 2014'

Close Bloomberg Data License Connection

close(c)

See Also

| |

Related Examples

More About