Hello,
I have a list of 100,000+ RICs in a .csv file and I want to create a code that opens the file and retrieves bonds' monthly midyield, midprice, ask price, bid price, ask yield, bid yield, ratings, and monthly transaction volume and saves the output in a new .csv file. Ideally, the code should read RICs by chunks and move on to another chunk automatically (this is where my code fails, it only retrieves data for 1 chunk).
I have read every single thread on this topic but since I have 0 technical background, I am struggling to optimise my code.
I would appreciate if you could edit my Eikon code and provide a sample code for RDP.
#Importing
import refinitiv.dataplatform as rdp
import json
import pandas as pd
import os
from pandas.io.json import json_normalize
from pydash.arrays import chunk
import time
symbologylookup_endpoint = rdp.Endpoint(session,
'https://api.refinitiv.com/discovery/symbology/v1/lookup')
pd.set_option("display.max_columns", None)
pd.set_option("display.max_rows", None)
import eikon as ek
session=rdp.open_desktop_session('XX')
#create a list of RICs
import csv
csvReader = csv.reader(open("Data.csv"))
instruments=[]
for row in csvReader:
instruments.append(row[0])
#Loop through RICs
content_df = []
Bond_fields = ["TR.MIDYIELD","TR.MIDPRICE","TR.ASKPRICE.date","TR.ASKPRICE", "TR.BIDPRICE", "TR.ASKYIELD","TR.BIDYIELD",'TR.GR.Rating(BondRatingSrc=FTC:S&P:MDY).RatingSourceDescription','TR.GR.Rating(BondRatingSrc=FTC:S&P:MDY)','TR.GR.Rating(BondRatingSrc=FTC:S&P:MDY).date']
chunklist=2000
for i in range(0, len(instruments), chunklist):
stock = instruments[i:i+chunklist]
df, err = ek.get_data(stock, Bond_fields,{'CALCMETHOD':'SUM','Frq': 'M', 'SDate': '2016-01-01','EDate': '2021-12-31'})
content_df.append(df)
content_df = pd.concat(content_df)
content_df
@zoya faberov @jason.ramchandani01 @j.dessain