Rblp / Rblpapi

R package interfacing the Bloomberg API from https://www.bloomberglabs.com/api/
Other
167 stars 75 forks source link

Connection funnyness #382

Closed st501351 closed 1 year ago

st501351 commented 1 year ago

I had a weird issue today after years of working the same way. I used to just call blpConnect() then call bdh with no connection but today it started giving an error "Error in bdh_Impl(con, securities, fields, start.date, end.date, options, : Attempt to access out of range index '0' on array element 'fieldData' which has 0 value(s)."

Strangely sometimes if I would call blpDisconnect it would then work as expected.

Workaround is putting blpConnect/disConnect around all calls but this is new to me and wondering if bbg changed the API or whatever. Could be my fault

eddelbuettel commented 1 year ago

We tend to keep the connection object in the package namespace as an invisible global state variable. Maybe something changed and the API now gets stale. I would not be able to tell as I have not had access to Bloomberg for a few years now....

st501351 commented 1 year ago

Now I can't recreate a minimal example so I guess it was just me.

Just out of curiosity: does blpDisconnect do anything? image

eddelbuettel commented 1 year ago

Well maybe try again tomorrow after a fresh logon and see then. We can hopefully close this.

Widely used APIs tend not to get changed willy-nilly by reasonable provides -- but a lot can get in the way starting from your local networking to the telco / network to the backend. Bloomberg is famously reliable but hickups can happen.

st501351 commented 1 year ago

Yeah will see tomorrow and if I can't reproduce will close

johnlaing commented 1 year ago

Confirming that the API seems to work just fine for me.

One thing that I noticed in the image you pasted was the phrase "Restarting R session..." I'm not sure which GUI this is from as I do everything in the terminal myself. Is it possible that you may have saved a workspace containing a stale connection, and then inadvertently reloaded it?

To answer your other question: no, blpDisconnect does not actually do anything. This was actually a surprise to me on investigating it, but in fact we have documented it:

Description This function provides an empty stub and does not really disconnect.