Hi,
Me and my team are trying to create a tool that automatically reads in a spreadsheet of ours, turns it into a RIC list csv, and then we import that into the DSS web gui to go and make a request with. However, when we import the list of around 33,000 contracts, only about 25% of them exist... which is very confusing to us because the format of the options RICs looks correct and we followed all the documentation on this to the best of our knowledge. We checked on some of the RICs the system says doesn't exist, and they are indeed correct strike prices and such that we verified exist.
This begs the question, has there been a naming schema change or something like that? When we do this for more recent months, we haven't had issues.
See below our code which makes the list given our spreadsheet, it shows exactly how we go from information like the date, strike to the RIC by following the documentation exactly.
dates = lines[dates_row][1:]
strikes_data = lines[dates_row+2:]
month_mapping = {
1: ('A', 'M'), 2: ('B', 'N'), 3: ('C', 'O'), 4: ('D', 'P'), 5: ('E', 'Q'), 6: ('F', 'R'),
7: ('G', 'S'), 8: ('H', 'T'), 9: ('I', 'U'), 10: ('J', 'V'), 11: ('K', 'W'), 12: ('L', 'X')
}
for i in range(len(strikes_data)):
strikes = strikes_data[i][1:]
for j in range(len(strikes)):
if strikes[j] and dates[j]:
try:
strike_price = int(float(strikes[j]))
date_str = dates[j]
date = datetime.strptime(date_str, '%m/%d/%Y')
week_of_month = (date.day - 1) // 7 + 1
month_code_call, month_code_put = month_mapping[date.month]
year_code = str(date.year % 100)
day_of_week = date.strftime('%A')
if day_of_week == 'Friday':
ric_format = f'ES{week_of_month}W'
elif day_of_week == 'Monday':
ric_format = f'1AE{week_of_month}W'
elif day_of_week == 'Tuesday':
ric_format = f'E1B{week_of_month}W'
elif day_of_week == 'Wednesday':
ric_format = f'EC{week_of_month}W'
elif day_of_week == 'Thursday':
ric_format = f'E1D{week_of_month}W'
else:
raise ValueError(f"Invalid day of week: {day_of_week}")
call_code = f"{ric_format}{strike_price:04d}{month_code_call}{year_code}"
put_code = f"{ric_format}{strike_price:04d}{month_code_put}{year_code}"
refinitiv_codes.append(call_code)
refinitiv_codes.append(put_code)
Find in the image attached examples of RICs produced by the above code that do not exist, and we cannot find out why!
Any help is appreciated!