vfilimonov / pydatastream

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

INVALID CODE OR EXPRESSION ENTERED #2

Closed picoding closed 9 years ago

picoding commented 9 years ago

Hi,

I not sure if this is a bug or just mistake in query (misusing - I am not familiar with the DS).

When I try:

raw1 = DWE.fetch(['POEURSP'], freq='D')

raw2 = DWE.fetch(['POLZLSF'], freq='D')

Both requests work.

But

raw_m = DWE.fetch(['POEURSP', 'POLZLSF'], freq='D')

raises exception:

pydatastream.pydatastream.DatastreamException: Failure (error 2): $$"ER", E100, INVALID CODE OR EXPRESSION ENTERED, POLZLSF(P) --> "POEURSP,POLZLSF~D"

Same result for

raw_m = DWE.request('POEURSP,POLZLSF~D')

In R below code returns (not sure if it is equivalent) data without problem:

dat <- ds(user, c("POEURSP", "POLZLSF"), period = "D")
vfilimonov commented 9 years ago

Hello,

I would rather be surprised that the first two queries work. Your tickers (POEURSP and POLZLSF) are exchange rates and Datastream does not have the "closing price" field (P) for them - only bid, offer and mid prices (EB, EO, ER). When you provide these specific fields - everything will be fine:

raw1 = DWE.fetch(['POEURSP'], freq='D')
raw2 = DWE.fetch(['POLZLSF'], freq='D')
print raw1.head()
print raw2.head()

raw_m = DWE.fetch(['POEURSP', 'POLZLSF'], fields=['ER','EB','EO'], freq='D')
print raw_m['ER'].head()
print raw_m['EB'].head()
print raw_m['EO'].head()

Eventually (from the output) it returns the mid-rate (ER) by default for single ticker if no fields are provided. But for some reason for multiple tickers it tries to retrieve the field P, which does not exist (thus it returns an error: "INVALID CODE OR EXPRESSION ENTERED, POLZLSF(P)").

I don't remember the implementation of the RDatastream, but possibly it retrieves all tickers one-by-one, and thus does not have this issue.

You could check all available fields for each ticker on the Datastream web-portal. The login is the same as you provide for the library, but without DS: prefix, password is the same. Once you're in - search for ticker and under the plot you will see some buttons with mnemonics and button ">>" which opens a list of all available mnemonics for a given ticker.

image

Best Vladimir