vfilimonov / pydatastream

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

use 'Base Date' as date_from #15

Closed gvb1234 closed 5 years ago

gvb1234 commented 6 years ago

In the excel add-in, you have the option to set the starting date as "Base Date", in which case, the starting date becomes the date corresponding to the oldest available data point of all series in the request.

Any idea how the request string should be in this case?

vfilimonov commented 6 years ago

Hello

Unfortunately, I don’t have the excel add-in. Could you please provide a bit of context to your question?

Best regards, Vladimir

gvb1234 commented 6 years ago

I'm not sure what you mean by context.

If you put "Base Date" as starting date, the datastream add-in looks up the first available date and this gives the longest available history for the requested tickers.

My guess is that they have a way of specifying the request string for that, but I have not found it yet...

vfilimonov commented 6 years ago

Do you mean the string “Base Date”? What type of securities are you fetching?

I haven’t seen such syntax before, so I would suggest to contact the support of TR. If they reply something constructive - please let me know.

As a workaround you could always request the start date which is far before the expected start (e.g. 1970-01-01 or 1900-01-01) and drop nans if necessary.

gvb1234 commented 6 years ago

Yes, absolutely, it is the literal string "Base Date" (no quotes).

I tried putting the string in the request, with and without capitals, with and without space, and so on, nothing works.

In the excel add-in, it works for all securities (well, all that I tried).

I've put 1950 and remove the nans. Will update if/when TR tells me the correct format...

vfilimonov commented 6 years ago

I suspect that the "base date" could be some macro/constant in the Excel with the system-defined starting date (http://excelsemipro.com/2010/06/microsoft-excel-date-systems-for-windows-and-mac/), so within the add-on it could be translated into 1900-01-01 or 1904-01-02.

gvb1234 commented 6 years ago

I don't think so. When you change securities, you get a different starting date, and no nans ever (though, tbh, maybe the nans are stripped by the add-in in the background before populating the spreadsheet).

gvb1234 commented 6 years ago

I finally got an answer from TR:

You can run static request for all series with datatype BDATE, and then a second request for time series from that date.

Of course, that would mean taking the oldest of all BDATEs if the request has several tickers...

vfilimonov commented 6 years ago

Great! Are you open for submitting a PR with this feature?

vfilimonov commented 5 years ago

Now you can use 'BDATE' as a date_from when fetching:

res = DS.fetch(['@AAPL','U:MMM'], 'P', date_from='BDATE')

It is in master and at some point soon I will push it to the pypi.