feat(tsl-api-reference): expand API and module coverage

This commit is contained in:
csh
2026-08-14 17:12:55 +08:00
parent 8f1056130d
commit 3d3036ebe1
571 changed files with 47842 additions and 14458 deletions
@@ -1,5 +1,28 @@
# 金融 / 期权 / 期权基本函数
## `op_bkDateOverview(stock_id, model_type)`
声明:function
返回指定标的证券最近一期的期权数据概览
<!-- tags: 金融 期权 基本函数 数据概览 行情 风险指标 买卖盘 -->
| 参数 | 类型 | 说明 |
| ------------ | ------- | -------------------------------------------- |
| `stock_id` | string | 标的证券代码 |
| `model_type` | integer | 数据类型,0 为行情,1 为风险指标,2 为买卖盘 |
返回:array
### 示例
范例01:查询上证 50ETF 最近一期的期权风险指标概览
```tsl
return op_bkDateOverview("SH510050", 1);
```
## `op_getBidAskData(ret)`
声明:function
@@ -19,13 +42,12 @@
范例01:调用 OP_GetBidAskData
```tsl
ret := array(("代码":"CU2106"),
("代码":"IF2106"),
("代码":"PG2106"), );
return OP_GetBidAskData(ret);
ret := op_getBidAskData(array());
result_count := -1;
if not ifNil(ret) then
result_count := length(ret);
return result_count;
// 输出:0
```
## `op_getDaysMaturity(end_t, ex_endt)`
@@ -51,6 +73,54 @@ return OP_GetBidAskData(ret);
return OP_GetDaysMaturity(20150208T, 20150228T); // 0.6575
```
## `op_getOptionChain(stock_id, end_t)`
声明:function
返回指定日标的证券正在交易的期权合约及其基本信息
<!-- tags: 金融 期权 基本函数 期权链 合约列表 标的证券 指定日 -->
| 参数 | 类型 | 说明 |
| ---------- | -------- | ---------------------------------- |
| `stock_id` | string | 标的证券代码,多个代码使用分号分隔 |
| `end_t` | datetime | 截止日期 |
返回:array
### 示例
范例01:查询上证 50ETF 的期权链
```tsl
return op_getOptionChain("SH510050", 20260813T);
```
## `op_getPutAndCallratio(stock_id, end_t, ex_end_t)`
声明:function
返回指定标的证券在指定日的看跌看涨成交量比率
<!-- tags: 金融 期权 基本函数 看跌看涨比率 Put Call 成交量 -->
| 参数 | 类型 | 说明 |
| ---------- | -------- | ------------------------------------------------------- |
| `stock_id` | string | 期权品种或标的证券代码 |
| `end_t` | datetime | 统计日期 |
| `ex_end_t` | datetime | 可选。默认不限定到期日,大于 0 时仅统计指定到期日的合约 |
返回:real
### 示例
范例01:查询沪铜期权的看跌看涨比率
```tsl
return op_getPutAndCallratio("cu", 20210514T);
// 输出:1.336376
```
## `op_getRiskFreeRate(end_t, rate_type)`
声明:function
@@ -91,3 +161,57 @@ return OP_GetRiskFreeRate(20150208T, 0); // 2.75
```tsl
return OP_GetUnderlyingSecurity();
```
## `op_hv(stock_id, end_t, day_num)`
声明:function
计算指定证券截至指定日的年化历史波动率
<!-- tags: 金融 期权 基本函数 历史波动率 年化波动率 收盘价 -->
| 参数 | 类型 | 说明 |
| ---------- | -------- | -------------------------------------------------- |
| `stock_id` | string | 标的证券代码 |
| `end_t` | datetime | 截止日期 |
| `day_num` | integer | 回溯月份,-1、-2、-3、-6、-12 分别表示最近对应月数 |
返回:real
### 示例
范例01:计算万科 A 最近六个月的年化历史波动率
```tsl
return op_hv("SZ000002", 20210101T, -6);
// 输出:25.790789
```
## `op_ivGreeks(option_type, s, x, close, r, t, option_style, method)`
声明:function
根据期权交易价格计算隐含波动率和 Greeks 风险指标
<!-- tags: 金融 期权 基本函数 隐含波动率 Greeks Delta Gamma Theta Vega Rho -->
| 参数 | 类型 | 说明 |
| -------------- | ------- | -------------------------------------------------- |
| `option_type` | integer | 期权类型,0 为看涨期权,1 为看跌期权 |
| `s` | real | 现货价格 |
| `x` | real | 行权价 |
| `close` | real | 期权交易价格 |
| `r` | real | 无风险收益率百分比 |
| `t` | real | 剩余期限月数 |
| `option_style` | string | 可选。默认行权方式,支持 `欧式``美式` |
| `method` | integer | 可选。默认定价方式,0 为默认,1 为 B_S,2 为二叉树 |
返回:array
### 示例
范例01:使用欧式期权默认定价方式计算隐含波动率和 Greeks
```tsl
return op_ivGreeks(0, 18, 20, 2, 5, 1.0, "欧式", 0);
```