diff --git a/vnpy/app/cta_strategy_pro/template_spread.py b/vnpy/app/cta_strategy_pro/template_spread.py index fc1572a7..bd16bed1 100644 --- a/vnpy/app/cta_strategy_pro/template_spread.py +++ b/vnpy/app/cta_strategy_pro/template_spread.py @@ -429,30 +429,54 @@ class CtaSpreadTemplate(CtaTemplate): dist_record['price'] = price dist_record['symbol'] = self.vt_symbol dist_record['operation'] = operation - + symbol, exchange = extract_vt_symbol(self.vt_symbol) + trade = TradeData( + symbol=symbol, + exchange=exchange, + volume=volume, + price=price, + datetime=self.cur_datetime, + orderid=self.cur_datetime.strftime('o_%Y%m%d%H%M%S%f'), + tradeid=self.cur_datetime.strftime('t_%Y%m%d%H%M%S%f'), + sys_orderid=self.cur_datetime.strftime('so_%Y%m%d%H%M%S%f'), + time=self.cur_datetime.strftime('%Y-%m-%d %H:%M:%S'), + strategy_name=self.strategy_name, + gateway_name='-' + ) if operation == 'buy': self.position.open_pos(Direction.LONG, volume=volume) dist_record['long_pos'] = self.position.long_pos dist_record['short_pos'] = self.position.short_pos + trade.offset=Offset.OPEN + trade.direction=Direction.LONG if operation == 'short': self.position.open_pos(Direction.SHORT, volume=volume) dist_record['long_pos'] = self.position.long_pos dist_record['short_pos'] = self.position.short_pos - + trade.offset = Offset.OPEN + trade.direction = Direction.SHORT if operation == 'cover': self.position.close_pos(Direction.LONG, volume=volume) dist_record['long_pos'] = self.position.long_pos dist_record['short_pos'] = self.position.short_pos - + trade.offset = Offset.CLOSE + trade.direction = Direction.LONG if operation == 'sell': self.position.close_pos(Direction.SHORT, volume=volume) dist_record['long_pos'] = self.position.long_pos dist_record['short_pos'] = self.position.short_pos + trade.offset = Offset.CLOSE + trade.direction = Direction.SHORT self.save_dist(dist_record) self.pos = self.position.pos + # 回测时,补充self.vt_symbol的交易记录 + if self.backtesting: + self.cta_engine.append_trade(trade) + + def save_dist(self, dist_data): """ 保存策略逻辑过程记录=》 csv文件按 @@ -1126,11 +1150,12 @@ class CtaSpreadTemplate(CtaTemplate): if len(self.active_orders) == 0: self.entrust = 0 - def check_liquidity(self): + def check_liquidity(self, direction=None, ask_volume=1, bid_volume=1): """实盘检查流动性缺失""" if self.backtesting: return True + # 检查流动性缺失 if not self.cur_act_tick.bid_price_1 <= self.cur_act_tick.last_price <= self.cur_act_tick.ask_price_1 \ and self.cur_act_tick.volume > 0: self.write_log(u'流动性缺失导致leg1最新价{0} /V:{1}超出买1 {2}卖1 {3}范围,' @@ -1145,6 +1170,22 @@ class CtaSpreadTemplate(CtaTemplate): self.cur_pas_tick.bid_price_1, self.cur_pas_tick.ask_price_1)) return False + # 如果设置了方向和volume,检查是否满足 + if direction==Direction.LONG: + if self.cur_act_tick.ask_volume_1 < ask_volume: + self.write_log(f'主动腿的卖1委量:{self.cur_act_tick.ask_volume_1}不满足:{ask_volume}') + return False + if self.cur_pas_tick.bid_volume_1 < bid_volume: + self.write_log(f'被动腿的买1委量:{self.cur_pas_tick.bid_volume_1}不满足:{bid_volume}') + return False + elif direction == Direction.SHORT: + if self.cur_act_tick.bid_volume_1 < bid_volume: + self.write_log(f'主动腿的买1委量:{self.cur_act_tick.bid_volume_1}不满足:{bid_volume}') + return False + if self.cur_pas_tick.ask_volume_1 < ask_volume : + self.write_log(f'被动腿的卖1委量:{self.cur_pas_tick.ask_volume_1}不满足:{ask_volume}') + return False + return True def check_near_up_nor_down(self): @@ -1199,7 +1240,10 @@ class CtaSpreadTemplate(CtaTemplate): self.write_log(u'强制平仓日,不开仓') return [] # 检查流动性缺失 - if not self.check_liquidity() and not force: + if not self.check_liquidity( direction=Direction.SHORT, + ask_volume=grid.volume * self.pas_vol_ratio, + bid_volume=grid.volume * self.act_vol_ratio + ) and not force: return [] # 检查涨跌停距离 if self.check_near_up_nor_down(): @@ -1265,7 +1309,12 @@ class CtaSpreadTemplate(CtaTemplate): self.write_log(u'强制平仓日,不开仓') return [] # 检查流动性缺失 - if not self.check_liquidity() and not force: + if not self.check_liquidity( + direction=Direction.LONG, + ask_volume=grid.volume * self.act_vol_ratio, + bid_volume=grid.volume * self.pas_vol_ratio + ) \ + and not force: return [] # 检查涨跌停距离 if self.check_near_up_nor_down(): @@ -1319,7 +1368,11 @@ class CtaSpreadTemplate(CtaTemplate): self.write_log(u'停止状态,不平仓') return [] # 检查流动性缺失 - if not self.check_liquidity() and not force: + if not self.check_liquidity( + direction=Direction.SHORT, + ask_volume=grid.volume * self.pas_vol_ratio, + bid_volume=grid.volume * self.act_vol_ratio + ) and not force: return [] # 检查涨跌停距离 if self.check_near_up_nor_down(): @@ -1393,7 +1446,11 @@ class CtaSpreadTemplate(CtaTemplate): self.write_log(u'停止状态,不平仓') return [] # 检查流动性缺失 - if not self.check_liquidity() and not force: + if not self.check_liquidity( + direction=Direction.LONG, + ask_volume=grid.volume * self.act_vol_ratio, + bid_volume=grid.volume * self.pas_vol_ratio + ) and not force: return [] # 检查涨跌停距离 if self.check_near_up_nor_down(): diff --git a/vnpy/data/tdx/future_contracts.json b/vnpy/data/tdx/future_contracts.json index 4e501455..857fe8e2 100644 --- a/vnpy/data/tdx/future_contracts.json +++ b/vnpy/data/tdx/future_contracts.json @@ -4,7 +4,7 @@ "mi_symbol": "a2101", "full_symbol": "A2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.09, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 123, @@ -22,7 +22,7 @@ "mi_symbol": "ag2012", "full_symbol": "AG2012", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.12, "symbol_size": 15, "price_tick": 1.0, "open_interesting": 652, @@ -70,7 +70,7 @@ "mi_symbol": "AP010", "full_symbol": "AP2010", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 188275, @@ -88,7 +88,7 @@ "mi_symbol": "au2012", "full_symbol": "AU2012", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 1000, "price_tick": 0.02, "open_interesting": 35, @@ -108,7 +108,7 @@ "mi_symbol": "b2010", "full_symbol": "B2010", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 111, @@ -132,7 +132,7 @@ "mi_symbol": "bb2105", "full_symbol": "BB2105", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.2, "symbol_size": 500, "price_tick": 0.05, "open_interesting": 2, @@ -180,7 +180,7 @@ "mi_symbol": "c2101", "full_symbol": "C2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 1337, @@ -198,7 +198,7 @@ "mi_symbol": "CF101", "full_symbol": "CF2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 5, "price_tick": 5.0, "open_interesting": 1431, @@ -216,7 +216,7 @@ "mi_symbol": "CJ101", "full_symbol": "CJ2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 5, "price_tick": 5.0, "open_interesting": 34982, @@ -234,7 +234,7 @@ "mi_symbol": "cs2101", "full_symbol": "CS2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 252, @@ -276,7 +276,7 @@ "mi_symbol": "CY101", "full_symbol": "CY2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 5, "price_tick": 5.0, "open_interesting": 1, @@ -300,7 +300,7 @@ "mi_symbol": "eb2101", "full_symbol": "EB2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.12, "symbol_size": 5, "price_tick": 1.0, "open_interesting": 115, @@ -324,7 +324,7 @@ "mi_symbol": "eg2101", "full_symbol": "EG2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.11, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 722, @@ -372,7 +372,7 @@ "mi_symbol": "FG104", "full_symbol": "FG2104", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 20, "price_tick": 1.0, "open_interesting": 999, @@ -420,7 +420,7 @@ "mi_symbol": "hc2101", "full_symbol": "HC2101", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 586, @@ -444,7 +444,7 @@ "mi_symbol": "i2101", "full_symbol": "I2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.11, "symbol_size": 100, "price_tick": 0.5, "open_interesting": 1361, @@ -468,7 +468,7 @@ "mi_symbol": "IC2009", "full_symbol": "IC2009", "exchange": "CFFEX", - "margin_rate": 0.1, + "margin_rate": 0.12, "symbol_size": 200, "price_tick": 0.2, "open_interesting": 113728, @@ -516,7 +516,7 @@ "mi_symbol": "j2101", "full_symbol": "J2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.09, "symbol_size": 100, "price_tick": 0.5, "open_interesting": 171367, @@ -540,7 +540,7 @@ "mi_symbol": "jd2010", "full_symbol": "JD2010", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 368055, @@ -564,7 +564,7 @@ "mi_symbol": "jm2101", "full_symbol": "JM2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.09, "symbol_size": 60, "price_tick": 0.5, "open_interesting": 203, @@ -588,7 +588,7 @@ "mi_symbol": "JR101", "full_symbol": "JR2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 20, "price_tick": 1.0, "open_interesting": 2, @@ -606,7 +606,7 @@ "mi_symbol": "l2101", "full_symbol": "L2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.11, "symbol_size": 5, "price_tick": 5.0, "open_interesting": 383, @@ -630,7 +630,7 @@ "mi_symbol": "LR011", "full_symbol": "LR2011", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 20, "price_tick": 1.0, "open_interesting": 45, @@ -647,7 +647,7 @@ "mi_symbol": "m2101", "full_symbol": "M2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 1145871, @@ -667,7 +667,7 @@ "mi_symbol": "MA105", "full_symbol": "MA2105", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 4000, @@ -715,7 +715,7 @@ "mi_symbol": "nr2011", "full_symbol": "NR2011", "exchange": "INE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 5.0, "open_interesting": 4, @@ -739,7 +739,7 @@ "mi_symbol": "OI101", "full_symbol": "OI2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 1417, @@ -757,7 +757,7 @@ "mi_symbol": "p2101", "full_symbol": "P2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.09, "symbol_size": 10, "price_tick": 2.0, "open_interesting": 674, @@ -805,7 +805,7 @@ "mi_symbol": "PM103", "full_symbol": "PM2103", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 50, "price_tick": 1.0, "open_interesting": 3, @@ -823,7 +823,7 @@ "mi_symbol": "pp2101", "full_symbol": "PP2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.11, "symbol_size": 5, "price_tick": 1.0, "open_interesting": 697, @@ -847,7 +847,7 @@ "mi_symbol": "rb2101", "full_symbol": "RB2101", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 1190, @@ -889,7 +889,7 @@ "mi_symbol": "RM101", "full_symbol": "RM2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 1318, @@ -908,7 +908,7 @@ "mi_symbol": "rr2012", "full_symbol": "RR2012", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 10, @@ -932,7 +932,7 @@ "mi_symbol": "RS011", "full_symbol": "RS2011", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.2, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 6, @@ -948,7 +948,7 @@ "mi_symbol": "ru2101", "full_symbol": "RU2101", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 5.0, "open_interesting": 600, @@ -970,7 +970,7 @@ "mi_symbol": "SA101", "full_symbol": "SA2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 20, "price_tick": 1.0, "open_interesting": 290637, @@ -1026,7 +1026,7 @@ "mi_symbol": "SF010", "full_symbol": "SF2010", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 5, "price_tick": 2.0, "open_interesting": 46583, @@ -1050,7 +1050,7 @@ "mi_symbol": "SM101", "full_symbol": "SM2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 5, "price_tick": 2.0, "open_interesting": 116292, @@ -1098,7 +1098,7 @@ "mi_symbol": "sp2012", "full_symbol": "SP2012", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 10, "price_tick": 2.0, "open_interesting": 249, @@ -1122,7 +1122,7 @@ "mi_symbol": "SR107", "full_symbol": "SR2107", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 3059, @@ -1140,7 +1140,7 @@ "mi_symbol": "ss2011", "full_symbol": "SS2011", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 5, "price_tick": 5.0, "open_interesting": 12, @@ -1164,7 +1164,7 @@ "mi_symbol": "T2012", "full_symbol": "T2012", "exchange": "CFFEX", - "margin_rate": 0.1, + "margin_rate": 0.02, "symbol_size": 10000, "price_tick": 0.005, "open_interesting": 61523, @@ -1179,7 +1179,7 @@ "mi_symbol": "TA102", "full_symbol": "TA2102", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.06, "symbol_size": 5, "price_tick": 2.0, "open_interesting": 3082, @@ -1203,7 +1203,7 @@ "mi_symbol": "TF2012", "full_symbol": "TF2012", "exchange": "CFFEX", - "margin_rate": 0.1, + "margin_rate": 0.012, "symbol_size": 10000, "price_tick": 0.005, "open_interesting": 27699, @@ -1218,7 +1218,7 @@ "mi_symbol": "TS2012", "full_symbol": "TS2012", "exchange": "CFFEX", - "margin_rate": 0.1, + "margin_rate": 0.005, "symbol_size": 20000, "price_tick": 0.005, "open_interesting": 5922, @@ -1233,7 +1233,7 @@ "mi_symbol": "UR101", "full_symbol": "UR2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.05, "symbol_size": 20, "price_tick": 1.0, "open_interesting": 102002, @@ -1257,7 +1257,7 @@ "mi_symbol": "v2101", "full_symbol": "V2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.09, "symbol_size": 5, "price_tick": 5.0, "open_interesting": 396, @@ -1281,7 +1281,7 @@ "mi_symbol": "WH101", "full_symbol": "WH2101", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.07, "symbol_size": 20, "price_tick": 1.0, "open_interesting": 35, @@ -1299,7 +1299,7 @@ "mi_symbol": "wr2107", "full_symbol": "WR2107", "exchange": "SHFE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 1.0, "open_interesting": 5, @@ -1323,7 +1323,7 @@ "mi_symbol": "y2101", "full_symbol": "Y2101", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.08, "symbol_size": 10, "price_tick": 2.0, "open_interesting": 664, @@ -1343,7 +1343,7 @@ "mi_symbol": "ZC102", "full_symbol": "ZC2102", "exchange": "CZCE", - "margin_rate": 0.1, + "margin_rate": 0.05, "symbol_size": 100, "price_tick": 0.2, "open_interesting": 394, @@ -1392,7 +1392,7 @@ "mi_symbol": "pg2011", "full_symbol": "PG2011", "exchange": "DCE", - "margin_rate": 0.1, + "margin_rate": 0.11, "symbol_size": 20, "price_tick": 1.0, "open_interesting": 59, diff --git a/vnpy/trader/ui/kline/kline.py b/vnpy/trader/ui/kline/kline.py index c6a1d4d0..e7b6e4dd 100644 --- a/vnpy/trader/ui/kline/kline.py +++ b/vnpy/trader/ui/kline/kline.py @@ -1146,7 +1146,7 @@ class KLineWidget(KeyWraper): self.pi_main.addItem(arrow) self.list_trade_arrow.append(arrow) - def add_trades(self, df_trades): + def add_trades(self, df_trades,include_symbols=[], exclude_symbols=[]): """ 批量导入交易记录(vnpy回测中导出的trade.csv) :param df_trades: @@ -1161,6 +1161,15 @@ class KLineWidget(KeyWraper): else: col_datetime = 'time' for idx in df_trades.index: + + # 要显示的合约 + symbol = df_trades['symbol'].loc[idx] + if len(include_symbols) > 0 and symbol not in include_symbols: + continue + + if len(exclude_symbols) > 0 and symbol in exclude_symbols: + continue + # 时间 trade_time = df_trades[col_datetime].loc[idx] if not isinstance(trade_time, datetime) and isinstance(trade_time, str): @@ -1499,6 +1508,43 @@ class KLineWidget(KeyWraper): class GridKline(QtWidgets.QWidget): """多kline同时展示,时间联动""" + # kline_setting说明: + # dict 结构,{图:配置}。 配置,也是dict结构,配置项:配置值 + # 配置项目1:data_file,k线的csv文件, + # 包含时间,高低开平,volume等 + # 包含主图/副图指标等数据 + # 一次生成,或者在策略中,通过K线export生成 + # 配置项目2:main_indicators,主图指标 + # 指标变量必须在data_file文件中存在字段 + # 配置项3:sub_indicators, 副图指标 + # 指标变量必须在data_file文件中存在字段 + + # 配置项4:trade_list_file,开平仓交易记录 + # 每条记录包含开仓,平仓,收益信息 + # 回测时,每个策略实例,都产生trade_list.csv文件 + + # 配置项5:trade_file,交易记录 + # 每条记录,为单一开仓或平仓信息 + # 实盘时,引擎为每个策略实例产生trade.csv + # 回测时,引擎生成一个trade.csv,包含多个策略实例的交易 + # 配置项6:trade_include_symbols,[symbol, symbol] + # 必须包含的显示交易信息的合约,例如套利合约时,只显示套利合约对,不显示主动腿、被动腿 + # 配置项7:trade_exclude_symbols,[symbol, symbol] + # 排除显示交易信息的合约,例如套利合约时,只显示套利合约对,不显示主动腿、被动腿 + + # 配置项8: tns_file,多空事务的csv文件, + # 包含时间,多、空,价格 + # 由策略生成,一般用于显示一段时间的趋势 + + # 配置项9: dist_file, 复杂事务的csv文件 + # 记录自定义的逻辑记录 + # 包含时间,价格,volume,信号识别,操作,止损价,止盈价,当前多单仓位、空单仓位等 + # 在策略模板的dist_fieldnames定义,自行扩展 + # 回放时,支持include、exclude,对‘操作[operation]’这个字段的值进行过滤。 + # 配置选项10:dist_include_list, 显示dist数据时,对operation字段需要包含的内容 + # 配置选项11:dist_exclude_list, 显示dist数据时,对operation字段需要排除的内容 + + # 配置项12: bi_file / duan_file / bi_zs_file / duan_zs_file,支持缠论的化线 def __init__(self, parent=None, kline_settings={}, title='', relocate=True): self.parent = parent @@ -1622,7 +1668,12 @@ class GridKline(QtWidgets.QWidget): if trade_file and os.path.exists(trade_file): print(f'loading {trade_file}') df_trade = pd.read_csv(trade_file) - self.kline_dict[kline_name].add_trades(df_trade) + + self.kline_dict[kline_name].add_trades( + df_trades=df_trade, + include_symbols=kline_setting.get('trade_include_symbols' ,[]), + exclude_symbols=kline_setting.get('trade_excclude_symbols', [])) + # 加载tns( 回测、实盘产生的) tns_file = kline_setting.get('tns_file', None) @@ -1640,7 +1691,7 @@ class GridKline(QtWidgets.QWidget): df_markup.rename(columns={'operation': 'markup'}, inplace=True) self.kline_dict[kline_name].add_markups(df_markup=df_markup, include_list=kline_setting.get('dist_include_list', []), - exclude_list=['buy', 'short', 'sell', 'cover']) + exclude_list=kline_setting.get('dist_exclude_list',['buy', 'short', 'sell', 'cover'])) # 笔 bi_file = kline_setting.get('bi_file', None) diff --git a/vnpy/trader/utility.py b/vnpy/trader/utility.py index 5ba33d35..29fe1f9a 100644 --- a/vnpy/trader/utility.py +++ b/vnpy/trader/utility.py @@ -118,11 +118,8 @@ def get_full_symbol(symbol: str): symbol_month = symbol.replace(underlying_symbol, '') if len(symbol_month) == 3: - if symbol_month[0] == '0': - # 支持2020年合约 - return '{0}2{1}'.format(underlying_symbol, symbol_month) - else: - return '{0}1{1}'.format(underlying_symbol, symbol_month) + # 支持2020年合约 + return '{0}2{1}'.format(underlying_symbol, symbol_month) else: return symbol