{"id":13526549,"url":"https://github.com/bashtage/arch","last_synced_at":"2025-05-13T17:05:05.335Z","repository":{"id":20197553,"uuid":"23468876","full_name":"bashtage/arch","owner":"bashtage","description":"ARCH models in Python","archived":false,"fork":false,"pushed_at":"2025-05-06T06:14:43.000Z","size":198785,"stargazers_count":1393,"open_issues_count":32,"forks_count":260,"subscribers_count":49,"default_branch":"main","last_synced_at":"2025-05-06T07:33:33.613Z","etag":null,"topics":["adf","arch","bootstrap","df-gls","dickey-fuller","finance","financial-econometrics","forecasting","garch","model-confidence-set","multiple-comparison-procedures","phillips-perron","reality-check","risk","spa","time-series","unit-root","variance","volatility"],"latest_commit_sha":null,"homepage":"http://bashtage.github.io/arch/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bashtage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-08-29T15:41:28.000Z","updated_at":"2025-05-05T07:41:07.000Z","dependencies_parsed_at":"2023-09-22T03:04:54.865Z","dependency_job_id":"55030c5c-db55-483f-b171-9d6ccc721603","html_url":"https://github.com/bashtage/arch","commit_stats":{"total_commits":666,"total_committers":37,"mean_commits":18.0,"dds":"0.30330330330330335","last_synced_commit":"256887c5ffe45856ea07859295fa316f63cb4590"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Farch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Farch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Farch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Farch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashtage","download_url":"https://codeload.github.com/bashtage/arch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990460,"owners_count":21995774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adf","arch","bootstrap","df-gls","dickey-fuller","finance","financial-econometrics","forecasting","garch","model-confidence-set","multiple-comparison-procedures","phillips-perron","reality-check","risk","spa","time-series","unit-root","variance","volatility"],"created_at":"2024-08-01T06:01:31.383Z","updated_at":"2025-05-13T17:05:05.307Z","avatar_url":"https://github.com/bashtage.png","language":"Python","funding_links":[],"categories":["Code-Resource","金融数据处理","Python","时间序列","Time Series Analysis","Curated List","编程","Python：量化金融第一生态"],"sub_categories":["2020","Time Series","网络服务_其他","Books","Time Series Analysis","Python","六、时间序列分析与预测"],"readme":"# arch\r\n\r\n[![arch](https://bashtage.github.io/arch/doc/_static/images/color-logo-256.png)](https://github.com/bashtage/arch)\r\n\r\nAutoregressive Conditional Heteroskedasticity (ARCH) and other tools for\r\nfinancial econometrics, written in Python (with Cython and/or Numba used\r\nto improve performance)\r\n\r\n| Metric                     |                                                                                                                                                                                                                                          |\r\n| :------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\r\n| **Latest Release**         | [![PyPI version](https://badge.fury.io/py/arch.svg)](https://badge.fury.io/py/arch)                                                                                                                                                      |\r\n|                            | [![conda-forge version](https://anaconda.org/conda-forge/arch-py/badges/version.svg)](https://anaconda.org/conda-forge/arch-py)                                                                                                          |\r\n| **Continuous Integration** | [![Build Status](https://dev.azure.com/kevinksheppard0207/kevinksheppard/_apis/build/status/bashtage.arch?branchName=main)](https://dev.azure.com/kevinksheppard0207/kevinksheppard/_build/latest?definitionId=1\u0026branchName=main)        |\r\n| **Coverage**               | [![codecov](https://codecov.io/gh/bashtage/arch/branch/main/graph/badge.svg)](https://codecov.io/gh/bashtage/arch)                                                                                                                       |\r\n| **Code Quality**           | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/93f6fd90209842bf97fd20fda8db70ef)](https://www.codacy.com/manual/bashtage/arch?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=bashtage/arch\u0026utm_campaign=Badge_Grade) |\r\n|                            | [![codebeat badge](https://codebeat.co/badges/18a78c15-d74b-4820-b56d-72f7e4087532)](https://codebeat.co/projects/github-com-bashtage-arch-main)                                                                                         |\r\n| **Citation**               | [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.593254.svg)](https://doi.org/10.5281/zenodo.593254)                                                                                                                                  |\r\n| **Documentation**          | [![Documentation Status](https://readthedocs.org/projects/arch/badge/?version=latest)](https://arch.readthedocs.org/en/latest/)                                                                                                          |\r\n\r\n## Module Contents\r\n\r\n- [Univariate ARCH Models](#volatility)\r\n- [Unit Root Tests](#unit-root)\r\n- [Cointegration Testing and Analysis](#cointegration)\r\n- [Bootstrapping](#bootstrap)\r\n- [Multiple Comparison Tests](#multiple-comparison)\r\n- [Long-run Covariance Estimation](#long-run-covariance)\r\n\r\n### Python 3\r\n\r\n`arch` is Python 3 only. Version 4.8 is the final version that supported Python 2.7.\r\n\r\n## Documentation\r\n\r\nDocumentation from the main branch is hosted on\r\n[my github pages](https://bashtage.github.io/arch/).\r\n\r\nReleased documentation is hosted on\r\n[read the docs](https://arch.readthedocs.org/en/latest/).\r\n\r\n## More about ARCH\r\n\r\nMore information about ARCH and related models is available in the notes and\r\nresearch available at [Kevin Sheppard's site](https://www.kevinsheppard.com).\r\n\r\n## Contributing\r\n\r\nContributions are welcome. There are opportunities at many levels to contribute:\r\n\r\n- Implement new volatility process, e.g., FIGARCH\r\n- Improve docstrings where unclear or with typos\r\n- Provide examples, preferably in the form of IPython notebooks\r\n\r\n## Examples\r\n\r\n\u003ca id=\"volatility\"\u003e\u003c/a\u003e\r\n\r\n### Volatility Modeling\r\n\r\n- Mean models\r\n  - Constant mean\r\n  - Heterogeneous Autoregression (HAR)\r\n  - Autoregression (AR)\r\n  - Zero mean\r\n  - Models with and without exogenous regressors\r\n- Volatility models\r\n  - ARCH\r\n  - GARCH\r\n  - TARCH\r\n  - EGARCH\r\n  - EWMA/RiskMetrics\r\n- Distributions\r\n  - Normal\r\n  - Student's T\r\n  - Generalized Error Distribution\r\n\r\nSee the [univariate volatility example notebook](https://bashtage.github.io/arch/univariate/univariate_volatility_modeling.html) for a more complete overview.\r\n\r\n```python\r\nimport datetime as dt\r\nimport pandas_datareader.data as web\r\nst = dt.datetime(1990,1,1)\r\nen = dt.datetime(2014,1,1)\r\ndata = web.get_data_yahoo('^FTSE', start=st, end=en)\r\nreturns = 100 * data['Adj Close'].pct_change().dropna()\r\n\r\nfrom arch import arch_model\r\nam = arch_model(returns)\r\nres = am.fit()\r\n```\r\n\r\n\u003ca id=\"unit-root\"\u003e\u003c/a\u003e\r\n\r\n### Unit Root Tests\r\n\r\n- Augmented Dickey-Fuller\r\n- Dickey-Fuller GLS\r\n- Phillips-Perron\r\n- KPSS\r\n- Zivot-Andrews\r\n- Variance Ratio tests\r\n\r\nSee the [unit root testing example notebook](https://bashtage.github.io/arch/unitroot/unitroot_examples.html)\r\nfor examples of testing series for unit roots.\r\n\r\n\u003ca id=\"unit-root\"\u003e\u003c/a\u003e\r\n\r\n### Cointegration Testing and Analysis\r\n\r\n- Tests\r\n  - Engle-Granger Test\r\n  - Phillips-Ouliaris Test\r\n- Cointegration Vector Estimation\r\n  - Canonical Cointegrating Regression\r\n  - Dynamic OLS\r\n  - Fully Modified OLS\r\n\r\nSee the [cointegration testing example notebook](https://bashtage.github.io/arch/unitroot/unitroot_cointegration_examples.html)\r\nfor examples of testing series for cointegration.\r\n\r\n\u003ca id=\"bootstrap\"\u003e\u003c/a\u003e\r\n\r\n### Bootstrap\r\n\r\n- Bootstraps\r\n  - IID Bootstrap\r\n  - Stationary Bootstrap\r\n  - Circular Block Bootstrap\r\n  - Moving Block Bootstrap\r\n- Methods\r\n  - Confidence interval construction\r\n  - Covariance estimation\r\n  - Apply method to estimate model across bootstraps\r\n  - Generic Bootstrap iterator\r\n\r\nSee the [bootstrap example notebook](https://bashtage.github.io/arch/bootstrap/bootstrap_examples.html)\r\nfor examples of bootstrapping the Sharpe ratio and a Probit model from statsmodels.\r\n\r\n```python\r\n# Import data\r\nimport datetime as dt\r\nimport pandas as pd\r\nimport numpy as np\r\nimport pandas_datareader.data as web\r\nstart = dt.datetime(1951,1,1)\r\nend = dt.datetime(2014,1,1)\r\nsp500 = web.get_data_yahoo('^GSPC', start=start, end=end)\r\nstart = sp500.index.min()\r\nend = sp500.index.max()\r\nmonthly_dates = pd.date_range(start, end, freq='M')\r\nmonthly = sp500.reindex(monthly_dates, method='ffill')\r\nreturns = 100 * monthly['Adj Close'].pct_change().dropna()\r\n\r\n# Function to compute parameters\r\ndef sharpe_ratio(x):\r\n    mu, sigma = 12 * x.mean(), np.sqrt(12 * x.var())\r\n    return np.array([mu, sigma, mu / sigma])\r\n\r\n# Bootstrap confidence intervals\r\nfrom arch.bootstrap import IIDBootstrap\r\nbs = IIDBootstrap(returns)\r\nci = bs.conf_int(sharpe_ratio, 1000, method='percentile')\r\n```\r\n\r\n\u003ca id=\"multiple-comparison\"\u003e\u003c/a\u003e\r\n\r\n### Multiple Comparison Procedures\r\n\r\n- Test of Superior Predictive Ability (SPA), also known as the Reality\r\n    Check or Bootstrap Data Snooper\r\n- Stepwise (StepM)\r\n- Model Confidence Set (MCS)\r\n\r\nSee the [multiple comparison example notebook](https://bashtage.github.io/arch/multiple-comparison/multiple-comparison_examples.html)\r\nfor examples of the multiple comparison procedures.\r\n\r\n\u003ca id=\"long-run-covariance\"\u003e\u003c/a\u003e\r\n\r\n### Long-run Covariance Estimation\r\n\r\nKernel-based estimators of long-run covariance including the\r\nBartlett kernel which is known as Newey-West in econometrics.\r\nAutomatic bandwidth selection is available for all of the\r\ncovariance estimators.\r\n\r\n```python\r\nfrom arch.covariance.kernel import Bartlett\r\nfrom arch.data import nasdaq\r\ndata = nasdaq.load()\r\nreturns = data[[\"Adj Close\"]].pct_change().dropna()\r\n\r\ncov_est = Bartlett(returns ** 2)\r\n# Get the long-run covariance\r\ncov_est.cov.long_run\r\n```\r\n\r\n## Requirements\r\n\r\nThese requirements reflect the testing environment. It is possible\r\nthat arch will work with older versions.\r\n\r\n- Python (3.9+)\r\n- NumPy (1.19+)\r\n- SciPy (1.5+)\r\n- Pandas (1.1+)\r\n- statsmodels (0.12+)\r\n- matplotlib (3+), optional\r\n\r\n\r\n### Optional Requirements\r\n\r\n- Numba (0.49+) will be used if available **and** when installed without building the binary modules. In order to ensure that these are not built, you must set the environment variable `ARCH_NO_BINARY=1` and install without the wheel.\r\n\r\n```shell\r\nexport ARCH_NO_BINARY=1\r\npython -m pip install arch\r\n```\r\n\r\nor if using Powershell on windows\r\n\r\n```powershell\r\n$env:ARCH_NO_BINARY=1\r\npython -m pip install arch\r\n```\r\n\r\n- jupyter and notebook are required to run the notebooks\r\n\r\n## Installing\r\n\r\nStandard installation with a compiler requires Cython. If you do not\r\nhave a compiler installed, the `arch` should still install. You will\r\nsee a warning but this can be ignored. If you don't have a compiler,\r\n`numba` is strongly recommended.\r\n\r\n### pip\r\n\r\nReleases are available PyPI and can be installed with `pip`.\r\n\r\n```shell\r\npip install arch\r\n```\r\n\r\nYou can alternatively install the latest version from GitHub\r\n\r\n```bash\r\npip install git+https://github.com/bashtage/arch.git\r\n```\r\n\r\nSetting the environment variable `ARCH_NO_BINARY=1` can be used to\r\ndisable compilation of the extensions.\r\n\r\n### Anaconda\r\n\r\n`conda` users can install from conda-forge,\r\n\r\n```bash\r\nconda install arch-py -c conda-forge\r\n```\r\n\r\n**Note**: The conda-forge name is `arch-py`.\r\n\r\n### Windows\r\n\r\nBuilding extension using the community edition of Visual Studio is\r\nsimple when using Python 3.8 or later. Building is not necessary when numba\r\nis installed since just-in-time compiled code (numba) runs as fast as\r\nahead-of-time compiled extensions.\r\n\r\n### Developing\r\n\r\nThe development requirements are:\r\n\r\n- Cython (0.29+, if not using ARCH_NO_BINARY=1, supports 3.0.0b2+)\r\n- pytest (For tests)\r\n- sphinx (to build docs)\r\n- sphinx-immaterial (to build docs)\r\n- jupyter, notebook and nbsphinx (to build docs)\r\n\r\n### Installation Notes\r\n\r\n1. If Cython is not installed, the package will be installed\r\n    as-if `ARCH_NO_BINARY=1` was set.\r\n2. Setup does not verify these requirements. Please ensure these are\r\n    installed.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashtage%2Farch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbashtage%2Farch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashtage%2Farch/lists"}