tahistory

Historical technical analysis for Bloomberg connection V3

Description

example

d = tahistory(c) returns the Bloomberg® V3 session technical analysis data study and element definitions.

example

d = tahistory(c,s,startdate,enddate,study,period,Name,Value) returns the Bloomberg V3 session technical analysis data study and element definitions with additional options specified by one or more name-value pair arguments.

Examples

collapse all

Return all available Bloomberg studies and use the DMI study to run a technical analysis for a security.

Create the Bloomberg connection.

c = blp;

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

List the available Bloomberg studies.

d = tahistory(c)
d =

         dmiStudyAttributes: [1x1 struct]
       smavgStudyAttributes: [1x1 struct]
        bollStudyAttributes: [1x1 struct]
         maoStudyAttributes: [1x1 struct]
          fgStudyAttributes: [1x1 struct]
         rsiStudyAttributes: [1x1 struct]
        macdStudyAttributes: [1x1 struct]
         tasStudyAttributes: [1x1 struct]
       emavgStudyAttributes: [1x1 struct]
      maxminStudyAttributes: [1x1 struct]
        ptpsStudyAttributes: [1x1 struct]
        cmciStudyAttributes: [1x1 struct]
        wlprStudyAttributes: [1x1 struct]
       wmavgStudyAttributes: [1x1 struct]
     trenderStudyAttributes: [1x1 struct]
         gocStudyAttributes: [1x1 struct]
        kltnStudyAttributes: [1x1 struct]
    momentumStudyAttributes: [1x1 struct]
         rocStudyAttributes: [1x1 struct]
         maeStudyAttributes: [1x1 struct]
       hurstStudyAttributes: [1x1 struct]
        chkoStudyAttributes: [1x1 struct]
          teStudyAttributes: [1x1 struct]
       vmavgStudyAttributes: [1x1 struct]
       tmavgStudyAttributes: [1x1 struct]
         atrStudyAttributes: [1x1 struct]
         rexStudyAttributes: [1x1 struct]
         adoStudyAttributes: [1x1 struct]
          alStudyAttributes: [1x1 struct]
         etdStudyAttributes: [1x1 struct]
         vatStudyAttributes: [1x1 struct]
        tvatStudyAttributes: [1x1 struct]
          pdStudyAttributes: [1x1 struct]
          rvStudyAttributes: [1x1 struct]
      ipmavgStudyAttributes: [1x1 struct]
       pivotStudyAttributes: [1x1 struct]
          orStudyAttributes: [1x1 struct]
         pcrStudyAttributes: [1x1 struct]
          bsStudyAttributes: [1x1 struct]

d contains structures pertaining to each available Bloomberg study.

Display the name-value pairs for the DMI study.

d.dmiStudyAttributes
ans = 

              period: [1x104 char]
     priceSourceHigh: [1x123 char]
      priceSourceLow: [1x121 char]
    priceSourceClose: [1x125 char]

Obtain more information about the period property.

d.dmiStudyAttributes.period
ans =

DEFINITION period {

    Min Value = 1

    Max Value = 1

    TYPE Int64

} // End Definition: period

Run the DMI study for the IBM® security for the last month with period equal to 14, the high price, the low price, and the closing price.

d = tahistory(c,'IBM US Equity',floor(now)-30,floor(now),'dmi',...
             'all_calendar_days','period',14,...
             'priceSourceHigh','PX_HIGH',...
             'priceSourceLow','PX_LOW','priceSourceClose','PX_LAST')
d = 

         date: [31x1 double]
     DMI_PLUS: [31x1 double]
    DMI_MINUS: [31x1 double]
          ADX: [31x1 double]
         ADXR: [31x1 double]

d contains a studyDataTable with one studyDataRow for each interval returned.

Display the first five dates in the returned data.

d.date(1:5,1)
ans =

     735507.00
     735508.00
     735509.00
     735510.00
     735511.00

Display the first five prices in the plus DI line.

d.DMI_PLUS(1:5,1)
ans =

         18.92
         17.84
         16.83
         15.86
         15.63

Display the first five prices in the minus DI line.

d.DMI_MINUS(1:5,1)
ans =

         30.88
         29.12
         28.16
         30.67
         29.24

Display the first five values of the Average Directional Index.

d.ADX(1:5,1)
ans =

         22.15
         22.28
         22.49
         23.15
         23.67

Display the first five values of the Average Directional Movement Index Rating.

d.ADXR(1:5,1)
ans =

         25.20
         25.06
         25.05
         25.60
         26.30

Close the Bloomberg connection.

close(c)

Run a technical analysis to return the DMI study for a security with a pricing source.

Create the Bloomberg connection.

c = blp;

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

Run the DMI study for the Microsoft® security with pricing source ETPX for the last month with period equal to 14, the high price, the low price, and the closing price.

d = tahistory(c,'MSFT@ETPX US Equity',floor(now)-30,floor(now),...
             'dmi','all_calendar_days','period',14,...
             'priceSourceHigh','PX_HIGH','priceSourceLow','PX_LOW',...
             'priceSourceClose','PX_LAST')
d = 

         date: [31x1 double]
     DMI_PLUS: [31x1 double]
    DMI_MINUS: [31x1 double]
          ADX: [31x1 double]
         ADXR: [31x1 double]

d contains a studyDataTable with one studyDataRow for each interval returned.

Display the first five dates in the returned data.

d.date(1:5,1)
ans =

     735507.00
     735508.00
     735509.00
     735510.00
     735511.00

Display the first five prices in the plus DI line.

d.DMI_PLUS(1:5,1)
ans =

         28.37
         30.63
         32.72
         30.65
         29.37

Display the first five prices in the minus DI line.

d.DMI_MINUS(1:5,1)
ans =

         21.97
         21.17
         19.47
         18.24
         17.48

Display the first values of the Average Directional Index.

d.ADX(1:5,1)
ans =

         13.53
         13.86
         14.69
         15.45
         16.16

Display the first five values of the Average Directional Movement Index Rating.

d.ADXR(1:5,1)
ans =

         15.45
         15.36
         15.53
         15.85
         16.37

Close the Bloomberg connection.

close(c)

Create a Bloomberg® connection, and then return data for a DMI study. The tahistory 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 tahistory function returns data as a structure.

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

Run the DMI study for the IBM® security from June 12, 2017 through June 16, 2017 with period equal to 14, the high price, the low price, and the closing price.

d = tahistory(c,'IBM US Equity','6/12/2017','6/16/2017','dmi', ...
    'all_calendar_days','period',14,'priceSourceHigh','PX_HIGH', ...
    'priceSourceLow','PX_LOW','priceSourceClose','PX_LAST');

Access the DMI study data for the first three dates.

d(1:3,:)
ans =

  3×5 table

       date        DMI_PLUS    DMI_MINUS     ADX     ADXR 
    ___________    ________    _________    _____    _____

    12-Jun-2017     30.48        16.31      33.93    45.26
    13-Jun-2017     28.88        15.45      33.67    44.10
    14-Jun-2017     26.62        18.98      32.46    42.67

d is a table that contains these columns:

  • date -- Date

  • DMI_PLUS -- Prices in plus DI line

  • DMI_MINUS -- Prices in minus DI line

  • ADX -- Average Directional Index values

  • ADXR -- Average Directional Movement Index Rating values

Access the first three dates in the returned data.

d.date(1:3)
ans = 

  3×1 datetime array

   12-Jun-2017
   13-Jun-2017
   14-Jun-2017

Close the Bloomberg connection.

close(c)

Create a Bloomberg® connection, and then return data for a DMI study. The tahistory function returns data 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 table by setting the DataReturnFormat property of the connection object. If you do not set this property, the tahistory function returns data as a structure.

c.DataReturnFormat = 'timetable';

Adjust the display format of the returned data for currency.

format bank

Run the DMI study for the IBM® security from June 12, 2017 through June 16, 2017 with period equal to 14, the high price, the low price, and the closing price.

d = tahistory(c,'IBM US Equity','6/12/2017','6/16/2017','dmi', ...
    'all_calendar_days','period',14,'priceSourceHigh','PX_HIGH', ...
    'priceSourceLow','PX_LOW','priceSourceClose','PX_LAST');

Access the DMI study data for the first three dates.

d(1:3,:)
ans =

  3×4 timetable

       date        DMI_PLUS    DMI_MINUS     ADX     ADXR 
    ___________    ________    _________    _____    _____

    12-Jun-2017     30.48        16.31      33.93    45.26
    13-Jun-2017     28.88        15.45      33.67    44.10
    14-Jun-2017     26.62        18.98      32.46    42.67

d is a timetable that contains these columns:

  • date -- Date

  • DMI_PLUS -- Prices in plus DI line

  • DMI_MINUS -- Prices in minus DI line

  • ADX -- Average Directional Index values

  • ADXR -- Average Directional Movement Index Rating values

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

Start date, specified as a numeric scalar, character vector, or string scalar to denote the start date of the date range for the returned tick data.

Example: floor(now-1)

Data Types: double | char | string

End date, specified as a numeric scalar, character vector, or string scalar to denote the end date of the date range for the returned tick data.

Example: floor(now)

Data Types: double | char | string

Study type, specified as a character vector or string scalar to denote the study to use for historical analysis.

Data Types: char | string

Periodicity, specified as one of these values to denote the data to return. For specifying multiple values, use a cell array. For example, when period is set to {'daily','all_calendar_days'}, tahistory returns daily data for all calendar days, and reports missing data as NaNs. When period is set to 'active_days_only', tahistory returns data using the default periodicity for active trading days only. The default periodicity depends on the security. If a security is reported on a monthly basis, the default periodicity is monthly. These tables show the values for period.

To specify the periodicity of the return data, see this table.

ValueDescription
'daily'

Return data for each day.

'weekly'

Return data for each week.

'monthly'

Return data for each month.

'quarterly'

Return data for each quarter.

'semi_annually'

Return data semiannually.

'yearly'

Return data for each year.

The anchor date is the date to which all other reported dates are related. To specify the anchor date, see this table.

ValueDescription
'actual'

Anchor date specification for an actual date. For this function, for periodicities other than daily, enddate is the anchor date.

If the period is weekly and the enddate is a Thursday, every data point is a Thursday, or the nearest prior business day to Thursday. If the period is monthly and the enddate is the 20th of a month, every data point is the 20th of each month in the date range.

'calendar'

Anchor date specification for a calendar year.

'fiscal'

Anchor date specification for a fiscal year.

To specify returning data for particular days, see this table.

ValueDescription
'non_trading_weekdays'Return data for all weekdays.
'all_calendar_days'Return data for all calendar days.
'active_days_only'Return data for only active trading days.

To specify how to fill missing values, see this table.

ValueDescription
'previous_value'Fill missing values with previous values for dates without trading activity for the security.
'nil_value'Fill missing values with a NaN for dates without trading activity for the security.

Data Types: char | cell

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'period',14, 'priceSourceHigh','PX_HIGH', 'priceSourceLow','PX_LOW', 'priceSourceClose','PX_LAST'

Note

For details about the full list of name-value pair arguments, see the Bloomberg tool located at C:\blp\API\APIv3\bin\BBAPIDemo.exe.

Period, specified as the comma-separated pair consisting of 'period' and a numeric scalar. For details about the period, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: double

High price, specified as the comma-separated pair consisting of 'priceSourceHigh' and a character vector or string scalar. For details about the high price, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: char | string

Low price, specified as the comma-separated pair consisting of 'priceSourceLow' and a character vector or string scalar. For details about the low price, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: char | string

Closing price, specified as the comma-separated pair consisting of 'priceSourceClose' and a character vector or string scalar. For details about the closing price, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: char | string

Output Arguments

collapse all

Technical analysis data, returned as a structure, table, or timetable. The data type of the returned data depends on the DataReturnFormat and DatetimeType properties of the connection object.

For details about the data, see the Bloomberg API Developer’s Guide using the WAPI <GO> option from the Bloomberg terminal.

Introduced in R2012b