blpsrv
Bloomberg服务器connection V3
Description
Theblpsrv
function creates ablpsrv
object. Theblpsrv
object represents a Bloomberg®服务器connection.
Other functions connect to different Bloomberg services: Bloomberg Desktop (blp
), and Bloomberg B-PIPE®(bpipe
). For details about these services, seeComparing Bloomberg Connections。
For details about Bloomberg connection requirements, seeData Server Connection Requirements。To ensure a successful Bloomberg connection, perform the required steps before executingblpsrv
。For details, seeInstalling Bloomberg and Configuring Connections。
Creation
Description
c = blpsrv (uuid、ipaddress、端口、超时)
also sets theTimeOutproperty.
Caution
To refer to a Bloomberg connection in other functions, use the connection object created by theblpsrv
function. Otherwise, usingblpsrv
as an input argument opens multiple Bloomberg connections, causing unexpected behavior and exhausting memory resources.
Properties
Uuid
—Bloomberg user identity UUID
numeric scalar
Bloomberg user identity UUID, specified as a numeric scalar. To find your UUID, enterIAM
in the Bloomberg terminal and pressGO。
Example:12345678
Data Types:double
User
—Bloomberg user
Bloomberg user identity object
This property is read-only.
Bloomberg user, specified as a Bloomberg user identity object.
Example:[1x1 com.bloomberglp.blpapi.impl.aT]
Userip
—IP address of the machine running MATLAB®
成立r vector
This property is read-only.
IP address of the machine running MATLAB, specified as a character vector.
Example:'111.11.11.111'
Data Types:char
Session
—Bloomberg V3 session
Bloomberg V3 API Session object
This property is read-only.
Bloomberg V3 session, specified as a Bloomberg V3 API Session object.
Example:[1x1 com.bloomberglp.blpapi.Session]
IPAddress
—Bloomberg Server IP address
成立r vector|string scalar
Bloomberg Server IP address, specified as a character vector or string scalar that identifies the machine running the Bloomberg Server.
Example:'111.11.11.111'
Data Types:char
|string
Port
—Port number
numeric scalar
Port number, specified as a numeric scalar that identifies the port number of the machine running the Bloomberg Server.
Example:8194
Data Types:double
TimeOut
—Timeout
numeric scalar
Timeout specifying the time in milliseconds that MATLAB attempts to connect to the machine running the Bloomberg Server before timing out, specified as a numeric scalar.
Example:10
Data Types:double
DatetimeType
—Date and time data type
''
(default) |'datetime'
Date and time data type, specified as one of these values.
Value | Description |
---|---|
'' (default) |
Return date and time values as MATLAB date numbers. |
'datetime' |
Return date and time values as adatetime array. |
You can specify these values using a character vector or string (for example,"datetime"
).
When you create ablpsrv
object, theblpsrv
function leaves this property unset. To retrieve data, you must set this property value manually at the command line or in a script using dot notation, for example:
c.DatetimeType = 'datetime';
-
Note
If the
DataReturnFormat
property value is'table'
and theDatetimeType
property value is'datetime'
, then the returned data is a table that contains date and time values as adatetime
array. If theDataReturnFormat
property value is an empty character vector, then setting theDatetimeType
property to'datetime'
returns date and time values for aggregated ticks and historical requests as MATLAB date numbers.
DataReturnFormat
—返回数据格式
'cell'
|'structure'
|'table'
|'timetable'
返回数据格式, specified as one of these values, which determine the data type of the returned data.
Value | Data Type of Returned Data |
---|---|
'cell' |
cell array |
'table' |
table |
'timetable' |
timetable |
'structure' |
structure |
Note
The default data type of the returned data depends on the executed function. To specify the default data type, set theDataReturnFormat
property to''
。For default data types, see the supported function list.
You can specify these values using a character vector or string (for example,"table"
).
When you create ablpsrv
object, theblpsrv
function leaves this property unset. To retrieve data, you must set this property value manually at the command line or in a script using dot notation, for example:
c.DataReturnFormat = 'structure';
Supported Function | Valid Data Types for Returned Data |
---|---|
category |
|
eqs |
|
fieldinfo |
|
fieldsearch |
|
lookup |
|
portfolio |
|
getbulkdata |
|
getdata |
|
history |
|
tahistory |
|
timeseries |
|
Note
Regardless of theDatetimeType
property value, if theDataReturnFormat
property value is'timetable'
, then thegetdata
andgetbulkdata
functions return a table that contains date and time values asdatetime
arrays.
Object Functions
Bloomberg服务器Connection
close |
CloseBloombergconnection V3 |
get |
Properties ofBloombergconnection V3 |
isconnection |
DetermineBloombergconnection V3 |
Bloomberg服务器Data Retrieval
eqs |
Equity screening data forBloombergconnection V3 |
getbulkdata |
Bulk data with header information forBloombergconnection V3 |
getdata |
Current data forBloombergconnection V3 |
history |
Historical data forBloombergconnection V3 |
portfolio |
Current portfolio data forBloombergconnection V3 |
realtime |
Real-time data forBloombergconnection V3 |
stop |
Unsubscribe real-time requests forBloombergconnection V3 |
tahistory |
Historical technical analysis forBloombergconnection V3 |
timeseries |
Intraday tick data forBloombergconnection V3 |
Bloomberg服务器Data Information
category |
Field category search forBloombergconnection V3 |
fieldinfo |
Field information forBloombergconnection V3 |
fieldsearch |
Field search forBloombergconnection V3 |
lookup |
Find information about securities forBloombergconnection V3 |
Examples
连接到Bloomberg服务器
连接到the Bloomberg Server using the IP address of the machine running the Bloomberg Server. This example assumes the following:
The Bloomberg UUID is
12345678
。The IP address for the machine running the Bloomberg Server is
'111.11.11.111'
。
uuid = 12345678; ipaddress ='111.11.11.111'; c = blpsrv(uuid,ipaddress)
c = blpsrv with properties: Uuid: 12345678 User: [1x1 com.bloomberglp.blpapi.impl.aT] Userip: '111.11.11.112' Session: [1x1 com.bloomberglp.blpapi.Session] IPAddress: '111.11.11.111' Port: 8194 TimeOut: 0 DatetimeType: '' DataReturnFormat: ''
blpsrv
connects to the machine running the Bloomberg Server using the default port number8194
。blpsrv
creates the Bloomberg Server connection objectc
with these properties:
Bloomberg user identity UUID
Bloomberg user identity object
IP address of the machine running MATLAB
Bloomberg V3 API Session object
IP address of the machine running the Bloomberg Server
Port number of the machine running the Bloomberg Server
Number in milliseconds specifying how long MATLAB attempts to connect to the machine running the Bloomberg Server before timing out
Date and time data type
返回数据格式
Request the last and open prices for Microsoft®。
formatbank% Display data format for currencys ='MSFT US Equity'; f = {'LAST_PRICE';'OPEN'}; [d,sec] = getdata(c,s,f)
d = LAST_PRICE: 33.34 OPEN: 33.60 sec = 'MSFT US Equity'
getdata
returns a structured
with the last and open prices. Also,getdata
returns the name of the security insec
。
Close the Bloomberg Server connection.
close(c)
连接到Bloomberg服务器with Port Number
连接到the Bloomberg Server using the IP address of the machine running the Bloomberg Server. This example assumes the following:
The Bloomberg UUID is
12345678
。The IP address for the machine running the Bloomberg Server is
'111.11.11.111'
。The port number of the machine running the Bloomberg Server is
8194
。
uuid = 12345678; ipaddress ='111.11.11.111'; port = 8194; c = blpsrv(uuid,ipaddress,port)
c = blpsrv with properties: Uuid: 12345678 User: [1x1 com.bloomberglp.blpapi.impl.aT] Userip: '111.11.11.112' Session: [1x1 com.bloomberglp.blpapi.Session] IPAddress: '111.11.11.111' Port: 8194 TimeOut: 0 DatetimeType: '' DataReturnFormat: ''
blpsrv
connects to the machine running the Bloomberg Server using the port number8194
and creates the Bloomberg Server connection objectc
with these properties:
Bloomberg user identity UUID
Bloomberg user identity object
IP address of the machine running MATLAB
Bloomberg V3 API Session object
IP address of the machine running the Bloomberg Server
Port number of the machine running the Bloomberg Server
Number in milliseconds specifying how long MATLAB attempts to connect to the machine running the Bloomberg Server before timing out
Date and time data type
返回数据格式
Request the last and open prices for Microsoft.
formatbank% Display data format for currencys ='MSFT US Equity'; f = {'LAST_PRICE';'OPEN'}; [d,sec] = getdata(c,s,f)
d = LAST_PRICE: 33.34 OPEN: 33.60 sec = 'MSFT US Equity'
getdata
returns a structured
with the last and open prices. Also,getdata
returns the name of the security insec
。
Close the Bloomberg Server connection.
close(c)
连接到Bloomberg服务器with Timeout
连接到the Bloomberg Server using the IP address of the machine running the Bloomberg Server. This example assumes the following:
The Bloomberg UUID is
12345678
。The IP address for the machine running the Bloomberg Server is
'111.11.11.111'
。The port number of the machine running the Bloomberg Server is your default port number.
The timeout value is 10 milliseconds.
uuid = 12345678; ipaddress ='111.11.11.111'; port = []; timeout = 10; c = blpsrv(uuid,ipaddress,port,timeout)
c = blpsrv with properties: Uuid: 12345678 User: [1x1 com.bloomberglp.blpapi.impl.aT] Userip: '111.11.11.112' Session: [1x1 com.bloomberglp.blpapi.Session] IPAddress: '111.11.11.111' Port: 8194 TimeOut: 10 DatetimeType: '' DataReturnFormat: ''
blpsrv
connects to the machine running the Bloomberg Server using the default port number8194
and a timeout value of 10 milliseconds.blpsrv
creates the Bloomberg Server connection objectc
with these properties:
Bloomberg user identity UUID
Bloomberg user identity object
IP address of the machine running MATLAB
Bloomberg V3 API Session object
IP address of the machine running the Bloomberg Server
Port number of the machine running the Bloomberg Server
Number in milliseconds specifying how long MATLAB attempts to connect to the machine running the Bloomberg Server before timing out
Date and time data type
返回数据格式
Request the last and open prices for Microsoft.
formatbank% Display data format for currencys ='MSFT US Equity'; f = {'LAST_PRICE';'OPEN'}; [d,sec] = getdata(c,s,f)
d = LAST_PRICE: 33.34 OPEN: 33.60 sec = 'MSFT US Equity'
getdata
returns a structured
with the last and open prices. Also,getdata
returns the name of the security insec
。
Close the Bloomberg Server connection.
close(c)
Version History
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- 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)