Description Usage Arguments Value See Also Examples
View source: R/HighLevelFunctions.R
By default, this methods blocks call, until the file is available (which can be several minutes) (see sync
parameter
for details)
1 2 | GetData(con, fields, tickers, sync = TRUE, parser = GetDataParser,
verbose = FALSE)
|
con |
The |
fields |
A vector of fields, e.g. c('PX_LAST', 'NAME') |
tickers |
A vector of Bloomberg tickers to be downloaded, e.g. c('SPX Index', 'IBM US Equity') |
sync |
If TRUE, the call does not return until the response file is available, or if a timeout occurs |
parser |
The parser used to convert the file into an R object. See |
verbose |
Prints output if TRUE |
A list containing the downloaded data. If you use the default parser, then a dataframe is returned. More precisely, the list contains the following items:
connection
The BdlConnection
object used to connect ot Bloomberg (R). This contains the credentials necessary.
requestTime
The time at which the request was sent to Bloomberg (R)
requestFileName
The name of the file that was uploaded to Bloomberg (R)
replyTime
The time at which the reply was downloaded from Bloomberg (R). Applies only if sync == TRUE
replyFileName
The name of the file that was uploaded to Bloomberg (R)
GetReply(parser., verbose.)
A callback function to download the reply file. The paramaeters are optional and allow
you to overwrite their counterparts given in the GetSnapshot
call.
success
TRUE
if the method call was successful. In case of sync == TRUE
, this means that a reply file
was successfully downloaded and parsed. Otherwise, it means that the request file was successfully uploaded.
GetHistory, GetSnapshot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ## Not run:
#' con <- BdlConnection(user = 'dl111111',
pw = 'XvH,gE2A',
key = '3xzZl0yA')
#######################
#Sync call
data <- GetData(con,
fields = c('PX_LAST', 'NAME', 'CRNCY'),
tickers = c('SPX Index', 'SMI Index', 'IBM US Equity', '120421Q FP Equity'))
#the call blocks, and after 5 minutes or so, you get the reply
if(data$success) {
data$reply
#or extract a single value
data$reply['SPX Index', 'PX_LAST']
}
#If your data does not make sense, or you have other problems, you can re-download again using
#any other parser, and overwriting the verbose parameter:
cat(data$GetReply(verbose. = TRUE, parser. = function(x) x))
#######################
#Async call
data <- GetData(con,
fields = c('PX_LAST', 'NAME', 'CRNCY'),
tickers = c('SPX Index', 'SMI Index', 'IBM US Equity', '120421Q FP Equity'),
sync = FALSE)
#the method returns after uploading. 5 minutes later, you can request to download
#the reply using the callback:
reply <- data$GetReply()
if(!is.null(reply)) {
#do something with the data
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.