-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: BLPAPI_ERROR_INVALID_CONVERSION for field PX_VOLUME #163
Comments
I'd say "their fault": R> library(Rblpapi)
Rblpapi version 0.3.3.2 using Blpapi headers 3.8.8.1 and run-time 3.8.8.1.
Please respect the Bloomberg licensing agreement and terms of service.
R> fieldInfo("PX_VOLUME")
id mnemonic datatype ftype
PX_VOLUME PR013 PX_VOLUME Int32 String
R> fieldInfo("VOLUME")
id mnemonic datatype ftype
VOLUME RQ013 VOLUME Int64 Real
R> It is declared 'String' and 'Int32' which does not make a lot of sense. Maybe we can add another workaround. Thoughts, @armstrtw ? |
I realize this likely does not help the OP, but I found it peculiar and wanted to note it here in case it helps with deciding how to work around it. The
I would volunteer to help but at present I cannot push code written on my BBG terminal to Github. |
Fine-tuning Joel's idea:
The volume on 12/15 exceeds the max for int32 of ~2.1b. So that explains why we can't make it an int32. What's unexplained is why they declare it as such. I guess someone should ask Bloomberg... |
Int32 does not make sense for this field. I am happy to raise it with BBG. |
Raised with BBG, they are having their programmers look at it. Will update here when I hear from them. BBG helpdesk reference: H#680960625 |
@wmorgan85 I have pasted in the helpdesk reference for this issue. |
Thanks, I am following up internally On Tue, 19 Apr 2016 at 00:21 joel23888 [email protected] wrote:
|
@joel23888 have your got BBG's reply? The same error occurs while I try to retrieve 'PX_VOLUME' of UKX Index 2012-06-16. |
I have not received a response from them. @wmorgan85 any updates on this? @eiwin would it work for you if you use VOLUME instead of PX_VOLUME? See #159. Also please update to the v0.3.4 if you have not already. Then you should get: > bdh("UKX Index", "VOLUME", as.Date("2012-06-13"), as.Date("2012-06-18"))
date VOLUME
1 2012-06-13 831658496
2 2012-06-14 1064836032
3 2012-06-15 2531612416
4 2012-06-18 934686144 Incidentally, 2012-06-16 was a Saturday so are you actually expecting a data point on that date? |
The overall issue seems to be that many fields show up in fieldInfo as int32, they are automatically upscaled to int64 when the magnitude of the observation exceeds int32, which seems to happen frequently upon frequency reduction / aggregation. There are two fixes I can see.
As much as I don't like the idea of forcing ints as doubles it would be far less work to maintain if we go this route. I don't see much hope for this being fixed by bbg in any reasonable time horizon. So, I think we should deal with it in the package. Totally open to other suggestions. |
Just thinking out loud: can we not 'pretest' by casting to double and compare to A little bird whispered something to me recently too that there are plans about more reflective answer data sets as the issue has been recognised in some quarters. No timeline, of course. |
but we are not doing lazyFrame any more. We need to know the types before we make the request. Or did I misunderstand your suggestion. |
I was thinking about that too. Well that sucks. New idea then: always store in double vector, if values "contained" then downcast to int vector. |
@joel23888 |
I asked the BBG helpdesk for an update and their advice boils down to handling this issue on the Rblpapi side. They also said that their programmers are reviewing the data types list (no timelines). |
A further update. BBG helpdesk explained how this is handled in VBA: there is a DataType property returned along with data, which can be checked and handled appropriately. I then went and looked in the C++ API Reference v3.8 to check this out and will share what I found, which is hopefully on the right path. (Also checked v3.7 and it is the same in this respect.) If you look in http://bloomberg.github.io/blpapi-docs/cpp/3.8/classblpapi_1_1Element.html there is a function Also in http://bloomberg.github.io/blpapi-docs/cpp/3.8/classblpapi_1_1Element.html if you search "API will convert data types as long as there is no loss of precision involved" you can see that they explicitly mention "An INT32 can be returned as Int32, Int64, Float64, std::string". |
Yes, thanks @joel23888 , that is the field we used to use for lazyFrame. The problem is that as you walk through the rows of the response having the datatype change. It's not so much a problem in Excel as the cells don't care about what 'type' the cell above it is. However, in a dataframe or time series, you've already allocated a vector for the whole response. So, if it changes in mid-read, then you've got to go back and reallocate the whole thing to the new type, and then recopy your previous captured rows into it, and repoint the list element in your response to the new vector. Not such a big deal, but in my opinion, just to allocate all int32's as doubles (at least for BDH) would be a simple way to avoid the messiness of the mid-read reallocation. |
So I've done a little further digging and gathered thoughts on this. The field search service (//blp/apiflds) gives you per field the data type and 'ftype' (unfortunately not the beautiful Jaguar, but instead some mysterious internal Bloomberg enumeration). This data type represents the expected type for the current value of the field, i.e. that which comes from the ReferenceDataRequest. HOWEVER, looking at each of the requests in C# (ReferenceDataRequest and HistoricalDataRequest), PX_LAST and PX_VOLUME are both coming through as 64-bit floats. As mentioned in a previous post, these are accessible by accessing the type property of the specific field. @armstrtw mentioned that there is a concern that the type of the column will change mid-read. This should never be the case for historical fields. Indeed, the response from the development team suggests that all historical fields will always return 64-bit floats. Hope this helps. In the interim, here's the example of the suggested Bloomberg approach of how to do the type inference (albeit truncated)
|
Any progress on this? I'm hitting this converting Rbbg code. Thanks |
I thought we had dealt with this issue. I think easiest to pull any ints as doubles in bdh. |
use double for int32 and int64 field types in bdh (closes #163)
So this works now (thanks to Whit) with a new option that we introduced in > bdh("SPX Index", "PX_VOLUME", as.Date("2000-12-14"), as.Date("2000-12-15"))
Error in bdh_Impl(con, securities, fields, start.date, end.date, options, :
Attempt to access value of element 'PX_VOLUME'(type: 'Float64') as 'Int32' type. But now: > bdh("SPX Index", "PX_VOLUME", as.Date("2000-12-14"), as.Date("2000-12-15"), int.as.double=TRUE)
date PX_VOLUME
1 2000-12-14 1403351296
2 2000-12-15 2449779712 |
Hi, I have followed johnlaing's instruction to add
However, I have received the following error message:
May I know if I have missed some other packages?
Regards, |
@clivelamkk Why are you a) highjacking another thread and b) still refusing to format your post? Show some courtesy, please. |
@eddelbuettel @ I have found out the solution from your previous post #207 and it was working. Thank you and sorry for making my mistake of not formatting my question properly in my previous posts. |
Downloading
PX_VOLUME
for the tickerSPX Index
fails withError: BLPAPI_ERROR_INVALID_CONVERSION
. The fieldVOLUME
works.Reproducible example:
Output:
Output of
traceback()
:Output of
sessionInfo()
:The text was updated successfully, but these errors were encountered: