GS Quant
raw JSON → 1.6.22 verified Mon Apr 27 auth: no python
GS Quant is a Python toolkit for quantitative finance developed by Goldman Sachs. It provides analytics, risk models, and market data access used by the firm's risk management and trading platforms. The current version is 1.6.22, with monthly releases.
pip install gs-quant Common errors
error ModuleNotFoundError: No module named 'gs_quant' ↓
cause Package installed as 'gs-quant' but imported with hyphen.
fix
Use 'import gs_quant' (with underscore).
error ImportError: cannot import name 'GsSession' from 'gs_quant.session' ↓
cause GsSession was renamed to Session in version 1.5+.
fix
Use 'from gs_quant.session import Session'.
error gs_quant.exceptions.GsAuthenticationError: Authentication failed. Check your client ID and secret. ↓
cause Missing or invalid credentials. The environment variables GS_CLIENT_ID and GS_CLIENT_SECRET are not set or incorrect.
fix
Set GS_CLIENT_ID and GS_CLIENT_SECRET environment variables, or pass them to Session.use().
Warnings
breaking GS Quant v1.0+ dropped support for Python 3.8 and below. Upgrade to Python 3.9+. ↓
fix Update Python to >=3.9 and pip install gs-quant>=1.0
deprecated The GsSession class is deprecated in favor of Session in v1.5+. ↓
fix Use 'from gs_quant.session import Session' instead of 'from gs_quant.session import GsSession'
gotcha Imports must use underscores: 'gs_quant' not 'gs-quant'. The hyphen is only in the PyPI package name. ↓
fix Always use 'from gs_quant...' in your code.
gotcha API keys for production must be set via environment variables, not hardcoded. The library checks env vars GS_CLIENT_ID and GS_CLIENT_SECRET. ↓
fix Set environment variables before importing gs_quant, or use Session.use() with explicit credentials.
Imports
- GxQuantApi wrong
from gsquant.api import GxQuantApicorrectfrom gs_quant.api import GxQuantApi - RiskModel wrong
from gs-quant.risk import RiskModelcorrectfrom gs_quant.risk import RiskModel - Session
from gs_quant.session import Session
Quickstart
from gs_quant.session import Session
from gs_quant.api import GxQuantApi
import os
# Authenticate with client id and secret
Session.use(client_id=os.environ.get('GS_CLIENT_ID', ''),
client_secret=os.environ.get('GS_CLIENT_SECRET', ''))
# Fetch risk model data
api = GxQuantApi()
model = api.get_risk_model('GSM2')
print(model.name)