API Reference

BLPData.SessionType
Session(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)
source
BLPData.ClientModeType

Sets 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.

source
BLPData.stopFunction
stop(session::Session)

Stops a session.

Once a Session has been stopped it can only be destroyed.

source
BLPData.bdhFunction
bdh(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 a Dict.

  • periodicity expects the string value for the periodicitySelection 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))
source
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.

source
BLPData.bdsFunction
bds(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)
source
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.

source