vfilimonov/pydatastream

can't download several tickers with fetch

gvb1234 opened this issue · 4 comments

I can't seem to be able to fetch several tickers at once with fetch. For instance

DWE.fetch(['EUDOLLR','USDOLLR'],date_from='2000',freq='D')

does not work. However, I can do it one by one as

DWE.fetch('EUDOLLR',date_from='2000',freq='D')
DWE.fetch('USDOLLR',date_from='2000',freq='D')

and both give the correct 'P' field. I tried

DWE.fetch(['EUDOLLR(P)','USDOLLR(P)'],date_from='2000',freq='D')
DWE.fetch(['EUDOLLR','USDOLLR'],fields=['P'],date_from='2000',freq='D')

but these do not work either.

Am I missing something?

There's a slight ambiguity of what "P" stands for.
For cash equities there's a datatype "P" which correspond to adjusted price.
However when one does the request to an API, "P" also stands for the default field. And if no fields (datatypes) are supplied, API will assume that you request "P".

However it looks like further (I don't have a documentation to verify that), that when one requests several symbols, API will treat the "P" (even if it is implied, i.e. not supplied to the request string explicitly) as a datatype and will try to retrieve such datatype. In case of exchange rates (EUDOLLR, USDOLLR) there're no such datatype - they have only bid/ask/mid rates ("EB", "EO", "ER"). So the error means exactly what it tells: INVALID CODE OR EXPRESSION ENTERED, USDOLLR(P).

So to retrieve the rates you need to supply proper datatype. For example for the mid-rate

DWE.fetch(['EUDOLLR','USDOLLR'],fields=['ER'],date_from='2000',freq='D')

or all three of them:

DWE.fetch(['EUDOLLR','USDOLLR'],fields=['ER','EB','EO'],date_from='2000',freq='D')

I'm not sure if it is possible via the API, however it is possible in the Datastream Navigator. If you log in with the same credentials as for the API (except for the username, which should be XXXXXX if your API log in DS:XXXXXX), and search for a specific symbol - then under the chart you will see a short list of available datatypes.
I would guess that the first might be taken as default, though I'm not sure.

If you click on ">>" you'll see the longer list of datatypes for a specific ticker, which is though not always complete. In particular it does not contain static fields, and not all timeseries are listed as well.

Further - on top line of the menu of the Datastream Navigator you could click on "Datatype search" and then select a proper asset class. Here you can see the complete list of datatypes.

Some description is added to README. So I'm closing it for now