TRKD - result.json()['GetInterdayTimeSeries_Response_5']['MetaFields']['NAME_LL'] is None

I'm trying to retrieve data using the following RICs one by one, and for each result I need the indname = result.json()['GetInterdayTimeSeries_Response_5']['MetaFields']['NAME_LL'].
RIC = ['NLRSLY=ECI', 'DERSL=ECI', 'USRSL=ECI', 'AURSL=ECI', 'GBRSL=ECI', 'PLPMIY=ECI', 'ESRSLY=ECI', 'ITRSL=ECI', 'SGRSL=ECI', 'HKRSL=ECI', 'CHRSL=ECI', 'RURSLY=ECI', 'CARSLS=ECI', 'JPRSLS=ECI', 'BRRSL=ECI', 'NORSL=ECI', 'IERSL=ECI', 'SERSLM=ECI', 'CZRSLY=ECI', 'HURETY=ECI', 'IDRSLS=ECI', 'DKRSLY=ECI', 'MXRTSL=ECI', 'GRRSLY=ECI']
Every time I ran the for loop to get the result, it will return the following error which means the result.json()['GetInterdayTimeSeries_Response_5']['MetaFields']['NAME_LL'] is NONE for this RIC. But the RIC name that caused this error will change if I ran the loop again. And when I use the same code to just retrieve data from one single RIC which caused an error before, it will return the correct indname.
<ipython-input-3-012c1395d5cf> in get_trkd_quotes(token, appid, ric, interval, attempt)
63 response = result.json()['GetInterdayTimeSeries_Response_5']['Row']
64
---> 65 indname = result.json()['GetInterdayTimeSeries_Response_5']['MetaFields']['NAME_LL']
66
67 for dict in response:
TypeError: 'NoneType' object is not subscriptable
The api limitation is not exceeded since I was just requesting less than 10 records every time.
It seems this error cannot be reproduced because the RIC that causes error is changing randomly, what would be the cause of it?
Best Answer
-
Hi @chuchen.cai,
Most likely you are breaching the data limits on the API calls. I tried your code and added a time delay as such:
for ric in rics:
time.sleep(2)and was able to successfully get all the results, multiple times.
Interestingly, when the requests are not throttled, the server omitted the Metafield - Local Name, in the response, which is why your application throws an error.
Expected response:
{
'GetInterdayTimeSeries_Response_5': {
'Row': [{
'CLOSE': -8.9,
'TIMESTAMP': '2021-01-31T00:00:00+00:00'
}, {
'CLOSE': -5.8,
'TIMESTAMP': '2021-02-28T00:00:00+00:00'
}
],
'MetaFields': {
'NAME_LL': 'Retail Sales YY*'
}
}
}Bad response:
{
'GetInterdayTimeSeries_Response_5': {
'Row': [{
'CLOSE': -8.9,
'TIMESTAMP': '2021-01-31T00:00:00+00:00'
}, {
'CLOSE': -5.8,
'TIMESTAMP': '2021-02-28T00:00:00+00:00'
}
],
'MetaFields': None
}
}I will raise a service ticket on your behalf for this issue.
0
Answers
-
Hi @chuchen.cai,
Can you post you complete code snippet so that we can help you debug it. Nothing is evident from the snapshot that you have provided.
0 -
Hello @chuchen.cai
Besides the complete code snippet that contains your RKD request message which my colleague requested, could you please confirm if you can replicate the issue with the same query parameters on the RKD API Catalog page?
0 -
Thanks for your reply. The code is like :
rics = ['NLRSLY=ECI', 'DERSL=ECI', 'USRSL=ECI', 'AURSL=ECI', 'GBRSL=ECI', 'PLPMIY=ECI', 'ESRSLY=ECI', 'ITRSL=ECI', 'SGRSL=ECI', 'HKRSL=ECI', 'RURSLY=ECI', 'CARSLS=ECI', 'JPRSLS=ECI', 'BRRSL=ECI', 'NORSL=ECI', 'IERSL=ECI', 'SERSLM=ECI', 'CZRSLY=ECI', 'HURETY=ECI',
'IDRSLS=ECI', 'DKRSLY=ECI', 'MXRTSL=ECI', 'GRRSLY=ECI']
trkddata = []
AUTH_URL = 'https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/'; \
'TokenManagement_1/CreateServiceToken_1'
token = authorize(user = config['trkd']['username'], pw = config['trkd']['password'], appid = config['trkd']['application'])
appid = config['trkd']['application']for ric in rics:
today = datetime.today()
last3month = today - relativedelta(months=+3)
date_from_monthly = last3month.strftime('%Y-%m-%dT00:00:00')
date_to = today.strftime('%Y-%m-%dT00:00:00')
interval = 'MONTHLY'
quote_request_message = {
'GetInterdayTimeSeries_Request_5':{
'Field': ['CLOSE'],
'MetaField': ['NAME_LL'],
'TrimResponse': False,
'Symbol': ric,
'StartTime':date_from_monthly,
'EndTime':date_to,
'Interval': interval,
}
}
quote_url = 'https://api.trkd.thomsonreuters.com/api/TimeSeries/TimeSeries.svc/REST/TimeSeries_1/GetInterdayTimeSeries_5';
headers = {
'content-type': 'application/json;charset=utf-8',
'X-Trkd-Auth-ApplicationID': appid,
'X-Trkd-Auth-Token': token
}
result = send_request(quote_url, quote_request_message, headers)
response = result.json()['GetInterdayTimeSeries_Response_5']['Row']
indname = result.json()['GetInterdayTimeSeries_Response_5']['MetaFields']['NAME_LL']
trkddata.append(response)It returns the following error, while every time the ric causes this error is different.
I've seen 'ESRSLY=ECI', 'DERSL=ECI' and 'AURSL=ECI'. But when I request the data for each ric individually using the same code, it will get correct response and indname. I also query the name from the RKD API Catalog page, it also seems to be correct.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-26-691b033f0497> in <module>
39 response = result.json()['GetInterdayTimeSeries_Response_5']['Row']
40
---> 41 indname = result.json()['GetInterdayTimeSeries_Response_5']['MetaFields']['NAME_LL']
42
43 trkddata.append(response)
TypeError: 'NoneType' object is not subscriptable0 -
In addition, when the error occurs, the returned response is like this:
{'GetInterdayTimeSeries_Response_5': {'Row': [{'CLOSE': 4.3,
'TIMESTAMP': '2021-01-31T00:00:00+00:00'},
{'CLOSE': 0.7, 'TIMESTAMP': '2021-02-28T00:00:00+00:00'}],
'MetaFields': None}}The MetaFields is None, which should be 'Retail Sales YY*'
0 -
Hi @chuchen.cai,
I have raised a support ticker # 09807927 for you. You should directly get updates to this case in your email.
0 -
Thanks a lot! The time delay works XD
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 616 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 652 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛