
Do you manage lists of instruments in Workspace Application and want to access them programmatically with Python? This article shows you how to use the Data Library to retrieve the constituents of your saved lists. Hence, it contains two sections, which are
Prerequisites:
- Workspace Application installed, running, and logging-on on the same machine with the Python script
- As the Workspace application provides the Data API Proxy allowing you to connect to the Data Platform
- Data Library installed (pip install lseg.data)
1 ) Manage a list with Workspace Application
Other than access and using saved instrument lists and portfolios with the Data Library in Python, you can also use the Workspace Application to create and modify the list according to your requirements, then used the saved list on application in Workspace, such as Monitor.
1.1 ) To launch the "Portfolios & Lists Manager" application in Workspace Desktop, you can type "PAL" into the Workspace's search bar and press enter or click on the App name in the pop-up list.

1.2) Click the "Create Portfolio" button on the top left of the window.

1.3) Then select "Type" as "Watchlist" and fill the details. From here, you can click "Save" to save the list or click on "Constituents" tab to edit the instruments in the list.

1.4) In "Constituents" tab, you can manage instruments in the list by adding/deleting. Then click "Save" to save the list.


Now we can see the list that was added (named article-saved-list) is being shown in Portfolios & Lists Manager (PAL). We can use the List Code to access the list with Data Library for Python.

1.5) Alternatively, you can also use SCREENER app or GOVSRCH app (Advanced Search), in the Workspace Application, to search for instruments with filters applied based on your criteria. Then you can add the result into a list, name the list, and save it.


Now the lists saved from SCREENER, GOVSRCH result (named list-from-screener and list-from-govsrch) is being shown in Portfolios & Lists Manager (PAL). We can use their List Code to access the list with Data Library for Python.

2) Retrieve constituents of your saved lists and portfolios with Data Library for Python
You can use constituents of your saved lists or portfolios as the universe parameter of Data Library's get_data() function to use the instruments as an input of get_data() function.
2.1 ) To use list as an input. Use 'list("<LIST CODE>")' For example,
import lseg.data as ld
ld.open_session()
list_data = ld.get_data("List('article-saved-list')",['TR.CompanyMarketCap','DSPLY_NAME','CF_LAST'])
list_data

search_list_data = ld.get_data("List('list-from-govsrch')",['TR.CommonName'])
search_list_data

screener_list_data = ld.get_data("List('list-from-screener')",['TR.CompanyMarketCap','DSPLY_NAME','CF_LAST'])
screener_list_data

2.2) For instruments in portfolio as an input. Use ["Portfolio('<YOUR PORTFOLIO CODE>','<YYYYMMDD>')"]
For example,

fields = ['TR.PortfolioStatementDate','TR.PortfolioModifiedDate','TR.PortfolioConstituentName',
'TR.PortfolioShares','TR.PortfolioWeight','TR.PortfolioDate',
'TR.PriceClose','TR.CompanyMarketCap']
port_data = ld.get_data(["Portfolio('TEST-PORTFOLIO','20240221')"], fields)
port_data

Conclusion
This article demonstrated to you can easily access the saved lists/portfolios in your Workspace application with the Data Library for Python by using the functions explained. This integration enables efficient analysis allowing you to leverage your curated data directly in your Python workflows. You can explore the Data Library further to enhance your workflows. Related resources can be found at the top right of this article.