Actuarial library for the China Life Insurance Mortality Table (CL 2010-2013): survivorship, commutation columns, net single and annual premiums, and reserves by three independent methods, with a command line tool and a dependency-free SVG chart renderer.
| 项 | 要求 | 本项目验证环境 |
|---|---|---|
| MoonBit 编译器 | moonc ≥ 0.10.14 | v0.10.19+97801ee1b |
| 构建工具 | moon 工具链 | moon 0.1.20261029 |
| 第三方依赖 | 无 | — |
moon add hua1104/moonactuary# 安装 MoonBit 工具链(Linux / macOS)
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
export PATH="$HOME/.moon/bin:$PATH"
git clone https://github.com/hua1104/moonactuary.git
cd moonactuary
moon build --target native # 产物:_build/native/debug/build/cmd/main/main.exe
moon build --target all # 同时产出 wasm / wasm-gc / js / nativemoon run cmd/main demo$ moon run examples/quickstart
CL1 非养老类业务一表(男)
30 岁生存人数 l30 986359
30 岁平均余命 e30 47.25
两全保险趸缴纯保费 A 0.614601
年缴均衡纯保费 P 0.038895
第 10 年末准备金 V 0.437487// 取一张经验表,构造(表, 利率)估值对
let china = @moonactuary.ChinaTable::of_code("CL1").unwrap()
let table = china.table()
let v = @moonactuary.Valuation::of(
table=table,
interest=@moonactuary.Interest::of(0.025), // 预定利率 2.5%
)
// 生存函数
println(table.lx(30)) // 986359
println(table.expectation(30)) // 47.25,30 岁男性的平均余命
// 两全保险趸缴纯保费与年缴均衡纯保费
println(v.endowment_insurance(30, 20)) // 0.614601
println(v.annual_premium_endowment(30, 20)) // 0.038895
// 准备金:前瞻法
let premium = v.annual_premium_endowment(30, 20)
println(v.reserve_endowment(30, 20, 10, premium)) // 0.437487,第 10 年末moonactuary <命令> [选项]| 命令 | 作用 |
|---|---|
| tables | 列出六张经验表及其零岁平均余命 |
| table | 打印生命表函数 lx / dx / Lx / Tx / ex |
| premium | 计算趸缴纯保费与年缴均衡纯保费 |
| compare | 按相同产品假设对比六张经验表的保费结果 |
| reserve | 打印逐年准备金表(前瞻 / 后顾 / Fackler 三列) |
| plot | 生成 SVG 曲线,输出到标准输出 |
| demo | 最小演示:一条命令触发全部核心功能路径 |
| verify | 一键验收:跨六张表、三档利率、三类产品交叉校核 |
| 选项 | 含义 | 默认 |
|---|---|---|
| --table | 经验表 CL1–CL6 | CL1 |
| --age | 投保年龄 | 30 |
| --term | 保险期间(年) | 20 |
| --rate | 预定利率百分数,如 2.5 表示 2.5% | 2.5 |
| --product | 险种 whole(终身)/ term(定期)/ endowment(两全) | endowment |
| --from --to | 生命表年龄区间 | 0 105 |
| --kind | 曲线 mortality / survival | mortality |
| --format | compare 输出格式 table / csv | table |
| --help | 打印用法 | — |
$ moon run cmd/main tables
中国人身保险业经验生命表(2010-2013)
代码 业务表 e0 e20 e40 e60
------------------------------------------------------------
CL1 非养老类业务一表(男) 76.42 56.93 37.71 20.03
CL2 非养老类业务一表(女) 81.71 62.05 42.43 23.62
CL3 非养老类业务二表(男) 80.35 60.74 41.38 23.21
CL4 非养老类业务二表(女) 85.44 65.68 45.98 26.94
CL5 养老类业务表(男) 83.13 63.44 43.90 25.34
CL6 养老类业务表(女) 88.13 68.33 48.55 29.30$ moon run cmd/main premium --product whole --age 40 --rate 3.0
CL1 · 终身寿险 · 投保年龄 40 · 期间 20 年 · 利率 3.00%
----------------------------------------------------
趸缴纯保费 0.343820
年缴均衡纯保费 0.015261moon run cmd/main compare --product term --age 40 --term 10 --rate 3.5
moon run cmd/main compare --format csv > premiums.csv$ moon run cmd/main table --from 30 --to 32
CL1 非养老类业务一表(男) · 生命表函数(基数 1,000,000)
------------------------------------------------------------------------------------
年龄 qx lx dx Lx Tx ex
------------------------------------------------------------------------------------
30 0.000797 986359 786 985966 46602129 47.25
31 0.000847 985573 835 985156 45616162 46.28
32 0.000903 984738 889 984294 44631007 45.32$ moon run cmd/main reserve --term 5
CL1 · 两全保险 · 投保年龄 30 · 期间 5 年 · 年缴保费 0.185955
------------------------------------------------------------------
年度 年龄 前瞻准备金 后顾准备金 Fackler 偏差
------------------------------------------------------------------
0 30 0.000000 0.000000 0.000000 0.00
1 31 0.189958 0.189958 0.189958 0.00
2 32 0.384790 0.384790 0.384790 0.00
3 33 0.584638 0.584638 0.584638 0.00
4 34 0.789655 0.789655 0.789655 0.00
5 35 1.000000 1.000000 1.000000 0.00$ moon run cmd/main plot --kind mortality > qx.svg # 对数刻度死亡率曲线
$ moon run cmd/main plot --kind survival > lx.svg # 生存人数曲线$ moon run cmd/main demo
moonactuary demo — CL(2010-2013) 寿险精算最小演示
中国人身保险业经验生命表(2010-2013)
代码 业务表 e0 e20 e40 e60
------------------------------------------------------------
CL1 非养老类业务一表(男) 76.42 56.93 37.71 20.03
CL2 非养老类业务一表(女) 81.71 62.05 42.43 23.62
CL3 非养老类业务二表(男) 80.35 60.74 41.38 23.21
CL4 非养老类业务二表(女) 85.44 65.68 45.98 26.94
CL5 养老类业务表(男) 83.13 63.44 43.90 25.34
CL6 养老类业务表(女) 88.13 68.33 48.55 29.30
【教科书基准校核】CL1 生存函数
参照:l0/d0/L0/T0/e0 = 1000000 / 867 / 999567 / 76420142 / 76.42
年龄 qx lx dx Lx Tx ex
0 0.000867 1000000 867 999567 76420142 76.42
1 0.000615 999133 614 998826 75420575 75.49
2 0.000445 998519 444 998296 74421750 74.53
3 0.000339 998074 338 997905 73423453 73.57
4 0.000280 997736 279 997596 72425548 72.59
5 0.000251 997456 250 997331 71427952 71.61
101 0.476447 1658 790 1263 2409 1.45
105 1.000000 85 85 43 43 0.50
【第一原则恒等式】1 = A_x + d · ä_x
6 张表 × 3 利率 × 7 年龄,残差上限 0.00
【示例保单】CL1 · 两全保险 · 投保年龄 30 · 期间 20 年 · 预定利率 2.50%
趸缴纯保费 0.614601
年缴均衡纯保费 0.038895
【准备金三条路径】前瞻法 / 后顾法 / Fackler 递推
年度 年龄 前瞻法 后顾法 Fackler 偏差
------------------------------------------------------------------
0 30 0.000000 0.000000 0.000000 0.00
1 31 0.039102 0.039102 0.039102 0.00
...
19 49 0.936714 0.936714 0.936714 0.00
20 50 1.000000 1.000000 1.000000 0.00
三条独立路径最大偏差 0.00,第 20 年末准备金为 1.000000(等于满期给付额)moonactuary acceptance verification
生命表:6 张 CL(2010-2013) 经验表
利率:2.5% / 3.0% / 3.5%
产品:终身寿险 / 定期寿险 / 两全保险
恒等式校核:126 项,最大残差 0.000000000000
准备金校核:1134 项,最大偏差 0.000000000000
PASS:全部核心精算路径交叉校核通过.
├── cltables.mbt 六张经验表的 qx 数据与业务分类
├── lifetable.mbt 生存函数递推、分数年龄假设、概率函数
├── interest.mbt 利息理论:名义/贴现/力、各类年金
├── valuation.mbt 换算列 D C M N R S 与生命年金
├── insurance.mbt 趸缴/年缴纯保费、准备金、变额保险
├── tables.mbt ChinaTable 枚举与元数据
├── fmt.mbt 定点小数与对齐排版
├── svg.mbt 零依赖 SVG 渲染器(支持对数轴)
├── *_test.mbt 黑盒与白盒测试
├── examples/
│ └── quickstart/ 最小可运行样例
├── cli/ 命令行前端:参数解析与六个子命令
│ ├── args.mbt
│ ├── commands.mbt
│ └── run.mbt
└── cmd/main/ 可执行文件入口(把 argv 交给 cli,仅此而已)moon test # 62 项测试
moon coverage analyze # 覆盖率报告bash scripts/acceptance.shpowershell -ExecutionPolicy Bypass -File scripts/acceptance.ps1| 阶段 | 命令 |
|---|---|
| 检查 | moon check --target all |
| 构建 | moon build --target all(wasm / wasm-gc / js / native) |
| 测试 | moon test --target all |
| 格式 | moon fmt --check |
| 接口 | moon info 后确认 .mbti 无漂移 |
| 冒烟 | 运行 demo / tables / premium / reserve 并核对关键数字 |
pub enum ChinaTable {
NonPensionIMale
NonPensionIFemale
NonPensionIIMale
NonPensionIIFemale
PensionMale
PensionFemale
}pub enum FractionalAge {
UniformDeaths
ConstantForce
Hyperbolic
}pub struct Interest {
rate : Double
}fn LifeTable::from_qx(qx~ : Array[Double], id? : String, label? : String, radix? : Double, fraction? : FractionalAge) -> LifeTablepub struct Point {
x : Double
y : Double
}fn fixed(value : Double, places : Int) -> Stringfn pad_left(value : String, width : Int) -> Stringfn pad_right(value : String, width : Int) -> Stringfn percent(value : Double, places : Int) -> Stringfn rule(width : Int, pattern : Char) -> StringInstall
Download zipActuarial library for the China Life Insurance Mortality Table (CL 2010-2013): survivorship, commutation columns, net single and annual premiums, and reserves by three independent methods, with a command line tool and a dependency-free SVG chart renderer.