Syntax for screener

Hi Team,

I use this formula in screener, now I am trying to replace the "HK" here with a pre-defined items.

Economic_Sector,err = ek.get_data('SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.ExchangeCountryCode,"HK"), CURN=USD)',

'TR.TRBCEconomicSector',

{'Sdate':start_date,'Scale':scale,'Curn':curn})

For example:

I set country_code='HK'

and put the country_code into the formula, like this:

Economic_Sector,err = ek.get_data('SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.ExchangeCountryCode, country_code ), CURN=USD)',

'TR.TRBCEconomicSector',

{'Sdate':start_date,'Scale':scale,'Curn':curn})


Do you have idea why it doesnt work and how should I correct this.

Here is the error message:

KeyError                                  Traceback (most recent call last)
<ipython-input-24-b53aff9d8165> in <module>
9 Economic_Sector,err = ek.get_data('SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.ExchangeCountryCode,"country_code"), CURN=USD)',
10 'TR.TRBCEconomicSector',
---> 11 {'Sdate':start_date,'Scale':scale,'Curn':curn})
12 13 Economic_Sector
~\Anaconda3\lib\site-packages\refinitiv\dataplatform\legacy\data_grid.py in get_data(instruments, fields, parameters, field_name, raw_output, debug, raw_response)
206 return result
207 --> 208 return get_data_frame(result, field_name)
209 210
~\Anaconda3\lib\site-packages\refinitiv\dataplatform\legacy\data_grid.py in get_data_frame(data_dict, field_name)
255 headers = [header.get('field', header.get('displayName')) for header in data_dict['headers'][0]]
256 else:
--> 257 headers = [header['displayName'] for header in data_dict['headers'][0]]
258 data = numpy.array([[get_data_value(value) for value in row] for row in data_dict['data']])
259 if len(data):

KeyError: 'headers'


Thanks!


Best Answer

Answers