The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
December 1999First printingNew for MATLAB®5.3 (Release 11)
June 2000Online onlyRevised for Version 1.2
December 2000Online onlyRevised for Version 1.3
February 2003Online onlyRevised for Version 1.4
June 2004Online onlyRevised for Version 1.5 (Release 14)
August 2004Online onlyRevised for Version 1.6 (Release 14+)
September 2005 Second printingRevised for Version 1.7 (Release 14SP3)
March 2006Online onlyRevised for Version 1.8 (Release 2006a)
September 2006 Online onlyRevised for Version 1.9 (Release 2006b)
March 2007Third printingRevised for Version 2.0 (Release 2007a)
September 2007 Online onlyRevised for Version 3.0 (Release 2007b)
March 2008Online onlyRevised for Version 3.1 (Release 2008a)
October 2008Online onlyRevised for Version 3.2 (Release 2008b)
March 2009Online onlyRevised for Version 3.3 (Release 2009a)
September 2009 Online onlyRevised for Version 3.4 (Release 2009b)
March 2010Online onlyRevised for Version 3.5 (Release 2010a)
Communicating with Financial Data Servers........A-2
Retrieving Connection Properties
...................A-2
Retrieving Data
...................................A-2
Index
vii
viiiContents
Getting Started
• “Product Overview” on page 1-2
• “About Data Servers and Da ta Service Providers” on page 1-3
1
1 Getting Started
Product Overview
This toolbox, used with the MATLAB®product, effectively turns your
MATLAB workstation into a financial data acquisition terminal. T he toolbox
enables you to:
• Retrieve and analyze a wide variety of security data from financial data
• Access market, time-series, and historical market data in MATLAB.
• Monitor the status and history of each connection to a supported data
• Fetch data fields for multiple securities in a single call.
• Look up security ticker symbols from the toolbox GUI or the MATLAB
servers in MATLAB.
service provider.
command line.
1-2
About Data Servers and Data Service Providers
AboutDataServersandDataServiceProviders
In this section...
“Supported Data Service Providers” on page 1-3
“Data Server Connection Requirements” on page 1-3
Supported Data Service Providers
This toolbox supports connections to financial data servers that the following
corporations provide:
• Bloomberg L.P. (
• FactSet Research Systems, Inc. (
• Federal Reserve Economic Data (FRED)
(
http://research.stlouisfed.org/fred2/)
• Haver Analytics (
• Interactive Data Pricing and Reference Data
(
http://www.interactivedata-prd.com/)
• Kx Systems, Inc. (
• Thomson Reuters (
• Yahoo!, Inc. (
http://www.bloomberg.com)
http://www.factset.com)
http://www.haver.com)
http://www.kx.com)
http://www.thomsonreuters.com/)
http://finance.yahoo.com)
Data Server Connection Requirements
To connect to some of these data servers, additional requirements apply.
Additional Software Requirements
The following data service p roviders require you to install proprietary
software on your PC:
• Bloomberg
1-3
1 Getting Started
Note You must have a Bloomberg®software licens e for the host on which
the D atafeed Toolbox™ and MATLAB software are running.
• Interactive Data Pricing and Reference Data’s R emote Plus™
• Haver Analytics
• Kx Systems. Inc.
• Reuters
You must have a valid license for required client software on your machine.
If you do not, the following error message appears when you try to connect
toadataserver:
Invalid MEX-file
For more information about how to obtain required software, contact your
data server sales representative.
1-4
Proxy Information Requirements
The following data service providers may require you to specify a proxy host
and proxy port plus a username and password if the user’s site requires
proxy authentication:
• FactSet
• Federal Reserve Economic Data
• Thomson Datastream
• Yahoo!
For information on how to specify these settings, see “Specifying Proxy Server
Settings” in the MATLAB documentation.
FactSet Data Service Requirements
You need a license to use FactSet®FAST technology. For more information,
see the FactSet Web site at
http://www.factset.com.
About Data Servers and Data Service Providers
Reuters Data Service Requirements
Configuring Reuters®Connections Using the Reuters Configuration
Editor software. You must use the Reuters Configuration Editor to
configure your connections as follows:
1 In a DOS prompt, set your CLASSPATH environment variable :
set CLASSPATH=%CLASSPATH%; ...
$MATLAB/toolbox/datafeed/datafeed/config_editor.jar
2 Navigate to the Datafeed Toolbox folder:
cd %MATLAB%\toolbox\datafeed\datafeed
3 Enter the followin g command to run the Reuters Configuration Editor:
b If you are running an SSL connection, add the following to your
connection configuration:
dacs_GenerateLocks=false
For more information, see the reuters function reference page.
Troubleshooting Issues with Reuters Configuration Editor. These errors
occur when you attempt to use the Reuters Configuration Editor to configure
connections on a machine on which an XML Parser is not installed.
java com.reuters.rfa.tools.config.editor.ConfigEditor
org.xml.sax.SAXException: System property
org.xml.sax.driver not specified
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(U nknown
Source)
at com.reuters.rfa.tools.config.editor.rfaConfigRuleDB.rf aConfi
gRuleDB.java:56)
at com.reuters.rfa.tools.config.editor.ConfigEditor.init
(ConfigEditor.java:86)
at (com.reuters.rfa.tools.config.editor.ConfigEditor.
(ConfigEditor.java:61) at
com.reuters.rfa.tools.config.editor.ConfigEditor.main
(ConfigEditor.java:1303)
To address this problem, download an XML parser file, and then include a
path to this file in your
The following example shows how to set your
variable to include the XML parser file
You need the following to connect to Thomson®data servers:
• AlicenseforThomson
• To connect to the Thomson
®
DataWorks®.
®
Datastream®API from the Web, you need a
user name, password, and URL provided by Thomson.
For more information, see the Thomson Web site at
http://www.thomsonreuters.com.
1-8
Communicatingwith
Financial Data S ervers
• “Communication Management” on page 2-2
• “Connection Object Properties” on page 2-4
• “Disconnecting from Data Servers” on page 2-7
2
2 Communicating with Financial Data Servers
Communication Management
In this section...
“Communicating with Data Servers” on page 2-2
“Core Functions” on page 2-2
“Connecting to the Bloomberg Data Server” on page 2-3
Communicating with Data Servers
This section uses the Bloomberg financial data server as an example of how to
retrieve data with the Datafeed Toolbox software. You can communicate with
other supported data servers using a similar set of toolbox functions.
Core Functions
The following set of core functions manage communication with each
supported financial data server.
2-2
• To establish a connection to the appropriate data server, use:
- blp
- datastream
- factset
- fred
- haver
- idc
- kx
- reuters
- yahoo
• To retrieve connection properties, use get.
• To terminate a connection, use
close.
Communication Management
Connecting to th
This example sho
data server.
Note If you hav
blpapi3.
file
function or ed
ws how to u se the
e not used the
jar
to the MATLAB java classpath. Use the javaaddpath
it your
classpath.txt file.
e Bloomberg Data Server
blp function to connect to the Bloomberg
blp function before you will need to add the
2-3
2 Communicating with Financial Data Servers
Connection Object Properties
In this section...
“How to Retrieve Connection Properties” on page 2-4
“Example: Retriev ing Data on a Security” o n page 2-5
The syntax for the Bloomberg V3 connection object constructor is:
b = blp;
How to Retrieve Connection Properties
To retrieve the properties of a connection object, use the get function. This
function returns different values depending upon which data server you are
using.
get(b)
b=
2-4
session: [1x1 com.bloomberglp.blpapi.Session]
ipaddress: 'localhost'
port: 8194.00
You can get the values of the individual properties by using the property
names:
get(b,{'port','session'})
ans =
port: 8194.00
session: [1x1 com.bloomberglp.blpapi.Session]
For example, return just the connection handle with the ipaddress arg u m ent:
ip = get(b,{'ipaddress'})
ip =
localhost
Connection Object Properties
Note A single property is not returned as a structure.
Example: Retrieving Data on a Security
Establish a connection, b, to a Bloomberg data server:
b = blp;
Use the blp.timeseries method to return data on a security:
d = timeseries(b,'IBM US Equity','11/16/2009');
d(1:10,:)
ans =
If the final input argument is not a ran g e it must be a whole date value, i.e.
'11/16/2009' but not '11/16/2009 12:30:00' or 730316 but not 730316.5.
The code
timeseries(b,'IBM US Equity', now) will error. Use one of
MATLAB’s rounding functions to ensure a whole date value:
d = timeseries(b,'IBM US Equity',fl
oor(now));
To return data on a particular field for a range of dates, use the blp.history
method:
data = history(b,'IBM US Equity','Last_Price','07/15/99','08/02/99')
data =
730316.00122.33
730317.00122.27
2-5
2 Communicating with Financial Data Servers
730320.00120.81
730321.00115.09
730322.00115.77
730323.00111.17
730324.00112.01
730327.00110.38
730328.00113.30
730329.00115.21
730330.00112.51
730331.00112.79
730334.00109.71
2-6
Disconnecting from Data Servers
To close a data server connection and disconnect, use the close function
with the format:
close(b)
You must have previously created the connection object with one of the
connection functions.
Disconnecting from Data Servers
2-7
2 Communicating with Financial Data Servers
2-8
Example:Retrieving
Bloomberg Data
3
3 Example: Retrieving Bloomberg
Using blp Methods
In this section...
“About This Example” on page 3-2
“Retrieving Field Data” on page 3 -2
“Retrieving Time Series Data” on page 3-3
“Retrieving Historical Data” on page 3-3
About This Example
Thefollowingexampleillustratestheuseoftheblp methods to retrieve data
from a B loomberg data server.
Note If you have not used the blp function before you will need to add the
file
blpapi3.jar to the MATL AB java classpath. Use the javaaddpath
function or edit your classpath.txt file.
®
Data
3-2
Retrieving Field Data
The getdata method obtains Bloombe rg field data. Theentiresetoffielddata
provides statistics for all possible securities, but it does not apply universally
to any one security.
Obtaining Data
To obtain data for specific fields of a given security, use the getdata function
with the following syntax:
d = getdata(Connect, Security, Fields)
For example, use the Bloomberg conne ction object c to retrieve the values
of the fields
d = getdata(c,'IBM US Equ ity' , {'Open';'Last_Price'})
d=
Open and Last_Price:
Open: 126.2500
Last_Price: 125.1250
Using blp Methods
Retrieving Time Series Data
The timeseries method returns price and volumedataforaparticular
security on a specified date. Use the following command to return time-series
data for a given security and a specific date:
data = timeseries(Connection, Security, Date)
Date
can be a MATLAB date string or serial date number. If the final input
argumentisnotarangeitmustbeawholedatevalue,i.e.
but not '11/16/2009 12:30:00' or 730316 but not 730316.5.Thecode
timeseries(b,'IBM US Equity', now) will error. Use one of MATLAB’s
rounding functions to ensure a whole date value.
To obtain time-series data for the current day, use the alternate form of the
function:
data = timeseries(Connection, Security, floor(now))
'11/16/2009'
To obtain time-series data for IBM using an existing connection c1,enter
the function:
data = timeseries(c1, 'IBM US Equity ', floor(now));
Retrieving Historical Data
Use the history method to obtain historical data for a specific security.
To obtain historical data for a specified field of a particular security, run:
d = history(Connect,Security,Field,FromDate,ToDate)
history
For instructions on determining valid field names, see .
For example, to obtain the closing price for
to August 2, 1999 using the connection
returns data for the date range from FromDate to ToDate.
IBM for the dates July 15, 1999
c1,enter:
data = history(c1, 'IBM U S Equity', 'Last_Price',...
'07/15/99', '08/02/99');
3-3
3 Example: Retrieving Bloomberg
®
Data
3-4
4
Datafeed Toolbox Graphical
User Interface
• “Introduction” on page 4-2
• “Using the Datafeed Dialog Box” on page 4-3
4 Datafeed Toolbox™ Graphical User Interface
Introduction
You can use the Datafeed Toolbox Graphical User Interface (GUI) to connect
to and retrieve information from some supported data service providers.
This GUI consists of two dialog boxes:
• The Datafeed dialog box. U se this dialog box to connect to and retrieve data
from the following service providers:
- Bloomberg
- Interactive Data Pricing and Reference Data’s RemotePlus
- Yahoo!
For more information on how to use this dialog box, see “Using the Datafeed
Dialog Box” on page 4-3.
• The Securities Lookup dial og box. You can use this dialog box to find the
ticker symbol for a security when you know part of the security name. Use
this d i al og box with connections to the following service providers:
®
4-2
- Bloomberg
- Interactive Data Pricing and Reference Data’s RemotePlus
For more information on how to use this dialog box, see “Using the Datafeed
Securities Lookup Dialog Box” on page 4-6.
Using the Datafeed Dialog Box
In this section...
“About the Datafeed Dialog Box” on page 4-3
“Connecting to Data Servers” on p age 4-4
“Retrieving Data” on page 4-5
“Using the Datafeed Securities Lookup Dialog Box” on page 4-6
“Setting Overrides” on page 4-8
About the Datafeed Dialog Box
The Datafeed dialog box establishes the connection with the data server
and manages data retrieva l. To display this dialog b ox , enter the
command in the MATLAB Command Window.
The Datafeed dialog box consists of two tabs:
Using the Datafeed Dialog Box
dftool
• The Connection tab establishes communicationwithadataserver. For
more information, see “Connecting to Data Servers” on page 4-4.
• The Data tab specifies the data request. For more information, see
“Retrieving Data” on page 4-5.
• You can also set overrides for the data you retrieve. For more information,
see “Setting Overrides” on page 4-8.
The following figure summarizes how to connect to data servers and retrieve
data using the Datafeed dialog box.
4-3
4 Datafeed Toolbox™ Graphical User Interface
4. After the connection is made,
click the Data tab to begin
data retrieval.
3. Click to establish a connection to the data server.
1. Enter port number on data server (Bloomberg data
servers only).
The Datafeed Dialog Box
4-4
5. Click to close the highlighted connection.
2. Enter IP address of data server or use the default
values (Bloomberg data servers only).
Connecting to Data Servers
1 Click the Connect button to establish a connection.
Using the Datafeed Dialog Box
2 When the Connected message appears in the Status field, click the Data
tab to begin the process of retrieving data from the data server. For more
information, see “Retrieving Data” on page 4-5.
3 Click the Disconnect button to terminate the session highlighted in the
Current Connections box.
For Bloomberg data servers, you must also specify the port number and IP
address of the server:
1 Enter the port number on the data server in the Port Number field.
2 Enter the IP address of the data server in the IP Address field .
3 To establish a connection to the Bloomberg data server, follow steps 1
through 3 above.
Tip You can also connect to the Bloomberg data server by selecting the
Connect button and accepting the default values.
Retrieving Data
The Data tab allows you to retrieve data from the data server as follows:
1 Enter the security symbol in the Enter Security field.
3 Specify whether you want the default set of data, or the full set:
• Select the Default fields button for the default set of data.
• Select the All fields button for the full set of data.
4 Click the Get Data button to retrieve the data from the data server.
5 (Optional) Click the Override button if you want to set overrides on the
data you request from the data server. For more information, see “Setting
Overrides” on page 4-8.
The following figure summarizes these steps.
4-5
4 Datafeed Toolbox™ Graphical User Interface
2. Enter security symbol if known,
or click Add button to add
security to Selected Securities list.
2a. Use to find security symbol, if unknown.
(For Bloomberg and
Interactive Data Pricing and Reference Data
data servers only)
Security fields.
4-6
Variable in MATLAB
workspace.
Using the Datafeed Securities Lookup Dialog Box
When requesting data from Bloomberg or Interactive Data Pricing and
Reference Data’s RemotePlus servers, you can use the Datafee d Securities
Data retrieved
from the connection.
1. Click to retrieve data.
Using the Datafeed Dialog Box
Lookup dialog box to obtain the ticker symbol for a given security if you know
only part of the security name.
1 Click the Lookup button on the Datafeed dialog box Data tab. The
Securities Lookup dialog box opens.
2 Specify your choice of market in the Choose Market field.
3 Enter the known part of the security name in the Lookup field.
4 Click Submit. All possible values o f the company name and ticker symbol
corresponding to the security name you sp ecif ied display in the Security
and Symbol list.
5 Select one or more securit ie s from the list, and then click Select.
The s elected securities are added to the Selected Securities list o n the
Data tab.
The following figure summarizes these steps.
4-7
4 Datafeed Toolbox™ Graphical User Interface
2. Enter lookup search string.
4. Search results returned from data server.
This field displays all possible
values of company name and ticker
symbol. Select desired securities from
list.
4-8
1. Indicate choice of market.
3. Click to send
request to data
server.
5. Enter selected
securities on Data
tab.
Setting Overrides
To set overrides on retrieved data:
1 Click the Override button. The Override values dialog box opens.
2 Select the field to override from the Override fields selection list.
3 Enter the desired override value in the Override value field.
4 Click Add to add the field to override to the Override field settings list.
5 Click Apply to apply overrides to the current session and keep the Override
values dialog box open, or click OK to apply the overrides and close the
dialog box.
The following figure summarizes these steps.
Using the Datafeed Dialog Box
2. Enter desired override value.
3. Click Add to add the field
to the Override field settings list.
Lists data to override.
1. Select field to override.
4a. Apply overrides and close
dialog. Return to previous
dialog box.
historical data for the specified field for the date range
ToDate. You can set the time period with the optional Period argument
to return a more specific data set. You can further specify returned data
by appending the
Note If a call to the fetch function with the HISTORY argument
encounters an invalid security in a list of securities to retrieve, it
returns no data for any securities in the list.
data = fetch(Connect,'Security', 'TIMESERIES', now)
uses SearchSt ring to find the ticker symbol f or a security trading in a
designated market. The output
ticker is a column vector of possible
ticker values.
Note If you supply Ident without a period or currency, enter [] for
the missing values.
data = fetch(Connect, 'Security', 'REALTIME', 'Fields',
'MATLABProg')
subscribes to a given security or list of securities,
requesting the indicated fields, and runs any specified MATLAB
Arguments
bloomberg.fetch
function. See pricevol, showtrades,orstockticker for information
on the data returned by asynchronous Bloomberg events.
data = fetch(Connect, 'Security', 'STOP') unsubscribes the list
of securities from processing Bloomberg real-time events.
Connect
'Security'
'Flag'
'Currency'
'Ident'
Bloomberg connection object cre ate d with the bloomberg function.
A MATLAB string containing the name of a security, or a cell array of
strings containing a list of securities, specified in a format recognizable by
the B loomberg server. You can substitute a
CUSIP number for a security
name as needed. You can only call a single security when using the
TIMESERIES flag as well.
Note This argument is case sensitive.
AMATLABstringindicatingthedatesfor which to retrieve data. Possible
values are:
•
DEFAULT: Data from most recent bid, ask, or trade. If you do not specify
a
Flag value, fetch uses the default value of 'DEFAULT'.
TODAY: Today’s data only.
•
ENHANCED: Data from most recent date of each individual field.
•
(Optional) Currency in which the fetc h function returns historical data.
A list of valid currenciesappearsinthefile
Default =
[].
@bloomberg/bbfields.mat.
(Optional) Security type identifier. A list of valid security type identifiers
appears in the file
@bloomberg/bbfields.mat.Default=[].
6-7
bloomberg.fetch
'Fields'
'Override'
'Values'
'Date'
'Minutes'
'TickField'
'FromDate'
'ToDate'
'Period'
A MATLAB string or cell array of strings specifying specific fields for
which you request data. A list of valid field names appears in the file
@bloomberg/bbfields.mat. The variable bbfieldnames contains the list
of field names. D efault =
[].
(Optional) String or cell array of strings containing override field list.
Default =
[].
(Optional) String or cell array of strings containing override field values.
Date string, serial date number, or cell array of dates that specifies dates
for the time-series data. Specify
now to retrieve today’s time-series data.
(Optional) Numeric value for tick interval in minutes.
(Optional) You can specify a string or numeric value for this field. For
example,
of type
TickField = 'Trade' or TickField = 1 return data for ticks
Trade.Usethecommanddftool('ticktypes') to return the
list of intraday tick fields.
Beginning date for historical data.
Note You can specify dates in any of the formats supported by datestr
and datenum that display a year, month, and day.
End date for historical data.
(Optional) Period of the data. A MATLAB three-part string w ith the
format:
6-8
'Frequency Days Data'
Frequency
•
d: Daily (default)
w:Weekly
•
m:Monthly
•
q:Quarterly
•
Values:
bloomberg.fetch
• s: Semiannually
y:Yearly
•
Days Values:
•
o: Omit all days for which there is no data (default)
i: Include all trading days
•
a: Include all calendar days
•
Data Values:
•
b: Report missing data using Bloomberg (default)
s: Show missing data as last found value
•
n: Report missing data as NaN
•
For example, 'dan' returns daily data for all calendar days, reporting
missing values as
value.
NaN.Ifavalueisunspecified,fetch returns a default
'Currency'
Note If you do not specify a value for Period, fetch uses default values.
(Optional) Currency type. The file @bloomberg/bbfields.mat lists
supported currencies.
6-9
bloomberg.fetch
'Market'
A MATLAB string indicating the market in which a particular security
trades. Possible values are:
•
Comdty: (Commodities)
Corp: (Corporate bonds)
•
Equity:(Equities)
•
Govt: (Government bonds)
•
Index:(Indexes)
•
M-Mkt:(MoneyMarketsecurities)
•
Mtge: Mortgage-backed securities)
•
Muni: (Municipal bonds)
•
Pfd: (Preferred stocks)
•
'MATLABProg'
A string that is the name of any valid MATLAB program.
ExamplesRetrieving Header Data
Retrieve header data for a United States equity with ticker ABC:
D = fetch(C,'ABC US Equit y')
6-10
Retrieving Opening and Closing Prices
Retrieve the opening and closing prices:
D = fetch(C,'ABC US Equit y',' GETDATA',...
{'Last_Price';'Open'})
Retrieving Override Fields
Retrieve the requested fields, given override fields and values:
bloomberg.timeseries is not recom m e nd ed. Use blp.timeseries
instead.
Syntaxd = timeseries(c,s,f,t)
d = timeseries(c,s,f,{startdate,enddate})
d = timeseries(c,s,f,t,b)
Descriptiond = timeseries(c,s,f,t) returns the tick data for the security s for
the date
robust functionality, refer to the
d = timeseries(c,s,f,{startdate,enddate}) returns the tick data
for the security
d = timeseries(c,s,f,t,b) returns the tick data for the security s for
the date
requested with an interval is returned with the columns representing
Time, Open, High, Low, Last Price and Volume of the ticks in the bar.
t. This method uses the BloombergActiveX interface. F or more
bloomberg.fetch method.
s for the date range defined by startdate and enddate.
t in intervals of b minutes for the field, f.Intradaytickdata
ExamplesExample 1
The command
returns today’s time series for the given security with the timestamp
and tick value.
Example 2
The command
returns today’s Last Price series for the given security aggregated into
5-minute intervals minute intervals.
Example 3
The command
6-30
d = timeseries(c,'ABC US Equity','Last Price',floor(now))
d = timeseries(c,'ABC US Equity','Last Price',floor(now),5)
bloomberg.timeseries
d = timeseries(c,'ABC US Equity','Last Price',...
{'12/08/2008 00:00:00','12/10/2008 23:59:59.99'},5)
returns the Last Price series for 12/08/2008 and 12/10/2008 for the
given security, aggregated into 5-minute intervals.
See Alsobloomberg.fetch, bloomberg.getdata, bloomberg.history
6-31
blp
PurposeBloomberg V3 communications server connection
Syntaxc = blp
Descriptionc = blp makes a connection to the local Bloomberg V3 communications
server.
ExamplesEstablish a connection, c, to a Bloomberg data server:
c=blp
See Alsoblp.close, blp.getdata, blp.his tory, blp.realtime,
blp.timeseries
6-32
PurposeClose connection to Bloomberg V3 data server
Syntaxclose(C)
Descriptionclose(C) closes the connection, C, to the Bloomberg V3 session.
blp.close
6-33
blp.display
PurposeDisplay Bloomberg V3 connection object
Syntaxdisp = display(c)
Descriptiondisp = display(c) displays the Bloomberg V3 connection object.
6-34
PurposeGet Bloomberg V3 connection properties
SyntaxV = get(C,'PropertyName')
V = get(C)
DescriptionV = get(C,'PropertyName') returns the value of the specified
properties for the Bloomberg V3 connection object.
string or cell array of strings containing property names. The property
names are
V = get(C) returns a structure where each field name is the name of a
property of
session, ipaddress,andport.
C an d each field contains the value of th a t property.
'PropertyName' is a
See Alsoblp.getdata, blp.history, blp.realt ime, blp.timeseries
blp.get
6-35
blp.getdata
PurposeCurrent Bloomberg V3 data
SyntaxD = getdata(B,S,F)
D = getdata(B,S,F,O,OV)
DescriptionD = getdata(B,S,F) returns the data for the fields F for the security
list
S for the Bloomberg V3 connection object B
D = getdata(B,S,F,O,OV)
security list
values
S using the override fields O with corresponding override
OV.
returns the data for the fields F for the
ExamplesD = getdata(C,'ABC US E quit y',{'LAST_PRICE';'OPEN'}) returns
today’s current and open price of the given security.
D = fetch(C,'3358ABCD4
Corp','GETDATA',{'YLD_YTM_ASK','ASK','OAS_SPREAD_ASK','OAS_VOL_ASK'},
{'ASK','OAS_VOL_ASK'},{'99.125000','14.000000'})
requested fields given override fields and values.
returns the
See Alsoblp, blp.history, blp.realtime, blp.timeseries
6-36
blp.history
PurposeBloomberg V3 historical data
SyntaxD = history(S,F,FromDate,ToDate)
D = history(C,S,F,FromDate,ToDate,Per)
D = history(S,F,FromDate,ToDate,Per,Cur)
DescriptionD = history(S,F,FromDate,ToDate) returns the historical data for
the security list
D = history(C,S,F,FromDate,ToDate,Per) returns the historical
data for the field,
the period of the data. For example,
returns daily data for all calendar days reporting missing data as NaN.
Per = {'actual'} returns the data using the default periodicity and
default calendar reporting missing data as
Per are as follows:
ValueTime Period
daily
S for the fields F for the dates FromDate to ToDate.
F, for the dates FromDate to ToDate. Per specifies
Per = {'daily','calendar'}
NaN. The possible values of
Daily
weekly
monthly
quarterly
semi_annually
yearly
actual
calendar
fiscal
non_trading_weekdays
all_calendar_days
active_days_only
Weekly
Monthly
Quarterly
Semi annually
Yearly
Anchor date specification
Anchor date specification
Anchor date specification
Non trading weekdays
Return all calendar days
Active trading days only
6-37
blp.history
ValueTime Period
previous_value
nil_value
D = history(S,F,FromDate,ToDate,Per,Cur) returns the
historical data for the security list
FromDate to ToDate based on the given currency, Cur.Loadthefile
bloomberg/bbfields to see the list of supported currencies.
ExamplesD = history(C,'ABC US E quit y',...
'LAST_PRICE','8/01/99','8/10/99')
given dates for the given security using the default period of the data.
D = history(C,'ABC US E quit y',...
'LAST_PRICE','8/01/99','8/10/99','monthly')
monthly closing price for the given dates for the given security.
D = history(C,'ABC US E quit y',...
'LAST_PRICE','8/01/99','8/10/99','monthly','USD')
monthly closing price converted to US dollars for the given dates for
the given security.
Fill missing values with previous
values
Fill missing values with NaN
S for the fields F for the dates
returns the closing price for the
returns the
returns the
D = history(C,'ABC US E quit y',...
'LAST_PRICE','8/01/99','8/10/99',
{'daily','actual','all_calendar_days', 'nil_value'},'US D')
returns the daily closing price converted to US dollars for the given
dates for the given security.
D = history(C,'ABC US E quit y',...
'LAST_PRICE','8/01/99','8/10/99',[],'USD')
price conv erted to US dollars for the given dates for the given security
using the default period of the data.
See Alsoblp, blp.realtime, blp.timeseries
6-38
returns the closing
blp.realtime
PurposeBloomberg V3 realtime data retrieval
Syntax[SUBS,T] = realtime(C,S,F,API)
Description[SUBS,T] = realtime(C,S,F,API) subscribes to a given security or
list of securities
by
API. It returns the subscription list, SUBS and the timer T associated
with the real time callback for the subscriptionlist. Runtheexample
v3showtrades for information on the data returned by asynchronous
Bloomberg events. Type
example.
Examplesrealtime(C,'ABC US
Equity',{'Last_Trade','Volume'},'v3stockticker')
the security
and Volume to update in realtime while running the
function
v3stockticker.
See Alsoblp, blp.history, blp.timeseries
S requesting the fields F and runs the specified function
help v3showtrades for information on the
subscribes to
ABC US Equity requesting the fields Last_Trade
6-39
blp.stop
PurposeUnsubscribe real time requests for Bloomberg V3
Syntaxstop(B,SUBS,T)
stop(B,SUBS,T,S)
Descriptionstop(B,SUBS,T)unsubscribes all real time requests associated with
the Bloomberg connection,
associated with the real time callback for the subscription list.
stop(B,SUBS,T,S)unsubscribes all real time requests associated with
the Bloomberg unsubscribes real time r equests for each security,
the subscription list,
callback for the subscription list.
B, and subscription list, S UBS.T is the timer
SUBS. T is the timer associated with the real time
S,on
6-40
blp.timeseries
PurposeBloomberg V3 intraday tick data
SyntaxD = timeseries(C,S,T)
D = timeseries(C,S,{StartDate,EndDate})
D = timeseries(C,S,T,B,F)
DescriptionD = timeseries(C,S,T) returns the raw tick data for the security S
for the date T.
D = timeseries(C,S,{StartDate,EndDate}) returns the raw tick
data for the security
EndDate.
D = timeseries(C,S,T,B,F)returns the tick data for the security S for
the date
requested with an interval is returned with the columns representing
Time, Open, High, Low, Last Price, number of ticks and Volume of
the ticks in the bar.
T in intervals of B minutes for the field, F.Intradaytickdata
ExamplesD = timeseries(C,'ABC US Equity',FLOOR(NOW)) returns today’s
time series for the given security. The timestamp and tick value are
returned.
S for the date range defined by StartDate and
D = timeseries(C,'ABC US Equity',FLOOR(NOW),5,'Trade')
returns today’s Trade tick series for the given security aggregated into
5 minute intervals.
D = timeseries(C,'ABC US Equity',{'12/08/2008
00:00:00','12/10/2008 23:59:59.99'},5,'Trade')
Trade tick series for 12/08/2008 and 12/10/2008 for the given security
aggregated into 5 minute intervals.
See Alsoblp, blp.history, blp.realtime
returns the
6-41
datastream
PurposeEstablish connections to Thomson Datastream API
See Alsodatastream.close, datastream.fetch, datastream.get,
datastream.isconnection
6-42
datastream.close
PurposeClose connections to Thomson Datastream data servers
Syntaxclose(Connect)
Arguments
Connect
Thomson Datastream connection object created with
the
datastream function.
Descriptionclose(Connect) closes a connection to a Thomson Datastream data
server.
See Alsodatastream
6-43
datastream.fetch
PurposeRequest data from Thomson Datastream data servers
Syntaxdata = fetch(Connect, 'Security')
data = fetch(Connect, 'Security', 'Fields')
data = fetch(Connect, 'Security', 'Fields', 'Date')
data = fetch(Connect, 'Security', 'Fields', 'FromDate',
'ToDate')
data = fetch(Connect, 'Security', 'Fields', 'FromDate',
'ToDate', 'Period')
data = fetch(Connect, 'Security', 'Fields', 'FromDate',
'ToDate', 'Period', 'Currency')
Arguments
Connect
'Security'
'Fields'
'Date'
'FromDate'
Thomson Datastream connection
object created with the
datastream function.
MATLAB string containing the
name of a security, or cell array
of strings containing names of
multiple securities. This data
is in a format recognizable by
the Thomson Datastream data
server.
(Optional) MATLAB string or cell
array of strings indicating the
data fields for which to retrieve
data.
(Optional) MATLAB string
indicating a specific calendar date
for which you request data.
(Optional) Start date for historical
data.
6-44
datastream.fetch
'ToDate'
(Optional) End date for historical
data. If you specify a value for
'ToDate', 'FromDate' cannot be
an empty value.
Note You can specify dates in
any of the formats supported by
datestr and datenum that show
a year, month, and day.
'Period'
'Currency'
(Optional) Period within a date
range.
•
•
•
Period values are:
'd': daily values
'w':weeklyvalues
'm': monthly values
(Optional) Currency in which
fetch returns the data.
Note You can enter the optional arguments 'Fields', 'FromDate',
'ToDate', 'Period',and'Currenc y' as MATLAB strings or empty
arrays (
[]).
Descriptiondata = fetch(Connect, 'Security') returns the default time series
for the indicated security.
data = fetch(Connect, 'Security', 'Fields') returns data for
the specified security and fields.
data = fetch(Connect, 'Security', 'Fields', 'Date') returns
data for the specified secu r ity and fields on a particu lar da t e.
6-45
datastream.fetch
data = fetch(Connect, 'Security', 'Fields', 'FromDate',
'ToDate')
indicated date range.
data = fetch(Connect, 'Security', 'Fields', 'FromDate',
'ToDate', 'Period')
with the indicated period.
data = fetch(Connect, 'Security', 'Fields', 'FromDate',
'ToDate', 'Period', 'Currency')
which to report the data.
Note The Thomson Datastream interface returns all data as strings.
For example, it returns
array of strings within the structure. There is no way to determine the
data type from the Datastream
ExamplesRetrieving Time Series Data
returns data for the specified s ecurity and fields for the
returns instrument data for the g iven range
also specifies the currency in
Price data to the MATLAB workspace as a cell
®
interface.
6-46
Return the trailing one-year price time series for the instrument
'P', which is the default value for the 'Fields' argument using the
command:
data = f
etch(Connect, 'ICI')
Or the command:
data =
fetch(Connect, 'ICI', 'P')
Retrieving Opening and Closing Prices
Return the closing and opening prices for the instruments P and PO on
the date September 1, 2007.
data = fetch(Connect, 'ICI', {'P', ' PO'} , '09/01/2007')
datastream.fetch
Retrieving Monthly Opening and Closing Prices for a
Specified Date Range
Return the monthly closing and opening prices for the securities ICI
and IBM from 09/01/2005 to 09/01/2007: