Main Content

timeseries

Intraday tick data for Bloomberg connection V3

Description

example

d = timeseries(c,s,date) retrieves raw tick data using the connection object and a security for a specific date.

example

d = timeseries(c,s,date,interval,field) retrieves raw tick data that is aggregated into intervals for a specific field.

example

d = timeseries(c,s,date,[],field,options,values) retrieves raw tick data without an aggregation interval for a specific field with the specified options and corresponding values.

example

d = timeseries(c,s,{startdate,enddate}) retrieves raw tick data for a date range using a start date and an end date.

example

d = timeseries(c,s,{startdate,enddate},interval,field) retrieves raw tick data for a specific date range aggregated into intervals for a specific field.

example

d = timeseries(c,s,{startdate,enddate},[],field) retrieves raw tick data for a specific date range without an aggregation interval for a specific field.

example

d = timeseries(c,s,{startdate,enddate},[],field,options,values) retrieves raw tick data for a specific date range without an aggregation interval for a specific field with specified options and corresponding values.

example

d = timeseries(c,s,{startdate:enddate,starttime,endtime},interval) retrieves raw trade tick data for a specific time range for each day within a specific date range, aggregated into intervals.

example

d = timeseries(c,s,{startdate:enddate,starttime,endtime},interval,field) uses a specific field for tick data to return.

example

d = timeseries(c,s,{startdate:dayincrement:enddate,starttime,endtime},interval) retrieves raw trade tick data for a whole day increment within a specific date and time range, aggregated into intervals.

example

d = timeseries(c,s,{startdate:dayincrement:enddate,starttime,endtime},interval,field) uses a specific field for tick data to return.

Examples

collapse all

First, create a Bloomberg® Desktop connection. Then, retrieve tick data for a specific date. Use a security with and without a pricing source to retrieve tick data.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE® using bpipe.

Retrieve the trade tick series using the IBM® security for today.

d = timeseries(c,'IBM US Equity',floor(now))
d = 

    'TRADE'    [735537.40]    [181.69]    [100.00]
    'TRADE'    [735537.40]    [181.69]    [100.00]
    'TRADE'    [735537.40]    [181.68]    [100.00]
    ...

The columns in d are:

  • Tick type

  • Numeric representation of the date and time

  • Tick value

  • Tick size

Here, the first row shows that 100 IBM shares sold for $181.69 today.

Retrieve the trade tick series using the Microsoft® security with pricing source ETPX for today.

d = timeseries(c,'MSFT@ETPX US Equity',floor(now))
d = 

    'TRADE'    [735537.40]    [35.53]    [100.00]
    'TRADE'    [735537.40]    [35.55]    [200.00]
    'TRADE'    [735537.40]    [35.55]    [100.00]
    ...

Here, the first row shows that 100 Microsoft shares are sold for $35.53 today.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve tick data for a specific date. Specify the tick data to return using a time interval and field.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Retrieve the trade tick series using the IBM security aggregated into 5-minute intervals for today.

d = timeseries(c,'IBM US Equity',floor(now),5,'Trade')
d =

  Columns 1 through 7

   735537.40        181.69        181.99        180.10        181.84     252322.00        861.00
   735537.40        181.90        181.97        181.57        181.65      78570.00        535.00
   735537.40        181.73        182.18        181.58        182.07     124898.00        817.00
     ...

  Column 8

   45815588.00
   14282076.00
   22710954.00
   ...

The columns in d contain the following:

  • Numeric representation of date and time

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume of ticks

  • Number of ticks

  • Total tick value in the bar

Here, the first row of data shows prices and tick data for the current date. The next row shows tick data for 5 minutes later.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve tick data for a specific date and field. Use option and value to return additional data.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Retrieve the trade tick series using the 'F US Equity' security without specifying the aggregation parameter for today. Also, return the condition codes.

d = timeseries(c,'F US Equity',floor(now),[],'Trade',...
               'includeConditionCodes','true')
d =

    'TRADE'    [735556.57]    [17.12]    [   100.00]    'R6,IS'  
    'TRADE'    [735556.57]    [17.12]    [   100.00]    ''       
    'TRADE'    [735556.57]    [17.12]    [   500.00]    ''       
    ...

The columns in d contain the following:

  • Tick type

  • Numeric representation of the date and time

  • Tick value

  • Tick size

  • Condition codes

Here, the first row shows that 100 'F US Equity' security shares sold for $17.12 today.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve tick data for a specific date range.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Retrieve the tick series for the 'F US Equity' security for the last business day from the beginning of the day to noon.

d = timeseries(c,'F US Equity',{floor(now-4),floor(now-3.5)})
d =

    'TRADE'    [735552.67]    [17.09]    [   200.00]
    'TRADE'    [735552.67]    [17.09]    [   100.00]
    'TRADE'    [735552.67]    [17.09]    [   100.00]
   ...

The columns in d are:

  • Tick type

  • Numeric representation of the date and time

  • Tick value

  • Tick size

Here, the first row shows that 200 'F US Equity' security shares were sold for $17.09 on the last business day.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve tick data for a specific date range. Specify the interval and field.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Retrieve the trade tick series for the past 50 days for the IBM security aggregated into 5-minute intervals.

d = timeseries(c,'IBM US Equity',{floor(now)-50,floor(now)},5,'Trade')
ans =

  Columns 1 through 7

   735487.40        187.20        187.60        187.02        187.08     207683.00        560.00
   735487.40        187.03        187.13        186.65        186.78      46990.00        349.00
   735487.40        186.78        186.78        186.40        186.47      51589.00        399.00
     ...

Column 8

   38902968.00
    8779374.00
    9626896.00
   ...

The columns in d contain the following:

  • Numeric representation of date and time

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume of ticks

  • Number of ticks

  • Total tick value in the bar

The first row of data shows prices and tick data for the current date. The next row shows tick data for 5 minutes later.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve tick data for a specific date range and numerous fields.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Return the Bid, Ask, and trade tick series for the security 'F US Equity' for yesterday with a time interval at noon, without specifying the aggregation parameter.

d = timeseries(c,'F US Equity',{floor(now-1)+.5,floor(now-1)+.51},...
               [],{'Bid','Ask','Trade'})
d = 

    'TRADE'    [735550.50]    [16.71]    [100.00]
    'ASK'      [735550.50]    [16.71]    [312.00]
    'BID'      [735550.50]    [16.70]    [177.00]
    ...

The columns in d are:

  • Tick type

  • Numeric representation of the date and time

  • Tick value

  • Tick size

Here, the first row shows that 100 'F US Equity' security shares sold for $16.71 yesterday.

Close the Bloomberg connection.

close(c)

First, create a Bloomberg Desktop connection. Then, retrieve tick data for a specific date range. Specify options and values to return additional data.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE using bpipe.

Return the trade tick series for the security 'F US Equity' for yesterday with a time interval at noon, without specifying the aggregation parameter. Also, return the condition codes, exchange codes, and broker codes.

d = timeseries(c,'F US Equity',{floor(now-1)+.5,floor(now-1)+.51},...
               [],'Trade',{'includeConditionCodes',...
               'includeExchangeCodes','includeBrokerCodes'},...
               {'true','true','true'})
d = 

    'TRADE'    [735550.50]    [16.71]    [100.00]    'T'     'D'
    'TRADE'    [735550.50]    [16.70]    [400.00]    'IS'    'B'
    'TRADE'    [735550.50]    [16.70]    [100.00]    'IS'    'B'
    ...

The columns in d contain the following:

  • Tick type

  • Numeric representation of the date and time

  • Tick value

  • Tick size

  • Exchange condition codes

  • Exchange codes

Broker codes are available for Canadian, Finnish, Mexican, Philippine, and Swedish equities only. In this case, the broker buy code appears in the seventh column and the broker sell code appears in the eighth column.

Here, the first row shows that 100 'F US Equity' security shares sold for $16.71 yesterday.

Close the Bloomberg connection.

close(c)

Use Bloomberg® to retrieve raw trade tick data by specifying a time range for each day in a specific date range. Specify the time interval for the tick data.

Create the Bloomberg® connection.

c = blp;

Alternatively, you can connect to Bloomberg® Server using blpsrv or Bloomberg® B-PIPE® using bpipe.

Retrieve the trade tick series for the 'F US Equity' security for the last two days. Use the time range from the beginning of the trading day through noon. Retrieve tick data aggregated into 5-minute intervals. d is a numeric matrix.

s = 'F US Equity';
startdate = datetime('today')-1;
enddate = datetime('today');
starttime = "09:30:00";
endtime = "12:00:00";
interval = 5;

d = timeseries(c,s,{startdate:enddate,starttime,endtime},interval);

Set the display output for currency.

format bank

Display the first three ticks.

d(1:3,:)
ans =

  Columns 1 through 5

     736959.40         11.71         11.81         11.71         11.79
     736959.40         11.79         11.81         11.75         11.79
     736959.40         11.80         11.82         11.78         11.80

  Columns 6 through 8

    1375547.00       1190.00   16196757.00
     598924.00        898.00    7058724.00
     488655.00        641.00    5768371.50

The columns in d are:

  • Numeric representation of date and time

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume of ticks

  • Number of ticks

  • Total tick value in the bar

The first row shows tick data at the start time of the time range. The next row shows tick data for 5 minutes later.

Determine the maximum high price for the last two days.

highprices = d(:,3);
m = max(highprices)
m =

         11.82

Close the Bloomberg® connection.

close(c)

Use Bloomberg® to retrieve raw tick data by specifying a time range for each day in a specific date range. Specify the time interval and the field for the type of tick data to return. Here, specify the bid tick data.

Create the Bloomberg® connection.

c = blp;

Alternatively, you can connect to Bloomberg® Server using blpsrv or Bloomberg® B-PIPE® using bpipe.

Retrieve the tick series for the 'F US Equity' security for the last two days. Use the time range from the beginning of the trading day through noon. Retrieve tick data aggregated into 5-minute intervals. Specify retrieving the bid tick series. d is a numeric matrix.

s = 'F US Equity';
startdate = datetime('today')-1;
enddate = datetime('today');
starttime = "09:30:00";
endtime = "12:00:00";
interval = 5;
field = 'BID';

d = timeseries(c,s,{startdate:enddate,starttime,endtime},interval,field);

Set the display output for currency.

format bank

Display the first three ticks.

d(1:3,:)
ans =

  Columns 1 through 5

     736959.40         11.70         11.80         11.70         11.79
     736959.40         11.79         11.80         11.75         11.79
     736959.40         11.79         11.81         11.78         11.80

  Columns 6 through 8

     397711.00       1442.00    4681704.50
     450997.00       1698.00    5311330.50
     464761.00       1391.00    5481707.50

The columns in d are:

  • Numeric representation of date and time

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume of ticks

  • Number of ticks

  • Total tick value in the bar

The first row shows tick data at the start time of the time range. The next row shows tick data for 5 minutes later.

Determine the maximum high price for the last two days.

highprices = d(:,3);
m = max(highprices)
m =

         11.81

Close the Bloomberg® connection.

close(c)

Use Bloomberg® to retrieve raw trade tick data by specifying a time range for each day in a specific date range. Specify a day increment for the date range and the time interval for the tick data.

Create the Bloomberg® connection.

c = blp;

Alternatively, you can connect to Bloomberg® Server using blpsrv or Bloomberg® B-PIPE® using bpipe.

Retrieve the trade tick series for the 'IBM US Equity' security for the last two months. Set the day increment to 5 days. Use the time range from the beginning of the trading day through noon. Retrieve tick data aggregated into 5-minute intervals. d is a numeric matrix.

s = 'IBM US Equity';
startdate = datetime('today')-60;
enddate = datetime('today');
dayincrement = 5;
starttime = "09:30:00";
endtime = "12:00:00";
interval = 5;

d = timeseries(c,s,{startdate:dayincrement:enddate,starttime,endtime}, ...
    interval);

Set the display output for currency.

format bank

Display the first three ticks.

d(1:3,:)
ans =

  Columns 1 through 5

     736900.40        147.00        147.04        146.55        146.62
     736900.40        146.62        146.87        146.62        146.71
     736900.40        146.72        146.79        146.52        146.54

  Columns 6 through 8

     125558.00        393.00   18440146.00
      39535.00        258.00    5800969.00
      49659.00        314.00    7282961.00

The columns in d are:

  • Numeric representation of date and time

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume of ticks

  • Number of ticks

  • Total tick value in the bar

The first row shows tick data at the start time of the time range. The next row shows tick data for 5 minutes later.

After the tick data for the first day in the date range, d contains tick data for a trading day that is 5 days later.

Close the Bloomberg® connection.

close(c)

Use Bloomberg® to retrieve raw tick data by specifying a time range for each day in a specific date range. Specify a day increment for the date range, the time interval for the tick data, and the field for the type of tick data to return. Here, specify the bid tick data.

Create the Bloomberg® connection.

c = blp;

Alternatively, you can connect to Bloomberg® Server using blpsrv or Bloomberg® B-PIPE® using bpipe.

Retrieve the trade tick series for the 'F US Equity' security for the last two months. Set the day increment to 5 days. Use the time range from the beginning of the trading day through noon. Retrieve tick data aggregated into 5-minute intervals. Specify the bid tick series. d is a numeric matrix.

s = 'F US Equity';
startdate = datetime('today')-60;
enddate = datetime('today');
dayincrement = 5;
starttime = "09:30:00";
endtime = "12:00:00";
interval = 5;
field = 'BID';

d = timeseries(c,s,{startdate:dayincrement:enddate,starttime,endtime}, ...
    interval,field);

Set the display output for currency.

format bank

Display the first three ticks.

d(1:3,:)
ans =

  Columns 1 through 5

     736900.40         11.50         11.54         11.49         11.50
     736900.40         11.50         11.50         11.48         11.48
     736900.40         11.48         11.49         11.44         11.44

  Columns 6 through 8

     422305.00       1158.00    4863894.00
     575966.00       1180.00    6617854.00
     288147.00       1489.00    3305491.75

The columns in d are:

  • Numeric representation of date and time

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume of ticks

  • Number of ticks

  • Total tick value in the bar

The first row shows tick data at the start time of the time range. The next row shows tick data for 5 minutes later.

After the tick data for the first day in the date range, d contains tick data for a trading day that is 5 days later.

Close the Bloomberg® connection.

close(c)

Create a Bloomberg® connection, and then return intraday tick data. The timeseries function returns data for dates as a datetime array.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE® using bpipe.

Return data as a table by setting the DataReturnFormat property of the connection object. If you do not set this property, the timeseries function returns data as a numeric array.

Return dates as a datetime array by setting the DatetimeType property of the connection object. In this case, the table contains dates in variables that are datetime arrays.

c.DataReturnFormat = 'table';
c.DatetimeType = 'datetime';

Adjust the display format of the returned data for currency.

format bank

Retrieve the trade tick series for the IBM® security aggregated into 5-minute intervals for today. d is a table that contains the tick series data.

s = 'IBM US Equity';
date = floor(now);
interval = 5;
field = 'Trade';

d = timeseries(c,s,date,interval,field);

Access the first three ticks of data.

d(1:3,:)
ans =

  3×8 table

       DATE         OPEN      HIGH      LOW      CLOSE      VOLUME      NUMBER_OF_TICKS    TOTAL_VALUE
    ___________    ______    ______    ______    ______    _________    _______________    ___________

    21-Dec-2017    153.17    153.31    153.08    153.31    152524.00        442.00         23367632.00
    21-Dec-2017    153.35    153.35    152.82    152.84     46051.00        291.00          7048618.50
    21-Dec-2017    152.84    153.21    152.82    153.16     30966.00        225.00          4737307.50

d contains columns with the following data:

  • Date

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume

  • Number of ticks

  • Total tick value in the bar

Access the first three dates in the DATE column.

d.DATE(1:3)
ans = 

  3×1 datetime array

   21-Dec-2017
   21-Dec-2017
   21-Dec-2017

Close the Bloomberg connection.

close(c)

Create a Bloomberg® connection, and then return intraday tick data. The timeseries function returns data for dates as a timetable.

Create the Bloomberg connection.

c = blp;

Alternatively, you can connect to the Bloomberg Server using blpsrv or Bloomberg B-PIPE® using bpipe.

Return data as a timetable by setting the DataReturnFormat property of the connection object. If you do not set this property, the timeseries function returns data as a numeric array.

c.DataReturnFormat = 'timetable';

Adjust the display format of the returned data for currency.

format bank

Retrieve the trade tick series for the IBM® security aggregated into 5-minute intervals for today. d is a timetable that contains the tick series data.

s = 'IBM US Equity';
date = floor(now);
interval = 5;
field = 'Trade';

d = timeseries(c,s,date,interval,field);

Access the first three ticks of data.

d(1:3,:)
ans =

  3×7 timetable

       DATE         OPEN      HIGH      LOW      CLOSE      VOLUME      NUMBER_OF_TICKS    TOTAL_VALUE
    ___________    ______    ______    ______    ______    _________    _______________    ___________

    21-Dec-2017    153.17    153.31    153.08    153.31    152524.00        442.00         23367632.00
    21-Dec-2017    153.35    153.35    152.82    152.84     46051.00        291.00          7048618.50
    21-Dec-2017    152.84    153.21    152.82    153.16     30966.00        225.00          4737307.50

d is a timetable that contains the following data:

  • Date

  • Open price

  • High price

  • Low price

  • Closing price

  • Volume

  • Number of ticks

  • Total tick value in the bar

Close the Bloomberg connection.

close(c)

Input Arguments

collapse all

Bloomberg connection, specified as a connection object created using blp, blpsrv, or bpipe.

Security, specified as a character vector or string scalar for a single Bloomberg security.

Data Types: char | string

Date, specified as a numeric scalar, character vector, string scalar, or datetime array. date specifies the date for the returned tick data based on the entire day from midnight until 11:59:59 p.m.

Example: floor(now)

Data Types: double | char | string | datetime

Time interval, specified as a numeric scalar to denote the number of minutes between ticks for the returned tick data.

Data Types: double

Bloomberg field, specified as one of these values that define the tick data to return.

Request TypeValid Bloomberg Field Values

IntradayBarRequest with time interval specified

'TRADE'
'BID'
'ASK'
'BID_BEST'
'ASK_BEST'

IntradayTickRequest with no time interval specified

'TRADE'
'BID'
'ASK'
'BID_BEST'
'ASK_BEST'
'SETTLE'

Bloomberg API options, specified as one of the values in this table.

ValueDescription

'includeConditionCodes'

Exchange condition codes associated with the event

'includeExchangeCodes'

Exchange code where tick originated

'includeBrokerCodes'

Broker code

'includeRpsCodes'

Reporting party side

'includeNonPlottableEvents'

After-hours data

Note

The value 'includeNonPlottableEvents' applies to raw intraday requests only.

To specify more than one Bloomberg API option, use a cell array of these values.

Specify the corresponding Bloomberg API value for each API option. The number of options must match the number of values.

For example, to specify one Bloomberg API option, enter:

d = timeseries(c,'F US Equity',floor(now),[],'Trade',...
               'includeConditionCodes','true');

To specify two Bloomberg API options, enter:

d = timeseries(c,'F US Equity',floor(now),[],'Trade',...
               {'includeConditionCodes','includeExchangeCodes'},...
               {'true','true'});

For details about the options, see the Bloomberg API Developer’s Guide.

Data Types: char | cell

Bloomberg API values, specified as 'true' or 'false'. Each value corresponds to the specified Bloomberg API option. To specify more than one Bloomberg API value, use a cell array. The number of values must match the number of options.

For example, to specify one Bloomberg API option, enter:

d = timeseries(c,'F US Equity',floor(now),[],'Trade',...
               'includeConditionCodes','true');

To specify two Bloomberg API options, enter:

d = timeseries(c,'F US Equity',floor(now),[],'Trade',...
               {'includeConditionCodes','includeExchangeCodes'},...
               {'true','true'});

Data Types: char | cell

Start date, specified as a numeric scalar, character vector, string scalar, or datetime array. This date specifies the beginning of the date range for the returned tick data. If no ticks are present in the date range, then returned tick data is empty.

Example: floor(now-1)

Data Types: double | char | string | datetime

End date, specified as a numeric scalar, character vector, string scalar, or datetime array. This date specifies the end of the date range for the returned tick data. If no ticks are present in the date range, then returned tick data is empty.

Example: floor(now)

Data Types: double | char | string | datetime

Start time, specified as a character vector, string scalar, or datetime array. This time specifies the start time of the time range for the returned tick data.

Example: '09:30:00'

Data Types: char | string | datetime

End time, specified as a character vector, string scalar, or datetime array. This time specifies the end time of the time range for the returned tick data.

Example: '16:30:00'

Data Types: char | string | datetime

Day increment, specified as a numeric scalar. This number specifies the whole day increment for a specific date range. For example, if the day increment is 7, then the returned data contains ticks for every 7th day starting from the first day within the date range.

Data Types: double

Output Arguments

collapse all

Bloomberg tick data, returned as one of these data types:

  • Cell array for requests without a specified time interval (raw tick data)

  • Numeric array for requests with a specified time interval

  • table

  • timetable

The data type of the tick data depends on the DataReturnFormat and DatetimeType properties of the connection object.

Note

The Bloomberg API returns the tick time with precision in seconds.

Limitations

When the data request is too large, timeseries displays this error message:

Timeout error:
Error using blp/timeseries>processResponseEvent (line 338) REQUEST FAILED: responseError = {

source = bbdbl7

code = -2

category = TIMEOUT

message = Timed out getting data from store [nid:327]

subcategory = INTERNAL_ERROR

}

To fix this error, shorten the length of the date range by modifying the input arguments startdate and enddate.

Tips

  • For better performance, add the Bloomberg file blpapi3.jar to the MATLAB® static Java® class path by modifying the file $MATLAB/toolbox/local/javaclasspath.txt. For details about the static Java class path, see Static Path of Java Class Path.

  • You cannot retrieve Bloomberg intraday tick data for a date more than 140 days ago.

  • The Bloomberg API Developer’s Guide states that 'TRADE' corresponds to LAST_PRICE for IntradayTickRequest and IntradayBarRequest.

  • Bloomberg V3 intraday tick data supports additional name-value pairs. For details on these pairs, see the Bloomberg API Developer’s Guide by typing WAPI and clicking the <GO> button on the Bloomberg terminal.

  • You can check data and field availability by using the Bloomberg Excel® Add-In.

Version History

Introduced in R2010a