Skip to main content

IBOR估值核对工具

Project description

xaudit 用法

命令

xaudit CONFIG_PATH

读取单个 .sql.txt 配置文件,生成 HTML 报告。默认输出到当前目录,文件名为 <配置文件名>.html

xaudit CONFIG_PATH --output report.html
xaudit CONFIG_PATH -o report.html

读取单个配置文件,并把报告写入指定路径。--output 只能和单个配置文件一起使用,不能用于目录扫描。

xaudit DIRECTORY

按文件名顺序扫描目录第一层的 .sql.txt 配置文件,并在该目录下分别生成 <配置文件名>.html

xaudit

扫描当前目录第一层的 .sql.txt 配置文件。

xaudit --version

查看版本号。

配置文件格式

配置文件使用 .sql.txt 后缀。每个配置块之间用 ---- 分隔。

  • 必须定义两个 -- connection: 块;第一个连接用于每个对比的第一段 SQL,第二个连接用于第二段 SQL。
  • -- url: 必须是完整的字面量数据库 URL,不能写环境变量。
  • 每个 -- compare: 块必须包含两个以分号结束的 SQL 语句。
  • -- tolerance: 可作为全局容差,也可写在单个 -- compare: 块中覆盖全局容差。
  • -- keys: 可作为全局主键列,也可写在单个 -- compare: 块中覆盖全局主键列;多个列用逗号分隔。未配置时默认使用查询结果第一列作为主键列。
  • -- param: 支持固定值列表或查询结果;参数名只能使用大写字母、数字和下划线。
  • SQL 中使用 {{PARAM_NAME}} 引用参数;多个参数会按笛卡尔积展开为多个对比。
  • -- rule: 格式为 <expression> => <result>,结果支持字符串、IGNORENONE

rule 表达式示例

rule 使用 Python 表达式语法,布尔与/或需要写成小写 and / or

-- rule: FA['id'] == IBOR['id'] and abs(FA['amount'] - IBOR['amount']) < 1 => IGNORE
-- rule: FA['status'] == 'CANCELLED' or IBOR['status'] == 'CANCELLED' => "cancelled record"
-- rule: (FA['id'] == IBOR['id']) and (FA['amount'] != IBOR['amount']) => "same id amount diff"

最简范例

保存为 amount_check.sql

-- connection: FA
-- url: postgresql://user:password@localhost:5432/source_db
----
-- connection: IBOR
-- url: postgresql://user:password@localhost:5432/target_db
----
-- compare: amount_check
select id, amount
from source_amount;

select id, amount
from target_amount;

运行:

xaudit amount_check.sql --output amount_check.html

全功能范例

保存为 full_check.sql

-- connection: FA
-- url: postgresql://ibor_user:ibor_user@localhost:5432/ibor-demo
----
-- connection: IBOR
-- url: postgresql://ibor_user:ibor_user@localhost:5432/ibor-demo
----
-- tolerance: 0.01
----
-- keys: trade_date, portfolio_id, secu_code
----
-- param: TRADE_DATE
-- values: 20260604,20260605
----
-- param: PORTFOLIO_ID
-- connection: IBOR
select distinct portfolio_id
from irmp.ibor_bond_position
where trade_date in (20260604, 20260605)
  and secu_code like '%HK'
  and calc_basis = '1'
  and invest_type = '1';
----
-- compare: total_pnl
-- tolerance: 0.001
-- keys: trade_date, portfolio_id, secu_code
-- rule: abs(FA['ytd_total_pnl'] - IBOR['ytd_total_pnl']) < 1 => "rounding difference"
-- rule: FA['trade_date'] == IBOR['trade_date'] => IGNORE
select
  cast(replace(enddate, '-', '') as int) as trade_date,
  concat(t1.stkid, '.', 'HK') as secu_code,
  'XIR_' || book as portfolio_id,
  reportpl as ytd_total_pnl
from ods_faas.bd_ods_faas_glhs_bond_rpt_nxt_his t1
where cast(replace(enddate, '-', '') as int) = {{TRADE_DATE}}
  and 'XIR_' || book = {{PORTFOLIO_ID}};

select
  trade_date,
  portfolio_id,
  secu_code,
  ytd_total_pnl
from irmp.ibor_bond_position
where secu_code like '%HK'
  and trade_date = {{TRADE_DATE}}
  and portfolio_id = {{PORTFOLIO_ID}}
  and calc_basis = '1'
  and invest_type = '1';

运行:

xaudit full_check.sql --output full_check.html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ibor_audit_tool-0.1.10.tar.gz (52.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ibor_audit_tool-0.1.10-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file ibor_audit_tool-0.1.10.tar.gz.

File metadata

  • Download URL: ibor_audit_tool-0.1.10.tar.gz
  • Upload date:
  • Size: 52.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ibor_audit_tool-0.1.10.tar.gz
Algorithm Hash digest
SHA256 726532a44d950146dfbdc894658abd2680a3a2eb345a462d1515348adc4590d7
MD5 97990014627cd489a35369e2e4a80a98
BLAKE2b-256 10eacf5829e5b2daa987194fe5388a8dd292233a1b2763b74f8fcbce454a3f74

See more details on using hashes here.

File details

Details for the file ibor_audit_tool-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: ibor_audit_tool-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ibor_audit_tool-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d9c328f4df8223b9a4c5e66423f81717629d5f1e3deb1dd917fcb3b81825de7b
MD5 61dd03e8bf501d9988a3813c01b00313
BLAKE2b-256 7d2911b50e9418a896c3541f397ce92f8e3260d047c982fca2f902372815f337

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page