Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ beqs_Impl <- function(con, screenName, screenType, group, pitdate, languageId, v
.Call(`_Rblpapi_beqs_Impl`, con, screenName, screenType, group, pitdate, languageId, verbose)
}

blpConnect_Impl <- function(host, port, app_name_) {
.Call(`_Rblpapi_blpConnect_Impl`, host, port, app_name_)
blpConnect_Impl <- function(host, port, app_name_, app_identity_key_) {
.Call(`_Rblpapi_blpConnect_Impl`, host, port, app_name_, app_identity_key_)
}

#' This function retrieves the version of Bloomberg API headers.
Expand Down
7 changes: 5 additions & 2 deletions R/blpConnect.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
##' to connect to bpipe. If this is NULL Rblpapi connects to the
##' Bloomberg API but cannot authenticate with an app name. This requires
##' the user to authenticate with a user uuid.
##' @param appIdentityKey the application identity key. For Desktop API,
##' this is generated from the APRE screen on Bloomberg terminal.
##' @return In the \code{default=TRUE} case nothing is returned, and
##' this connection is automatically used for all future calls which
##' omit the \code{con} argument. Otherwise a connection object is
Expand All @@ -58,10 +60,11 @@
blpConnect <- function(host=getOption("blpHost", "localhost"),
port=getOption("blpPort", 8194L),
default=TRUE,
appName = getOption("blpAppName", NULL)) {
appName = getOption("blpAppName", NULL),
appIdentityKey = getOption("blpAppIdentityKey", NULL)) {
if (storage.mode(port) != "integer") port <- as.integer(port)
if (storage.mode(host) != "character") stop("Host argument must be character.", call.=FALSE)
con <- blpConnect_Impl(host, port, appName)
con <- blpConnect_Impl(host, port, appName, appIdentityKey)

if (default) .pkgenv$con <- con else return(con)
}
6 changes: 5 additions & 1 deletion man/blpConnect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ BEGIN_RCPP
END_RCPP
}
// blpConnect_Impl
SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_);
RcppExport SEXP _Rblpapi_blpConnect_Impl(SEXP hostSEXP, SEXP portSEXP, SEXP app_name_SEXP) {
SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_, SEXP app_identity_key_);
RcppExport SEXP _Rblpapi_blpConnect_Impl(SEXP hostSEXP, SEXP portSEXP, SEXP app_name_SEXP, SEXP app_identity_key_SEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const std::string >::type host(hostSEXP);
Rcpp::traits::input_parameter< const int >::type port(portSEXP);
Rcpp::traits::input_parameter< SEXP >::type app_name_(app_name_SEXP);
rcpp_result_gen = Rcpp::wrap(blpConnect_Impl(host, port, app_name_));
Rcpp::traits::input_parameter< SEXP >::type app_identity_key_(app_identity_key_SEXP);
rcpp_result_gen = Rcpp::wrap(blpConnect_Impl(host, port, app_name_, app_identity_key_));
return rcpp_result_gen;
END_RCPP
}
Expand Down Expand Up @@ -260,7 +261,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_Rblpapi_bds_Impl", (DL_FUNC) &_Rblpapi_bds_Impl, 7},
{"_Rblpapi_getPortfolio_Impl", (DL_FUNC) &_Rblpapi_getPortfolio_Impl, 7},
{"_Rblpapi_beqs_Impl", (DL_FUNC) &_Rblpapi_beqs_Impl, 7},
{"_Rblpapi_blpConnect_Impl", (DL_FUNC) &_Rblpapi_blpConnect_Impl, 3},
{"_Rblpapi_blpConnect_Impl", (DL_FUNC) &_Rblpapi_blpConnect_Impl, 4},
{"_Rblpapi_getHeaderVersion", (DL_FUNC) &_Rblpapi_getHeaderVersion, 0},
{"_Rblpapi_getRuntimeVersion", (DL_FUNC) &_Rblpapi_getRuntimeVersion, 0},
{"_Rblpapi_bsrch_Impl", (DL_FUNC) &_Rblpapi_bsrch_Impl, 4},
Expand Down
8 changes: 6 additions & 2 deletions src/blpConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void sessionFinalizer(SEXP session_) {
}

// [[Rcpp::export]]
SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_) {
SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_, SEXP app_identity_key_) {
SessionOptions sessionOptions;
sessionOptions.setServerHost(host.c_str());
sessionOptions.setServerPort(port);
Expand All @@ -54,6 +54,10 @@ SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_) {
std::string authentication_string = APP_PREFIX + app_name;
sessionOptions.setAuthenticationOptions(authentication_string.c_str());
}
if (app_identity_key_ != R_NilValue) {
std::string app_identity_key = Rcpp::as<std::string>(app_identity_key_);
sessionOptions.setApplicationIdentityKey(app_identity_key);
}
Session* sp = new Session(sessionOptions);

if (!sp->start()) {
Expand All @@ -69,7 +73,7 @@ SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_) {
#else // ie if defined(NoBlpHere)

#include <Rcpp/Lightest>
SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_) {
SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_, SEXP app_identity_key_) {
return R_NilValue;
}

Expand Down