跳转到主要内容

financial

金融领域聚合函数

pg_financial · 金融领域聚合函数

概览

ID扩展软件包版本类别许可证编程语言
4840financialpg_financial1.0.1FUNCPostgreSQLC
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d-r否是否是是否

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY1.0.119 18 17 16 15pg_financial-
RPMPIGSTY1.0.119 18 17 16 15pg_financial_$v-
DEBPIGSTY1.0.119 18 17 16 15postgresql-$v-pg-financial-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
el8.aarch64N/APIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
el9.x86_64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
el9.aarch64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
el10.x86_64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
el10.aarch64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
d12.x86_64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
d12.aarch64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
d13.x86_64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
d13.aarch64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
u22.x86_64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
u22.aarch64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
u24.x86_64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
u24.aarch64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
u26.x86_64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
u26.aarch64PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1PIGSTY 1.0.1
软件包版本平台仓库大小下载
pg_financial_191.0.1el9.x86_64pigsty21.5 KiBpg_financial_19-1.0.1-1PGSTY.el9.x86_64.rpm
pg_financial_191.0.1el9.aarch64pigsty21.6 KiBpg_financial_19-1.0.1-1PGSTY.el9.aarch64.rpm
pg_financial_191.0.1el10.x86_64pigsty21.8 KiBpg_financial_19-1.0.1-1PGSTY.el10.x86_64.rpm
pg_financial_191.0.1el10.aarch64pigsty21.5 KiBpg_financial_19-1.0.1-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-financial1.0.1d13.x86_64pigsty12.9 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~trixie_amd64.deb
postgresql-19-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~trixie_arm64.deb
postgresql-19-pg-financial1.0.1u22.x86_64pigsty13.6 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~jammy_amd64.deb
postgresql-19-pg-financial1.0.1u22.aarch64pigsty13.7 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~jammy_arm64.deb
postgresql-19-pg-financial1.0.1u24.x86_64pigsty13.4 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~noble_amd64.deb
postgresql-19-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~noble_arm64.deb
postgresql-19-pg-financial1.0.1u26.x86_64pigsty13.9 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~resolute_amd64.deb
postgresql-19-pg-financial1.0.1u26.aarch64pigsty13.5 KiBpostgresql-19-pg-financial_1.0.1-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_financial_181.0.1el8.x86_64pigsty21.5 KiBpg_financial_18-1.0.1-1PGSTY.el8.x86_64.rpm
pg_financial_181.0.1el8.aarch64pigsty21.5 KiBpg_financial_18-1.0.1-1PGSTY.el8.aarch64.rpm
pg_financial_181.0.1el9.x86_64pigsty21.5 KiBpg_financial_18-1.0.1-1PGSTY.el9.x86_64.rpm
pg_financial_181.0.1el9.aarch64pigsty21.6 KiBpg_financial_18-1.0.1-1PGSTY.el9.aarch64.rpm
pg_financial_181.0.1el10.x86_64pigsty21.8 KiBpg_financial_18-1.0.1-1PGSTY.el10.x86_64.rpm
pg_financial_181.0.1el10.aarch64pigsty21.5 KiBpg_financial_18-1.0.1-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-financial1.0.1d13.x86_64pigsty12.9 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~trixie_amd64.deb
postgresql-18-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~trixie_arm64.deb
postgresql-18-pg-financial1.0.1u22.x86_64pigsty13.6 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~jammy_amd64.deb
postgresql-18-pg-financial1.0.1u22.aarch64pigsty13.7 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~jammy_arm64.deb
postgresql-18-pg-financial1.0.1u24.x86_64pigsty13.4 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~noble_amd64.deb
postgresql-18-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~noble_arm64.deb
postgresql-18-pg-financial1.0.1u26.x86_64pigsty13.9 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~resolute_amd64.deb
postgresql-18-pg-financial1.0.1u26.aarch64pigsty13.5 KiBpostgresql-18-pg-financial_1.0.1-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_financial_171.0.1el8.x86_64pigsty21.5 KiBpg_financial_17-1.0.1-1PGSTY.el8.x86_64.rpm
pg_financial_171.0.1el8.aarch64pigsty21.5 KiBpg_financial_17-1.0.1-1PGSTY.el8.aarch64.rpm
pg_financial_171.0.1el9.x86_64pigsty21.5 KiBpg_financial_17-1.0.1-1PGSTY.el9.x86_64.rpm
pg_financial_171.0.1el9.aarch64pigsty21.6 KiBpg_financial_17-1.0.1-1PGSTY.el9.aarch64.rpm
pg_financial_171.0.1el10.x86_64pigsty21.8 KiBpg_financial_17-1.0.1-1PGSTY.el10.x86_64.rpm
pg_financial_171.0.1el10.aarch64pigsty21.5 KiBpg_financial_17-1.0.1-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-financial1.0.1d13.x86_64pigsty12.9 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~trixie_amd64.deb
postgresql-17-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~trixie_arm64.deb
postgresql-17-pg-financial1.0.1u22.x86_64pigsty13.8 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~jammy_amd64.deb
postgresql-17-pg-financial1.0.1u22.aarch64pigsty14.0 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~jammy_arm64.deb
postgresql-17-pg-financial1.0.1u24.x86_64pigsty13.4 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~noble_amd64.deb
postgresql-17-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~noble_arm64.deb
postgresql-17-pg-financial1.0.1u26.x86_64pigsty13.9 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~resolute_amd64.deb
postgresql-17-pg-financial1.0.1u26.aarch64pigsty13.5 KiBpostgresql-17-pg-financial_1.0.1-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_financial_161.0.1el8.x86_64pigsty21.5 KiBpg_financial_16-1.0.1-1PGSTY.el8.x86_64.rpm
pg_financial_161.0.1el8.aarch64pigsty21.5 KiBpg_financial_16-1.0.1-1PGSTY.el8.aarch64.rpm
pg_financial_161.0.1el9.x86_64pigsty21.5 KiBpg_financial_16-1.0.1-1PGSTY.el9.x86_64.rpm
pg_financial_161.0.1el9.aarch64pigsty21.6 KiBpg_financial_16-1.0.1-1PGSTY.el9.aarch64.rpm
pg_financial_161.0.1el10.x86_64pigsty21.8 KiBpg_financial_16-1.0.1-1PGSTY.el10.x86_64.rpm
pg_financial_161.0.1el10.aarch64pigsty21.5 KiBpg_financial_16-1.0.1-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-financial1.0.1d13.x86_64pigsty12.9 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~trixie_amd64.deb
postgresql-16-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~trixie_arm64.deb
postgresql-16-pg-financial1.0.1u22.x86_64pigsty13.8 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~jammy_amd64.deb
postgresql-16-pg-financial1.0.1u22.aarch64pigsty14.0 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~jammy_arm64.deb
postgresql-16-pg-financial1.0.1u24.x86_64pigsty13.4 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~noble_amd64.deb
postgresql-16-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~noble_arm64.deb
postgresql-16-pg-financial1.0.1u26.x86_64pigsty13.9 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~resolute_amd64.deb
postgresql-16-pg-financial1.0.1u26.aarch64pigsty13.5 KiBpostgresql-16-pg-financial_1.0.1-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_financial_151.0.1el8.x86_64pigsty21.5 KiBpg_financial_15-1.0.1-1PGSTY.el8.x86_64.rpm
pg_financial_151.0.1el8.aarch64pigsty21.5 KiBpg_financial_15-1.0.1-1PGSTY.el8.aarch64.rpm
pg_financial_151.0.1el9.x86_64pigsty21.5 KiBpg_financial_15-1.0.1-1PGSTY.el9.x86_64.rpm
pg_financial_151.0.1el9.aarch64pigsty21.6 KiBpg_financial_15-1.0.1-1PGSTY.el9.aarch64.rpm
pg_financial_151.0.1el10.x86_64pigsty21.8 KiBpg_financial_15-1.0.1-1PGSTY.el10.x86_64.rpm
pg_financial_151.0.1el10.aarch64pigsty21.5 KiBpg_financial_15-1.0.1-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-financial1.0.1d12.aarch64pigsty13.0 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-financial1.0.1d13.x86_64pigsty12.9 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~trixie_amd64.deb
postgresql-15-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~trixie_arm64.deb
postgresql-15-pg-financial1.0.1u22.x86_64pigsty13.8 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~jammy_amd64.deb
postgresql-15-pg-financial1.0.1u22.aarch64pigsty14.0 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~jammy_arm64.deb
postgresql-15-pg-financial1.0.1u24.x86_64pigsty13.4 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~noble_amd64.deb
postgresql-15-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~noble_arm64.deb
postgresql-15-pg-financial1.0.1u26.x86_64pigsty13.9 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~resolute_amd64.deb
postgresql-15-pg-financial1.0.1u26.aarch64pigsty13.5 KiBpostgresql-15-pg-financial_1.0.1-1PGSTY~resolute_arm64.deb

源码

pig build pkg pg_financial;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install pg_financial;		# install by package name
pig install financial;		# install by extension name

pig install financial -v 19;   # install for PG 19
pig install financial -v 18;   # install for PG 18
pig install financial -v 17;   # install for PG 17
pig install financial -v 16;   # install for PG 16
pig install financial -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION financial;

用法

financial: PostgreSQL 的金融计算函数

提供 XIRR(不规则内部收益率)聚合函数,类似于电子表格程序中的 XIRR 函数。

CREATE EXTENSION financial;

函数

函数说明
xirr(amount float8, date timestamptz [, guess float8] ORDER BY date)计算不规则内部收益率

示例

-- 基本 XIRR 计算
SELECT xirr(amount, time ORDER BY time) FROM transaction;
-- 0.0176201237088334

-- 使用显式初始猜测值(Excel 兼容的默认值为 0.1)
SELECT xirr(amount, time, 0.1 ORDER BY time) FROM transaction;

-- 按投资组合计算 XIRR
SELECT portfolio, xirr(amount, time ORDER BY time)
FROM transaction
GROUP BY portfolio;

-- 作为窗口函数使用
SELECT xirr(amount, time) OVER (ORDER BY time)
FROM transaction;

当牛顿法无法收敛时返回 NULL。提供更好的猜测值在某些情况下可能有所帮助。

表格阅读器