menu
Data

Financial Series

This tutorial provides an overview of how to interact with financial data series. We'll walk through some examples of how to retrieve and visualize market data in order to analyze the performance of different assets. In this tutorial we will examine the prices of equity baskets, which provide investors with exposure to different market themes through custom baskets of stocks.

Retrieving Prices

First, let's get the prices of the Goldman Sachs Hedge Fund VIP Basket (Ticker: GSTHHVIP). This is a custom basket created by the Goldman Sachs Investment Research (GIR) group to track stocks which are widely held by the hedge fund community in the US, based on 13-F filings.

info

Note

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

We'll use the GS Custom Basket Prices dataset, which contains prices for a selection of GS thematic equity baskets. This dataset contains the closePrice field, which tracks the official closing price for each asset on a daily basis, and is exposed in GS Quant as Fields.CLOSE_PRICE:

from gs_quant.data import Dataset, Fields
from datetime import date

basket_ds = Dataset('GSCB_FLAGSHIP')
start_date = date(2007,1,1)

vip_px = basket_ds.get_data_series(Fields.CLOSE_PRICE, start=start_date, ticker='GSTHHVIP')
vip_px.tail()

Output:

Out[1]:
2019-06-14    269.314751
2019-06-17    271.106028
2019-06-18    274.046304
2019-06-19    276.174911
2019-06-20    279.399869
dtype: float64

The first observation in the series is on 28th November 2007, and prices are available up to the most recent US market close. Let's plot the series to see how the basket has performed over the last 10+ years:

vip_px.plot()

Output:

Comparing Performance

In addition to the Hedge Fund VIP Basket, the Portfolio Strategies Group within Goldman Sachs Investment Research also computes a basket of stocks which are most widely shorted across the hedge fund community. This basket is called the HF Important Shorts Basket (ticker: GSTHVISP). We'll retrieve the price history for this basket:

visp_px = basket_ds.get_data_series(Fields.CLOSE_PRICE, start=start_date, ticker='GSTHVISP')
visp_px.tail()

Output:

Out[3]:
2019-06-14    231.022088
2019-06-17    230.661374
2019-06-18    232.949564
2019-06-19    233.424179
2019-06-20    235.450614
dtype: float64

Now let's compare the prices of the two assets. First, we'll align the two series so that they cover the same date range, then index both series to 100 on the initial date and plot:

import gs_quant.timeseries as ts
import pandas as pd

[vip, visp] = ts.align(vip_px, visp_px, ts.Interpolate.INTERSECT)
vip = ts.index( vip, 100 )
visp = ts.index( visp, 100 )
compare = pd.DataFrame({'vip': vip, 'visp': visp})
compare.plot()

Output:

Looks like the VIP basket has outperformed, the VISP basket over the last 5 or so years. Next we'll analyze performance over a few key statistical dimensions.

Analyzing Series

There are a few basic properties of a financial series we would look at in order to evaluate how it would fit into a portfolio. We'll run a quick analysis of our two series to evaluate them against these dimensions. Here's a quick summary of what we are going to compute:

MeasureDescription
Annual VolatilityHistorical annualized realized volatility
Max DrawdownMaximum peak-to-trough percentage drawdown over a given period
CorrelationDegree of linear relationship between the two assets

Use the GS Quant timeseries functions to calculate, and then plot results:

import gs_quant.timeseries as ts
import matplotlib.pyplot as plt

window = 22     # 1 month (22 business day) lookback

vols = pd.DataFrame({'vip': ts.volatility(vip, window), 'visp': ts.volatility(visp, window)})
draws = pd.DataFrame({'vip': ts.max_drawdown(vip, window), 'visp': ts.max_drawdown(visp, window)})
corr = ts.correlation(vip, visp, window )

plot, axs = plt.subplots(3, sharex=True)
plot.suptitle('Hedge Fund VIP vs Hedge Fund VIP Short')

axs[0].title.set_text('Volaility')
axs[1].title.set_text('Max Drawdown')
axs[2].title.set_text('Correlation')

axs[0].plot(vols)
axs[1].plot(draws)
axs[2].plot(corr)

Output:

A few quick takeaways, which were probably intuitive from the original price curves:

  • The hedge fund short basket generally has lower volatility than the long basket
  • The long basket has larger maximum drawdown than the short basket
  • The correlation between the products is generally close to 1

Related Content


This site is for informational purposes only and does not constitute an offer to sell, or the solicitation of an offer to buy, any security. The Goldman Sachs Marquee® platform is for institutional and professional clients only. Some of the services and products described on this site may not be available in certain jurisdictions or to certain types of client. Please contact your Goldman Sachs sales representative with any questions. Nothing on this site constitutes an offer, or an invitation to make an offer from Goldman Sachs to purchase or sell a product. This site is given for purely indicative purposes and does not create any contractual relationship between you and Goldman Sachs. Any market information contained on the site (including but not limited to pricing levels) is based on data available to Goldman Sachs at a given moment and may change from time to time. 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. © 2023 Goldman Sachs. All rights reserved.
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. © 2023 Goldman Sachs. All rights reserved.
Not all products and functionality mentioned on this website are currently available through our API platform.
All loans and deposit products are provided by Goldman Sachs Bank USA, Salt Lake City Branch. Member FDIC.
Brokerage and investment advisory services offered by our investment products are provided by Goldman Sachs & Co. LLC (`‘GS&CO.`’), which is an SEC registered broker-dealer and investment adviser, and member FINRA/SIPC. Research our firm at FINRA's BrokerCheck. Custody and clearing services are provided by Apex Clearing Corporation, a registered broker-dealer and member FINRA/SIPC. Please consider your objectives before investing. A diversified portfolio does not ensure a profit or protect against a loss. Past performance does not guarantee future results. Investment outcomes and projections are forward-looking statements and hypothetical in nature. Neither this website nor any of its contents shall constitute an offer, solicitation, or advice to buy or sell securities in any jurisdictions where GS&Co. is not registered. Any information provided prior to opening an investment account is on the basis that it will not constitute investment advice and that GS&Co. is not a fiduciary to any person by reason of providing such information. For more information about our investment offerings, visit our Full Disclosures.
Investment products are: NOT FDIC INSURED ∙ NOT A DEPOSIT OR OTHER OBLIGATION OF, OR GUARANTEED BY, GOLDMAN SACHS BANK USA ∙ SUBJECT TO INVESTMENT RISKS, INCLUDING POSSIBLE LOSS OF THE PRINCIPAL AMOUNT INVESTED