# 金融 / 债券 / 中间函数 ## `bdV_dataProvider(dbtype)` 声明:function 返回债券估值-供应商类型 | 参数 | 类型 | 说明 | | -------- | ---- | ----------------------------------- | | `dbtype` | int | 用户自定义,数据供应商,其取值如下: | 返回:string ## `bdV_getFactorValue(dbtype, id, settlement_date, option)` 声明:function 根据ID获取债券指标 | 参数 | 类型 | 说明 | | ----------------- | -------- | ---------------------- | | `dbtype` | int | 用户自定义,数据提供商 | | `id` | int | 用户自定义,债券指标 | | `settlement_date` | datetime | 日期,结算日 | | `option` | int | 用户自定义,选择权 | 返回:array ## `bdV_internalCode(dbtype, id)` 声明:function 返回债券内部代码,与系统股票相关 | 参数 | 类型 | 说明 | | -------- | ------ | ---------------------- | | `dbtype` | int | 用户自定义,数据提供商 | | `id` | string | 字符串,代码 | 返回:string ### 示例 范例01:返回SH124063'的债券内部代码 ```tsl return bdV_InternalCode(0, 'SH124063'); // 输出:SH124063.zz ``` ## `bondCoupDayBS(goal_date, end_t, f)` 声明:function 返回当前付息期内截止到交易日的天数,与系统股票相关 | 参数 | 类型 | 说明 | | ----------- | ----------- | ------------------ | | `goal_date` | t_data_time | 日期类型,到期日 | | `end_t` | t_data_time | 日期类型,交易日 | | `f` | int | 整数类型,付息频率 | 返回:integer ### 示例 范例01:调用函数 ```tsl // 返回'BK000002'在2003年3月18日当前付息期内截止到交易日的天数 setSysParam(PN_Stock(), 'BK000002'); // 设置股票代码 goal_date := intToDate(base(502026)); // 到期日 end_t := 20030318T; // 交易日 f := base(502021); // 付息频率 return bondCoupDayBs(goal_date, end_t, f); // 输出:334 ``` ## `bondCoupDaysNC(goal_date, end_t, f)` 声明:function 返回债券交易日距下一次付息日的实际天数,与系统股票相关 | 参数 | 类型 | 说明 | | ----------- | -------- | ---------------- | | `goal_date` | datetime | 日期类型,到期日 | | `end_t` | datetime | 日期类型,交易日 | | `f` | int | 整数,付息频率 | 返回:int ### 示例 范例01:调用函数 ```tsl SetSysParam(PN_Stock(), 'BK000002'); // 设置股票代码 GoalDate := IntToDate(base(502026)); // 到期日 EndT := 20030318T; // 交易日 f := base(502021); // 付息频率 return BondCoupDaysNC(GoalDate, EndT, f); ``` ## `bondDaysbetween(begt, endt, o_ption)` 声明:function 返回相隔天数 | 参数 | 类型 | 说明 | | --------- | -------- | ----------------------------------- | | `begt` | datetime | 日期。起始日期 | | `endt` | datetime | 日期。截止日期 | | `o_ption` | int | 用户自定义。返回结果类型,取值如下: | 返回:int ## `bondDuration(bond_type, y, t, c, f)` 声明:function 返回债券的久期,与系统股票相关 | 参数 | 类型 | 说明 | | ----------- | ---- | --------------------------------- | | `bond_type` | int | 用户自定义,债券类型,其取值如下: | | `y` | real | 实数,到期收益率/年 | | `t` | real | 实数,到期支付期 | | `c` | real | 实数,息票率/年 | | `f` | int | 整数,付息频率 | 返回:real ### 示例 范例01:调用函数 ```tsl return bondDuration(0, 0.0799999982118607, 40, 0.100000001490116, 2); // 输出:19.74 ``` ## `bondProvider()` 声明:function 返回债券数据来源系统参数 返回:real ## `bondRemainPayNumber(goal_date, end_t, f)` 声明:function 返回债券剩余的付息次数,与系统股票相关 | 参数 | 类型 | 说明 | | ----------- | ----------- | ------------------ | | `goal_date` | t_data_time | 日期类型,到期日 | | `end_t` | t_data_time | 日期类型,交易日 | | `f` | int | 整数类型,付息频率 | 返回:integer ### 示例 范例01:调用函数 ```tsl // 返回'BK000002'在2003年4月18日剩余的付息次数 setSysParam(PN_Stock(), 'BK000002'); // 设置股票代码 goal_date := intToDate(base(502026)); // 到期日 end_t := 20030418T; // 交易日 f := base(502021); // 付息频率 return bondRemainPayNumber(goal_date, end_t, f); // 输出:8 ``` ## `nSharesOfConvertibleBond(info_id, end_t)` 声明:function 返回可转债流通股本,与系统股票相关 | 参数 | 类型 | 说明 | | --------- | -------- | ------------------ | | `info_id` | int | 整数,数据表索引号 | | `end_t` | datetime | 日期,截止日期 | 返回:float ### 示例 范例01:调用函数 ```tsl SetSysParam(PN_Stock(), 'BK000002'); // 设置股票代码 EndT := 20030318T; // 截止日 return NSharesOfConvertibleBond(91, EndT); ``` ## `nSharesOfCorporationBond(info_id, end_t)` 声明:function 返回企业债券流通股本,与系统股票相关 | 参数 | 类型 | 说明 | | --------- | -------- | ------------------ | | `info_id` | int | 整数,数据表索引号 | | `end_t` | datetime | 日期,截止日期 | 返回:float ### 示例 范例01:调用函数 ```tsl SetSysParam(PN_Stock(), 'BK000002'); // 设置股票代码 EndT := 20120318T; // 截止日 return NSharesOfCorporationBond (90, EndT); ``` ## `nSharesOfGovBond(info_id, end_t)` 声明:function 返回国债流通股本,与系统股票相关 | 参数 | 类型 | 说明 | | --------- | -------- | -------- | | `info_id` | int | 无效参数 | | `end_t` | datetime | 无效参数 | 返回:float ### 示例 范例01:调用函数 ```tsl SetSysParam(PN_Stock(), 'BK000000'); // 设置股票代码 return NSharesOfGovBond(0, 0); ``` ## `pn_bonddataprovider()` 声明:function 返回字符串"bdpd",债券提供商系统参数 返回:string ## `pn_bondStandardDate()` 声明:function 返回债券基准公布日串,用于债券取现金流 返回:string ### 示例 范例01:结果:BondStandardDate ```tsl return Pn_BondStandardDate(); // 输出:BondStandardDate ```