vba - Bloomberg API: How to check wether connection works? -
i implementing tool relies on bloombergs blpapilib2, bloomberg api com lib 3.5.
before giving user access refresh-data functionality, want make sure connection works. approach far:
check wether library available , linked. loop through references job.
open connection session.start() . hoping error here, won't give me one. thus, step 3.
request data , verify (make sure not empty)
surporisingly, cannot reliably reproduce getting empty result. expected session relies on user being looged terminal. seems wrong; if log out, request handled , return correct data.
i can imagine 2 scenarios:
some background caching in bbcom-server
an alternative authentication method used
i have 2 questions:
q1. best way make sure user able download data?
q2. how can verify whether connection has been established , user authenticated?
thanks.
to "cut" connection, need log out , log in on different machine. if log out feed still available using api.
this how test connection - think works well. have bloombergwrapper
class handles low level stuff of communicating api , has following functions:
private psession blpapicomlib2.session private pservice blpapicomlib2.service private sub class_initialize() dim locstatusbar variant dim locbbresult variant on error goto error_handler if application.statusbar = false locstatusbar = false else locstatusbar = application.statusbar application.statusbar = "connecting bloomberg..." set psession = new blpapicomlib2.session psession.start psession.openservice ("//blp/refdata") set pservice = psession.getservice("//blp/refdata") application.statusbar = locstatusbar exit sub error_handler: if instr(err.description, "timeout") call msgbox("a bloomberg timeout has occured. make sure logged on terminal.", vbcritical + vbokonly, "bloomberg error...") end if if locstatusbar <> "" application.statusbar = locstatusbar end sub private sub class_terminate() psession.stop set psession = nothing end sub
Comments
Post a Comment