menu
Data

Charting Data

A simple way to chart data in GS Quant is by installing matplotlib. This plotting library can be used to easily generate plots, histograms, power spectra, bar charts, error charts, scatter plots, etc.

Let's use this library to chart calculated implied volatility from GS Quant.

info

Note

Examples require an initialized GsSession and data subscription. Please refer to Sessions for details.

Querying Data

First, let's retrieve S&P 500 end of day implied volatility for 1 month tenor with forward strike:

from gs_quant.data import Dataset
from gs_quant.markets import PricingContext


market_date = PricingContext.current.market.date  # Determine current market date

vol_dataset = Dataset(Dataset.GS.EDRVOL_PERCENT_STANDARD)  # Initialize the equity implied volatility dataset
vol_data = vol_dataset.get_data(market_date, market_date, ticker='SPX', tenor='1m', strikeReference='forward')

print(vol_data.tail())

Output:

    absoluteStrike              assetId  ... ticker            updateTime
21     4049.365704  MA4B66MW5E27U8P32SB  ...    SPX  2019-06-17T22:18:01Z
22     4193.985908  MA4B66MW5E27U8P32SB  ...    SPX  2019-06-17T22:18:01Z
23     4338.606111  MA4B66MW5E27U8P32SB  ...    SPX  2019-06-17T22:18:01Z
24     5061.707130  MA4B66MW5E27U8P32SB  ...    SPX  2019-06-17T22:18:01Z
25     5784.808149  MA4B66MW5E27U8P32SB  ...    SPX  2019-06-17T22:18:01Z

[5 rows x 9 columns]

Charting Data

Implied Volatility By Strike

Now, let's use vol_data to chart the implied volatility by relative strike:

info

Note

Remember to install matplotlib.

add the following import statement to have matplot available:

import matplotlib.pyplot as plt

then plot your data like so:

strikes = vol_data['relativeStrike']
vols = vol_data['impliedVolatility'] * 100

plt.plot(strikes, vols, label='Implied Volatility by Strike')
plt.xlabel('Relative Strike')
plt.ylabel('Implied Volatility')
plt.title('Implied Volatility by Strike')

plt.show()

Which will create a plot like this:

Implied Volatility By Tenor

Likewise we can use the same technique to chart the implied volatility by tenor:

from gs_quant.timeseries.measures import _to_offset

vol_data = vol_dataset.get_data(market_date, market_date, ticker='SPX', relativeStrike=1.0, strikeReference='forward')
# Create a new column converting relative dates to actual date times
vol_data.loc[:, 'tenorDate'] = vol_data.index + vol_data['tenor'].map(_to_offset)
# Sort the data frame by the newly created column
vol_data = vol_data.sort_values(by=['tenorDate'])
tenors = vol_data['tenor']
vols = vol_data['impliedVolatility'] * 100
plt.plot(tenors, vols, label='Implied Volatility by Tenor')
plt.xlabel('Tenor')
plt.ylabel('Implied Volatility')
plt.title('Implied Volatility by Tenor')
plt.show()

Producing:

Implied Volatility Area By Tenor And Strike

Now, let's combine the two and plot a vol surface to chart the implied volatility by tenor and strike:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm

from gs_quant.data import Dataset
from gs_quant.datetime import point_sort_order
from gs_quant.markets import PricingContext

# Initialize the dataset for equity implied volatility
vol_dataset = Dataset(Dataset.GS.EDRVOL_PERCENT_STANDARD)

market_date = PricingContext.current.market.date
tenors_to_plot = ["2w", "1m", "2m", "3m", "4m", "5m", "6m", "9m", "1y"]
fig = plt.figure(figsize=(16, 9))
ax = fig.add_subplot(111, projection='3d')

# Implied vol data for the current market data date
vol_data = vol_dataset.get_data(market_date, market_date, ticker='SPX', strikeReference='forward')
vol_data = vol_data[vol_data.tenor.isin(tenors_to_plot)]
vol_data['tenorDays'] = vol_data.tenor.map(lambda t: point_sort_order(t))

# Reformat the data
X = vol_data.relativeStrike.unique()
Y = vol_data.tenorDays.unique()
Z = np.array([vol_data[vol_data.tenorDays == y].impliedVolatility.values.tolist() for y in Y]) * 100
X, Y = np.meshgrid(X, Y)

# Plot the surface
ax.xaxis.set_label_text("Strike")
ax.yaxis.set_label_text("Tenor")
ax.zaxis.set_label_text("Implied Vol")
ax.set_zlim(0, 75)
ax.set_yticks(vol_data.tenorDays.unique())
ax.set_yticklabels(vol_data.tenor.unique())
surface = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, linewidth=0, antialiased=False)

plt.show()

The previous example should produce a 3D graph similar to this:


Related Content


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.