gs_quant.timeseries.econometrics.returns¶
-
returns
(series, obs=1, type=<Returns.SIMPLE: 'simple'>)[source]¶ Calculate returns from price series
- Parameters
series (
Series
) – time series of pricesobs (
int
) – number of observationstype (
Returns
) – returns type: simple, logarithmic or absolute
- Return type
Series
- Returns
date-based time series of return
Usage
Compute returns series from price levels, based on the value of type:
Type
Description
simple
Simple arithmetic returns
logarithmic
Logarithmic returns
absolute
Absolute returns
Simple
Simple geometric change in asset prices, which can be aggregated across assets
\(Y_t = \frac{X_t}{X_{t-obs}} - 1\)
where \(X_t\) is the asset price at time \(t\)
Logarithmic
Natural logarithm of asset price changes, which can be aggregated through time
\(Y_t = log(X_t) - log(X_{t-obs})\)
where \(X_t\) is the asset price at time \(t\)
Absolute
Absolute change in asset prices
\(Y_t = X_t - X_{t-obs}\)
where \(X_t\) is the asset price at time \(t\)
Examples
Generate price series and take compute returns
>>> prices = generate_series(100) >>> returns = returns(prices)
See also