pkgname <- "Rblpapi"
source(file.path(R.home("share"), "R", "examples-header.R"))
options(warn = 1)
library('Rblpapi')

base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv')
cleanEx()
nameEx("bdh")
### * bdh

flush(stderr()); flush(stdout())

### Name: bdh
### Title: Run 'Bloomberg Data History' Queries
### Aliases: bdh

### ** Examples

## Not run: 
##D   bdh("SPY US Equity", c("PX_LAST", "VOLUME"), start.date=Sys.Date()-31)
##D 
##D   ## example for an options field: request monthly data; see section A.2.4 of
##D   ##  http://www.bloomberglabs.com/content/uploads/sites/2/2014/07/blpapi-developers-guide-2.54.pdf
##D   ## for more
##D   opt <- c("periodicitySelection"="MONTHLY")
##D   bdh("SPY US Equity", c("PX_LAST", "VOLUME"),
##D       start.date=Sys.Date()-31*6, options=opt)
##D 
##D   ## example for non-date start
##D   bdh("SPY US Equity", c("PX_LAST", "VOLUME"),
##D       start.date="-6CM", options=opt)
##D 
##D   ## example for options and overrides
##D   opt <- c("periodicitySelection"="QUARTERLY")
##D   ovrd <- c("BEST_FPERIOD_OVERRIDE"="1GQ")
##D   bdh("IBM US Equity", "BEST_SALES", start.date=Sys.Date()-365.25*4,
##D       options=opt, overrides=ovrd)
##D 
##D   ## example for returnRelativeDate option
##D   opt <- c(periodicitySelection="YEARLY", periodicityAdjustment="FISCAL", returnRelativeDate=TRUE)
##D   bdh("GLB ID Equity", "CUR_MKT_CAP", as.Date("1997-12-31"), as.Date("2017-12-31"), options=opt)
## End(Not run)



cleanEx()
nameEx("bdp")
### * bdp

flush(stderr()); flush(stdout())

### Name: bdp
### Title: Run 'Bloomberg Data Point' Queries
### Aliases: bdp

### ** Examples

## Not run: 
##D   bdp(c("ESA Index", "SPY US Equity"), c("PX_LAST", "VOLUME"))
##D 
##D   ##  using overrides (cf https://github.com/Rblp/Rblpapi/issues/67)
##D   bdp("EN00 Index", "MLI_OAS", overrides=c(MLI_DATE="20150831"))
##D 
##D   ##  another override example (cf http://stackoverflow.com/a/39373019/143305)
##D   ovrd <- c("CALC_INTERVAL"="10Y", "MARKET_DATA_OVERRIDE"="PE_RATIO")
##D   bdp("SPX Index", "INTERVAL_AVG", overrides=ovrd)
## End(Not run)



cleanEx()
nameEx("bds")
### * bds

flush(stderr()); flush(stdout())

### Name: bds
### Title: Run 'Bloomberg Data Set' Queries
### Aliases: bds

### ** Examples

## Not run: 
##D   ## simple query
##D   bds("GOOG US Equity", "TOP_20_HOLDERS_PUBLIC_FILINGS")
##D   ## example of using overrides
##D   overrd <- c("START_DT"="20150101", "END_DT"="20160101")
##D   bds("CPI YOY Index","ECO_RELEASE_DT_LIST", overrides = overrd)
## End(Not run)



cleanEx()
nameEx("beqs")
### * beqs

flush(stderr()); flush(stdout())

### Name: beqs
### Title: Run 'Bloomberg EQS' Queries
### Aliases: beqs

### ** Examples

## Not run: 
##D head(beqs("Global Oil Companies YTD Return"), 20)
##D head(beqs("Global Oil Companies YTD Return", "GLOBAL"), 20)
##D head(beqs("Global Oil Companies YTD Return", "GLOBAL", "GERMAN"), 20)
##D head(beqs("Global Oil Companies YTD Return", "GLOBAL", "GERMAN", "GENERAL"), 20)
##D head(beqs("Global Oil Companies YTD Return", "GLOBAL", "ENGLISH", "GENERAL",
##D           as.Date("2015-09-30")), 20)
## End(Not run)



cleanEx()
nameEx("blpAuthenticate")
### * blpAuthenticate

flush(stderr()); flush(stdout())

### Name: blpAuthenticate
### Title: Authenticate Bloomberg API access
### Aliases: blpAuthenticate

### ** Examples

## Not run: 
##D blpConnect(host=blpHost, port=blpPort)
##D blpAuthenticate(uuid=blpUUID, ip=blpIP_address)
##D bdp("IBM US Equity", "NAME")
##D 
##D blpid <- blpAuthenticate(uuid=blpUUID, ip=blpIP_address)
##D bdp("IBM US Equity", "NAME", identity=blpid)
## End(Not run)



cleanEx()
nameEx("blpConnect")
### * blpConnect

flush(stderr()); flush(stdout())

### Name: blpConnect
### Title: Establish connection to Bloomberg service
### Aliases: blpConnect

### ** Examples

## Not run: 
##D   con <- blpConnect()   # adjust as needed
## End(Not run)



cleanEx()
nameEx("blpDisconnect")
### * blpDisconnect

flush(stderr()); flush(stdout())

### Name: blpDisconnect
### Title: Placeholder function for disconnection from Bloomberg
### Aliases: blpDisconnect

### ** Examples

## Not run: 
##D   blpDisconnect(con)
## End(Not run)



cleanEx()
nameEx("bsrch")
### * bsrch

flush(stderr()); flush(stdout())

### Name: bsrch
### Title: Run 'Bloomberg SRCH' Queries
### Aliases: bsrch

### ** Examples

## Not run: 
##D head(bsrch("FI:YOURSRCH"), 20)
## End(Not run)



cleanEx()
nameEx("defaults")
### * defaults

flush(stderr()); flush(stdout())

### Name: defaultConnection
### Title: Return the default connection/authentication objects
### Aliases: defaultConnection defaultAuthentication

### ** Examples

## Not run: 
##D   con <- defaultConnection()
##D   blpid <- defaultAuthentication()
## End(Not run)



cleanEx()
nameEx("fieldInfo")
### * fieldInfo

flush(stderr()); flush(stdout())

### Name: fieldInfo
### Title: Run 'Bloomberg Field Data' Queries
### Aliases: fieldInfo

### ** Examples

## Not run: 
##D   fieldInfo(c("PX_LAST", "VOLUME"))
## End(Not run)



cleanEx()
nameEx("fieldSearch")
### * fieldSearch

flush(stderr()); flush(stdout())

### Name: fieldSearch
### Title: Search for matching data fields
### Aliases: fieldSearch

### ** Examples

## Not run: 
##D   head(fieldSearch("vwap"), 20)
## End(Not run)




cleanEx()
nameEx("getBars")
### * getBars

flush(stderr()); flush(stdout())

### Name: getBars
### Title: Get Open/High/Low/Close/Volume Bars from Bloomberg
### Aliases: getBars

### ** Examples

## Not run: 
##D   getBars("ES1 Index")
## End(Not run)



cleanEx()
nameEx("getHeaderVersion")
### * getHeaderVersion

flush(stderr()); flush(stdout())

### Name: getHeaderVersion
### Title: Get Bloomberg library header version
### Aliases: getHeaderVersion

### ** Examples

## Not run: 
##D    getHeaderVersion()
## End(Not run)



cleanEx()
nameEx("getRuntimeVersion")
### * getRuntimeVersion

flush(stderr()); flush(stdout())

### Name: getRuntimeVersion
### Title: Get Bloomberg library run-time version
### Aliases: getRuntimeVersion

### ** Examples

## Not run: 
##D    getRuntimeVersion()
## End(Not run)



cleanEx()
nameEx("getTicks")
### * getTicks

flush(stderr()); flush(stdout())

### Name: getTicks
### Title: Get Ticks from Bloomberg
### Aliases: getTicks

### ** Examples

## Not run: 
##D   res <- getTicks("ES1 Index")
##D   str(res)
##D   head(res, 20)
##D   res <- getTicks("ES1 Index", returnAs="data.table")
##D   str(res)
##D   head(res, 20)
## End(Not run)



cleanEx()
nameEx("lookupSecurity")
### * lookupSecurity

flush(stderr()); flush(stdout())

### Name: lookupSecurity
### Title: Look up symbol from Bloomberg
### Aliases: lookupSecurity

### ** Examples

## Not run: 
##D   lookupSecurity("IBM")
##D   lookupSecurity("IBM", maxResuls=1000)    # appears to be capped at 1000
##D   lookupSecurity("IBM", "mtge")
##D   lookupSecurity("IBM ", "mtge")           # trailing space affects query
##D 
##D   ## modify the symbol column (cf issue ticket 215 at GitHub)
##D   res <- lookupSecurity("IBM")
##D   res[, "symbol"] <- sub(pattern="^(.+)<(.)(.+)>$", "\\1 \\U\\2\\E\\3",
##D                          perl=TRUE, res[, "security"])
##D   res
## End(Not run)



cleanEx()
nameEx("subscribe")
### * subscribe

flush(stderr()); flush(stdout())

### Name: subscribe
### Title: Subscribe to streaming market data
### Aliases: subscribe

### ** Examples

## Not run: 
##D   subscribe(securities=c("TYZ5 Comdty","/cusip/912810RE0@BGN"),
##D             fields=c("LAST_PRICE","BID","ASK"),
##D             fun=function(x) print(str(x$data)))
## End(Not run)



### * <FOOTER>
###
cleanEx()
options(digits = 7L)
base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
grDevices::dev.off()
###
### Local variables: ***
### mode: outline-minor ***
### outline-regexp: "\\(> \\)?### [*]+" ***
### End: ***
quit('no')
