feat(tsl-api-reference): add class and framework API lookup

This commit is contained in:
csh
2026-08-20 13:49:55 +08:00
parent 7233646398
commit 651c1f68d2
637 changed files with 25498 additions and 36673 deletions
@@ -0,0 +1,50 @@
# 应用专题 / 衍生品分析 / 期权专项
## `op_getiVXByDay(op_type, return_type)`
声明:function
求某一时点的的 iVX 或中间变量,与当前标的代码,时间,周期相关
<!-- tags: 时间处理 日期时间 期权 指数 -->
| 参数 | 类型 | 说明 |
| ------------- | ------- | -------------------------------------- |
| `op_type` | any | 控制计算方法、数据口径或返回格式的选项 |
| `return_type` | integer | 控制计算方法、数据口径或返回格式的选项 |
返回:any
## `op_getiVXByDays(stock_id, begt, endt, cycle, op_type, return_type)`
声明:function
根据给定周期 cycle,计算标的 StockID 从 begt 到 endt 一段时间的 iVX,可以选择纳入计算范
<!-- tags: 筛选 时间处理 日期时间 期权 指数 -->
| 参数 | 类型 | 说明 |
| ------------- | -------- | -------------------------------------- |
| `stock_id` | string | 目标证券、指数、基金或对象的代码标识 |
| `begt` | datetime | 计算或查询区间的开始日期 |
| `endt` | datetime | 计算或查询区间的结束日期 |
| `cycle` | string | 计算或行情数据使用的周期 |
| `op_type` | any | 控制计算方法、数据口径或返回格式的选项 |
| `return_type` | integer | 控制计算方法、数据口径或返回格式的选项 |
返回:any
## `op_getUnderlyingIdByType(underlying_type, if_delisted_option)`
声明:function
根据期权标的类型,获取对应的标的代码
<!-- tags: 查询 期权合约 期权 指数 -->
| 参数 | 类型 | 说明 |
| -------------------- | ------- | -------------------------------------- |
| `underlying_type` | any | 控制计算方法、数据口径或返回格式的选项 |
| `if_delisted_option` | boolean | 控制该项处理是否启用 |
返回:any
@@ -0,0 +1,163 @@
# 应用专题 / 衍生品分析 / 期权专项
## `opDeltaHedging`
声明:class
用于 50ETF 期权与标的 ETF 两腿 Delta 对冲策略的回测与结果分析
<!-- tags: 期权 Delta对冲 策略回测 风险分析 -->
父类:`tsBackTesting`
### `FOptionArr`
声明:field
期权交易信息表,包含代码、方向、动作和成交量
可见性:`public`
类型:array
### `FHedgingType`
声明:field
对冲方式:0 不对冲、1 静态对冲、2 固定时间动态对冲、3 Delta 阈值对冲、4 ETF 阈值对冲
可见性:`public`
类型:integer
### `FFeeRate`
声明:field
交易费率百分比,默认值为 0
可见性:`public`
类型:real
### `FDeltaThreshold`
声明:field
Delta 涨幅百分比变化阈值,仅用于对冲方式 3
可见性:`public`
类型:real
### `FETFThreshold`
声明:field
ETF 涨幅百分比变化阈值,仅用于对冲方式 4
可见性:`public`
类型:real
### `GetOptionDelta(v_beg_t, v_end_t)`
声明:function
获取区间内各回测周期的期权 Delta、Delta 涨幅及标的价格变化
<!-- tags: 期权 Delta 标的价格 -->
可见性:`public`
| 参数 | 类型 | 说明 |
| --------- | -------- | ------------ |
| `v_beg_t` | datetime | 查询区间起点 |
| `v_end_t` | datetime | 查询区间终点 |
返回:array
### `GetPortfolioDelta(v_beg_t, v_end_t)`
声明:function
获取区间内每日的期权 Delta、标的 Delta 和组合 Delta
<!-- tags: 组合Delta 期权 对冲 -->
可见性:`public`
| 参数 | 类型 | 说明 |
| --------- | -------- | ------------ |
| `v_beg_t` | datetime | 查询区间起点 |
| `v_end_t` | datetime | 查询区间终点 |
返回:array
### `GetDeltaAndEtfStatistics(v_beg_t, v_end_t)`
声明:function
统计区间内期权 Delta、标的 ETF 和组合 Delta 的分布特征
<!-- tags: Delta统计 ETF 组合风险 -->
可见性:`public`
| 参数 | 类型 | 说明 |
| --------- | -------- | ------------ |
| `v_beg_t` | datetime | 查询区间起点 |
| `v_end_t` | datetime | 查询区间终点 |
返回:array
### `GetPortfolioDeltaStatistics(v_beg_t, v_end_t)`
声明:function
统计组合 Delta 的最小值、分位数、最大值、平均值和标准差
<!-- tags: 组合Delta 统计 风险分析 -->
可见性:`public`
| 参数 | 类型 | 说明 |
| --------- | -------- | ------------ |
| `v_beg_t` | datetime | 查询区间起点 |
| `v_end_t` | datetime | 查询区间终点 |
返回:array
### `GetHedgeData(v_beg_t, v_end_t)`
声明:function
获取区间对冲次数和对冲交易明细
<!-- tags: 对冲交易 交易明细 -->
可见性:`public`
| 参数 | 类型 | 说明 |
| --------- | -------- | ------------ |
| `v_beg_t` | datetime | 查询区间起点 |
| `v_end_t` | datetime | 查询区间终点 |
返回:array
### `GetPortfolioReturnAndRiskByMonth(v_beg_t, v_end_t)`
声明:function
按月返回组合年化收益率、年化标准差和年化夏普比率
<!-- tags: 月度评价 年化收益 夏普比率 -->
可见性:`public`
| 参数 | 类型 | 说明 |
| --------- | -------- | ------------ |
| `v_beg_t` | datetime | 查询区间起点 |
| `v_end_t` | datetime | 查询区间终点 |
返回:array
@@ -0,0 +1,137 @@
# 应用专题 / 衍生品分析 / 期权品种指标与筛选
## `ts_Options_Screening`
声明:class
按期权品种、类型、到期月份和价值状态筛选同一品种的期权合约
<!-- tags: 期权筛选 期权合约 衍生品 -->
### `FEndT`
声明:field
筛选日期,默认 `today()`
可见性:`public`
类型:date
### `FOptionArr`
声明:field
初始期权列表;可直接设置或通过重写 `GetOptionArr` 提供
可见性:`public`
类型:array
### `FOPPZID`
声明:field
期权品种或标的代码;空字符串表示不按品种筛选
可见性:`public`
类型:string
### `FOPType`
声明:field
期权类型;0 为全部,1 为认购,2 为认沽
可见性:`public`
类型:integer
### `FOPMaturityDate`
声明:field
到期月份序号;0 为全部,1 为近月,2 为次近月,依次类推
可见性:`public`
类型:integer
### `FOPValueState`
声明:field
期权价值状态或价值状态区间,定义为行权价与标的资产价格之比
可见性:`public`
类型:real\|array
### `FValueStateMethod`
声明:field
价值状态邻近选择方式;0 为整体最邻近,1 为前后邻近
可见性:`public`
类型:integer
### `GetOptionArr()`
声明:function
返回初始期权列表;可重写以替代 `FOptionArr`
可见性:`public`
返回:array
### `Main()`
声明:function
按照当前字段配置执行期权筛选
可见性:`public`
返回:nil
### `GetScreenedOptionArr()`
声明:function
返回筛选后的期权代码列表
可见性:`public`
返回:array
### `GetOptionData(if_screened)`
声明:function
返回期权类型、到期日和价值状态等详情
可见性:`public`
| 参数 | 类型 | 说明 |
| ------------- | ------- | ------------------------------------------- |
| `if_screened` | boolean | true 返回筛选后数据,false 返回初始期权数据 |
返回:array
## `op_underlying_hv(n)`
声明:function
计算期权标的资产的历史波动率
<!-- tags: 期权 标的资产 历史波动率 -->
| 参数 | 类型 | 说明 |
| ---- | ------- | ------------ |
| `n` | integer | 历史计算天数 |
返回:real
@@ -0,0 +1,67 @@
# 应用专题 / 衍生品分析 / 期权专项
## `b_sOfStock(option_type, s, x, r, std, t)`
声明:function
股票期权定价模型
<!-- tags: 证券 个股 期权合约 期权 风险管理 -->
| 参数 | 类型 | 说明 |
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `option_type` | any | 0:认购期权,1:认沽期权 (2) S:现货价格 (3) X:行权价 (4) R:无风险收益,可以使用 OP_GetRiskFreeRate 函数得到 5 Std:期权波动率 (6) T:剩余期限(月),可以使用 OP_GetDaysMaturity 得到 ⚫ 举例: return B_SOfStock(0,18,20,5,131.7407,1.00) |
| `s` | any | 标的价格或模型输入值 |
| `x` | array | 模型输入特征或自变量数据 |
| `r` | any | 收益率、利率或模型参数 |
| `std` | any | 股票期权定价模型使用的 `std` 输入值 |
| `t` | datetime | 期限、时间或待处理数据 |
返回:any
## `op_delta(method, r, std, rf)`
声明:function
计算 Delta 值,与系统证券,周期,截止日相关
<!-- tags: 期权 风险管理 -->
| 参数 | 类型 | 说明 |
| -------- | ------- | ------------------------------------------------------------------------------------------------------- |
| `method` | integer | 风险指标计算方式,整数,用于指定指标计算使用的定价模型。 取值 含义 备注 期权系列 03:期权行情及风险指标 |
| `r` | any | 收益率、利率或模型参数 |
| `std` | any | 计算 Delta 值,与系统证券,周期,截止日相关使用的 `std` 输入值 |
| `rf` | any | 计算 Delta 值,与系统证券,周期,截止日相关使用的 `rf` 输入值 |
返回:any
## `op_greeks(method)`
声明:function
计算期权隐含波动率及风险指标,底层调用函数为 OP_IVGreeks,与系统证券,周期,截止
<!-- tags: 执行 风险管理 风控 风险波动 期权合约 期权 -->
| 参数 | 类型 | 说明 |
| -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `method` | datetime | 计算方法,缺省值为 0,详见 OP_Delta 中的 Method 说明,其他计算参数都可根据给 定的期权、周期、时间确定,或直接使用缺省值计算,详见 OP_Delta 参数说明 ⚫ 举例: //范例1 SetSysParam(pn_stock(),"OP10000001"); SetSysParam(PN_Cycle(),cy_1m()); SetSysParam(pn_date(),20150210T+0.99); Return OP_Greeks(); //欧式期权默认用BS 计算 // |
返回:any
## `op_iv(rtype, hist_n, o_cendt)`
声明:function
使用期权现价反推隐含波动率(%),与系统证券,周期,截止日相关
<!-- tags: 风险波动 期权合约 期权 风险管理 -->
| 参数 | 类型 | 说明 |
| --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `rtype` | datetime | 返回类型,期权现价超过理论边界处理 (2) HistN:N 日波动率,当 rtype=3 且当日期权现价超过理论边界处理时生效,返回期权 HistN 日波动率(%)(年化),默认值 10。 (3) o_Cendt:返回参数,用于返回类别的提示 |
| `hist_n` | any | 使用期权现价反推隐含波动率(%),与系统证券,周期,截止日相关使用的 `hist_n` 输入值 |
| `o_cendt` | any | 使用期权现价反推隐含波动率(%),与系统证券,周期,截止日相关使用的 `o_cendt` 输入值 |
返回:any
@@ -0,0 +1,63 @@
# 应用专题 / 衍生品分析 / 期货专项
## `bondFuture_rd_invoicePrice(bond_id)`
声明:function
返回指定期货相对于指定债券标的发票价格,与系统证券代码时间周期相关
<!-- tags: 期货合约 价格数据 行情 时间处理 日期时间 期货 -->
| 参数 | 类型 | 说明 |
| --------- | ---- | -------- |
| `bond_id` | any | 债券代码 |
返回:real
## `bondFuture_va_basis(bond_id, market_id, dbtype)`
声明:function
国债期货指定品种代码指定日对应的单个个券标的基差,与证券代码,时间相关
<!-- tags: 期货合约 时间处理 日期时间 期货 -->
| 参数 | 类型 | 说明 |
| ----------- | ---- | ---------------------------------------------------------------------------------------------------------------- |
| `bond_id` | any | 目标证券、指数、基金或对象的代码标识 |
| `market_id` | any | BondID 取 0、1、2 时使用,国债市场板块选项: 0:银行间国债 1:上交所国债 2:深交所国债 |
| `dbtype` | any | BondID 取 0、1、2 时使用,国债估值数据来源: 0:中证估值 1:中债估值 3:中债优先 4:按交易所分 2:天软估值(推荐) |
返回:any
## `bondFuture_va_irr(bond_id, market_id, dbtype)`
声明:function
国债期货指定品种代码指定日对应的单个个券标的 IRR,与证券代码,时间相关
<!-- tags: 期货合约 时间处理 日期时间 期货 -->
| 参数 | 类型 | 说明 |
| ----------- | ---- | -------------------------------------- |
| `bond_id` | any | 目标证券、指数、基金或对象的代码标识 |
| `market_id` | any | 目标证券、指数、基金或对象的代码标识 |
| `dbtype` | any | 控制计算方法、数据口径或返回格式的选项 |
返回:any
## `bondFuture_va_netBasis(bond_id, market_id, dbtype)`
声明:function
国债期货指定品种代码指定日对应的单个个券标的净基差,与证券代码,时间相关
<!-- tags: 期货合约 时间处理 日期时间 期货 -->
| 参数 | 类型 | 说明 |
| ----------- | ---- | -------------------------------------- |
| `bond_id` | any | 目标证券、指数、基金或对象的代码标识 |
| `market_id` | any | 目标证券、指数、基金或对象的代码标识 |
| `dbtype` | any | 控制计算方法、数据口径或返回格式的选项 |
返回:any