📝 docs(tsl): complete and lint codegen reference

This commit is contained in:
csh
2026-07-07 16:46:51 +08:00
parent 16e0992dd2
commit bbf6977f57
232 changed files with 39191 additions and 29763 deletions
+76 -76
View File
@@ -1,6 +1,6 @@
# 衍生品 / 定价
### `warrantBenchClose(endt)`
## `warrantBenchClose(endt)`
标的收盘价,与系统证券pn_stock()有关。
@@ -10,13 +10,13 @@
返回:float
### `warrantBenchId()`
## `warrantBenchId()`
标的代码。
返回:string
### `warrantBenchVolatility(endt)`
## `warrantBenchVolatility(endt)`
标的证券年波动率(%),标的证券去年到今年截止日(刚好一年)的指定日波动率(%),周期为日线。与系统证券pn_stock()有关。
@@ -26,7 +26,7 @@
返回:float
### `warrantDurationMonth(end_t)`
## `warrantDurationMonth(end_t)`
剩余存续期限(月),即当前日与行权截止日之间相距的月数。
@@ -36,7 +36,7 @@
返回:float
### `warrantGearing(end_t)`
## `warrantGearing(end_t)`
杠杆倍数,标的证券价格/(权证价格/行权比例),与系统证券pn_stock()有关。
@@ -46,7 +46,7 @@
返回:float
### `warrantNzjz(end_t)`
## `warrantNzjz(end_t)`
内在价值,与系统证券pn_stock()有关。
@@ -56,7 +56,7 @@
返回:float
### `warrantOptionTypeByBs(v1, v2)`
## `Warrant_OptionTypeByBS(v1, v2)`
B-S理论价值,若v1为认购,则返回0,若v2为认沽,则返回1。与系统证券pn_stock()有关。
@@ -67,7 +67,7 @@ B-S理论价值,若v1为认购,则返回0,若v2为认沽,则返回1。
返回:bool
### `warrantPriceByBs(end_t)`
## `warrantPriceByBs(end_t)`
B-S理论价值,若权证性质为认购,则返回0,若权证性质为认沽,则返回1。与系统证券pn_stock()有关。
@@ -77,7 +77,7 @@ B-S理论价值,若权证性质为认购,则返回0,若权证性质为认
返回:bool
### `warrantSjjz(end_t)`
## `warrantSjjz(end_t)`
时间价值,即权证价格 - 内在价值,与系统证券pn_stock()有关。
@@ -87,7 +87,7 @@ B-S理论价值,若权证性质为认购,则返回0,若权证性质为认
返回:float
### `warrantYhbdl(end_t, rf)`
## `warrantYhbdl(end_t, rf)`
隐含波动率(%),利用权证性质认沽、标的收盘、权证行权价、无风险收益率(%)、权证现价和剩余存续期限来求出隐含波动率(%)。
@@ -98,7 +98,7 @@ B-S理论价值,若权证性质为认购,则返回0,若权证性质为认
返回:float
### `warrantYjl(end_t)`
## `warrantYjl(end_t)`
溢价率(%)
@@ -108,34 +108,34 @@ B-S理论价值,若权证性质为认购,则返回0,若权证性质为认
返回:float
### `warrantDurationDay(end_t)`
## `warrantDurationDay(end_t)`
剩余存续期限(天),即当前日与行权截止日之间相距的天数。
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| 参数 | 类型 | 说明 |
| ------- | -------- | ------------------ |
| `end_t` | DateTime | 日期类型,截止日期 |
返回:Real
### `optionBlackScholesPrice2(contract_type, option_type, s, x, r, std, t, rf)`
## `optionBlackScholesPrice2(contract_type, option_type, s, x, r, std, t, rf)`
依据BS定价模型计算期权的价值
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `contract_type` | UserDefine | 用户自定义,期权品种类型 |
| `option_type` | UserDefine | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `std` | Real | 年化波动率(%),实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
| 参数 | 类型 | 说明 |
| --------------- | ---------- | -------------------------------------------------------- |
| `contract_type` | UserDefine | 用户自定义,期权品种类型 |
| `option_type` | UserDefine | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `std` | Real | 年化波动率(%),实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
返回:Real
#### 示例
### 示例
```tsl
//依据BS定价模型计算期权的价值
@@ -143,26 +143,26 @@ return optionBlackScholesPrice2(0,0,9,10,5,20,12,0);
//0.509121755321823
```
### `optionImpliedVolatilitylu2(contract_type, option_type, s, x, r, close, t, rf, lb, ub)`
## `optionImpliedVolatilitylu2(contract_type, option_type, s, x, r, close, t, rf, lb, ub)`
由期权交易价格依据BS定价模型倒推出的隐含波动率(%),采用二分法优化
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `contract_type` | UserDefine | 用户自定义,期权品种类型 |
| `option_type` | UserDefine | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `close` | Real | 期权交易价格,实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
| `lb` | Real | 二分法求解的下界(%),实数类型 |
| `ub` | Real | 二分法求解的上界(%),实数类型 |
| 参数 | 类型 | 说明 |
| --------------- | ---------- | -------------------------------------------------------- |
| `contract_type` | UserDefine | 用户自定义,期权品种类型 |
| `option_type` | UserDefine | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `close` | Real | 期权交易价格,实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
| `lb` | Real | 二分法求解的下界(%),实数类型 |
| `ub` | Real | 二分法求解的上界(%),实数类型 |
返回:Real
#### 示例
### 示例
```tsl
//计算股票期权的隐含波动率
@@ -170,24 +170,24 @@ return optionImpliedVolatilitylu2(0,0,9,11,2,2,36,0,0,100);
//40.0842725685217
```
### `optionImpliedVolatility2(contract_type, option_type, s, x, r, close, t, rf)`
## `optionImpliedVolatility2(contract_type, option_type, s, x, r, close, t, rf)`
返回期权的隐含波动率
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `contract_type` | Integer | 用户自定义,期权品种类型 |
| `option_type` | Integer | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `close` | Real | 期权交易价格,实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
| 参数 | 类型 | 说明 |
| --------------- | ------- | -------------------------------------------------------- |
| `contract_type` | Integer | 用户自定义,期权品种类型 |
| `option_type` | Integer | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `close` | Real | 期权交易价格,实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
返回:Real
#### 示例
### 示例
```tsl
//依据BS定价模型计算隐含波动率
@@ -196,24 +196,24 @@ return optionImpliedVolatility2(0,0,9,11,2,2,36,0);
备注:与二分法求解1的区别在于,此函数优化上下界已固定,上界(%)为1%,下界为500%
```
### `optionBlackScholesRi2(contract_type, option_type, s, x, r, std, t, rf)`
## `optionBlackScholesRi2(contract_type, option_type, s, x, r, std, t, rf)`
返回期权相关的风险指标
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `contract_type` | Integer | 用户自定义,期权品种类型 |
| `option_type` | Integer | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `std` | Real | 年化波动率(%),实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
| 参数 | 类型 | 说明 |
| --------------- | ------- | -------------------------------------------------------- |
| `contract_type` | Integer | 用户自定义,期权品种类型 |
| `option_type` | Integer | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `std` | Real | 年化波动率(%),实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
返回:Array
#### 示例
### 示例
```tsl
//依据BS定价模型计算期权风险指标
@@ -221,24 +221,24 @@ return optionBlackScholesRi2(0,0,2.365,2.2,2.75,25,12,0);
//结果:
```
### `optionBlackScholesDelta2(contract_type, option_type, s, x, r, std, t, rf)`
## `optionBlackScholesDelta2(contract_type, option_type, s, x, r, std, t, rf)`
返回期权相关的风险指标
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `contract_type` | Integer | 用户自定义,期权品种类型 |
| `option_type` | Integer | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `std` | Real | 年化波动率(%),实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
| 参数 | 类型 | 说明 |
| --------------- | ------- | -------------------------------------------------------- |
| `contract_type` | Integer | 用户自定义,期权品种类型 |
| `option_type` | Integer | 用户自定义,期权类型 |
| `s` | Real | 标的现价,实数类型 |
| `x` | Real | 期权的行权价,实数类型 |
| `r` | Real | 无风险年利率(%),实数类型 |
| `std` | Real | 年化波动率(%),实数类型 |
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
| `rf` | Real | 标的年化股息率(%),实数类型 |
返回:Real
#### 示例
### 示例
```tsl
//依据BS定价模型计算Delta值