Mirror docs/tsl/codegen into the bundled tsl-api-reference skill and rebuild the function index. Remove invalid duplicate API entries for cb_delistedbydate, createhttpsession, exportJsonString, and Anova_Bartlett so exact lookup returns the canonical entries.
248 lines
9.7 KiB
Markdown
248 lines
9.7 KiB
Markdown
# 衍生品 / 定价
|
||
|
||
## `warrantBenchClose(endt)`
|
||
|
||
标的收盘价,与系统证券pn_stock()有关。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------ | -------- | ------ |
|
||
| `endt` | datetime | 指定日 |
|
||
|
||
返回:float
|
||
|
||
## `warrantBenchId()`
|
||
|
||
标的代码。
|
||
|
||
返回:string
|
||
|
||
## `warrantBenchVolatility(endt)`
|
||
|
||
标的证券年波动率(%),标的证券去年到今年截止日(刚好一年)的指定日波动率(%),周期为日线。与系统证券pn_stock()有关。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------ | -------- | ------ |
|
||
| `endt` | datetime | 指定日 |
|
||
|
||
返回:float
|
||
|
||
## `warrantDurationMonth(end_t)`
|
||
|
||
剩余存续期限(月),即当前日与行权截止日之间相距的月数。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ------------------ |
|
||
| `end_t` | datetime | 日期类型,截止日期 |
|
||
|
||
返回:float
|
||
|
||
## `warrantGearing(end_t)`
|
||
|
||
杠杆倍数,标的证券价格/(权证价格/行权比例),与系统证券pn_stock()有关。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ------------ |
|
||
| `end_t` | datetime | 日期,截止日 |
|
||
|
||
返回:float
|
||
|
||
## `warrantNzjz(end_t)`
|
||
|
||
内在价值,与系统证券pn_stock()有关。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ------------------ |
|
||
| `end_t` | datetime | 日期类型,截止日期 |
|
||
|
||
返回:float
|
||
|
||
## `Warrant_OptionTypeByBS(v1, v2)`
|
||
|
||
B-S理论价值,若v1为认购,则返回0,若v2为认沽,则返回1。与系统证券pn_stock()有关。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ---- | ---- | ---- |
|
||
| `v1` | any | |
|
||
| `v2` | any | |
|
||
|
||
返回:bool
|
||
|
||
## `warrantPriceByBs(end_t)`
|
||
|
||
B-S理论价值,若权证性质为认购,则返回0,若权证性质为认沽,则返回1。与系统证券pn_stock()有关。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ------------ |
|
||
| `end_t` | datetime | 日期,截止日 |
|
||
|
||
返回:bool
|
||
|
||
## `warrantSjjz(end_t)`
|
||
|
||
时间价值,即权证价格 - 内在价值,与系统证券pn_stock()有关。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ------------------ |
|
||
| `end_t` | datetime | 日期类型,截止日期 |
|
||
|
||
返回:float
|
||
|
||
## `warrantYhbdl(end_t, rf)`
|
||
|
||
隐含波动率(%),利用权证性质认沽、标的收盘、权证行权价、无风险收益率(%)、权证现价和剩余存续期限来求出隐含波动率(%)。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ----------------- |
|
||
| `end_t` | datetime | 日期,截止日期 |
|
||
| `rf` | float | 无风险收益率(%) |
|
||
|
||
返回:float
|
||
|
||
## `warrantYjl(end_t)`
|
||
|
||
溢价率(%),
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ------------------ |
|
||
| `end_t` | datetime | 日期类型,截止日期 |
|
||
|
||
返回:float
|
||
|
||
## `warrantDurationDay(end_t)`
|
||
|
||
剩余存续期限(天),即当前日与行权截止日之间相距的天数。
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | -------- | ------------------ |
|
||
| `end_t` | DateTime | 日期类型,截止日期 |
|
||
|
||
返回:Real
|
||
|
||
## `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 | 标的年化股息率(%),实数类型 |
|
||
|
||
返回:Real
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
//依据BS定价模型计算期权的价值
|
||
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)`
|
||
|
||
由期权交易价格依据BS定价模型倒推出的隐含波动率(%),采用二分法优化
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| --------------- | ---------- | -------------------------------------------------------- |
|
||
| `contract_type` | UserDefine | 用户自定义,期权品种类型 |
|
||
| `option_type` | UserDefine | 用户自定义,期权类型 |
|
||
| `s` | Real | 标的现价,实数类型 |
|
||
| `x` | Real | 期权的行权价,实数类型 |
|
||
| `r` | Real | 无风险年利率(%),实数类型 |
|
||
| `close` | Real | 期权交易价格,实数类型 |
|
||
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
|
||
| `rf` | Real | 标的年化股息率(%),实数类型 |
|
||
| `lb` | Real | 二分法求解的下界(%),实数类型 |
|
||
| `ub` | Real | 二分法求解的上界(%),实数类型 |
|
||
|
||
返回:Real
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
//计算股票期权的隐含波动率
|
||
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)`
|
||
|
||
返回期权的隐含波动率
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| --------------- | ------- | -------------------------------------------------------- |
|
||
| `contract_type` | Integer | 用户自定义,期权品种类型 |
|
||
| `option_type` | Integer | 用户自定义,期权类型 |
|
||
| `s` | Real | 标的现价,实数类型 |
|
||
| `x` | Real | 期权的行权价,实数类型 |
|
||
| `r` | Real | 无风险年利率(%),实数类型 |
|
||
| `close` | Real | 期权交易价格,实数类型 |
|
||
| `t` | Real | 剩余存续期(月),到期权到期日前的剩余的有效期限,实数类型 |
|
||
| `rf` | Real | 标的年化股息率(%),实数类型 |
|
||
|
||
返回:Real
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
//依据BS定价模型计算隐含波动率
|
||
return optionImpliedVolatility2(0,0,9,11,2,2,36,0);
|
||
//40.0842468473625
|
||
备注:与二分法求解1的区别在于,此函数优化上下界已固定,上界(%)为1%,下界为500%
|
||
```
|
||
|
||
## `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 | 标的年化股息率(%),实数类型 |
|
||
|
||
返回:Array
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
//依据BS定价模型计算期权风险指标
|
||
return optionBlackScholesRi2(0,0,2.365,2.2,2.75,25,12,0);
|
||
//结果:
|
||
```
|
||
|
||
## `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 | 标的年化股息率(%),实数类型 |
|
||
|
||
返回:Real
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
//依据BS定价模型计算Delta值
|
||
return optionBlackScholesDelta2(0,0,2.365,2.2,2.75,25,12,0);
|
||
//结果:0.699959022086454
|
||
```
|