Data
Map Symbology with Security Master
A Security Master provides financial product reference data and is a foundational building block of any quantitative financial analytics engine. The core component of Goldman Sachs' Security Master is symbology, the data necessary to map from one identifier to another. Clients can retrieve this data via the GS Quant SDK.
Compatibility
Before running the examples in this guide, set source to be Security Master Service (defaults to Asset Service):
from gs_quant.markets.securities import SecurityMaster, SecurityMasterSource
SecurityMaster.set_source(SecurityMasterSource.SECURITY_MASTER)
Method availability varies by source:
Method | Asset Service | Security Master |
---|---|---|
get_asset | X | X |
get_identifiers | X | |
get_all_identifiers | X | |
map_identifiers | X | X |
Querying
You can look up a security using any of the identifier types in Security Master (e.g. ric, bbid, cusip, sedol). Identifiers that refer to the same security will be returned, subject to licensing.
Milestoning
Identifiers are milestoned, such that the history of each identifier for a given security can be viewed. By default, data that is currently valid will be retrieved. However, users can specify an "as of" date to see identifier values that were in effect on a past date. (Other fields such as asset type and descriptive tags are not milestoned.)
Note
Examples require an initialized GsSession. Please refer to Sessions for details.
Get By Identifier
import datetime
from gs_quant.markets.securities import SecurityIdentifier, SecurityMaster
security = SecurityMaster.get_asset('GS UN', SecurityIdentifier.BBID, as_of=datetime.date(2021, 1, 5))
print(security)
print(security.get_identifiers())
Output:
{
"name": "GOLDMAN SACHS GROUP INC (New York Stock)",
"type": "Single Stock",
"currency": "USD",
"tags": [],
"id": "GSPD901026E154",
"assetClass": "Equity",
"company": {
"name": "Goldman Sachs Group Inc/The",
"identifiers": {
"gsCompanyId": 25998
}
},
"product": {
"name": "GOLDMAN SACHS GROUP INC",
"identifiers": {
"gsid": 901026
}
},
"exchange": {
"name": "New York Stock",
"identifiers": {
"gsExchangeId": 154
}
}
}
Output for identifiers at point in time (specified by the as_of parameter):
{
"cusip": "38141G10",
"ric": "GS",
"isin": "US38141G1040",
"ticker": "GS",
"sedol": "2407966",
"bbid": "GS UN"
}
Field Selection
If you want to ensure the response only contains the fields that you are interested in, you can use
the fields
parameter. Example:
import datetime
from gs_quant.markets.securities import SecurityIdentifier, SecurityMaster
fields = ['id', 'name', 'type', 'assetClass']
security = SecurityMaster.get_asset('GS UN', SecurityIdentifier.BBID, as_of=datetime.date(2021, 1, 5), fields=fields)
print(security)
Output:
{
"name": "GOLDMAN SACHS GROUP INC (New York Stock)",
"type": "Single Stock",
"id": "GSPD901026E154",
"assetClass": "Equity"
}
Bulk Identifier Queries
You can retrieve identifier history for multiple assets at a time. For example:
import datetime
from gs_quant.markets.securities import SecurityIdentifier, SecurityMaster
ids = ['CTLP UW', 'TSLA UW', 'FB UW']
as_of = datetime.datetime(2021, 6, 5) # as-of-date used to map input IDs to assets
start = datetime.datetime(2000, 1, 5) # get identifier entries with update time after this time
end = as_of # get identifier entries with update time before this time
identifiers = SecurityMaster.get_identifiers(ids, SecurityIdentifier.BBID, as_of=as_of, start=start, end=end)
print(identifiers['CTLP UW'])
Output (note the ric and ticker changes for this asset):
[
{
"startDate": "2021-01-01",
"endDate": "2021-04-18",
"value": "USAT",
"updateTime": "2021-04-18T18:36:18.443Z",
"type": "ticker"
},
{
"startDate": "2021-04-19",
"endDate": "9999-99-99",
"value": "CTLP",
"updateTime": "2021-04-18T18:36:18.443Z",
"type": "ticker"
},
{
"startDate": "2021-01-01",
"endDate": "2021-04-17",
"type": "ric",
"value": "USAT.OQ",
"updateTime": "2021-04-18T14:54:47.406Z"
},
{
"startDate": "2021-04-19",
"endDate": "9999-99-99",
"type": "ric",
"value": "CTLP.OQ",
"updateTime": "2021-04-19T00:20:57.3Z"
}
]
To get identifiers for all stocks that you are subscribed to:
import datetime
from gs_quant.markets.securities import AssetType, SecurityMaster
from gs_quant.target.common import AssetClass
as_of = datetime.datetime(2021, 5, 1)
identifiers = SecurityMaster.get_all_identifiers(AssetClass.Equity, [AssetType.STOCK], as_of=as_of)
Mapping Between Identifiers
To map from one ID to other IDs for the same security, use the map_identifiers function. For example, if we have a security "GS UN" and want to find its CUSIP over a certain date range:
import datetime
from gs_quant.markets.securities import SecurityIdentifier, SecurityMaster
start = datetime.date(2021, 10, 11)
end = datetime.date(2021, 10, 15)
SecurityMaster.map_identifiers(SecurityIdentifier.BBID, ["GS UN"], [SecurityIdentifier.CUSIP], start, end)
Output:
{'2021-10-11': {'GS UN': {'cusip': '38141G104'}},
'2021-10-12': {'GS UN': {'cusip': '38141G104'}},
'2021-10-13': {'GS UN': {'cusip': '38141G104'}},
'2021-10-14': {'GS UN': {'cusip': '38141G104'}},
'2021-10-15': {'GS UN': {'cusip': '38141G104'}}}
Was this page useful?
Give feedback to help us improve developer.gs.com and serve you better.