def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList(dict(self._BenchmarkFT.getFactorMetaData(key="DataType"))) self.add_trait("BenchmarkPrice", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="基准价格", order=6)) self.BenchmarkPrice = searchNameInStrList(DefaultNumFactorList, ['价','Price','price']) self.BenchmarkID = self._BenchmarkFT.getID(ifactor_name=self.BenchmarkPrice)[0] if self._RateFT is not None: DefaultNumFactorList, DefaultStrFactorList = getFactorList(dict(self._RateFT.getFactorMetaData(key="DataType"))) self.add_trait("RiskFreeRate", Enum(None, *DefaultNumFactorList, arg_type="SingleOption", label="无风险利率", order=8)) return super().__QS_initArgs__()
def _on_FactorTable_changed(self, obj, name, old, new): if self.FactorTable is not None: DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self.FactorTable.getFactorMetaData(key="DataType"))) self.add_trait( "PriceFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="价格因子", order=1)) self.PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price']) self.add_trait( "BenchmarkID", Enum(*self.FactorTable.getID(ifactor_name=self.PriceFactor), arg_type="SingleOption", label="基准ID", order=2)) else: self.add_trait( "PriceFactor", Enum(None, arg_type="SingleOption", label="价格因子", order=1)) self.add_trait( "BenchmarkID", Enum(None, arg_type="SingleOption", label="基准ID", order=2))
def __QS_initArgs__(self): super().__QS_initArgs__() DefaultNumFactorList, DefaultStrFactorList = getFactorList(dict(self._MarketFT.getFactorMetaData(key="DataType"))) self.add_trait("Last", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="最新价", order=6, option_range=DefaultNumFactorList)) self.Last = searchNameInStrList(DefaultNumFactorList, ['新','收','Last','last','close','Close']) self.BuyLimit = _TradeLimit(account=self, direction="Buy") self.SellLimit = _TradeLimit(account=self, direction="Sell")
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList(dict(self._FactorTable.getFactorMetaData(key="DataType"))) self.add_trait("TestFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="测试因子", order=0)) self.add_trait("PriceFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="价格因子", order=2)) self.PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价','Price','price']) self.add_trait("ClassFactor", Enum(*(["无"]+DefaultStrFactorList), arg_type="SingleOption", label="类别因子", order=3)) self.add_trait("WeightFactor", Enum(*(["等权"]+DefaultNumFactorList), arg_type="SingleOption", label="权重因子", order=4))
def __QS_initArgs__(self): self.remove_trait("LongWeightAlloction") self.remove_trait("ShortWeightAlloction") DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FT.getFactorMetaData(key="DataType"))) DefaultNumFactorList.insert(0, None) self.add_trait( "ExpectedReturn", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="预期收益", order=5)) self.add_trait( "BenchmarkFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="基准权重", order=7)) self.add_trait( "AmountFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="成交金额", order=8)) self.SignalAdjustment = _SignalAdjustment() return Strategy.__QS_initArgs__(self)
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FactorTable.getFactorMetaData(key="DataType"))) self.add_trait( "Portfolio", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="策略组合", order=0)) self.add_trait( "BenchmarkPortfolio", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="基准组合", order=1)) self.add_trait( "GroupFactor", Enum(*DefaultStrFactorList, arg_type="SingleOption", label="资产类别", order=2)) self.add_trait( "PriceFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="价格因子", order=3)) self.PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price'])
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FactorTable.getFactorMetaData(key="DataType"))) self.add_trait( "TestFactors", ListStr(arg_type="MultiOption", label="测试因子", order=0, option_range=tuple(DefaultNumFactorList))) self.TestFactors.append(DefaultNumFactorList[0]) self.add_trait( "PriceFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="价格因子", order=2)) self.PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price']) self.add_trait( "IndustryFactor", Enum(*(["无"] + DefaultStrFactorList), arg_type="SingleOption", label="行业因子", order=3)) self.add_trait( "WeightFactor", Enum(*(["等权"] + DefaultNumFactorList), arg_type="SingleOption", label="权重因子", order=4))
def __QS_initArgs__(self): super().__QS_initArgs__() DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._MarketFT.getFactorMetaData(key="DataType"))) DefaultNumFactorList.insert(0, None) self.add_trait( "Last", Enum(*DefaultNumFactorList[1:], arg_type="SingleOption", label="最新价", order=0)) self.add_trait( "TradePrice", Enum(*DefaultNumFactorList[1:], arg_type="SingleOption", label="成交价", order=1)) self.add_trait( "Amt", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="成交额", order=2)) self.TradePrice = self.Last = searchNameInStrList( DefaultNumFactorList[1:], ['新', '收', 'Last', 'last', 'close', 'Close'])
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList(dict(self._FT.getFactorMetaData(key="DataType"))) self.add_trait("ExDate", Enum(*DefaultStrFactorList, arg_type="SingleOption", label="除息日", order=0)) self.add_trait("PayDate", Enum(*DefaultStrFactorList, arg_type="SingleOption", label="付息日", order=1)) self.add_trait("Interest", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="每手付息数", order=2)) self.add_trait("Principal", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="每手兑付本金数", order=3)) self.ExDate = searchNameInStrList(DefaultStrFactorList, ["除"]) self.PayDate = searchNameInStrList(DefaultStrFactorList, ["付"])
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._TargetTable.getFactorMetaData(key="DataType"))) self.add_trait( "TargetNAV", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="目标净值", order=0)) DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._StyleTable.getFactorMetaData(key="DataType"))) self.add_trait( "StyleNAV", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="风格净值", order=2))
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FactorTable.getFactorMetaData(key="DataType"))) self.add_trait( "TestFactors", ListStr(arg_type="MultiOption", label="测试因子", order=0, option_range=tuple(DefaultNumFactorList))) self.TestFactors.append(DefaultNumFactorList[0])
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList(dict(self._FT.getFactorMetaData(key="DataType"))) DefaultNumFactorList.insert(0, None) self.add_trait("Open", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="开盘价", order=0)) self.add_trait("High", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="最高价", order=1)) self.add_trait("Low", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="最低价", order=2)) self.add_trait("Last", Enum(*DefaultNumFactorList[1:], arg_type="SingleOption", label="最新价", order=3)) self.add_trait("Vol", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="成交量", order=4)) self.add_trait("TradePrice", Enum(*DefaultNumFactorList[1:], arg_type="SingleOption", label="成交价", order=5)) self.TradePrice = self.Last = searchNameInStrList(DefaultNumFactorList[1:], ['新','收','Last','last','close','Close'])
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FactorTable.getFactorMetaData(key="DataType"))) self.add_trait( "TestFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="测试因子", order=0)) self.FactorIDs = self._FactorTable.getID() DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._PriceTable.getFactorMetaData(key="DataType"))) self.add_trait( "PriceFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="价格因子", order=3)) self.PriceFactor = searchNameInStrList(DefaultNumFactorList, ["价", "Price", "price"])
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FactorTable.getFactorMetaData(key="DataType"))) self.add_trait( "PriceFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="价格因子", order=0)) self.PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price'])
def __QS_initArgs__(self): self.TurnoverBuffer = _TurnoverBuffer() DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FT.getFactorMetaData(key="DataType"))) self.add_trait( "TargetFactor", Enum(*DefaultNumFactorList, label="目标因子", arg_type="SingleOption", order=2)) self.GroupFactors.option_range = tuple(self._FT.FactorNames)
def __QS_initArgs__(self): if self._FT is not None: DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FT.getFactorMetaData(key="DataType"))) self.add_trait( "WeightFactor", Enum(*(["等权"] + DefaultNumFactorList), arg_type="SingleOption", label="权重因子", order=1)) self.GroupFactors.option_range = tuple(self._FT.FactorNames) self.add_trait( "GroupWeight", Enum(*(["等权"] + DefaultNumFactorList), arg_type="SingleOption", label="类别权重", order=3))
def __QS_initArgs__(self): super().__QS_initArgs__() DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._MarketFT.getFactorMetaData(key="DataType"))) DefaultNumFactorList.insert(0, None) self.add_trait( "Open", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="开盘价", order=3)) self.add_trait( "High", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="最高价", order=4)) self.add_trait( "Low", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="最低价", order=5))
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList( dict(self._FactorTable.getFactorMetaData(key="DataType"))) self.add_trait( "Portfolio", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="策略组合", order=0)) self.add_trait( "BenchmarkPortfolio", Enum(*(["无"] + DefaultNumFactorList), arg_type="SingleOption", label="基准组合", order=1)) self.add_trait( "AttributeFactors", ListStr(arg_type="MultiOption", label="特征因子", order=2, option_range=tuple(DefaultNumFactorList))) self.AttributeFactors.append(DefaultNumFactorList[-1]) self.add_trait( "IndustryFactor", Enum(*(["无"] + DefaultStrFactorList), arg_type="SingleOption", label="行业因子", order=3)) self.add_trait( "PriceFactor", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="价格因子", order=4)) self.PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price'])
def __QS_initArgs__(self): DefaultNumFactorList, DefaultStrFactorList = getFactorList(dict(self._FT.getFactorMetaData(key="DataType"))) self.add_trait("ContractMapping", Enum(*DefaultStrFactorList, arg_type="SingleOption", label="合约映射", order=3)) self.ContractMapping = searchNameInStrList(DefaultStrFactorList, ['映射','map','Map']) self.add_trait("SettlementPrice", Enum(*DefaultNumFactorList, arg_type="SingleOption", label="结算价", order=4)) self.SettlementPrice = searchNameInStrList(DefaultNumFactorList, ['结算','价','settle','Settle','price','Price'])
def __QS_genSysArgs__(self, args=None, **kwargs): SysArgs = super().__QS_genSysArgs__(None, **kwargs) if self.QSEnv.DSs.isEmpty(): return SysArgs DefaultDS = (self.QSEnv.DSs[args["数据源"]] if (args is not None) and (args.get("数据源") in self.QSEnv.DSs) else self.QSEnv.DSs.getDefaultDS()) DefaultNumFactorList, DefaultStrFactorList = getFactorList( DefaultDS.DataType) PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price']) if (args is None) or ("数据源" not in args): nSysArgs = len(SysArgs) SysArgs._QS_MonitorChange = False SysArgs.update({ "最新价": PriceFactor, "交易延迟": 0, "成交价": PriceFactor, "买入限制": self._genLimitArgs(None, DefaultDS.Name, True), "卖出限制": self._genLimitArgs(None, DefaultDS.Name, False), "数据源": DefaultDS.Name }) SysArgs.ArgInfo["最新价"] = { "type": "SingleOption", "order": nSysArgs, "range": DefaultNumFactorList } SysArgs.ArgInfo["交易延迟"] = { "type": "Integer", "order": nSysArgs + 1, "min": 0, "max": np.inf, "single_step": 1 } SysArgs.ArgInfo["成交价"] = { "type": "SingleOption", "order": nSysArgs + 2, "range": DefaultNumFactorList } SysArgs.ArgInfo["买入限制"] = {"type": "ArgSet", "order": nSysArgs + 3} SysArgs.ArgInfo["卖出限制"] = {"type": "ArgSet", "order": nSysArgs + 4} SysArgs.ArgInfo["数据源"] = { "type": "SingleOption", "range": list(self.QSEnv.DSs.keys()), "order": nSysArgs + 5, "refresh": True, "visible": False } SysArgs._QS_MonitorChange = True return SysArgs args._QS_MonitorChange = False args.ArgInfo["数据源"]["range"] = list(self.QSEnv.DSs.keys()) args["数据源"] = DefaultDS.Name if args["成交价"] not in DefaultNumFactorList: args["成交价"] = PriceFactor args.ArgInfo["成交价"]["range"] = DefaultNumFactorList if args["最新价"] not in DefaultNumFactorList: args["最新价"] = PriceFactor args.ArgInfo["最新价"]["range"] = DefaultNumFactorList args["买入限制"] = self._genLimitArgs(args["买入限制"], args["数据源"], nonbuyable=True) args["卖出限制"] = self._genLimitArgs(args["卖出限制"], args["数据源"], nonbuyable=False) args._QS_MonitorChange = True return args
def _genLimitArgs(self, args, ds_name, nonbuyable=True): DefaultDS = self.QSEnv.DSs[ds_name] DefaultNumFactorList, DefaultStrFactorList = getFactorList( DefaultDS.DataType) PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price']) if args is None: Args = { "禁止条件": _getDefaultNontradableIDFilter(DefaultDS, nonbuyable, self.QSEnv), "交易费率": 0.003, "成交额": "不限制", "最小单位": 0, "单位价格": PriceFactor } ArgInfo = { "禁止条件": { "type": "IDFilter", "order": 0, "factor_list": DefaultDS.FactorNames }, "交易费率": { "type": "Double", "order": 1, "min": 0, "max": 1, "single_step": 0.0001, "decimals": 4 }, "成交额": { "type": "SingleOption", "order": 2, "refresh": True, "range": ["不限制"] + DefaultNumFactorList }, "最小单位": { "type": "Integer", "order": 3, "min": 0, "max": np.inf, "single_step": 1 }, "单位价格": { "type": "SingleOption", "order": 4, "range": DefaultNumFactorList } } return QSArgs(Args, ArgInfo, self._onLimitSysArgChanged) args._QS_MonitorChange = False if not set(args.ArgInfo["禁止条件"]["factor_list"]).issubset( set(DefaultDS.FactorNames)): args["禁止条件"] = _getDefaultNontradableIDFilter( DefaultDS, nonbuyable, self.QSEnv) args.ArgInfo["禁止条件"]["factor_list"] = DefaultDS.FactorNames if args["成交额"] not in DefaultNumFactorList: args["成交额"] = "不限制" args.ArgInfo.pop("成交额限比", None) args.ArgInfo["成交额"]["range"] = ["不限制"] + DefaultNumFactorList if args["单位价格"] not in DefaultNumFactorList: args["单位价格"] = PriceFactor args.ArgInfo["单位价格"]["range"] = DefaultNumFactorList args._QS_MonitorChange = True return args
def __QS_genSysArgs__(self, args=None, **kwargs): if self.QSEnv.DSs.isEmpty(): return super().__QS_genSysArgs__(args=args, **kwargs) DefaultDS = (self.QSEnv.DSs[args["数据源"]] if (args is not None) and (args.get("数据源") in self.QSEnv.DSs) else self.QSEnv.DSs.getDefaultDS()) DefaultNumFactorList, DefaultStrFactorList = getFactorList( DefaultDS.DataType) PriceFactor = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price']) if (args is None) or ("数据源" not in args): SysArgs = { "测试因子": DefaultNumFactorList[0], "排序方向": "降序", "分组数": 10, "价格因子": PriceFactor, "行业因子": "无", "权重因子": "等权", "划分方式": "定比", "分类节点": [0.5], "调仓时点": DefaultDS.getDateTime(), "市场组合": None, "筛选条件": None, "随机微扰": False, "缺失处理": "丢弃", "数据源": DefaultDS.Name } ArgInfo = {} ArgInfo["测试因子"] = { "type": "SingleOption", "order": 0, "range": DefaultNumFactorList } ArgInfo["排序方向"] = { "type": "SingleOption", "order": 1, "range": ["降序", "升序"] } ArgInfo["分组数"] = { "type": "Integer", "min": 1, "max": np.inf, "order": 2, "refresh": True } ArgInfo["价格因子"] = { "type": "SingleOption", "range": DefaultNumFactorList, "order": 3 } ArgInfo["行业因子"] = { "type": "SingleOption", "range": ["无"] + DefaultDS.FactorNames, "order": 4 } ArgInfo["权重因子"] = { "type": "SingleOption", "range": ["等权"] + DefaultNumFactorList, "order": 5 } ArgInfo["划分方式"] = { "type": "SingleOption", "range": ["定比", "定量", "定界"], "refresh": True, "order": 6 } if SysArgs["划分方式"] == "定比": ArgInfo["分类节点"] = { "type": "ArgList", "subarg_info": { "type": "Double", "min": 0, "max": 1, "single_step": 0.01 }, "order": 7 } elif SysArgs["划分方式"] == "定量": ArgInfo["分类节点"] = { "type": "ArgList", "subarg_info": { "type": "Integer", "min": 0, "max": np.inf, "single_step": 1 }, "order": 7 } elif SysArgs["划分方式"] == "定界": ArgInfo["分类节点"] = { "type": "ArgList", "subarg_info": { "type": "Double", "min": -np.inf, "max": np.inf, "single_step": 0.01 }, "order": 7 } ArgInfo["调仓时点"] = {"type": "DateList", "order": 6} ArgInfo["市场组合"] = { "type": "IDFilter", "factor_list": DefaultDS.FactorNames, "order": 8 } ArgInfo["筛选条件"] = { "type": "IDFilter", "factor_list": DefaultDS.FactorNames, "order": 9 } ArgInfo["随机微扰"] = {"type": "Bool", "order": 10, "visible": False} ArgInfo["缺失处理"] = { "type": "SingleOption", "range": ["丢弃", "排在最前", "排在最后"], "order": 11, "visible": False } ArgInfo["数据源"] = { "type": "SingleOption", "range": list(self.QSEnv.DSs.keys()), "order": 12, "refresh": True, "visible": False } return QSArgs(SysArgs, ArgInfo, self.__QS_onSysArgChanged__) args._QS_MonitorChange = False args["数据源"] = DefaultDS.Name args.ArgInfo["数据源"]["range"] = list(self.QSEnv.DSs.keys()) if args["行业因子"] not in DefaultDS.FactorNames: args["行业因子"] = "无" args.ArgInfo["行业因子"]["range"] = ["无"] + DefaultDS.FactorNames if args["价格因子"] not in DefaultNumFactorList: args["价格因子"] = PriceFactor args.ArgInfo["价格因子"]["range"] = DefaultNumFactorList if args["测试因子"] not in DefaultNumFactorList: args["测试因子"] = DefaultNumFactorList[0] args.ArgInfo["测试因子"]["range"] = DefaultNumFactorList if not set(args["调仓时点"]).issubset(set(DefaultDS.getDateTime())): args["调仓时点"] = DefaultDS.getDateTime() if not set(args.ArgInfo["筛选条件"]["factor_list"]).issubset( set(DefaultDS.FactorNames)): args["筛选条件"] = None args.ArgInfo["筛选条件"]["factor_list"] = DefaultDS.FactorNames if not set(args.ArgInfo["市场组合"]["factor_list"]).issubset( set(DefaultDS.FactorNames)): args["市场组合"] = None args.ArgInfo["市场组合"]["factor_list"] = DefaultDS.FactorNames args._QS_MonitorChange = True return args
def __QS_genSysArgs__(self, args=None, **kwargs): AllDSNames = list(self.DSs.keys()) ArgInfo = {} if args is None: DefaultNumFactorList, DefaultStrFactorList = getFactorList( self.DSs[AllDSNames[0]].DataType) args = {"数据源": AllDSNames[0]} args["测试因子"] = DefaultNumFactorList[0] args["中性因子"] = list( set(self.DSs[AllDSNames[0]].FactorNames).difference({ "复权收盘价", "交易状态", "是否在市", "涨跌停", "特殊处理", "月收益率", "日收益率", "周收益率" })) args["变量类型"] = [] for iFactor in args["中性因子"]: if self.DSs[args["数据源"]].DataType[iFactor] == "string": args["变量类型"].append("Dummy") else: args["变量类型"].append("Regular") args["排序方向"] = "降序" args["风险数据源"] = None args["收益率因子"] = searchNameInStrList(DefaultNumFactorList, ["Ret", "ret", "收益"]) args["月度平均"] = False args["基准权重"] = "等权" args["优化器"] = "MATLAB" elif ( (args["基准权重"] != "等权") and (not set([args["测试因子"], args["收益率因子"], args["基准权重"]] + args["中性因子"] ).issubset(set(self.DSs[args["数据源"]].FactorNames))) ) or ((args["基准权重"] == "等权") and (not set([args["测试因子"], args["收益率因子"]] + args["中性因子"]).issubset( set(self.DSs[args["数据源"]].FactorNames)))): # 数据源发生了变化 DefaultNumFactorList, DefaultStrFactorList = getFactorList( self.DSs[args["数据源"]].DataType) args["测试因子"] = DefaultNumFactorList[0] args["中性因子"] = list( set(self.DSs[AllDSNames[0]].FactorNames).difference({ "复权收盘价", "交易状态", "是否在市", "涨跌停", "特殊处理", "月收益率", "日收益率", "周收益率" })) args["收益率因子"] = searchNameInStrList(DefaultNumFactorList, ["Ret", "ret", "收益"]) for iFactor in args["中性因子"]: if self.DSs[args["数据源"]].DataType[iFactor] == "string": args["变量类型"].append("Dummy") else: args["变量类型"].append("Regular") args["基准权重"] = "等权" else: DefaultNumFactorList, DefaultStrFactorList = getFactorList( self.DSs[args["数据源"]].DataType) ArgInfo["测试因子"] = { "数据类型": "Str", "取值范围": DefaultNumFactorList, "是否刷新": False, "order": 0, "是否可见": True } ArgInfo["排序方向"] = { "数据类型": "Str", "取值范围": ["升序", "降序"], "是否刷新": False, "order": 1, "是否可见": True } ArgInfo["中性因子"] = { "数据类型": "ArgList", "取值范围": { "数据类型": "Str", "取值范围": self.DSs[args["数据源"]].FactorNames }, "是否刷新": True, "order": 2, "是否可见": True } ArgInfo["变量类型"] = { "数据类型": "IndexedArgList", "取值范围": [{ "数据类型": "Str", "取值范围": ["Regular", "Dummy"] }, args["中性因子"]], "是否刷新": False, "order": 3, "是否可见": False } ArgInfo["风险数据源"] = { "数据类型": "RiskDS", "取值范围": [], "是否刷新": False, "order": 4, "是否可见": True } ArgInfo["收益率因子"] = { "数据类型": "Str", "取值范围": DefaultNumFactorList, "是否刷新": False, "order": 5 } ArgInfo["基准权重"] = { "数据类型": "Str", "取值范围": ["等权"] + DefaultNumFactorList, "是否刷新": False, "order": 6, "是否可见": True } ArgInfo["月度平均"] = { "数据类型": "Bool", "取值范围": [True, False], "是否刷新": False, "order": 7, "是否可见": False } ArgInfo["优化器"] = { "数据类型": "Str", "取值范围": list(BasePC.PCClasses.keys()), "是否刷新": False, "order": 8, "是否可见": True } ArgInfo["数据源"] = { "数据类型": "Str", "取值范围": AllDSNames, "是否刷新": True, "order": 9, "是否可见": False } return (args, ArgInfo)
def genSysArgInfo(self, arg=None): # arg=None 表示初始化参数 DefaultNumFactorList, DefaultStrFactorList = getFactorList( self.StdDataSource.DataType) if arg is None: arg = {} arg['启用卖空'] = False arg['可卖空条件'] = None arg['限买条件'] = getDefaultNontradableIDFilter( self.StdDataSource, True, self.QSEnv) arg['限卖条件'] = getDefaultNontradableIDFilter( self.StdDataSource, False, self.QSEnv) arg['成交价'] = searchNameInStrList(DefaultNumFactorList, ['价', 'Price', 'price']) arg['结算价'] = arg['成交价'] arg['交易费率'] = 0.003 arg['保证金率'] = 0.0 ArgInfo = {} ArgInfo['启用卖空'] = { '数据类型': 'Bool', '取值范围': [True, False], '是否刷新': False, '序号': 0, '是否可见': True } ArgInfo['可卖空条件'] = { '数据类型': 'IDFilterStr', '取值范围': self.StdDataSource.FactorNames, '是否刷新': False, '序号': 1 } ArgInfo['限买条件'] = { '数据类型': 'IDFilterStr', '取值范围': self.StdDataSource.FactorNames, '是否刷新': False, '序号': 2 } ArgInfo['限卖条件'] = { '数据类型': 'IDFilterStr', '取值范围': self.StdDataSource.FactorNames, '是否刷新': False, '序号': 3 } ArgInfo['成交价'] = { '数据类型': 'Str', '取值范围': DefaultNumFactorList, '是否刷新': False, '序号': 4, '是否可见': True } ArgInfo['结算价'] = { '数据类型': 'Str', '取值范围': DefaultNumFactorList, '是否刷新': False, '序号': 5, '是否可见': True } ArgInfo['交易费率'] = { '数据类型': 'Double', '取值范围': [0, 1, 0.0005], '是否刷新': False, '序号': 6, '是否可见': True } ArgInfo['保证金率'] = { '数据类型': 'Double', '取值范围': [0, 1, 0.0005], '是否刷新': False, '序号': 7, '是否可见': True } return (arg, ArgInfo)