For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
43 6 6 6

What is the best way to create a backtesting universe of stocks with the python API?

Hello.

I'm trying to use the Eikon python API to download a universe of stocks historically.

For each end of month since 1999, I want to get stocks with market cap greater than USD500m in the US. I used the screener to come up with this formula in excel. Is this correct? Is the historical market cap correct to get companies passing the market cap criteria as of that day? Do I have to use active and inactive?

=TR("SCREEN(U(IN(Equity(active or inactive,public,primary))/*UNV:Public*/), TR.CompanyMarketCap(SDate=2019-01-31)>=500000000, IN(TR.ExchangeCountryCode,""BM"",""CA"",""GL"",""US""), CURN=USD)","TR.CommonName;TR.CompanyMarketCap(SDate=2019-0"&"1-31);TR.ExchangeCountry","curn=USD RH=In CH=Fd SORTA=TR.ExchangeCountry")

What would be the best way to do that in python for each month end? Do you have any examples? That would be very useful.

Thanks. Charles

eikoneikon-data-apipythonworkspaceworkspace-data-apirefinitiv-dataplatform-eikonscreener
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
39.3k 76 11 27

For an authoritative answer I would suggest reaching out to Refinitiv Helpdesk, which you can do by either calling the Helpdesk number in your country or by using Contact Us capability in your Eikon application. This forum is intended for software developers using Eikon Data APIs, and the moderators on this forum do not have deep content expertise in every type of content available through Eikon. Refinitiv Helpdesk on the other hand will either have that expertise ready available or can reach out to content experts for the specific type of content you're interested in.
When contacting the Helpdesk ask for help with modeling the construction of your backtesting universe in Excel. If it's possible to do in Excel, it's quite easy to replicate using Eikon Data API. If it's not possible in Excel, it's not possible through the API either.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you Alex. I have asked Refinitiv. Even including inactive stocks, I noticed I do not get all the stocks from a certain date.

Upvote
33 0 0 3

From my experience, setting up backtest universes with Eikon data is nearly impossible - there is no data in most TR fields for delisted companies, and the Screener returns the active/inactive status as of today, not as seen on the date.

You are then at the mercy of survivorship bias.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
43 6 6 6

Thank you Doina. But if stocks have data at a certain date, we can assume they were active right? Therefore we need to include active and inactive in an historical screening?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I will also wait for an official answer on this, but try to check if any of the screens you use returns delisted companies, such as AAAA.OQ^K07 or ABAX.OQ^H18, then see if you find any TR fields for them, even in the appropriate time ranges.