menu

Secmaster SDK

In this tutorial you will learn how to use gs_quant to interact with Secmaster. It starts with authentication and then shows how to use different endpoints to retrieve data from Secmaster.

Getting started and authenticating

Run this code to authenticate.Gs_quant requires to be initialized session with your credentials. Provide 'client_id' and 'client_secret' to session initializer. If you see an error, please e-mail the error message to gs-marquee-help@gs.com..

import datetime
import json

from gs_quant.target.secmaster import SecMasterAssetType, SecMasterIdentifiers
from gs_quant.api.gs.secmaster import GsSecurityMasterApi
from gs_quant.markets.securities import SecurityIdentifier
from gs_quant.session import GsSession
import pandas as pd
GsSession.use(client_id="",
              client_secret="")

Pagination

Whenever you encounter an offsetKey in the response it means that results did not fit the page size, and this requires a more requests to get all data.

Initial call that returns first offsetKey

results  = GsSecurityMasterApi.get_many_securities(type_=SecMasterAssetType.Common_Stock, limit=500)
offset_key = results['offsetKey']
print(f"Offset key is {offset_key}")
pd.DataFrame(results['results'][-5:])[["id", "name", "currency", "assetClass", "type", "lastActiveDate"]]

Subsequent call using last offsetKey for next call. It returns next page of data. This pattern can be applied to all instances where offsetKey is returned

results  = GsSecurityMasterApi.get_many_securities(type_=SecMasterAssetType.Common_Stock, limit=10, offset_key=offset_key)
offset_key = results['offsetKey']
print(f"New offset key is {offset_key}")
pd.DataFrame(results['results'][-5:])[["id", "name", "currency", "assetClass", "type", "lastActiveDate"]]

Securities

The Securities section is the analytical core of the service, focusing on providing asset-specific data. It is designed for users who require detailed information about individual securities, need to trace the history and changes of security identifiers, or wish to obtain bulk security data by asset type.

Historical query

The historical query functionality is tailored for users requiring time-specific data retrieval. It allows you to perform a point-in-time query by specifying an identifier (e.g. bbid) and a precise date. This can be important for tasks such as data verification, back-testing models against historical data. It effectively enables you to 'query back in time', providing a snapshot of security's data as it existed at that exact moment

data = GsSecurityMasterApi.get_security_data(id_value="FB UN", id_type=SecurityIdentifier.BBID,
                                             effective_date=datetime.date(2021, 10, 28))
print( f"The bbid is: {data['identifiers.bbid']} and the issuer name is: {data['issuer.name']}.")  # Prints bbid and company name

Query by identifier

This functionality allows you to immediate access to current data on specific security. By inputting an identifier, users can quickly retrieve the latest available information about the security


data = GsSecurityMasterApi.get_security_data(id_value="GS UN", id_type=SecurityIdentifier.BBID)
print( f"The bbid is: {data['identifiers.bbid']} and the issuer name is: {data['issuer.name']}.")

Query by attribute

This functionality is a versatile tool for customized queries. Users can specify an asset type, or set of identifiers to retrieve matching securities. This function accepts multiple identifiers, either individually or in batch, enabling a broad or targeted browse. It is particular useful for users how need to extract a specific subset of data from a vast pool of securities, aligning with particular investment strategies, or research parameters.

etf  = GsSecurityMasterApi.get_many_securities(type_=SecMasterAssetType.ETF, limit=5)
[ print( f"The bbid is: {data['identifiers']['bbid']} and the issuer name is: {data['issuer']['name']}.") for data in etf["results"]]
print("-"*80)
single_asset = GsSecurityMasterApi.get_many_securities(bbid="IZB PW")
[ print( f"The bbid is: {data['identifiers']['bbid']} and the issuer name is: {data['issuer']['name']}.") for data in single_asset["results"]]
print("-"*80)
many_assets = GsSecurityMasterApi.get_many_securities(ric=["GOOGL.OQ", "VOD.L"])
[ print( f"The bbid is: {data['identifiers']['bbid']} and the issuer name is: {data['issuer']['name']}.") for data in many_assets["results"]]
print("-"*80)
ticker = GsSecurityMasterApi.get_many_securities(ticker="GS")
[ print( f"The name is: {data['name']} and the issuer name is: {data['issuer']['name']}.") for data in ticker["results"]]
print("-"*80)

Get all securities

This acts as an expansive layer over 'Query by Attribute', tailored for retrieving an extensive list of assets within a specific type, It simplifies the user experience by automatically handling the scrolling, thereby providing a seamless method to acquire a complete dataset of a chosen asset type.

data = GsSecurityMasterApi.get_all_securities(type_=SecMasterAssetType.Dutch_Cert)
print(json.dumps(data['results'][0:60], indent=4))  # Prints prettified response

Get identifier history

The 'Get identifier history' functionality is designed to provide a chronological account of how a particular identifier has changed for a security over time.

secm_id = "GSPD227284E154"
data = GsSecurityMasterApi.get_identifiers(secmaster_id=secm_id)
pd.DataFrame(data)

Map securities

This functionality is a powerful tool for converting between different types of security identifiers while also taking historical changes int account. Users can input a security's identifier alon with its type (e.g, bbid, sedol) and specify the desired output identifier types. This function then returns a mapping of the security across these different identifier systems.

mapping = GsSecurityMasterApi.map(SecurityIdentifier.BBID, ["GS UN"], start_date="2015-01-01", end_date="2020-01-01",
                                  output_types=[SecurityIdentifier.TICKER, SecurityIdentifier.RIC])
pd.DataFrame(mapping)

Search securities

This functionality is a designed for conducting full-text searches across many fields, including identifiers, company names. This is especially beneficial for users who require a more exploratory approach to data retrieval.

This supports also filtering options, where users can refine their search results using filters such as 'isPrimary', 'activeListing' and restrict searches to selected asset type. This helps narrow down the results

Plain full text search query:
results = GsSecurityMasterApi.search(q="TESLA")
[
    f"The bbid is: {data['identifiers']['bbid']} and the issuer name is: {data['issuer']['name']} and the type is: {data['type']}."
    for data in results
]
Full text query with filters
results = GsSecurityMasterApi.search(q="TESLA", is_primary=True, active_listing=True, type_=SecMasterAssetType.Common_Stock)
[
    f"The bbid is: {data['identifiers']['bbid']} and the issuer name is: {data['issuer']['name']}  and the type is: {data['type']}."
    for data in results
]

Get recent changes

You can get the list of recent identifier changes by providing between start/end time. The start/end time are limited to span of 5 days and should not start more than 30 days from now The API allows returning processed results highlighting the change nature (easier to interprate), or raw results easier to process programmatically

Raw results
start_time = datetime.datetime.now() - datetime.timedelta(hours=12)
data = GsSecurityMasterApi.get_deltas(raw=True, start_time=start_time)
pd.DataFrame(data['results'])
Processed results
start_time = datetime.datetime.now() - datetime.timedelta(hours=12)
data = GsSecurityMasterApi.get_deltas(raw=False, start_time=start_time)
sample = json.dumps(data['results'][:10], indent=4)
print(sample)

Corporates

Secmaster service allows providing a detailed insights into financial structure and activities of listed companies.

Capital Structure

This functionality is a tool for gaining a comprehensive understanding of different types of securities issued by a company. By utilizing various identifiers, users can pinpoint a specific company and retrieve a detailed list of its issued securities, including bonds, stocks and other. It supports point-in-time query.

from IPython.display import Markdown
ric = "VOD.L"
data = GsSecurityMasterApi.get_capital_structure(id_value=ric, id_type=SecurityIdentifier.RIC)
res = data['results'][0]
display(Markdown(f"Capital structure for {ric} matched {res['issuerName']}"))
display(pd.DataFrame([data['assetTypesTotal']]))
for t in res['types']:
    display(Markdown(f"**{t}**"))
    display(pd.DataFrame(res['types'][t][:5]))

Exchanges

You can fetch data about exchanges. The API allows either fetching all exchanges or query by exchange identifier

Get many exchanges

This functionally allows users to retrieve detailed information about exchanges. User can fetch all exchanges or query by selected identifiers.

data = GsSecurityMasterApi.get_exchanges()
pd.DataFrame(data['results'][:5])

Query exchanges by identifiers

data = GsSecurityMasterApi.get_exchanges(mic="XBUE") pd.DataFrame(data['results'])

data = GsSecurityMasterApi.get_exchanges(mic="XBUE")
pd.DataFrame(data['results'])

Get exchanges identifiers history

This functionality is designed to provide a historical view of the changes in exchange identifiers over time.

results = GsSecurityMasterApi.get_exchange_identifiers_history(gs_exchange_id=1)
pd.DataFrame(results)

GS DAP® is owned and operated by Goldman Sachs. This site is for informational purposes only and does not constitute an offer to provide, or the solicitation of an offer to provide access to or use of GS DAP®. Any subsequent commitment by Goldman Sachs to provide access to and / or use of GS DAP® would be subject to various conditions, including, amongst others, (i) satisfactory determination and legal review of the structure of any potential product or activity, (ii) receipt of all internal and external approvals (including potentially regulatory approvals); (iii) execution of any relevant documentation in a form satisfactory to Goldman Sachs; and (iv) completion of any relevant system / technology / platform build or adaptation required or desired to support the structure of any potential product or activity. All GS DAP® features may not be available in certain jurisdictions. Not all features of GS DAP® will apply to all use cases. Use of terms (e.g., "account") on GS DAP® are for convenience only and does not imply any regulatory or legal status by such term.
Certain solutions and Institutional Services described herein are provided via our Marquee platform. The Marquee platform is for institutional and professional clients only. This site is for informational purposes only and does not constitute an offer to provide the Marquee platform services described, nor an offer to sell, or the solicitation of an offer to buy, any security. Some of the services and products described herein may not be available in certain jurisdictions or to certain types of clients. Please contact your Goldman Sachs sales representative with any questions. Any data or market information presented on the site is solely for illustrative purposes. There is no representation that any transaction can or could have been effected on such terms or at such prices. Please see https://www.goldmansachs.com/disclaimer/sec-div-disclaimers-for-electronic-comms.html for additional information.
Transaction Banking services are offered by Goldman Sachs Bank USA (“GS Bank”). GS Bank is a New York State chartered bank, a member of the Federal Reserve System and a Member FDIC.
Mosaic is a service mark of Goldman Sachs & Co. LLC. This service is made available in the United States by Goldman Sachs & Co. LLC and outside of the United States by Goldman Sachs International, or its local affiliates in accordance with applicable law and regulations. Goldman Sachs International and Goldman Sachs & Co. LLC are the distributors of the Goldman Sachs Funds. Depending upon the jurisdiction in which you are located, transactions in non-Goldman Sachs money market funds are affected by either Goldman Sachs & Co. LLC, a member of FINRA, SIPC and NYSE, or Goldman Sachs International. For additional information contact your Goldman Sachs representative. Goldman Sachs & Co. LLC, Goldman Sachs International, Goldman Sachs Liquidity Solutions, Goldman Sachs Asset Management, L.P., and the Goldman Sachs funds available through Goldman Sachs Liquidity Solutions and other affiliated entities, are under the common control of the Goldman Sachs Group, Inc.
© 2025 Goldman Sachs. All rights reserved.