tahistory
Description
Examples
Return all available Bloomberg studies and use the DMI study to run a technical analysis for a security.
Create a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:
The authentication is Windows® authentication when you set
authtypeto'OS_LOGON'.The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.
The IP address for the machine running the Bloomberg B-PIPE process is
'111.11.11.112'.The port number of the machine running the Bloomberg B-PIPE process is
8194.
c is a bloombergBPIPE object.
authtype = 'OS_LOGON'; appname = ''; ipaddress = {'111.11.11.112'}; port = 8194; c = bloombergBPIPE(authtype,appname,ipaddress,port);
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 a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:
The authentication is Windows authentication when you set
authtypeto'OS_LOGON'.The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.
The IP address for the machine running the Bloomberg B-PIPE process is
'111.11.11.112'.The port number of the machine running the Bloomberg B-PIPE process is
8194.
c is a bloombergBPIPE object.
authtype = 'OS_LOGON'; appname = ''; ipaddress = {'111.11.11.112'}; port = 8194; c = bloombergBPIPE(authtype,appname,ipaddress,port);
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 a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:
The authentication is Windows authentication when you set
authtypeto'OS_LOGON'.The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.
The IP address for the machine running the Bloomberg B-PIPE process is
'111.11.11.112'.The port number of the machine running the Bloomberg B-PIPE process is
8194.
c is a bloombergBPIPE object.
authtype = 'OS_LOGON'; appname = ''; ipaddress = {'111.11.11.112'}; port = 8194; c = bloombergBPIPE(authtype,appname,ipaddress,port);
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-- DateDMI_PLUS-- Prices in plus DI lineDMI_MINUS-- Prices in minus DI lineADX-- Average Directional Index valuesADXR-- 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 a Bloomberg B-PIPE connection using the IP address of the machine running the Bloomberg B-PIPE process. This example uses the Bloomberg B-PIPE C++ interface and assumes the following:
The authentication is Windows authentication when you set
authtypeto'OS_LOGON'.The application name is blank because you are not connecting to Bloomberg B-PIPE using an application.
The IP address for the machine running the Bloomberg B-PIPE process is
'111.11.11.112'.The port number of the machine running the Bloomberg B-PIPE process is
8194.
c is a bloombergBPIPE object.
authtype = 'OS_LOGON'; appname = ''; ipaddress = {'111.11.11.112'}; port = 8194; c = bloombergBPIPE(authtype,appname,ipaddress,port);
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-- DateDMI_PLUS-- Prices in plus DI lineDMI_MINUS-- Prices in minus DI lineADX-- Average Directional Index valuesADXR-- Average Directional Movement Index Rating values
Close the Bloomberg connection.
close(c)
Input Arguments
Bloomberg
B-PIPE connection, specified as a bloombergBPIPE object.
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.
| Value | Description |
|---|---|
'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.
| Value | Description |
|---|---|
'actual' | Anchor date specification for an actual date. For this
function, for periodicities other than daily, If the period is weekly and the |
'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.
| Value | Description |
|---|---|
'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.
| Value | Description |
|---|---|
'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 Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
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
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.
Version History
Introduced in R2021a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)