financial

financial

pg_financial : Financial aggregate functions

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4840
financial
pg_financial
1.0.1
FUNC
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
topn
quantile
lower_quantile
count_distinct
omnisketch
ddsketch
tdigest
first_last_agg

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.0.1
18
17
16
15
14
pg_financial-
RPM
PIGSTY
1.0.1
18
17
16
15
14
pg_financial_$v-
DEB
PIGSTY
1.0.1
18
17
16
15
14
postgresql-$v-pg-financial-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el8.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el9.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el9.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el10.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el10.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d12.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d12.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d13.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d13.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u22.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u22.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u24.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u24.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PackageVersionOSORGSIZEFile URL
pg_financial_181.0.1el8.x86_64pigsty14.3 KiBpg_financial_18-1.0.1-1PIGSTY.el8.x86_64.rpm
pg_financial_181.0.1el8.aarch64pigsty14.5 KiBpg_financial_18-1.0.1-1PIGSTY.el8.aarch64.rpm
pg_financial_181.0.1el9.x86_64pigsty14.3 KiBpg_financial_18-1.0.1-1PIGSTY.el9.x86_64.rpm
pg_financial_181.0.1el9.aarch64pigsty14.4 KiBpg_financial_18-1.0.1-1PIGSTY.el9.aarch64.rpm
pg_financial_181.0.1el10.x86_64pigsty14.3 KiBpg_financial_18-1.0.1-1PIGSTY.el10.x86_64.rpm
pg_financial_181.0.1el10.aarch64pigsty14.6 KiBpg_financial_18-1.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-financial1.0.1d12.x86_64pigsty12.8 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~bookworm_amd64.deb
postgresql-18-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~bookworm_arm64.deb
postgresql-18-pg-financial1.0.1d13.x86_64pigsty12.8 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~trixie_amd64.deb
postgresql-18-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~trixie_arm64.deb
postgresql-18-pg-financial1.0.1u22.x86_64pigsty13.5 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~jammy_amd64.deb
postgresql-18-pg-financial1.0.1u22.aarch64pigsty13.7 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~jammy_arm64.deb
postgresql-18-pg-financial1.0.1u24.x86_64pigsty13.3 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~noble_amd64.deb
postgresql-18-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-18-pg-financial_1.0.1-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_financial_171.0.1el8.x86_64pigsty14.3 KiBpg_financial_17-1.0.1-1PIGSTY.el8.x86_64.rpm
pg_financial_171.0.1el8.aarch64pigsty14.5 KiBpg_financial_17-1.0.1-1PIGSTY.el8.aarch64.rpm
pg_financial_171.0.1el9.x86_64pigsty14.3 KiBpg_financial_17-1.0.1-1PIGSTY.el9.x86_64.rpm
pg_financial_171.0.1el9.aarch64pigsty14.4 KiBpg_financial_17-1.0.1-1PIGSTY.el9.aarch64.rpm
pg_financial_171.0.1el10.x86_64pigsty14.3 KiBpg_financial_17-1.0.1-1PIGSTY.el10.x86_64.rpm
pg_financial_171.0.1el10.aarch64pigsty14.6 KiBpg_financial_17-1.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-financial1.0.1d12.x86_64pigsty12.8 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~bookworm_amd64.deb
postgresql-17-pg-financial1.0.1d12.aarch64pigsty13.0 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~bookworm_arm64.deb
postgresql-17-pg-financial1.0.1d13.x86_64pigsty12.8 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~trixie_amd64.deb
postgresql-17-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~trixie_arm64.deb
postgresql-17-pg-financial1.0.1u22.x86_64pigsty13.8 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~jammy_amd64.deb
postgresql-17-pg-financial1.0.1u22.aarch64pigsty14.0 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~jammy_arm64.deb
postgresql-17-pg-financial1.0.1u24.x86_64pigsty13.4 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~noble_amd64.deb
postgresql-17-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-17-pg-financial_1.0.1-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_financial_161.0.1el8.x86_64pigsty14.3 KiBpg_financial_16-1.0.1-1PIGSTY.el8.x86_64.rpm
pg_financial_161.0.1el8.aarch64pigsty14.5 KiBpg_financial_16-1.0.1-1PIGSTY.el8.aarch64.rpm
pg_financial_161.0.1el9.x86_64pigsty14.3 KiBpg_financial_16-1.0.1-1PIGSTY.el9.x86_64.rpm
pg_financial_161.0.1el9.aarch64pigsty14.4 KiBpg_financial_16-1.0.1-1PIGSTY.el9.aarch64.rpm
pg_financial_161.0.1el10.x86_64pigsty14.3 KiBpg_financial_16-1.0.1-1PIGSTY.el10.x86_64.rpm
pg_financial_161.0.1el10.aarch64pigsty14.6 KiBpg_financial_16-1.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~bookworm_amd64.deb
postgresql-16-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~bookworm_arm64.deb
postgresql-16-pg-financial1.0.1d13.x86_64pigsty12.9 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~trixie_amd64.deb
postgresql-16-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~trixie_arm64.deb
postgresql-16-pg-financial1.0.1u22.x86_64pigsty13.8 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~jammy_amd64.deb
postgresql-16-pg-financial1.0.1u22.aarch64pigsty14.0 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~jammy_arm64.deb
postgresql-16-pg-financial1.0.1u24.x86_64pigsty13.3 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~noble_amd64.deb
postgresql-16-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-16-pg-financial_1.0.1-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_financial_151.0.1el8.x86_64pigsty14.3 KiBpg_financial_15-1.0.1-1PIGSTY.el8.x86_64.rpm
pg_financial_151.0.1el8.aarch64pigsty14.5 KiBpg_financial_15-1.0.1-1PIGSTY.el8.aarch64.rpm
pg_financial_151.0.1el9.x86_64pigsty14.3 KiBpg_financial_15-1.0.1-1PIGSTY.el9.x86_64.rpm
pg_financial_151.0.1el9.aarch64pigsty14.4 KiBpg_financial_15-1.0.1-1PIGSTY.el9.aarch64.rpm
pg_financial_151.0.1el10.x86_64pigsty14.3 KiBpg_financial_15-1.0.1-1PIGSTY.el10.x86_64.rpm
pg_financial_151.0.1el10.aarch64pigsty14.6 KiBpg_financial_15-1.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~bookworm_amd64.deb
postgresql-15-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~bookworm_arm64.deb
postgresql-15-pg-financial1.0.1d13.x86_64pigsty12.9 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~trixie_amd64.deb
postgresql-15-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~trixie_arm64.deb
postgresql-15-pg-financial1.0.1u22.x86_64pigsty13.8 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~jammy_amd64.deb
postgresql-15-pg-financial1.0.1u22.aarch64pigsty14.0 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~jammy_arm64.deb
postgresql-15-pg-financial1.0.1u24.x86_64pigsty13.4 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~noble_amd64.deb
postgresql-15-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-15-pg-financial_1.0.1-2PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_financial_141.0.1el8.x86_64pigsty14.3 KiBpg_financial_14-1.0.1-1PIGSTY.el8.x86_64.rpm
pg_financial_141.0.1el8.aarch64pigsty14.5 KiBpg_financial_14-1.0.1-1PIGSTY.el8.aarch64.rpm
pg_financial_141.0.1el9.x86_64pigsty14.3 KiBpg_financial_14-1.0.1-1PIGSTY.el9.x86_64.rpm
pg_financial_141.0.1el9.aarch64pigsty14.4 KiBpg_financial_14-1.0.1-1PIGSTY.el9.aarch64.rpm
pg_financial_141.0.1el10.x86_64pigsty14.3 KiBpg_financial_14-1.0.1-1PIGSTY.el10.x86_64.rpm
pg_financial_141.0.1el10.aarch64pigsty14.6 KiBpg_financial_14-1.0.1-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-financial1.0.1d12.x86_64pigsty12.9 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~bookworm_amd64.deb
postgresql-14-pg-financial1.0.1d12.aarch64pigsty12.9 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~bookworm_arm64.deb
postgresql-14-pg-financial1.0.1d13.x86_64pigsty12.8 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~trixie_amd64.deb
postgresql-14-pg-financial1.0.1d13.aarch64pigsty13.0 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~trixie_arm64.deb
postgresql-14-pg-financial1.0.1u22.x86_64pigsty13.8 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~jammy_amd64.deb
postgresql-14-pg-financial1.0.1u22.aarch64pigsty13.9 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~jammy_arm64.deb
postgresql-14-pg-financial1.0.1u24.x86_64pigsty13.3 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~noble_amd64.deb
postgresql-14-pg-financial1.0.1u24.aarch64pigsty13.3 KiBpostgresql-14-pg-financial_1.0.1-2PIGSTY~noble_arm64.deb

Source

pig build pkg pg_financial;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

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

Install this extension with pig:

pig install pg_financial;		# install via package name, for the active PG version
pig install financial;		# install by extension name, for the current active PG version

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
pig install financial -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION financial;

Usage

financial: financial calculation functions for PostgreSQL

Provides the XIRR (Irregular Internal Rate of Return) aggregate function, similar to XIRR in spreadsheet programs.

CREATE EXTENSION financial;

Functions

FunctionDescription
xirr(amount float8, date timestamptz [, guess float8] ORDER BY date)Compute Irregular Internal Rate of Return

Examples

-- Basic XIRR calculation
SELECT xirr(amount, time ORDER BY time) FROM transaction;
-- 0.0176201237088334

-- With explicit initial guess (Excel-compatible default is 0.1)
SELECT xirr(amount, time, 0.1 ORDER BY time) FROM transaction;

-- Per-portfolio XIRR
SELECT portfolio, xirr(amount, time ORDER BY time)
FROM transaction
GROUP BY portfolio;

-- As a window function
SELECT xirr(amount, time) OVER (ORDER BY time)
FROM transaction;

Returns NULL when Newton’s method fails to converge. Providing a better guess may help in some cases.

Last updated on