Universe¶
-
class
sim.
Universe
(feature_beta, factor_garch_spec, industry_garch_spec, resid_garch_spec, factor_loadings, industry_loadings, liquidity=0.5, gamma=2, freq='m')[source]¶ Bases:
object
The universe is a specification from which simulated realizations can be sampled. Stocks follow a factor model, they belong to industries and have an idiosyncratic component. Stocks are predictable by a single feature.
- Attributes
- feature_betafloat
The true coefficient.
- factor_garch_speclist
The garch specification for factor returns.
[sigma_sq_0, mu, alpha, beta, omega]
- industry_garch_speclist
The garch specification for industry returns.
[sigma_sq_0, mu, alpha, beta, omega]
- resid_garch_speclist
The garch specification for residual returns.
[sigma_sq_0, mu, alpha, beta, omega]
- factor_loadingsnumpy.ndarray
An array with factor loadings for each stock and factor. dim = n_stocks x n_factors
- industry_loadingsnumpy.ndarray
An array with industry loadings for each stock and industry. dim = n_stocks x n_industry This is usually a sparse matrix. One stock loads typically on one or two industries. A good number of industries is 10 to 20.
- liquidityfloat
A value between 0 and 1 that describes liquidity. A value of 1 means that the probability of observation is 100% each minute. 0.5 means that there is a 50% probability of observing a price each minute.
- gammafloat >=0
The microstructure noise will be zero-mean Gaussian with variance \(\gamma^2 var(r)\), where \(var(r)\) is the variance of the underlying true return process. This noise is be added to the price.
- freqstr,
's'
or'm'
. The granularity of the discretized continous price process.
Methods Summary
cond_cov
(self)Compute the daily coditional integrated covariance matrix of stock returns within regular market hours in the universe from a realized universe simulation.
simulate
(self, n_days)The price process of each stock is continous but sampled at random times and with Gaussian microstructure noise.
uncond_cov
(self)Compute the uncoditional covariance of stock returns in the universe from a universe specification.
uncond_var
(spec)Compute the uncoditional variance from a GARCH(1,1) specification.
Methods Documentation
-
cond_cov
(self)[source]¶ Compute the daily coditional integrated covariance matrix of stock returns within regular market hours in the universe from a realized universe simulation.
- Returns
- list
A list containing the conditional integrated covariance matrices of each day.
-
simulate
(self, n_days)[source]¶ The price process of each stock is continous but sampled at random times and with Gaussian microstructure noise. Importantly, the observation times are not synchronous across stocks. Observation times are restricted to market hours (9:30, 16:00) but the underlying process continues over night so that there are close-to-open gaps.
- Parameters
- n_daysint
The number of days of the sample path.
- Returns
- list of pd.DataFrame
A list with two elements, the prices of each stock in a pd.DataFrame and the feature of each stock in a pd.DataFrame with datetime_index.