Kiyosi
简体中文 | English
Kiyosi 是一个用 Rust 编写的衍生品定价库,提供 Python API。它支持香草及奇异期权定价、希腊值计算和隐含参数求解。
支持的产品与算法
| 金融产品 | 定价算法 |
|---|---|
| 欧式香草期权 | BSM 解析解、数值积分、Heston Fourier 积分与二维 FD、CRR、FD、MC |
| 美式香草期权 | Bjerksund–Stensland 2002 近似、数值积分、Heston 二维 FD、CRR、FD、最小二乘 MC |
| 数字期权(现金或资产支付) | 解析解、数值积分、CRR、FD、MC |
| 几何平均亚式期权 | 连续平均解析解、MC |
| 算术平均亚式期权 | Turnbull–Wakeman 连续平均近似、MC |
| 单障碍期权 | 解析法、CRR、数值积分、FD、MC |
| 双障碍期权 | 解析级数、FD、MC |
| 二元障碍、单触碰与单不触碰期权 | 解析法、FD |
| 双触碰与双不触碰期权 | 解析级数、FD |
| 雪球、二元雪球、三元雪球 | 数值积分、FD、MC |
| 凤凰结构 | 数值积分、FD、MC |
| 累购、累沽 | 数值积分、FD、MC |
| 区间累计 | BSM 区间概率解析求和 |
安装
需要 Python 3.12+:
python -m pip install kiyosi
wheel 安装无需 Rust;源码安装需 Rust/Cargo 和本机编译工具。
快速上手
使用有限差分(FD)引擎为标准雪球定价:
from datetime import date
from kiyosi.instruments import standard_snowball
from kiyosi.market import (
BlackScholesMertonParameters,
PricingContext,
monthly_schedule,
sse_calendar,
)
from kiyosi.pricing import FiniteDifferenceAutocallableEngine
start, end = date(2025, 1, 2), date(2026, 1, 5)
calendar = sse_calendar()
observations = monthly_schedule(
start=start,
end=end,
first_observation_month=1,
calendar=calendar,
)
snowball = standard_snowball(
coupon_rate=0.12,
initial_spot=100.0,
knock_in_level=80.0,
knock_out_level=103.0,
observation_dates=observations,
effective_date=start,
expiry_date=end,
)
context = PricingContext(
model_parameters=BlackScholesMertonParameters(
risk_free_rate=0.02,
dividend_yield=0.00,
volatility=0.20,
),
spot_price=100.0,
valuation_time=start,
calendar=calendar,
)
engine = FiniteDifferenceAutocallableEngine(
asset_step_count=800,
time_step_count=400,
scheme="rannacher",
)
price = engine.price(snowball, context)
notional = 1_000_000
print(f"NPV / notional: {price:.6f}")
print(f"NPV: {price * notional:,.2f}")
许可证
Metadata
Release files for kiyosi 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kiyosi-0.17.0.tar.gz | 1.3 MB | With provenance | Details for kiyosi-0.17.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kiyosi-0.17.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details for kiyosi-0.17.0-cp312-abi3-win_amd64.whl |
| kiyosi-0.17.0-cp312-abi3-manylinux_2_28_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.28+ x86-64 | Details for kiyosi-0.17.0-cp312-abi3-manylinux_2_28_x86_64.whl |
Total release size: 5.3 MB
Release files / kiyosi-0.17.0.tar.gz
| Download URL | kiyosi-0.17.0.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6994c6c0c70a9564791f76850519a9ba8f6cf9ba29b4520d39f5acc94a8f8975
|
|
BLAKE2b-256 checksum How to use checksums |
2ea6af901080ded491206873fe11b44f5898290a929a27e2716608862a55ea68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / kiyosi-0.17.0-cp312-abi3-win_amd64.whl
| Download URL | kiyosi-0.17.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f522d603cb033c23e7563f546b003395466e86b7ae4d26e55ee3ddd4de3800f1
|
|
BLAKE2b-256 checksum How to use checksums |
dd45af3c6ed9c8421b69bbef470984388c01b2688a27ce65644a0dab7e0cdf5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / kiyosi-0.17.0-cp312-abi3-manylinux_2_28_x86_64.whl
| Download URL | kiyosi-0.17.0-cp312-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2d80bcb887eaaf09a2df08e4d8b225fc7b017f5ebdfb940b4e871683951d1fc7
|
|
BLAKE2b-256 checksum How to use checksums |
aaa9c25059763d36359d91257c0417fb7ec2aef74c090ea7939fa9806417adac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for kiyosi 0.17.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 3 files in this release have been uploaded with provenance metadata.
Attestation for kiyosi-0.17.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.