Public API Reference
BLPData.Session — TypeSession(services;
host=nothing,
port=nothing,
client_mode=nothing,
service_check_timeout_msecs=nothing
service_download_timeout_msecs=nothing,
session_start_timeout_msecs=DEFAULT_SESSION_START_TIMEOUT_MSECS,
verbose::Bool=false
)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_AUTOtries to
connect to Desktop API, and falls back to Server API.
BLPAPI_CLIENTMODE_DAPIconnects to Desktop API.BLPAPI_CLIENTMODE_SAPIconnects to Server API.
The default when creating SessionOptions is BLPAPI_CLIENTMODE_AUTO.
See also Session.
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
fieldsis either a single string or an array of string values.optionsargument expects a key->value pairs or aDict.periodicityexpects the string value for theperiodicitySelectionoption.
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.bdp — Functionbdp(session::Session, security::AbstractString, fields;
options=nothing, # expects key->value pairs or Dict
verbose::Bool=false,
timeout_milliseconds::Integer=UInt32(0)
)Given a single field name or vector of field names at the fields argument, return a single named tuple with the result of a ReferenceDataRequest request.
For bulk data, bds method should be used instead.
Example
julia> BLPData.bdp(session, "PETR4 BS Equity", "PX_LAST")
(PX_LAST = 15.95,)
julia> BLPData.bdp(session, "PETR4 BS Equity", ["PX_LAST", "VOLUME"])
(PX_LAST = 15.95, VOLUME = 1.601771e8)BLPData.get_version_info — Functionget_version_info() :: VersionInfoReturns the version of the shared library for Bloomberg API.
BLPData.next_event — Functionnext_event(event_source; timeout_milliseconds::Integer=UInt32(0)) :: EventReads the next event in the stream events of the event_source. This method blocks until an event is available.
See also try_next_event.
Event Sources
The event_source can be either a Session or an EventQueue.
next_event(queue::EventQueue; timeout_milliseconds::Integer=Cint(0)) :: EventReturns the next event available in the queue. If timeout_milliseconds is zero, waits forever until an event is available.
BLPData.try_next_event — Functiontry_next_event(event_source) :: Union{Nothing, Event}Reads the next event in the stream events of the event_source. If no event is available, returns nothing. This method never blocks.
See also next_event.
Event Sources
The event_source can be either a Session or an EventQueue.
BLPData.subscribe — Functionsubscribe(session::Session, topics) :: SubscriptionListSubscribes to real-time events on a single topic or a list of topics. The topics argument should be an AbstractString or a Vector{AbstractString}.
See also unsubscribe, SubscriptionList.
Example
topic = "//blp/mktdata/ticker/PETR4 BS Equity?fields=BID,ASK"
subscription_list = BLPData.subscribe(session, topic)
i = 1 # event counter
evn = BLPData.try_next_event(session)
while evn != nothing
println("event $i")
println(evn)
i += 1
sleep(2) # let's wait for events
evn = BLPData.try_next_event(session)
end
BLPData.unsubscribe(session, subscription_list)BLPData.unsubscribe — Functionunsubscribe(session::Session, sublist::SubscriptionList)Unsubscribes to real-time events on topis in the sublist.
See also subscribe, SubscriptionList.
BLPData.SubscriptionList — TypeA list of SubscriptionTopics. This struct supports the basic vector API.
Examples
list = BLPData.SubscriptionList() # creates an empty list
append!(list, ["//blp/mktdata/ticker/PETR4 BS Equity?fields=BID,ASK", "//blp/mktdata/ticker/VALE3 BS Equity?fields=BID,ASK"])
for topic in list
println(topic)
endSee also SubscriptionTopic.
BLPData.SubscriptionTopic — TypeRepresents a Topic related to the subscription API.
Fields
correlation_id: unique identifier for tracking events in the event stream related to this subscription.topic: a valid subscription string for the BLPAPI.
See also subscribe.