I use Python's DSWS a lot, and often need to collect few data points for many instruments (more than 50). How can I use Python to loop through instruments and get results in one Pandas data-frame?
For - as an e.g. - a string 'tickers_of_interest_str' (see comment) from 2020-01-01 to 2020-03-01 and the default field ('X'), you can use the below:
# We need pandas in addition to DSWS as ds import pandas # We need to split our string of instruments as a list tickers_of_interest_lst = tickers_of_interest_str.split(",") # Get 1st instrument's data df = ds.get_data(tickers = tickers_of_interest_lst, fields = ['X'], start = '2020-01-01', end = '2020-03-01').T # Define a function to get chunks of 50 instrument lots def chunks(lst, n): """Yield successive n-sized chunks from lst.""" _lst =  for i in range(0, len(lst), n): _lst.append(lst[i:i + n]) return _lst # Use the pre-defined function up to the limit of DSWS - i.e.: 50 tickers_of_interest_chunks = chunks(lst = tickers_of_interest_lst[1:], n = 50) # Now collect all data and append to df for i in tickers_of_interest_chunks: _df = ds.get_data(tickers = ','.join(i), fields = ['X'], start = '2020-01-01', end = '2020-03-01').T df = df.append(_df) df = df.T display(df)