tahistory

Return historical technical analysis from Bloomberg connection V3

Syntax

  • d = tahistory(c) example
  • d = tahistory(c,s,startdate,enddate,study,period,Name,Value) example

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

expand all

Request the Bloomberg Directional Movement Indicator (DMI) Study for a Security

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 API 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)

Request the Bloomberg Directional Movement Indicator (DMI) Study for a Security with a Pricing Source

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 API 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)

Input Arguments

expand all

c — Bloomberg connectionconnection object

Bloomberg connection, specified as a connection object created using blp.

s — Securitystring

Security, specified as a string for a single Bloomberg security.

Data Types: char

startdate — Start datescalar | string

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

Example: floor(now-1)

Data Types: double | char

enddate — End datescalar | string

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

Example: floor(now)

Data Types: double | char

study — Study typestring

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

Data Types: char

period — Periodicity'daily' | 'weekly' | 'monthly' | 'quarterly' | 'semi_annually' | ...

Periodicity, specified as a cell array of enumerated strings to denote the period of the data to return. For example, when period is set to {'daily','calendar'}, this function returns daily data for all calendar days reporting missing data as NaNs. When period is set to {'actual'}, this function returns the data using the default periodicity and default calendar reporting missing data as NaNs. The default periodicity depends on the security. If a security is reported on a monthly basis, the default periodicity is monthly. The default calendar is actual trading days. This table shows the values for period.

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.
'actual'

Anchor date specification for an actual date. The anchor date is the date to which all other reported dates are related. For this function, for periodicities other than daily, enddate is the anchor date.

For example, if you set the period to weekly and the enddate is a Thursday, every reported data point would also be a Thursday, or the nearest prior business day to Thursday. Similarly, if you set the period to monthly and the enddate is the 20th of a month, each reported data point would be for 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.
'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.
'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 single 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' — Periodscalar

Period, specified as a 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

'priceSourceHigh' — High pricestring

High price, specified as a string. For details about the period, see the Bloomberg API Developer's Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: char

'priceSourceLow' — Low pricestring

Low price, specified as a string. For details about the period, see the Bloomberg API Developer's Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: char

'priceSourceClose' — Closing pricestring

Closing price, specified as a string. For details about the period, see the Bloomberg API Developer's Guide using the WAPI <GO> option from the Bloomberg terminal.

Data Types: char

Output Arguments

expand all

d — Technical analysis return datastructure

Technical analysis return data, returned as a structure. For details about the possible returned data, see the Bloomberg API Developer's Guide using the WAPI <GO> option from the Bloomberg terminal.

Was this topic helpful?