Hello all,
I am trying to download a list of index constituents using the eikon data API, however, i am getting a 'NoneType' object has no attribute 'get' error for this code :
import eikon as ek
import pandas as pd
from tqdm import tqdm # Import tqdm for progress tracking
Your Datastream API key
api_key = 'kEY '
Initialize the Eikon API with your API key
ek.set_app_key(api_key)
Define the directory to save data
save_directory = r'Enter your directory'
Define the chain RIC for NYSE and NASDAQ constituents
NYSE = ek.get_data('0#.NYA', fields=['TR.RIC'])[0]
NASDAQ = ek.get_data('0#.IXIC', fields=['TR.RIC'])[0]
Step 1: Merge NYSE and NASDAQ datasets
rics_df = pd.concat([NYSE, NASDAQ], ignore_index=True)
Step 2: Check for duplicates in the RIC column and drop them
rics_df.drop_duplicates(subset=['RIC'], inplace=True)
Step 3: Convert the 'RIC' column to a list
rics = rics_df['RIC'].tolist()
Count the number of items in the rics list
num_items_all = len(rics)
Display the first two and last two items
first_two = rics[:2] # First two items
last_two = rics[-2:] # Last two items
Print the results
print(f"Number of items in the rics list: {num_items_all}")
print(f"First two items: {first_two}")
print(f"Last two items: {last_two}")
Can someone help me solve this error? I have also tried to use random code to download data for various instruments and variables, and every time I get this error for the get data.
Best,