RKD API When a consume a chain of a lot of instruments (19K) I only need the ones that operate, so… I just want to know if there is a way to filter the operated instruments from the big chain through code.
Thanks for the support.
Regards
Hello @aendrch
According to the RKD API document, the child item is available in the ChildItem array attribute of the return JSON data from the RKD API Quote Service:
The example data:
{ "RetrieveItem_Response_3": { "ItemResponse": [ { "Item": [ { "RequestKey": { "Name": "0#.HSI", "Service": "IDN", "NameType": "RIC" }, .... "ChildItem": [ { "Name": ".HSI", "Status": { "StatusMsg": "OK", "StatusCode": 0 }, "Fields": { "Field": [ { "DataType": "Double", "Name": "CF_CLOSE", "Double": 19560.44 }, .... ] } }, { "Name": "0001.HK", "Status": { "StatusMsg": "OK", "StatusCode": 0 }, "Fields": { "Field": [ .... ] } }, ... ] } ] } ] } }
You can iterate JSON data array inside the ChildItem array to get data that you want.
Example with Python to get 0002.HK data of 0#.HSI Chain RIC.
for child_item in data['RetrieveItem_Response_3']['ItemResponse'][0]['Item'][0]['ChildItem']: if child_item['Name'] == '0002.HK': print(child_item)
Result:
Please note that you can use Field Filtering function to specify only interested fields or set expand chain to false in the request to reduce size of return data.