{"id":47707275,"url":"https://github.com/justkroft/option-implied-moments","last_synced_at":"2026-04-02T18:02:12.770Z","repository":{"id":347379835,"uuid":"1168799411","full_name":"justkroft/option-implied-moments","owner":"justkroft","description":"Algorithm to compute higher order return moments (volatility, skewness, kurtosis) from an implied volatility surface. ","archived":false,"fork":false,"pushed_at":"2026-03-27T17:21:12.000Z","size":406,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-28T01:41:02.323Z","etag":null,"topics":["asset-management","c","cython","finance","options","options-trading"],"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/justkroft.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2026-02-27T20:11:35.000Z","updated_at":"2026-03-27T17:21:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/justkroft/option-implied-moments","commit_stats":null,"previous_names":["justkroft/option-implied-moments"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/justkroft/option-implied-moments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkroft%2Foption-implied-moments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkroft%2Foption-implied-moments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkroft%2Foption-implied-moments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkroft%2Foption-implied-moments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justkroft","download_url":"https://codeload.github.com/justkroft/option-implied-moments/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justkroft%2Foption-implied-moments/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31312744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["asset-management","c","cython","finance","options","options-trading"],"created_at":"2026-04-02T18:01:14.065Z","updated_at":"2026-04-02T18:02:12.756Z","avatar_url":"https://github.com/justkroft.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![English](https://img.shields.io/badge/English-blue)](./README.md)\n[![日本語](https://img.shields.io/badge/日本語-red)](./README.ja.md)\n\n# 株式オプション価格から推定されるモーメント\n本リポジトリは、株式オプションデータからオプション・インプライド（すなわちリスク中立的）高次モーメントを計算するためのコードを含んでいる。ボラティリティ、歪度、尖度といった株式リターンの特性は、リスク中立測度 $\\mathbb{Q}$ のもとで、アウト・オブ・ザ・マネーの株式オプション契約に基づいて算出される。\n\n[[1]](#1) の手法を用いて、リスク中立的なボラティリティ、歪度、および尖度を計算する。同論文では、アウト・オブ・ザ・マネーのコールおよびプットの集合から、リスク中立リターン分布のモーメントの計算は以下のように定義される。\n\n$$\nVar^{\\mathbb{Q}} = \\frac{e^{r\\tau}V_{i,t} - \\mu^{2}}{\\tau},\n$$\n$$\nSkew^{\\mathbb{Q}} = \\frac{e^{r\\tau}W - 3\\mu e^{r\\tau}V + 2\\mu^{3}}{[e^{r\\tau}V-\\mu^{2}]^{3/2}},\n$$\n$$\nKurt^{\\mathbb{Q}} = \\frac{e^{r\\tau}X - 4\\mu e^{r\\tau}W + 6e^{r\\tau}\\mu^{2}V - 3\\mu^{4}}{[e^{r\\tau}V-\\mu^{2}]^{2}} - 3\n$$\n\n上記の数式では\n\n$$\n\\mu = e^{r\\tau} - 1 - \\frac{e^{r\\tau}}{2}V - \\frac{e^{r\\tau}}{6}W - \\frac{e^{r\\tau}}{24}X\n$$\n\n$V$、$W$、および $X$ は、測度 $\\mathbb{Q}$ の下で、時点 $t$ から $t+\\tau$ までの期間における株式リターンの対数の2乗、3乗、および4乗の期待値をそれぞれ表す。また、$r$ は同期間に対応する連続複利の無リスク金利である。\nこれらのパラメータを推定するために、 [[2]](#2) における台形則（trapezoidal rule）に基づく実装に従って、コールおよびプット・オプションの離散的なストライク価格を用いる。実装の詳細については、同論文の付録Bを参照してください。\n\n## プログラム実装の詳細\n本ライブラリのアーキテクチャは、3つの層から構成される。\n\n\u003e 注意：本ライブラリは、WRDS などのデータプロバイダから取得されるインプライド・ボラティリティ・サーフェス・データを用いる場合に最も良好に動作する。\n\n### C層\n\n数値計算はC言語で実装されている。\n- 正規累積分布関数（CDF） — complementary error function（相補誤差関数）を用いて近似される。\n\n$$\n\\Phi(x) = 0.5 \\times \\text{erfc}(\\frac{-x}{\\sqrt(2)})\n$$\n\n- ブラック・ショールズ価格付け — アウト・オブ・ザ・マネーのオプション価格は、インプライド・ボラティリティから標準的な閉形式解を用いて計算される。\n- コールおよびプットはストライク価格でソートされ、それぞれ価格付けされた後、[[2]](#2) に従い台形則によって個別に積分される。\n\n### Cython層\n\nCython層は、NumPyとC拡張の橋渡しとして機能する。Cythonの関数は、CSR（Compressed Sparse Row）形式で配置されたフラットなNumPy配列を入力として受け取る。ストライク価格、インプライド・ボラティリティ、およびフラグはすべてのグループにわたって連結され、`indptr` 配列が各グループの境界を示す。\nその後、各グループは OpenMP を用いて並列処理される。\n\n### Python層\n\nPython層はデータ前処理のみを担当する。具体的には、アウト・オブ・ザ・マネーのオプションのフィルタリング、コール・プットのフラグの整数の符号化、株および時間区間ごとのデータのソートとグループ化を行って、Cython層が要求するCSR形式を構築する。出力は Polars のDataFrameとして再構築される。\n\n# 使用方法\n\nセットアップ手順および使用例については、[英語版README](./README.md)を参照してください。\n\n# 参考文献\n\u003ca id=\"1\"\u003e[1]\u003c/a\u003e\nBakshi, G., Kapadia, N., \u0026 Madan, D. (2003). Stock return characteristics, skew laws, and the differential pricing of individual equity options. *The Review of Financial Studies, 16*(1), 101-143.\n\n\u003ca id=\"2\"\u003e[2]\u003c/a\u003e\nBali, Turan G. and Hu, Jianfeng and Murray, Scott, Option Implied Volatility, Skewness, and Kurtosis and the Cross-Section of Expected Stock Returns (January 1, 2019). Georgetown McDonough School of Business Research Paper, Available at SSRN: https://ssrn.com/abstract=2322945 or http://dx.doi.org/10.2139/ssrn.2322945\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustkroft%2Foption-implied-moments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustkroft%2Foption-implied-moments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustkroft%2Foption-implied-moments/lists"}