question

Upvotes
Accepted
6 2 2 3

How to use codebook to retrieve data from Screener with deal created date = today?

Hello, do we have a method to keep the DateWhenDealWasCreated field being updated to the date which is same with system today's date ?


As you can see now I need to manually update this field to the update to date value. But what we want is the date can be synchronized to Today without manual edit.

syntax.png


Also, is there a way to run the script in Python without launch of Eikon?

Thanks, Lin

pythoncodebookscreener
syntax.png (136.6 KiB)
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.

1 Answer

· Write an Answer
Upvotes
Accepted
14.2k 30 5 10

hi @linxiao.dai1 ,

The code below can be used to put yesterday's date into the query syntax (I tried to use today date but get an error as can be seen in the buttom cell of the code)

from datetime import date, timedelta
import refinitiv.dataplatform.eikon as ek

ek.set_app_key('DEFAULT_CODE_BOOK_APP_KEY')

today = date.today() - timedelta(days=1)
date_string = today.strftime('%Y%m%d')
syntax = 'SCREEN(U(IN(DEALS)/*UNV:DEALSPROJECTFINANCE*/), TR.PJFDateWhenDealWasCreated='+date_string+'/*dt:Date*/, CURN=USD)'
fields = ['TR.PJFSdcDealNumber','TR.PJFDateWhenDealWasCreated','TR.PJFAnnouncementDate','TR.PJFProjectName']
results, err = ek.get_data(syntax, fields)
results

1659931879293.png

For the second question, regarding the Eikon Data API - Quick start guide

The Eikon application integrates a Data API proxy that acts as an interface between the Eikon Data API Python library and the Eikon Data Platform. For this reason, the Eikon application must be running when you use the Eikon Data API Python library. When launched, the Eikon application starts listening for local websocket connections on port 9000 or the next available port if port 9000 is already occupied. You need to have a valid Eikon user account to be able to launch the Eikon application.

which means the Eikon Data API cannot be used without Eikon Desktop running, however, the platform session of the RD library can be used to retrieve the data. The example code is going to be posted in the comment


1659931533829.png (126.7 KiB)
1659931879293.png (125.3 KiB)
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.

import refinitiv.data as rd
rd.open_session()

from datetime import date, timedelta
yesterday= date.today() - timedelta(days=1)
date_string = yesterday.strftime('%Y%m%d')

syntax = 'SCREEN(U(IN(DEALS)/*UNV:DEALSPROJECTFINANCE*/), TR.PJFDateWhenDealWasCreated='+date_string+'/*dt:Date*/, CURN=USD)'
fields = ['TR.PJFSdcDealNumber','TR.PJFDateWhenDealWasCreated','TR.PJFAnnouncementDate','TR.PJFProjectName']
results = rd.get_data(syntax, fields)
results

1659931964721.png

Please let me know in case you have any further question

1659931964721.png (44.8 KiB)

much appreciated Samasiri for the detailed answer!!

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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