vfilimonov / pydatastream

Python interface to the Refinitiv Datastream (former Thomson Reuters Datastream)
MIT License
73 stars 31 forks source link

can't download several tickers with fetch #14

Closed gvb1234 closed 7 years ago

gvb1234 commented 7 years ago

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?

vfilimonov commented 7 years ago

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')
gvb1234 commented 7 years ago

Thank you Vladimir. I'm not surprised to see inconsistencies in the API, to be honest ;-)

Is it possible-with the API-to see which datatypes (and description) are available for a given ticker? Or which is the default?

vfilimonov commented 7 years ago

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.

vfilimonov commented 7 years ago

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