Files
playbook/docs/tsl/codegen/dotnet/bond/intermediate.md
T
csh b6160676b4 ♻️ refactor(tsl): rebuild codegen taxonomy
Move generated builtin and dotnet function docs into the upgraded taxonomy, remove legacy route pages, and regenerate function_index.tsv from markdown headings.
2026-07-07 16:36:08 +08:00

386 lines
9.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 债券 / 中间函数
### `bondDaysBetweenPreviousCouponandNextCoupon(settlement_date)`
上一个付息日与下一个付息日之间的天数
| 参数 | 类型 | 说明 |
| ----------------- | -------- | ------ |
| `settlement_date` | datetime | 结算日 |
返回:int
### `bondDaysBetweenPreviousCouponandSettlement(settlement_date)`
计息天数,上一个付息日与结算日之间的天数。
| 参数 | 类型 | 说明 |
| ----------------- | -------- | ------ |
| `settlement_date` | datetime | 结算日 |
返回:int
### `bondEndDateNewestPayment(settlement_date)`
当前计息年度的截止日
| 参数 | 类型 | 说明 |
| ----------------- | -------- | ------ |
| `settlement_date` | datetime | 结算日 |
返回:datetime
### `bondNumbersBetween(beg_t, end_t, frequency)`
结算日至到期日的债券付息次数(中间函数)
| 参数 | 类型 | 说明 |
| ----------- | -------- | -------------- |
| `beg_t` | datetime | 日期,开始日期 |
| `end_t` | datetime | 日期,截止日期 |
| `frequency` | int | 整数,频率 |
返回:int
### `bondNumbersBetweenSettlementandFutureDay(end_t, future_t)`
评估日与未来评估日之间的付息次数
| 参数 | 类型 | 说明 |
| ---------- | -------- | ---------- |
| `end_t` | datetime | 评估日 |
| `future_t` | datetime | 未来评估日 |
返回:int
### `bondPreviousCouponDateCalculator(settlement_date, dated_date, maturity_date)`
上一付息日(中间函数)
| 参数 | 类型 | 说明 |
| ----------------- | -------- | ------ |
| `settlement_date` | datetime | 结算日 |
| `dated_date` | datetime | 起息日 |
| `maturity_date` | datetime | 到期日 |
返回:datetime
### `bondYearsBetween(beg_t, end_t)`
两个日期之间的整年数
| 参数 | 类型 | 说明 |
| ------- | -------- | -------------- |
| `beg_t` | datetime | 日期,开始日期 |
| `end_t` | datetime | 日期,截止日期 |
返回:int
### `bondYearsBetweenDatedandSettlement(settlement_date)`
到期一次还本付息债券起息日至结算日的整年数
| 参数 | 类型 | 说明 |
| ----------------- | -------- | ------ |
| `settlement_date` | datetime | 结算日 |
返回:int
### `tEncodeDate(y, m, d)`
年月日组合成日期
| 参数 | 类型 | 说明 |
| ---- | ---- | -------- |
| `y` | int | 整数,年 |
| `m` | int | 整数,月 |
| `d` | int | 整数,日 |
返回:TDataTime
### `tEncodeDate2(day, d)`
日期与日重组
| 参数 | 类型 | 说明 |
| ----- | --------- | -------------- |
| `day` | TDataTime | 日期类型,日期 |
| `d` | int | 整数,日 |
返回:TDataTime
### `bondRemainPayNumber(goal_date, end_t, f)`
债券剩余的付息次数,与系统股票相关
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `goal_date` | TDataTime | 日期类型,到期日 |
| `end_t` | TDataTime | 日期类型,交易日 |
| `f` | Int | 整数类型,付息频率 |
返回:Integer
#### 示例
```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
```
### `bondCoupDayBs(goal_date, end_t, f)`
当前付息期内截止到交易日的天数,与系统股票相关
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `goal_date` | TDataTime | 日期类型,到期日 |
| `end_t` | TDataTime | 日期类型,交易日 |
| `f` | Int | 整数类型,付息频率 |
返回:Integer
#### 示例
```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
```
### `bondDuration(bond_type, y, t, c, f)`
债券的久期,与系统股票相关
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `bond_type` | Int | 用户自定义,债券类型,其取值如下: |
| `y` | Real | 实数,到期收益率/年 |
| `t` | Real | 实数,到期支付期 |
| `c` | Real | 实数,息票率/年 |
| `f` | Int | 整数,付息频率 |
返回:Real
#### 示例
```tsl
return bondDuration(0,0.0799999982118607,40,0.100000001490116,2);
//结果:19.74
```
### `bondProvider()`
债券数据来源系统参数
返回:Real
### `bondDaysBetweenDatedandMaturityDate()`
零息债券起息日到到期日的实际天数
返回:Integer
### `bondDaysBetweenDatedandSettlement(settlement_date)`
零息债券起息日到结算日的实际天数
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:Integer
### `bondDaysBetweenSettlementandMaturity(settlement_date)`
结算日至到期日的剩余天数
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:Integer
### `bondDaysBetweenSettlementandNextCoupon(settlement_date)`
结算日至下一个付息日的计息天数
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:Integer
### `bondNextCouponDate(settlement_date)`
结算日对应的下一个付息日
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:TDateTime
### `bondNumbersBetweenSettlementandMaturity(settlement_date)`
剩余付息次数,结算日至到期日剩余付息次数。
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:Real
### `bondPreviousCouponDate(settlement_date)`
结算日对应的上一个付息日
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:TDateTime
### `bondYearsBetweenDatedandMaturity()`
起息日到到期日的整年数
返回:Integer
### `bondYearsBetweenSettlementandMaturity(settlement_date)`
结算日至到期日剩余整年数
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:Integer
### `bondRemainDuration(settlement_date)`
结算日至到期日的剩余期限(单位:年)
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:Real
### `bondBeginDateNewestPayment(settlement_date)`
当前计息年度的起始日,根据债券的起息日和结算日计算
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `settlement_date` | TDateTime | 结算日 |
返回:TDateTime
### `bondPayMentByEndt(bondarr, endt)`
债券数组在指定日是否有付息以及相应的数据
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `bondarr` | Array | 一维数组,债券数组 |
| `endt` | TDateTime | 日期型时间,截止日 |
返回:TableArray
#### 示例
```tsl
bondarr:=array('SH196237','SZ101516','SH175901');
endt:=intToDate(20230116);
return bondPayMentByEndt(bondarr,endt);
//结果
```
### `getBondMaturityTradeData(endt, tpgp)`
债券到期兑付本金转化为交易数据
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `endt` | TDateTime | 日期型时间,截止日 |
| `tpgp` | TableArray | 数据表类型,昨持仓 |
返回:TableArray
#### 示例
```tsl
end_t:=intToDate(20170613);
tpgp:=array(
("截止日":42734.0,"代码":"BK078020","方向":1.0,"乘数":1.0,"保证金比例(%)":100.0,"保证金比例II(%)":nil,"数量":1330.0,"收盘":103.68,"市值":137899.32,"保证金占用":137899.32,"占净值比例(%)":0.14,"总成本":134984.59,"成本价":101.49,"浮动盈亏":2914.73,"浮盈率(%)":2.16,"证券类别":18.0,"行业名称":0.0),
("截止日":42734.0,"代码":"BK030014","方向":1.0,"乘数":1.0,"保证金比例(%)":100.0,"保证金比例II(%)":nil,"数量":25131.0,"收盘":76.76,"市值":1929151.06,"保证金占用":1929151.06,"占净值比例(%)":1.9,"总成本":1895204.27,"成本价":75.41,"浮动盈亏":33946.78,"浮盈率(%)":1.79,"证券类别":18.0,"行业名称":0.0)
);
return getBondMaturityTradeData(end_t,tpgp);
//结果
```
### `bondDataCheck(end_t)`
债券是否上市,与系统参数(债券代码)相关。
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `end_t` | TDateTime | 截止日期。 |
返回:Integer
#### 示例
```tsl
setSysParam(PN_Stock(),"SH127352");
return bondDataCheck(20180101T);
//结果:1
```
### `bondInterest(face_value, legal_coupon_rate, goal_date, end_t, f)`
债券应计利息。
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `face_value` | Real | 实数。面值。 |
| `legal_coupon_rate` | Real | 实数。票面利率。 |
| `goal_date` | TDateTime | 日期。到期日。 |
| `end_t` | TDateTime | 日期。截止日期。 |
| `f` | Integer | 整数。付息频率。 |
返回:Real
#### 示例
```tsl
return bondInterest(100,0.08,20101101T,20101010T,1);
//结果:7.5178
```
### `bondNegotiableShares(bond_id)`
债券流通股。
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `bond_id` | String | 字符串。债券代码。 |
返回:Real
#### 示例
```tsl
return bondNegotiableShares("SH120102");
```