# 应用专题 / 基金研究 / 基金定投 ## `ts_AIPBackTesting` 声明:class 在通用回测框架上封装定期定额、均线、价值平均和估值策略的基金定投流程 父类:`tsBackTesting` ### `FAIPFund` 声明:field 定投基金代码 可见性:`public` 类型:string ### `FAIPType` 声明:field 定投方法;0 为定期定额,1 为均线策略,2 为价值平均,3 为估值策略 可见性:`public` 类型:integer ### `FOriginalAmount` 声明:field 每期投入金额、基础金额或初始金额,单位为元 可见性:`public` 类型:real ### `FPurchaseRatio` 声明:field 申购费率,单位为百分比 可见性:`public` 类型:real ### `FDeductDay` 声明:field 自然周期内的扣款日;默认 -1 表示周期最后一个交易日 可见性:`public` 类型:integer ### `FStrategyType` 声明:field 均线策略或估值策略的执行方式 可见性:`public` 类型:integer ### `FLparamP` 声明:field 价格或估值高于基准时使用的正杠杆倍数 可见性:`public` 类型:real ### `FLParamN` 声明:field 价格或估值不高于基准时使用的负杠杆倍数 可见性:`public` 类型:real ### `FGearArr` 声明:field 均线偏离度或估值偏离与投资份数之间的分级靠档数据 可见性:`public` 类型:array ### `FMADays` 声明:field 均线策略使用的均线天数,默认 250 可见性:`public` 类型:integer ### `FValType` 声明:field 估值指标类型;0 市盈率、1 市净率、2 市销率、3 市现率 可见性:`public` 类型:integer ### `FValBenchmark` 声明:field 估值策略使用的估值基准,默认 15 可见性:`public` 类型:real ### `FIFTranPCT` 声明:field 是否将估值转换为历史百分位,默认 `False` 可见性:`public` 类型:boolean ### `FValOptArr` 声明:field 估值加权、股票样本、报告期和历史百分位计算参数 可见性:`public` 类型:array ### `BackTest()` 声明:function 执行基金定投回测主流程 可见性:`public` ### `GetTimeSeries()` 声明:function 返回定投周期时间序列;可重写以提供自定义扣款日期 可见性:`public` 返回:array ### `GetTradeOrder(v_end_t)` 声明:function 返回指定日期的基金申购赎回明细;使用框架时必须重写 可见性:`public` | 参数 | 类型 | 说明 | | --------- | -------- | ------------ | | `v_end_t` | datetime | 当前回测日期 | 返回:array ### `GetTA(v_end_t)` 声明:function 返回指定日期的申购赎回资金;可重写 可见性:`public` | 参数 | 类型 | 说明 | | --------- | -------- | ------------ | | `v_end_t` | datetime | 当前回测日期 | 返回:array ### `CumReturn(beg_t, end_t, rtype, annual)` 声明:function 计算区间定投收益率 可见性:`public` | 参数 | 类型 | 说明 | | -------- | -------- | -------------------------------------------------------- | | `beg_t` | datetime | 区间开始日 | | `end_t` | datetime | 区间截止日 | | `rtype` | integer | 收益率类型:0 时间加权、1 简单、2 资本加权、3 内部收益率 | | `annual` | boolean | 是否年化,默认不年化 | 返回:real ### `IntervalReturn(begt, endt)` 声明:function 返回区间定投累计收益率走势 可见性:`public` | 参数 | 类型 | 说明 | | ------ | -------- | ---------- | | `begt` | datetime | 区间开始日 | | `endt` | datetime | 区间截止日 | 返回:array