{"id":34060001,"url":"https://github.com/rafa-rod/vartests","last_synced_at":"2026-04-06T06:31:45.754Z","repository":{"id":62587045,"uuid":"429226911","full_name":"rafa-rod/vartests","owner":"rafa-rod","description":"Statistical tests for Value at Risk (VaR) Models.","archived":false,"fork":false,"pushed_at":"2025-09-16T22:47:12.000Z","size":103,"stargazers_count":14,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-16T23:22:38.899Z","etag":null,"topics":["backtest","backtesting","berkowitz","christoffersen","christoffersen-pelletier","duration-test","finance","kupiec-test","statistical-tests","value-at-risk"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafa-rod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-17T23:01:57.000Z","updated_at":"2025-09-16T22:47:16.000Z","dependencies_parsed_at":"2025-09-16T22:28:57.859Z","dependency_job_id":"a64036c2-7966-4b93-89c0-31f2f61c090c","html_url":"https://github.com/rafa-rod/vartests","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rafa-rod/vartests","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafa-rod%2Fvartests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafa-rod%2Fvartests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafa-rod%2Fvartests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafa-rod%2Fvartests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafa-rod","download_url":"https://codeload.github.com/rafa-rod/vartests/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafa-rod%2Fvartests/sbom","scorecard":{"id":758090,"data":{"date":"2025-08-11","repo":{"name":"github.com/rafa-rod/vartests","commit":"9eae106044aab6bfd9dbbe4bc38f24f9a9575aca"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2023-102","Warn: Project is vulnerable to: PYSEC-2023-114","Warn: Project is vulnerable to: GHSA-g7vv-2v7x-gj9p"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T22:22:54.903Z","repository_id":62587045,"created_at":"2025-08-22T22:22:54.903Z","updated_at":"2025-08-22T22:22:54.903Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31463012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["backtest","backtesting","berkowitz","christoffersen","christoffersen-pelletier","duration-test","finance","kupiec-test","statistical-tests","value-at-risk"],"created_at":"2025-12-14T04:03:04.718Z","updated_at":"2026-04-06T06:31:45.749Z","avatar_url":"https://github.com/rafa-rod.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- buttons --\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.linkedin.com/in/rafaelrod/\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/LinkedIn-0077B5?style=flat\u0026logo=linkedin\u0026logoColor=white\"\n            alt=\"LinkedIn\"\u003e\u003c/a\u003e \u0026nbsp;\n    \u003ca href=\"https://www.python.org/\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/python-v3-brightgreen.svg\"\n            alt=\"python\"\u003e\u003c/a\u003e \u0026nbsp;\n    \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg\"\n            alt=\"MIT license\"\u003e\u003c/a\u003e \u0026nbsp;\n    \u003ca href=\"https://github.com/psf/black\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\n            alt=\"Code style: black\"\u003e\u003c/a\u003e \u0026nbsp;\n    \u003ca href=\"http://mypy-lang.org/\"\u003e\n        \u003cimg src=\"http://www.mypy-lang.org/static/mypy_badge.svg\"\n            alt=\"Checked with mypy\"\u003e\u003c/a\u003e \u0026nbsp;\n\u003c/p\u003e\n\n\u003c!-- content --\u003e\n\n**vartests** is a Python library to perform some statistical tests to evaluate Value at Risk (VaR) Models, such as:\n\n- **T-test**: verify if mean of distribution is zero;\n- **Kupiec Test (1995)**: verify if the number of violations is consistent with the violations predicted by the model;\n- **Berkowitz Test (2001)**: verify if conditional distributions of returns \"GARCH(1,1)\"  used in the VaR Model is adherent to the data. In this specific test, we do not observe the whole data, only the tail;\n- **Christoffersen and Pelletier Test (2004)**: also known as Duration Test. Duration is time between violations of VaR. It tests if VaR Model has quickly response to market movements by consequence the violations do not form volatility clusters. This test verifies if violations has no memory i.e. should be independent.\n\n## Installation\n\n### Using pip\n\nYou can install using the pip package manager by running:\n\n```sh\npip install vartests\n```\n\nAlternatively, you could install the latest version directly from Github:\n\n```sh\npip install https://github.com/rafa-rod/vartests/archive/refs/heads/main.zip\n```\n\n## Why vartests is important?\n\nAfter VaR calculation, it is necessary to perform statistic tests to evaluate the VaR Models. To select the best model, they should be validated by backtests.\n\n## Example\n\nFirst of all, lets read a file with a PnL (distribution of profit and loss) of a portfolio in which also contains the VaR and its violations.\n\n```python\nimport pandas as pd\n\ndata = pd.read_excel(\"Example.xlsx\", index_col=0)\nviolations = data[\"Violations\"]\npnl = data[\"PnL\"] \ndata.sample(5)\n```\n\nThe dataframe looks like:\n\n```\n' |     PnL       |      VaR        |   Violations |\n  | -889.003707   | -2554.503872    |            0 |\n  | -2554.503872  | -2202.221691    |            1 | \n  | -887.527423   | -2193.692570    |            0 |  \n  | -274.344126   | -2160.290746    |            0 | \n  | 1376.018638   | -5719.833100    |            0 |'\n```\n\nNot all tests should be applied to the VaR Model. Some of them should be applied when the VaR Model has the assumption of zero mean or follow a specific distribution.\n\n```python\nimport vartests\n\nvartests.zero_mean_test(pnl, conf_level=0.95)\n```\n\nThis assumption is commonly used in parametric VaR like EWMA and GARCH Models. Besides that, is necessary check assumption of the distribution. So you should test with Berkowitz (2001):\n\n```python\nimport vartests\n\nvartests.berkowtiz_tail_test(pnl, volatility_window=252, var_conf_level=0.99, conf_level=0.95)\n```\n\nThe following tests should be used to any kind of VaR Models.\n\n```python\nimport vartests\n\nvartests.kupiec_test(violations, var_conf_level=0.99, conf_level=0.95)\n\nvartests.duration_test(violations, conf_level=0.95)\n```\n\nIf you want to see the failure ratio of the VaR Model, just type:\n\n```python\nimport vartests\n\nvartests.failure_rate(violations)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafa-rod%2Fvartests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafa-rod%2Fvartests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafa-rod%2Fvartests/lists"}