Skip to main content

Multiple Univariate ARCH modeling toolbox built on top of the ARCH package

Project description

MUArch

Continuous Integration

Build Status Build status

Documentation

Documentation Status

Coverage

Coverage Status

Installing

Install and update using pip and on conda.

This is a wrapper on top of Kevin Sheppard's ARCH package. The purpose of which are to:

  1. Enable faster Monte Carlo simulation
  2. Simulate innovations through copula marginals

In the package, there are 2 classes to aid you - UArch and MUArch. The UArch class can be defined using a similar API to arch_model in the original arch package. The MUArch is a collection of these UArch models.

Thus, if you have a function that generates uniform marginals, like a copula, you can create a dependence structure among the different marginals when simulating the GARCH processes.

If you need a copula package, I have one here. :)

Example

I'll list out a simple procedure to do AR-GARCH-Copula simulations.

from muarch import MUArch, UArch
from muarch.datasets import load_etf
from copulae import NormalCopula


returns = load_etf()  # load returns data
num_assets = returns.shape[1]

# sets up a MUArch model collection where each model defaults to 
# mean: AR(1)
# vol: GARCH(1, 1)
# dist: normal 
models = MUArch(num_assets, mean='AR', lags=1) 

# set first model to AR(1)-GARCH(1, 1) with skewt innovations  
models[0] = UArch('AR', lags=1, dist='skewt')  

# fit model, if you get complaints regarding non-convergence, you can scale the data up 
# using the scale parameter in the UArch or MUArch. i.e. UArch(..., scale=100). This will
# reduce numerical errors. Don't worry, I'll rescale the simulation values subsequently
models.fit(returns)

# Usually you'll want to fit the residuals to the copula, use the copula to generate the
# residuals and subsequently transform it back to returns 

residuals = models.residuals() # defaults to return the standardized residuals


cop = NormalCopula(dim=num_assets) # use a normal copula, you could of course use a TCopula
cop.fit(residuals)

# simulate 10 steps into the future, over 4 repetitions. This will return a (10 x 4 x 3) array
models.simulate_mc(10, 4, custom_dist=cop.random)

Future Works

This is actually a temporary hack so that others can do GARCH copula simulation. Another issue is that an ARFIMA mean model is not so easily specified (and simulated from) with the original arch package. You could specify an ARFIMA (or even just an ARMA model for the matter), fit it separately then use the residuals to fit a zero-mean model (pure GARCH). However, in such a way, the simulation is not so straightforward as you'll have to stitch the simulations from GARCH process and the mean model process back.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

muarch-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl (429.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

muarch-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl (431.1 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

Details for the file muarch-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: muarch-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 429.1 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for muarch-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9d698bc703f7d74c009c44c48df758c29109c501ba126de7a4e12b3c34776787
MD5 58001eb1e62918324b9589e2bfa6adc6
BLAKE2b-256 0d0a1df56b3607846c83b7756f90b0c57332d57afba0eeb4f1d960b7262f771d

See more details on using hashes here.

File details

Details for the file muarch-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: muarch-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 431.1 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for muarch-0.1.2-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 e6a36a8933cbdadc79cf7ad9b917181ac87573cc583db10c39a14b09979a33d6
MD5 63e3b546a83048f4a45f4ab1c67cc20f
BLAKE2b-256 5e2dbfb1a7582ad1bf895e9a710119b9e01499beb5b280f76f1d72e535dc6728

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page