API Reference
BLPData.Session
— TypeSession(services...;
host=nothing,
port=nothing,
client_mode=nothing,
service_check_timeout_msecs=nothing
)
Creates a new session for Bloomberg API.
See also stop
, ClientMode
.
Example
# starts a session with default parameters:
# * host=127.0.0.1, port=8194
# * client_mode = BLPAPI_CLIENTMODE_AUTO.
# * services = BLPData.DEFAULT_SERVICE_NAMES
session = Blpapi.Session()
# session with customized parameters
customized_session = Blpapi.Session("//blp/refdata",
host="my_host",
port=4444,
client_mode=Blpapi.BLPAPI_CLIENTMODE_DAPI)
BLPData.ClientMode
— TypeSets how to connect to the Bloomberg API.
BLPAPI_CLIENTMODE_AUTO
tries to
connect to Desktop API, and falls back to Server API.
BLPAPI_CLIENTMODE_DAPI
connects to Desktop API.BLPAPI_CLIENTMODE_SAPI
connects to Server API.
The default when creating SessionOptions
is BLPAPI_CLIENTMODE_AUTO
.
See also Session
, get_client_mode
.
BLPData.stop
— Functionstop(session::Session)
Stops a session.
Once a Session has been stopped it can only be destroyed.
BLPData.bdh
— Functionbdh(session::Session, security::AbstractString, fields, date_start::Date, date_end::Date;
periodicity=nothing, # periodicitySelection option
options=nothing, # expects key->value pairs or Dict
verbose::Bool=false,
timeout_milliseconds::Integer=UInt32(0)
Runs a query for historical data. Returns a Vector
of named tuples.
Internally, it issues a HistoricalDataRequest
in //blp/refdata
service.
See also bds
.
Arguments
fields
is either a single string or an array of string values.options
argument expects a key->value pairs or aDict
.periodicity
expects the string value for theperiodicitySelection
option.
Simple query example
using BLPData, DataFrames, Dates
# opens a session
session = BLPData.Session()
# query historical data
result = BLPData.bdh(session, "IBM US Equity", ["PX_LAST", "VWAP_VOLUME"], Date(2020, 1, 2), Date(2020, 1, 30))
# format result as a `DataFrame`
df = DataFrame(result)
Query with optional parameters
ticker = "PETR4 BS Equity"
field = "PX_LAST"
options = Dict(
"periodicityAdjustment" => "CALENDAR",
"periodicitySelection" => "DAILY",
"currency" => "BRL",
"pricingOption" => "PRICING_OPTION_PRICE",
"nonTradingDayFillOption" => "ACTIVE_DAYS_ONLY",
"nonTradingDayFillMethod" => "NIL_VALUE",
"adjustmentFollowDPDF" => false,
"adjustmentNormal" => true,
"adjustmentAbnormal" => true,
"adjustmentSplit" => true
)
# query for adjusted stock price
df = DataFrame(BLPData.bdh(session, ticker, field, Date(2019, 1, 1), Date(2019, 2, 10), options=options))
bdh(session::Session, securities::Vector{T1}, fields::Vector{T2}, date_start::Date, date_end::Date;
periodicity=nothing, # periodicitySelection option
options=nothing, # expects key->value pairs or Dict
verbose::Bool=false,
timeout_milliseconds::Integer=UInt32(0)
) where {T1<:AbstractString, T2<:AbstractString}
Runs a query for historical data. Returns a Dict
where the key is the security name and value is a Vector
of named tuples.
Internally, BLPData will process a ReferenceDataRequest
request for each security in parallel.
BLPData.bds
— Functionbds(session::Session, security::AbstractString, field::AbstractString;
options=nothing, # expects key->value pairs or Dict
verbose::Bool=false,
timeout_milliseconds::Integer=UInt32(0)
Runs a query for reference data of a security. Returns a Vector
of named tuples.
Internally, it issues a ReferenceDataRequest
in //blp/refdata
service.
See also bdh
.
Example
using BLPData, DataFrames
session = BLPData.Session()
result = BLPData.bds(session, "PETR4 BS Equity", "COMPANY_ADDRESS")
df = DataFrame(result)
bds(session::Session, securities::Vector{T}, field::AbstractString;
options=nothing, # expects key->value pairs or Dict
verbose::Bool=false,
timeout_milliseconds::Integer=UInt32(0)
) where {T<:AbstractString}
Runs a query for reference data of a security. Returns a Dict
where the key is the security name and value is a Vector
of named tuples.
Internally, BLPData will process a ReferenceDataRequest
request for each security in parallel.
BLPData.get_version_info
— Functionget_version_info() :: VersionInfo
Returns the version of the shared library for Bloomberg API.